Re: [csswg-drafts] [cssom-view] elementFromPoint, elementsFromPoint, and caretPositionFromPoint should not return an element inside a shadow tree

@hayatoito  Oh yeah, duh, you're right, they can just be merged with that change. So:

1. Let |frag| be the top-most fragment at |point| that responds to pointer events. (Or all of them for elementsFromPoint(), etc.)
2. If |frag| was generated by a text run (rather than a box), walk its ancestors in the fragment tree until you find a fragment generated by a box, and set |frag| to that.
3. Let |box| be the box that generated |frag|.
4. If |box| is an anonymous box, or was generated by a pseudo-element, or was generated by an element that's shadow-hidden from the call's context, walk its ancestors in the box tree until you find a box that doesn't match any of those conditions, and set |box| to that.
5. Return the element that generated |box|.

@rniwa Taking [your example](https://github.com/w3c/csswg-drafts/issues/556#issuecomment-423402029), and assuming the `slot` was still its default `display:contents`, then the element returned would be the `div`. You click on the "hi" fragment, find that it was generated by a text run, then walk the box tree upwards until you find the `div`; this can then be returned.

If the `slot` was `display:block` or something, then if you called `shadowRoot.elementFromPoint()`, you'd return the `slot`; if you called `document.elementFromPoint()`, the `slot` would fail the condition in step 4, so we'd keep walking upwards until we found the `div` and return that.

-- 
GitHub Notification of comment by tabatkins
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/556#issuecomment-429422850 using your GitHub account

Received on Friday, 12 October 2018 18:45:59 UTC