W3C home > Mailing lists > Public > www-style@w3.org > July 2008

Proposal for CSS 'pointer-events' property

From: Dean Jackson <dino@apple.com>
Date: Sat, 19 Jul 2008 06:17:22 +1000
Message-Id: <E096A2EE-8B0D-49FF-8C98-2284C4431DF2@apple.com>
To: www-style@w3.org

Hi all,

Here is a proposal for a new property we've been investigating (new to  
at least). We'd appreciate any feedback from the community.


Positioning and CSS transforms allow authors to create content with  
that overlap in many different ways. This flexibility in presentation,
however, has not been matched by improved control over event handling.  
still propagate through the document via the DOM hierarchy, a model  
which made
sense when parent elements always visually enclosed their children,  
but now
becomes more problematic. For example, if an element is overlayed by  
element that is not a descendent, there is no way for that background  
to receive mouse events.

We propose a new CSS property for HTML, "pointer-events", to address  
problem. This property is closely modeled on the SVG pointer-events  


Values for this property allow the content author to make elements  
or partially transparent to user events. This would also apply to  
other "hit
testing" behaviors such as dynamic pseudo-classes  
(:hover, :active, :focus),
hyperlinks, and Document.elementFromPoint().

Note that no values of this property cause an element to be hit-tested  
when it
would not have been hit tested before. When hit-testing text, text  
boxes are
used, as is already the case.

Note that the pointer-events property is only consulted when  
determining the
target of an event. Once the target element has been identified, event
propagation follows the existing DOM model.

   Value:          all | none | content | border | painted | inherit
   Initial:        all
   Applies to:     all elements
   Inherited:      yes
   Media:          visual

   The given element can be the target element for pointer events
   whenever the pointer is over the contents, background, or border
   of the element. This is the current HTML behavior. Note that  
   shadows and reflections do not hit test.

   The given element does not receive pointer events.

   The given element can be the target element for pointer events
   when the pointer is over the interior (i.e., content or background)
   of the element.

   The given element can be the target element for pointer events
   when the pointer is over the border of the element.

   The given element can be the target element for pointer events
   when the pointer is over a "painted" area. The pointer is over a  
   area if it is over the interior (i.e. content or background),
   or border of the element, and when the content, border or background
   does not have a 'transparent' color.


The property is very similar the SVG 'pointer-events' property, but  
in the following ways:

    * We do not want the property to interact with 'visibility';  
      hidden elements should not hit test. So we do not have the dual  
      (e.g. 'painted', 'visiblePainted') that SVG does.

    * SVG's 'fill' and 'stroke' values don't translate well to HTML's
      background, foreground, border model, so we propose just 'content'
      (background and foreground), and 'border'.

Because it's similar-but-not equivalent to SVG pointer-events, perhaps  
should have a different name?

Do we want separate values for foreground, background and border? SVGs  
vs. stroke doesn't map cleanly to HTML. It doesn't seem to make much  
sense to
hit test background and not content, but you may want to include/exclude

Should the implementation for 'painted' look at pixel alpha values?  
Doing so
would require examining pixels in content images, background images,  
image, background color, border color, text color, masks, CSS  
gradients etc.
This is both hard to implement, and could be very expensive at runtime  
every mouse move), but is something that content authors may want.

How does 'painted' interact with the opacity property? In WebKit, at  
elements with opacity: 0 still hit test.
Received on Friday, 18 July 2008 20:18:06 UTC

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:27:38 UTC