You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[css-highlight-api] Change highlightsFromPoint return type #12031 (#12215)
* change highlightsFromPoint return type
* add case for shadow elements + fix typos/style
* add exposed=Window to HighlightHitResult interface
* make HighlightHitResult a dictionary
* address feedback - change algorithm to more imperative, expand example
* PR feedback - use 'let', catch exceptions
* don't catch exceptions
@@ -665,23 +676,30 @@ method must return the result of running these steps:
665
676
1. If any of the following are true, return the empty [=sequence=]:
666
677
* <var>x</var> is negative
667
678
* <var>y</var> is negative
668
-
* <var>x</var> is greater than the <a>viewport</a> width excluding the size of a rendered scroll bar (if any)
669
-
* <var>y</var> is greater than the <a>viewport</a> height excluding the size of a rendered scroll bar (if any)
670
-
1. Otherwise, return a [=sequence=] of [=custom highlights=] given by ordering the highlights contained in this {{HighlightRegistry}} in descending order of [=priority=],
671
-
including only those highlights that contain at least one {{AbstractRange}}<var>abstractRange</var> that satisfies the following:
672
-
673
-
* Let <var>range</var> be a {{Range}} object whose [=start node=] and [=end node=] are set to <var>abstractRange</var>'s [=start node=] and [=end node=] respectively,
674
-
and [=start offset=] and [=end offset=] are set to <var>abstractRange</var>'s [=start offset=] and [=end offset=] respectively.
675
-
676
-
* The coordinates <var>x</var>,<var>y</var> fall inside at least one of the {{DOMRect}}s returned by calling {{Range/getClientRects()}} on <var>range</var>.
677
-
678
-
Note: The specifics of hit testing are out of scope of this
679
-
specification and therefore the exact details of
680
-
{{highlightsFromPoint()}} are therefore too. Hit testing
681
-
will hopefully be defined in a future revision of CSS or HTML.
682
-
683
-
* The <var>range</var>'s {{commonAncestorContainer}} is not in a [=shadow tree=] or is in a [=shadow tree=] whose
684
-
[=shadow root=] is [=list/contains|contained by=] by <var>options</var>.<var>shadowRoots</var>.
679
+
* <var>x</var> is greater than the [=viewport=] width excluding the size of a rendered scroll bar (if any)
680
+
* <var>y</var> is greater than the [=viewport=] height excluding the size of a rendered scroll bar (if any)
681
+
* The topmost [=box=] in the [=viewport=] in paint order that would be a target for hit testing at coordinates <var>x</var>,<var>y</var> when applying
682
+
the [=transforms=] that apply to the descendants of the viewport, has an element associated to it that's in a [=shadow tree=] whose
683
+
[=shadow root=] is not [=list/contains|contained by=]<var>options</var>.<var>shadowRoots</var>.
684
+
1. Otherwise, let <var>results</var> be an empty [=sequence=].
685
+
1. For each {{Highlight}}<var>highlight</var> in this {{HighlightRegistry}}:
686
+
1. Let <var>result</var> be a new {{HighlightHitResult}} with {{HighlightHitResult/highlight}} set to <var>highlight</var>.
687
+
1. For each {{AbstractRange}}<var>abstractRange</var> in <var>highlight</var>:
688
+
1. If <var>abstractRange</var> is an [=StaticRange/valid|invalid=]{{StaticRange}}, then [=iteration/continue=].
689
+
1. Let <var>range</var> be a new {{Range}} whose [=start node=] and [=end node=] are set to <var>abstractRange</var>'s
690
+
[=start node=] and [=end node=] respectively, and [=start offset=] and [=end offset=] are set to <var>abstractRange</var>'s
691
+
[=start offset=] and [=end offset=] respectively.
692
+
1. If the coordinates <var>x</var>,<var>y</var> fall inside at least one of the {{DOMRect}}s returned by calling {{Range/getClientRects()}}
693
+
on <var>range</var>, then append <var>abstractRange</var> to <var>result</var>.{{HighlightHitResult/ranges}}.
694
+
695
+
Note: The specifics of hit testing are out of scope of this
696
+
specification and therefore the exact details of
697
+
{{highlightsFromPoint()}} are too. Hit testing will
698
+
hopefully be defined in a future revision of CSS or HTML.
699
+
700
+
1. If <var>result</var>.{{HighlightHitResult/ranges}} is not empty, append <var>result</var> to <var>results</var>.
701
+
1. Sort <var>results</var> by descending order of [=priority=] of its {{HighlightHitResult}}s' {{HighlightHitResult/highlight}} attributes.
0 commit comments