Skip to content

Commit

Permalink
Define the foundations of find-in-page
Browse files Browse the repository at this point in the history
This serves as helpful structure for work such as #3539, or potentially
integrating with https://github.com/WICG/scroll-to-text-fragment or
https://github.com/WICG/display-locking.
  • Loading branch information
vmpstr authored Aug 11, 2020
1 parent a1ad979 commit 4191e0c
Showing 1 changed file with 50 additions and 7 deletions.
57 changes: 50 additions & 7 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -3075,9 +3075,12 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
<li><dfn data-x="dom-outerHTML" data-x-href="https://w3c.github.io/DOM-Parsing/#dom-element-outerhtml"><code>outerHTML</code></dfn></li>
</ul>

<p>The <dfn
data-x-href="https://w3c.github.io/selection-api/#selection-interface"><code>Selection</code></dfn>
interface is defined in the <cite>Selection API</cite> specification. <ref spec=SELECTION></p>
<p>The following features are defined in <cite>Selection API</cite>: <ref spec=SELECTION></p>

<ul class="brief">
<li><dfn data-x="document-selection" data-x-href="https://w3c.github.io/selection-api/#dfn-selection">selection</dfn></li>
<li><dfn data-x-href="https://w3c.github.io/selection-api/#selection-interface"><code>Selection</code></dfn></li>
</ul>

<p class="note">User agents are encouraged to implement the features described in
<cite>execCommand</cite>. <ref spec=EXECCOMMAND></p>
Expand Down Expand Up @@ -71836,10 +71839,9 @@ END:VCARD</pre>

<p>A node (in particular elements and text nodes) can be marked as <dfn>inert</dfn>. When a node
is <span>inert</span>, then the user agent must act as if the node was absent for the purposes of
targeting user interaction events, may ignore the node for the purposes of text search user
interfaces (commonly known as "find in page"), and may prevent the user from selecting text in
that node. User agents should allow the user to override the restrictions on search and text
selection, however.</p>
targeting user interaction events, may ignore the node for the purposes of
<span>find-in-page</span>, and may prevent the user from selecting text in that node. User agents
should allow the user to override the restrictions on search and text selection, however.</p>

<p class="example">For example, consider a page that consists of just a single <span>inert</span>
paragraph positioned in the middle of a <code>body</code>. If a user moves their pointing device
Expand Down Expand Up @@ -74583,6 +74585,47 @@ body { display:none }

</div>

<h3>Find-in-page</h3>

<h4>Introduction</h4>

<p>This section defines <dfn>find-in-page</dfn> — a common user-agent mechanism which allows users
to search through the contents of the page for particular information.</p>

<p>Access to <span>find-in-page</span> feature is provided via a <dfn>find-in-page
interface</dfn>. This is a user-agent provided user interface, which allows the user to specify
input and the parameters of the search. This interface can appear as a result of a shortcut or a
menu selection.</p>

<p>A combination of text input and settings in the <span>find-in-page interface</span> represents
the user <dfn data-x="fip-query">query</dfn>. This typically includes the text that the user wants
to search for, as well as optional settings (e.g., the ability to restrict the search to whole
words only).</p>

<p>The user-agent processes page contents for a given <span data-x="fip-query">query</span>, and
identifies zero or more <dfn data-x="fip-matches">matches</dfn>, which are content ranges that
satisfy the user <span data-x="fip-query">query</span>.</p>

<p>One of the <span data-x="fip-matches">matches</span> is identified to the user as the <dfn
data-x="fip-active-match">active match</dfn>. It is highlighted and scrolled into view. The user
can navigate through the <span data-x="fip-matches">matches</span> by advancing the <span
data-x="fip-active-match">active match</span> using the <span>find-in-page interface</span>.</p>

<p class="XXX"><a href="https://github.com/whatwg/html/issues/3539">Issue #3539</a> tracks
standardizing how <span>find-in-page</span> underlies the currently-unspecified <code
data-x="">window.find()</code> API.</p>

<h4>Interaction with selection</h4>

<p>The find-in-page process is invoked in the context of a document, and may have an effect on
the <span data-x="document-selection">selection</span> of that document. Specifically, the range
that defines the <span data-x="fip-active-match">active match</span> can dictate the current
selection. These selection updates, however, can happen at different times during the
find-in-page process (e.g. upon the <span>find-in-page interface</span> dismissal or upon a change
in the <span data-x="fip-active-match">active match</span> range).

<!-- TODO: Define scroll and highlight timing, as well as algorithms (what is and isn't found) -->

<h3 split-filename="dnd" id="dnd"><dfn>Drag and drop</dfn></h3>

<!-- v2: ideas for drag and drop:
Expand Down

0 comments on commit 4191e0c

Please sign in to comment.