From f8487d13bfe8b43b871ba83a14a0bccf229bd5ed Mon Sep 17 00:00:00 2001 From: Cameron McCormack Date: Thu, 28 Nov 2013 17:46:38 +1100 Subject: [PATCH] Bug 922669 - Part 3: Add a flag to represent whether a pseudo-element supports user action pseudo-classes (currently :hover and :active). r=bz --- layout/style/nsCSSPseudoElementList.h | 36 ++++++++++++++++++--------- layout/style/nsCSSPseudoElements.cpp | 7 ++++++ layout/style/nsCSSPseudoElements.h | 18 +++++++++++--- 3 files changed, 46 insertions(+), 15 deletions(-) diff --git a/layout/style/nsCSSPseudoElementList.h b/layout/style/nsCSSPseudoElementList.h index 650631b4637f..813d4b6ebd44 100644 --- a/layout/style/nsCSSPseudoElementList.h +++ b/layout/style/nsCSSPseudoElementList.h @@ -52,16 +52,28 @@ CSS_PSEUDO_ELEMENT(mozMathStretchy, ":-moz-math-stretchy", 0) CSS_PSEUDO_ELEMENT(mozMathAnonymous, ":-moz-math-anonymous", 0) // HTML5 Forms pseudo elements -CSS_PSEUDO_ELEMENT(mozNumberWrapper, ":-moz-number-wrapper", 0) -CSS_PSEUDO_ELEMENT(mozNumberText, ":-moz-number-text", 0) -CSS_PSEUDO_ELEMENT(mozNumberSpinBox, ":-moz-number-spin-box", 0) -CSS_PSEUDO_ELEMENT(mozNumberSpinUp, ":-moz-number-spin-up", 0) -CSS_PSEUDO_ELEMENT(mozNumberSpinDown, ":-moz-number-spin-down", 0) -CSS_PSEUDO_ELEMENT(mozProgressBar, ":-moz-progress-bar", 0) -CSS_PSEUDO_ELEMENT(mozRangeTrack, ":-moz-range-track", 0) -CSS_PSEUDO_ELEMENT(mozRangeProgress, ":-moz-range-progress", 0) -CSS_PSEUDO_ELEMENT(mozRangeThumb, ":-moz-range-thumb", 0) -CSS_PSEUDO_ELEMENT(mozMeterBar, ":-moz-meter-bar", 0) -CSS_PSEUDO_ELEMENT(mozPlaceholder, ":-moz-placeholder", 0) +CSS_PSEUDO_ELEMENT(mozNumberWrapper, ":-moz-number-wrapper", + CSS_PSEUDO_ELEMENT_SUPPORTS_USER_ACTION_STATE) +CSS_PSEUDO_ELEMENT(mozNumberText, ":-moz-number-text", + CSS_PSEUDO_ELEMENT_SUPPORTS_USER_ACTION_STATE) +CSS_PSEUDO_ELEMENT(mozNumberSpinBox, ":-moz-number-spin-box", + CSS_PSEUDO_ELEMENT_SUPPORTS_USER_ACTION_STATE) +CSS_PSEUDO_ELEMENT(mozNumberSpinUp, ":-moz-number-spin-up", + CSS_PSEUDO_ELEMENT_SUPPORTS_USER_ACTION_STATE) +CSS_PSEUDO_ELEMENT(mozNumberSpinDown, ":-moz-number-spin-down", + CSS_PSEUDO_ELEMENT_SUPPORTS_USER_ACTION_STATE) +CSS_PSEUDO_ELEMENT(mozProgressBar, ":-moz-progress-bar", + CSS_PSEUDO_ELEMENT_SUPPORTS_USER_ACTION_STATE) +CSS_PSEUDO_ELEMENT(mozRangeTrack, ":-moz-range-track", + CSS_PSEUDO_ELEMENT_SUPPORTS_USER_ACTION_STATE) +CSS_PSEUDO_ELEMENT(mozRangeProgress, ":-moz-range-progress", + CSS_PSEUDO_ELEMENT_SUPPORTS_USER_ACTION_STATE) +CSS_PSEUDO_ELEMENT(mozRangeThumb, ":-moz-range-thumb", + CSS_PSEUDO_ELEMENT_SUPPORTS_USER_ACTION_STATE) +CSS_PSEUDO_ELEMENT(mozMeterBar, ":-moz-meter-bar", + CSS_PSEUDO_ELEMENT_SUPPORTS_USER_ACTION_STATE) +CSS_PSEUDO_ELEMENT(mozPlaceholder, ":-moz-placeholder", + CSS_PSEUDO_ELEMENT_SUPPORTS_USER_ACTION_STATE) CSS_PSEUDO_ELEMENT(mozColorSwatch, ":-moz-color-swatch", - CSS_PSEUDO_ELEMENT_SUPPORTS_STYLE_ATTRIBUTE) + CSS_PSEUDO_ELEMENT_SUPPORTS_STYLE_ATTRIBUTE | + CSS_PSEUDO_ELEMENT_SUPPORTS_USER_ACTION_STATE) diff --git a/layout/style/nsCSSPseudoElements.cpp b/layout/style/nsCSSPseudoElements.cpp index 32a3d70a07eb..ef4d86c6adfe 100644 --- a/layout/style/nsCSSPseudoElements.cpp +++ b/layout/style/nsCSSPseudoElements.cpp @@ -112,3 +112,10 @@ nsCSSPseudoElements::FlagsForPseudoElement(const Type aType) "argument must be a pseudo-element"); return CSSPseudoElements_flags[index]; } + +/* static */ bool +nsCSSPseudoElements::PseudoElementSupportsUserActionState(const Type aType) +{ + return PseudoElementHasFlags(aType, + CSS_PSEUDO_ELEMENT_SUPPORTS_USER_ACTION_STATE); +} diff --git a/layout/style/nsCSSPseudoElements.h b/layout/style/nsCSSPseudoElements.h index 282e1eb00fbc..9e8b425ca41c 100644 --- a/layout/style/nsCSSPseudoElements.h +++ b/layout/style/nsCSSPseudoElements.h @@ -13,7 +13,7 @@ // Is this pseudo-element a CSS2 pseudo-element that can be specified // with the single colon syntax (in addition to the double-colon syntax, // which can be used for all pseudo-elements)? -#define CSS_PSEUDO_ELEMENT_IS_CSS2 (1<<0) +#define CSS_PSEUDO_ELEMENT_IS_CSS2 (1<<0) // Is this pseudo-element a pseudo-element that can contain other // elements? // (Currently pseudo-elements are either leaves of the tree (relative to @@ -22,10 +22,16 @@ // possible that in the future there might be container pseudo-elements // that form a properly nested tree structure. If that happens, we // should probably split this flag into two.) -#define CSS_PSEUDO_ELEMENT_CONTAINS_ELEMENTS (1<<1) +#define CSS_PSEUDO_ELEMENT_CONTAINS_ELEMENTS (1<<1) // Flag to add the ability to take into account style attribute set for the // pseudo element (by default it's ignored). -#define CSS_PSEUDO_ELEMENT_SUPPORTS_STYLE_ATTRIBUTE (1<<2) +#define CSS_PSEUDO_ELEMENT_SUPPORTS_STYLE_ATTRIBUTE (1<<2) +// Flag that indicate the pseudo-element supports a user action pseudo-class +// following it, such as :active or :hover. This would normally correspond +// to whether the pseudo-element is tree-like, but we don't support these +// pseudo-classes on ::before and ::after generated content yet. See +// http://dev.w3.org/csswg/selectors4/#pseudo-elements. +#define CSS_PSEUDO_ELEMENT_SUPPORTS_USER_ACTION_STATE (1<<3) // Empty class derived from nsIAtom so that function signatures can // require an atom from this atom list. @@ -79,6 +85,12 @@ public: return PseudoElementHasFlags(aType, CSS_PSEUDO_ELEMENT_SUPPORTS_STYLE_ATTRIBUTE); } + static bool PseudoElementSupportsUserActionState(nsIAtom *aAtom) { + return PseudoElementSupportsUserActionState(GetPseudoType(aAtom)); + } + + static bool PseudoElementSupportsUserActionState(const Type aType); + private: static uint32_t FlagsForPseudoElement(const Type aType);