These changes will likely go into the find-in-page section of the HTML spec
When a new active match is set, either by advancing through the match list or
due to a new find-in-page request, a beforematch
event is fired on a node
identified by the active match's range
start. This process follows
the following algorithm:
-
Identify the candidate match which will become the new active match. The active match's DOM range must not be collapsed.
-
At the next rendering opportunity, specifically step 12 "run the animation frame callbacks" of update-the-rendering:
2.1. If the DOM range representing the active match has been collapsed, start the search over again starting at this collapsed range.
2.2. Let "matchable ancestor" be the nearest flat-tree ancestor element of the beginning of the DOM range representing the active match which has the content-visibility: hidden-matchable property.
2.3. If the beforematch event has been disabled or there is no matchable ancestor, run scroll into view on the active match and end the algorithm.
2.4. Fire the beforematch event on the matchable ancestor.
2.5. Signal a need for another run of update-the-rendering.
-
At the next rendering opportunity (the next Step 12 of update-the-rendering):
3.1. Disable the beforematch event for the remaining lifetime of the document and start the search over again starting at the end of the active match's DOM range if any of the following conditions are true: - The DOM range representing the active match has been collapsed. - The active match has the
content-visibility: hidden-matchable
orcontent-visibility: hidden
in any ancestors. - The active match has thedisplay: none
property in any ancestors. - The active match'svisibility
property is notvisible
in any ancestors.3.2. Run scroll into view on the active match.
content-visibility: hidden-matchable
These changes will likely go into the css-contain-2 module.
'hidden-matchable':
This value behaves very similarly to 'hidden'. That is, the element skips its contents.
The skipped contents must not be accessible to user-agent features such as tab-order navigation, nor be selectable or focusable.
However, unlike 'hidden', the skipped contents must be accessible to the
find-in-page algorithm in order to allow the beforematch
event to fire.
(TODO: reference the find-in-page beforematch spec)