W3C home > Mailing lists > Public > www-style@w3.org > August 2010

[cssom-view] elementFromPoint vagueness and "hit testing"

From: David Flanagan <david@davidflanagan.com>
Date: Tue, 17 Aug 2010 13:22:03 -0700
Message-ID: <4C6AEF6B.8010301@davidflanagan.com>
To: www-style@w3.org
The elementFromPoint() method is specified to return an element "at the 
coordinates x,y .... determined through hit testing".  The specification 
(and even the definition) of "hit testing" is pushed off to a future 
version of CSS or HTML.  If I'm reading this correctly, an 
implementation that always returned document.documentElement would be 

Can we be a little more specific than this?  For example, is it 
appropriate to add something like this to the Note about hit testing: 
"Until hit testing is formally defined, implementors are encouraged to 
select the topmost, innermost element at the point x,y."

That is the intent, isn't it?  I assume that the hit-testing algorithm 
would be something like this (off the top of my head):

1) Make a list of all elements whose border edges include the point x,y.

2) Find the maximum z-index among those elements, and discard all 
elements in the list with a smaller z-index.

3) If only one element remains, return it.

4) For each element in the list, discard any ancestors of that element 
that are on the list.

5) If only one element remains, return it.

6) Return the element that appears last in document order.

Received on Tuesday, 17 August 2010 20:22:58 UTC

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:07:49 UTC