Skip to content

Conversation

lukewarlow
Copy link
Member

@lukewarlow lukewarlow commented Oct 6, 2025

These found some interop bugs in various browsers.

elementFromPoint-display-contents.html - Fails in Chromium, WebKit, and Firefox, and Servo.

elementsFromPoint-display-contents.html - Fails in WebKit. Passes in Chromium, Firefox and Servo.

Copy link
Contributor

@emilio emilio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The display inline tests I'm not sure are correct at least. It might be worth aligning the text as well on the display: contents ones, or click on 5, 5 or so rather than 0, 0?.

These found some interop bugs in various browsers.
@lukewarlow lukewarlow force-pushed the cssom-view-display-contents branch from 5be945f to 82ee032 Compare October 6, 2025 15:17
@lukewarlow lukewarlow requested a review from emilio October 6, 2025 15:24
<body>
<div id="targetDiv">Text Content</div>
<script>
var element = document.elementFromPoint(5, 5);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So... Thinking a bit more about this, I think both returning targetDiv and body might be reasonable? Specially once you consider shadow DOM behavior / slots. You might want to get the element that a click event would be dispatched to, if you hit a text node...

If the spec is unclear, I suggest landing these with .tentative.html and pointing to a CSS spec issue?

I agree in any case that document.elementsFromPoint(x, y).includes(document.elementFromPoint(x, y)) should be true. Maybe add a non-tentative test checking that?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To me the spec is actually quite clear, and to me it clearly says that display:contents elements shouldn't be included.

https://www.w3.org/TR/cssom-view-1/#dom-document-elementfrompoint

If there is a box in the viewport that would be a target for hit testing at coordinates x,y...

display:contents elements don't produce a box and so can't be included?

The same language is true for elementsFromPoint too. If the use case is retargeting like events do we should probably just expose that function separately?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, the point is that the text node does have a box. So the question is whether you retarget the text node to the display: contents element or just skip it.

Copy link
Member Author

@lukewarlow lukewarlow Oct 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well isn't text in the text node actually a text sequence?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, sure, but those should be included. Otherwise per spec if you hit a text sequence rather than a box you should return the root element from elementFromPoint, which doesn't seem like the intention, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well would the nearest parent that has a box not match this? E.g. body? That would be a box that's targeted by that hit test right? I guess because hit testing is undefined it's hard to know.

I'll open a spec issue to discuss this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lukewarlow lukewarlow changed the title Add cssom-view tests for display inline and contents Add cssom-view tests for contents Oct 7, 2025
@lukewarlow lukewarlow changed the title Add cssom-view tests for contents Add cssom-view tests for display contents Oct 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants