From c49b15f53c940bb0f5ed62b62c6719540e5b292e Mon Sep 17 00:00:00 2001 From: Stephanie Zhang Date: Fri, 15 May 2026 10:54:18 -0700 Subject: [PATCH 1/2] initial changes --- css-highlight-api-1/Overview.bs | 112 ++++++++++++++++++++++++-------- 1 file changed, 85 insertions(+), 27 deletions(-) diff --git a/css-highlight-api-1/Overview.bs b/css-highlight-api-1/Overview.bs index 6dc93d8650c0..f2b35addc646 100644 --- a/css-highlight-api-1/Overview.bs +++ b/css-highlight-api-1/Overview.bs @@ -55,6 +55,9 @@ spec:dom; type:dfn; for:Element; text:shadow root spec:dom; type:dfn; text:event spec:css2; type:dfn; text:viewport spec:cssom-view; type:dfn; text:transforms +spec:dom; type:interface; text:OpaqueRange +spec:dom; type:dfn; for:OpaqueRange; text:associated element +spec:dom; type:dfn; text:supports opaque ranges + + +
+ + + + A click inside the rendered text of: + * ta1 returns a {{HighlightHitResult}} containing r1, + since ta1 is in the main document. + * ta2 returns the empty [=sequence=], + since ta2 is in a [=shadow tree=] and no shadowRoots option is passed. + * ta2, called with { shadowRoots: [shadow] }, + returns a {{HighlightHitResult}} containing r2. + + The method {{highlightsFromPoint}} is defined as part of the {{HighlightRegistry}} interface as follows:
@@ -676,30 +723,38 @@ dictionary HighlightsFromPointOptions {
 The highlightsFromPoint(x, y, options)
 method must return the result of running these steps:
 
-1. If any of the following are true, return the empty [=sequence=]:
+1. If any of the following are true, return an empty [=sequence=]:
 	* x is negative
 	* y is negative
 	* x is greater than the [=viewport=] width excluding the size of a rendered scroll bar (if any)
 	* y is greater than the [=viewport=] height excluding the size of a rendered scroll bar (if any)
-	* The topmost [=box=] in the [=viewport=] in paint order that would be a target for hit testing at coordinates x,y when applying
-		the [=transforms=] that apply to the descendants of the viewport, has an element associated to it that's in a [=shadow tree=] whose
-		[=shadow root=] is not [=list/contains|contained by=] options.shadowRoots.
-1. Otherwise, let results be an empty [=sequence=].
+1. Let hitElement be the element associated with
+		the topmost [=box=] in the [=viewport=] in paint order that would be a target for hit testing at coordinates x,y when applying
+		the [=transforms=] that apply to the descendants of the viewport.
+
+	Note: The specifics of hit testing are out of scope of this specification
+	and therefore the exact details of {{highlightsFromPoint()}} are too.
+	Hit testing will hopefully be defined in a future revision of CSS or HTML.
+
+1. If hitElement is part of the internal implementation of
+		another element host that [=supports opaque ranges=],
+		set hitElement to host.
+1. If hitElement is in a [=shadow tree=] whose
+		[=shadow root=] is not [=list/contains|contained by=] options.shadowRoots,
+		return an empty [=sequence=].
+1. Let results be an empty [=sequence=].
 1. For each {{Highlight}} highlight in this {{HighlightRegistry}}:
 	1. Let result be a new {{HighlightHitResult}} with {{HighlightHitResult/highlight}} set to highlight.
 	1. For each {{AbstractRange}} abstractRange in highlight:
-		1. If abstractRange is an [=StaticRange/valid|invalid=] {{StaticRange}}, then [=iteration/continue=].
-		1. Let range be a new {{Range}} whose [=start node=] and [=end node=] are set to abstractRange's
-			[=start node=] and [=end node=] respectively, and [=start offset=] and [=end offset=] are set to abstractRange's 
-			[=start offset=] and [=end offset=] respectively.
-		1. If the coordinates x,y fall inside at least one of the {{DOMRect}}s returned by calling {{Range/getClientRects()}}
-			on range, then append abstractRange to result.{{HighlightHitResult/ranges}}.
-
-			Note: The specifics of hit testing are out of scope of this
-			specification and therefore the exact details of
-			{{highlightsFromPoint()}} are too. Hit testing will
-			hopefully be defined in a future revision of CSS or HTML.
-	
+		1. If abstractRange is one that the user agent would [[#range-invalidation|ignore when rendering]]
+			this {{HighlightRegistry}}'s [=associated Document=], [=iteration/continue=].
+		1. Let rects be:
+			* if abstractRange is an {{OpaqueRange}},
+				the result of calling {{OpaqueRange/getClientRects()}} on abstractRange;
+			* otherwise, the result of calling {{Range/getClientRects()}}
+				on a new {{Range}} with the same [=boundary points=] as abstractRange.
+		1. If the coordinates x, y fall inside at least one of the {{DOMRect}}s in rects,
+			then append abstractRange to result.{{HighlightHitResult/ranges}}.
 	1. If result.{{HighlightHitResult/ranges}} is not empty, append result to results.
 1. Sort results by descending order of [=priority=] of its {{HighlightHitResult}}s' {{HighlightHitResult/highlight}} attributes.
 1. Return results.
@@ -754,6 +809,9 @@ Changes since the Issue TBD)
 	* Added a {{HighlightRegistry/highlightsFromPoint}} method to
 	    {{HighlightRegistry}}.
 		(See Issue 7513)

From 4f88801d330dd88a49d4be6e280134e0b87cc8b3 Mon Sep 17 00:00:00 2001
From: Stephanie Zhang 
Date: Fri, 15 May 2026 12:01:37 -0700
Subject: [PATCH 2/2] Update issue url and link

---
 css-highlight-api-1/Overview.bs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/css-highlight-api-1/Overview.bs b/css-highlight-api-1/Overview.bs
index f2b35addc646..dde7b6828f24 100644
--- a/css-highlight-api-1/Overview.bs
+++ b/css-highlight-api-1/Overview.bs
@@ -811,7 +811,7 @@ Changes since the Issue TBD)
+		(See Issue 13929)
 	* Added a {{HighlightRegistry/highlightsFromPoint}} method to
 	    {{HighlightRegistry}}.
 		(See Issue 7513)