Opera Software ASA

CSS Hit Testing Module

Opera Editor's Draft — 20 August 2010

This version:
http://people.opera.com/lstorset/TR/pointer-events/ED-pointer-events-20100820.html
Latest version:
http://people.opera.com/lstorset/TR/pointer-events/
Previous versions:
http://webkit.org/specs/PointerEventsProperty.html
Editor:
, Opera Software

Abstract

This document describes how the SVG pointer-events property is extended for use in (X)HTML content. Furthermore, it suggests standard behavior for pointer events, which so far differs between user agents.

Status

This document is a work-in-progress proposal for review by the CSS Working Group and is subject to change without notice. This document has no formal standing within W3C. Please consult the group's home page and the W3C technical reports index for information about the latest publications by this group.

This document is based on earlier work by (Apple).

Contents

  1. 1 Introduction
  2. 2 The pointer-events property

1 Introduction

Positioning and CSS transforms allow authors to create content with elements that overlap in many different ways. Elements may be overlayed by other elements that may or may not be their children. The pointer-events property is closely modeled on the SVG pointer-events property and lets an element be entirely or partially transparent to events.

For reference, see the CSS Wiki page on hit testing.

2 The pointer-events property

In different circumstances, authors may want to control under what circumstances particular elements can become the target of pointer events. For example, the author might want a given element to ignore pointer events under all circumstances so that elements underneath the given element will become the target of pointer events.

The 'pointer-events' property specifies under what circumstances a given element can be the target element for a pointer event. It affects the circumstances under which the following are processed:

The pointer-events property was originally defined for SVG content and, as such, accepts property values specific to vector graphics (eg. relating to graphical fill and stroke). The following definition applies to the property when used with CSS layout boxes in general. Note that the property has a new initial value, "auto", which behaves as "visiblePainted" in SVG content and "visible" in non-SVG content.

Name: pointer-events
Value: auto | none | all | visible | visiblePainted | visibleFill | visibleStroke | painted | fill | stroke | background | border | inherit
Initial: auto
Applies to: all elements
Inherited: yes
Percentages: N/A
Media: visual

This property determines whether an element is transparent to user events. This also applies to other "hit testing" behaviors such as dynamic pseudo-classes (:hover, :active, :focus), hyperlinks, and Document.elementFromPoint().

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.

auto
In SVG content, behave as visiblePainted. Otherwise, behave as visible.
visible
The given element receives pointer events.

It is not determined whether this and the other visible* properties should apply to HTML.

none
The given element does not receive pointer events.
visiblePainted
visibleFill
visibleStroke
painted
The given element can be the target element for pointer events when the pointer is over a "painted" area. The pointer is over a painted area if it is over the interior (that is, fill or background) of the element and it is not 'none' or 'transparent' or it is over the perimeter (that is, stroke or border) of the element and it is not 'none'.

This is the current behavior in Trident and Presto HTML.

Furthermore, fully transparent areas of embedded images are not considered painted.

Should the requirement in this last sentence be made optional? None of the aforementioned engines supports this.

fill
The given element can be the target element for pointer events when the pointer is over the interior (that is, fill or background) of the element.
stroke
The given element can be the target element for pointer events when the pointer is over the perimeter (that is, stroke or border) of the element.
background
Synonym for fill
border
Synonym for stroke
all
The given element can be the target element for pointer events whenever the pointer is over the contents, background, or border of the element. Note that outlines, shadows and reflections do not hit test.

This is the current behavior in Gecko and WebKit HTML.