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

Properly, hit-testing applies to fragments; they're what results from layout.  (Boxes don't have positions or sizes, they're the result of applying box-construction only.)  ([explanation](https://drafts.csswg.org/css-display/#intro))

The relevant question is exactly how the traversal is done. Here's one method:

1. Let |frag| be the fragment at |point|.
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, walk its ancestors in the box tree until you find a box generated by an element, and set |box| to that.
5. Let |element| be the element that generated |box|.
6. If |element| isn't allowed to be returned in this context due to shadow-hiding, walk its ancestors in the flat tree until you find one that's allowed to be returned, and set |element| to that.
7. Return |element|.

@hayatoito Is this what we do? If not, what differs?

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

Received on Friday, 16 March 2018 17:51:36 UTC