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

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

From: Simon Fraser <smfr@me.com>
Date: Tue, 17 Aug 2010 13:41:17 -0700
Cc: www-style@w3.org
Message-id: <1E697B61-9C92-4091-956D-F9E9F5D309C2@me.com>
To: David Flanagan <david@davidflanagan.com>
On Aug 17, 2010, at 1:22 PM, David Flanagan wrote:

> 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 conforming.
> 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.

Hit testing behaves like painting in reverse, so perhaps it could be defined more simply in terms of rendering.

Received on Tuesday, 17 August 2010 20:42:07 UTC

This archive was generated by hypermail 2.4.0 : Monday, 23 January 2023 02:13:49 UTC