Bug 525952 part 2. Have different macros so nsCSSPseudoClassList.h consumers can tell apart state-related and not-state-related pseudo-classes. r=dbaron
authorBoris Zbarsky <bzbarsky@mit.edu>
Fri, 11 Dec 2009 02:37:41 -0500
changeset 35561 5bcdfa447ae5683c8c89b045f755987577325648
parent 35560 626e14ae4183e9ef681af16b00d9577794fd6a98
child 35562 40b14411b05a2e33d313174275fce116dd028a13
push id10635
push userbzbarsky@mozilla.com
push dateFri, 11 Dec 2009 07:38:06 +0000
treeherdermozilla-central@9af2a428dcb1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron
bugs525952
milestone1.9.3a1pre
Bug 525952 part 2. Have different macros so nsCSSPseudoClassList.h consumers can tell apart state-related and not-state-related pseudo-classes. r=dbaron
layout/style/nsCSSPseudoClassList.h
--- a/layout/style/nsCSSPseudoClassList.h
+++ b/layout/style/nsCSSPseudoClassList.h
@@ -37,69 +37,88 @@
  * ***** END LICENSE BLOCK ***** */
 
 /* atom list for CSS pseudo-classes */
 
 /*
  * This file contains the list of nsIAtoms and their values for CSS
  * pseudo-classes.  It is designed to be used as inline input to
  * nsCSSPseudoClasses.cpp *only* through the magic of C preprocessing.
- * All entries must be enclosed in the macro CSS_PSEUDO_CLASS which will
- * have cruel and unusual things done to it.  The entries should be kept
- * in some sort of logical order.  The first argument to
- * CSS_PSEUDO_CLASS is the C++ identifier of the atom.  The second
- * argument is the string value of the atom.
+ * All entries must be enclosed in the macros CSS_PSEUDO_CLASS or
+ * CSS_STATE_PSEUDO_CLASS which will have cruel and unusual things
+ * done to it.  The entries should be kept in some sort of logical
+ * order.  The first argument to CSS_PSEUDO_CLASS is the C++
+ * identifier of the atom.  The second argument is the string value of
+ * the atom.  CSS_STATE_PSEUDO_CLASS also takes the name of the state
+ * bit that the class corresponds to.  If CSS_STATE_PSEUDO_CLASS is
+ * not defined, it'll be automatically defined to CSS_PSEUDO_CLASS.
  */
 
 // OUTPUT_CLASS=nsCSSPseudoClasses
 // MACRO_NAME=CSS_PSEUDO_CLASS
 
+#ifdef DEFINED_CSS_STATE_PSEUDO_CLASS
+#error "This shouldn't be defined"
+#endif
+
+#ifndef CSS_STATE_PSEUDO_CLASS
+#define CSS_STATE_PSEUDO_CLASS(_name, _value, _bit) \
+  CSS_PSEUDO_CLASS(_name, _value)
+#define DEFINED_CSS_STATE_PSEUDO_CLASS
+#endif
+
 CSS_PSEUDO_CLASS(empty, ":empty")
 CSS_PSEUDO_CLASS(mozOnlyWhitespace, ":-moz-only-whitespace")
 CSS_PSEUDO_CLASS(mozEmptyExceptChildrenWithLocalname, ":-moz-empty-except-children-with-localname")
 CSS_PSEUDO_CLASS(lang, ":lang")
 CSS_PSEUDO_CLASS(notPseudo, ":not")
 CSS_PSEUDO_CLASS(mozBoundElement, ":-moz-bound-element")
 CSS_PSEUDO_CLASS(root, ":root")
 
 CSS_PSEUDO_CLASS(link, ":link")
 CSS_PSEUDO_CLASS(mozAnyLink, ":-moz-any-link") // what matches :link or :visited
 CSS_PSEUDO_CLASS(visited, ":visited")
 
-CSS_PSEUDO_CLASS(active, ":active")
-CSS_PSEUDO_CLASS(checked, ":checked")
-CSS_PSEUDO_CLASS(disabled, ":disabled")
-CSS_PSEUDO_CLASS(enabled, ":enabled")
-CSS_PSEUDO_CLASS(focus, ":focus")
-CSS_PSEUDO_CLASS(hover, ":hover")
-CSS_PSEUDO_CLASS(mozDragOver, ":-moz-drag-over")
-CSS_PSEUDO_CLASS(target, ":target")
-CSS_PSEUDO_CLASS(indeterminate, ":indeterminate")
+CSS_STATE_PSEUDO_CLASS(active, ":active", NS_EVENT_STATE_ACTIVE)
+CSS_STATE_PSEUDO_CLASS(checked, ":checked", NS_EVENT_STATE_CHECKED)
+CSS_STATE_PSEUDO_CLASS(disabled, ":disabled", NS_EVENT_STATE_DISABLED)
+CSS_STATE_PSEUDO_CLASS(enabled, ":enabled", NS_EVENT_STATE_ENABLED)
+CSS_STATE_PSEUDO_CLASS(focus, ":focus", NS_EVENT_STATE_FOCUS)
+CSS_STATE_PSEUDO_CLASS(hover, ":hover", NS_EVENT_STATE_HOVER)
+CSS_STATE_PSEUDO_CLASS(mozDragOver, ":-moz-drag-over", NS_EVENT_STATE_DRAGOVER)
+CSS_STATE_PSEUDO_CLASS(target, ":target", NS_EVENT_STATE_URLTARGET)
+CSS_STATE_PSEUDO_CLASS(indeterminate, ":indeterminate",
+                       NS_EVENT_STATE_INDETERMINATE)
 
 CSS_PSEUDO_CLASS(firstChild, ":first-child")
 CSS_PSEUDO_CLASS(firstNode, ":-moz-first-node")
 CSS_PSEUDO_CLASS(lastChild, ":last-child")
 CSS_PSEUDO_CLASS(lastNode, ":-moz-last-node")
 CSS_PSEUDO_CLASS(onlyChild, ":only-child")
 CSS_PSEUDO_CLASS(firstOfType, ":first-of-type")
 CSS_PSEUDO_CLASS(lastOfType, ":last-of-type")
 CSS_PSEUDO_CLASS(onlyOfType, ":only-of-type")
 CSS_PSEUDO_CLASS(nthChild, ":nth-child")
 CSS_PSEUDO_CLASS(nthLastChild, ":nth-last-child")
 CSS_PSEUDO_CLASS(nthOfType, ":nth-of-type")
 CSS_PSEUDO_CLASS(nthLastOfType, ":nth-last-of-type")
 
 // Image, object, etc state pseudo-classes
-CSS_PSEUDO_CLASS(mozBroken, ":-moz-broken")
-CSS_PSEUDO_CLASS(mozUserDisabled, ":-moz-user-disabled")
-CSS_PSEUDO_CLASS(mozSuppressed, ":-moz-suppressed")
-CSS_PSEUDO_CLASS(mozLoading, ":-moz-loading")
-CSS_PSEUDO_CLASS(mozTypeUnsupported, ":-moz-type-unsupported")
-CSS_PSEUDO_CLASS(mozHandlerDisabled, ":-moz-handler-disabled")
-CSS_PSEUDO_CLASS(mozHandlerBlocked, ":-moz-handler-blocked")
+CSS_STATE_PSEUDO_CLASS(mozBroken, ":-moz-broken", NS_EVENT_STATE_BROKEN)
+CSS_STATE_PSEUDO_CLASS(mozUserDisabled, ":-moz-user-disabled",
+                       NS_EVENT_STATE_USERDISABLED)
+CSS_STATE_PSEUDO_CLASS(mozSuppressed, ":-moz-suppressed",
+                       NS_EVENT_STATE_SUPPRESSED)
+CSS_STATE_PSEUDO_CLASS(mozLoading, ":-moz-loading", NS_EVENT_STATE_LOADING)
+CSS_STATE_PSEUDO_CLASS(mozTypeUnsupported, ":-moz-type-unsupported",
+                       NS_EVENT_STATE_TYPE_UNSUPPORTED)
+CSS_STATE_PSEUDO_CLASS(mozHandlerDisabled, ":-moz-handler-disabled",
+                       NS_EVENT_STATE_HANDLER_DISABLED)
+CSS_STATE_PSEUDO_CLASS(mozHandlerBlocked, ":-moz-handler-blocked",
+                       NS_EVENT_STATE_HANDLER_BLOCKED)
 
 CSS_PSEUDO_CLASS(mozHasHandlerRef, ":-moz-has-handlerref")
 
 // Match nodes that are HTML but not XHTML
 CSS_PSEUDO_CLASS(mozIsHTML, ":-moz-is-html")
 
 // Matches anything when the specified look-and-feel metric is set
 CSS_PSEUDO_CLASS(mozSystemMetric, ":-moz-system-metric")
@@ -113,22 +132,31 @@ CSS_PSEUDO_CLASS(mozLWTheme, ":-moz-lwth
 
 // -moz-lwtheme-brighttext matches a document that has a bright lightweight theme
 CSS_PSEUDO_CLASS(mozLWThemeBrightText, ":-moz-lwtheme-brighttext")
 
 // -moz-lwtheme-darktext matches a document that has a bright lightweight theme
 CSS_PSEUDO_CLASS(mozLWThemeDarkText, ":-moz-lwtheme-darktext")
 
 #ifdef MOZ_MATHML
-CSS_PSEUDO_CLASS(mozMathIncrementScriptLevel, ":-moz-math-increment-script-level")
+CSS_STATE_PSEUDO_CLASS(mozMathIncrementScriptLevel,
+                       ":-moz-math-increment-script-level",
+                       NS_EVENT_STATE_INCREMENT_SCRIPT_LEVEL)
 #endif
 
 // CSS 3 UI
 // http://www.w3.org/TR/2004/CR-css3-ui-20040511/#pseudo-classes
-CSS_PSEUDO_CLASS(required, ":required")
-CSS_PSEUDO_CLASS(optional, ":optional")
-CSS_PSEUDO_CLASS(valid, ":valid")
-CSS_PSEUDO_CLASS(invalid, ":invalid")
-CSS_PSEUDO_CLASS(inRange, ":in-range")
-CSS_PSEUDO_CLASS(outOfRange, ":out-of-range")
-CSS_PSEUDO_CLASS(defaultPseudo, ":default")
-CSS_PSEUDO_CLASS(mozReadOnly, ":-moz-read-only")
-CSS_PSEUDO_CLASS(mozReadWrite, ":-moz-read-write")
+CSS_STATE_PSEUDO_CLASS(required, ":required", NS_EVENT_STATE_REQUIRED)
+CSS_STATE_PSEUDO_CLASS(optional, ":optional", NS_EVENT_STATE_OPTIONAL)
+CSS_STATE_PSEUDO_CLASS(valid, ":valid", NS_EVENT_STATE_VALID)
+CSS_STATE_PSEUDO_CLASS(invalid, ":invalid", NS_EVENT_STATE_INVALID)
+CSS_STATE_PSEUDO_CLASS(inRange, ":in-range", NS_EVENT_STATE_INRANGE)
+CSS_STATE_PSEUDO_CLASS(outOfRange, ":out-of-range", NS_EVENT_STATE_OUTOFRANGE)
+CSS_STATE_PSEUDO_CLASS(defaultPseudo, ":default", NS_EVENT_STATE_DEFAULT)
+CSS_STATE_PSEUDO_CLASS(mozReadOnly, ":-moz-read-only",
+                       NS_EVENT_STATE_MOZ_READONLY)
+CSS_STATE_PSEUDO_CLASS(mozReadWrite, ":-moz-read-write",
+                       NS_EVENT_STATE_MOZ_READWRITE)
+
+#ifdef DEFINED_CSS_STATE_PSEUDO_CLASS
+#undef DEFINED_CSS_STATE_PSEUDO_CLASS
+#undef CSS_STATE_PSEUDO_CLASS
+#endif