Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

Latest commit

 

History

History
70 lines (52 loc) · 3.13 KB

beforematch-spec-draft.md

File metadata and controls

70 lines (52 loc) · 3.13 KB

beforematch event

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:

  1. Identify the candidate match which will become the new active match. The active match's DOM range must not be collapsed.

  2. 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.

  3. 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 or content-visibility: hidden in any ancestors. - The active match has the display: none property in any ancestors. - The active match's visibility property is not visible 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)