Bug 1082899 patch 3 - Add flag for marking pseudo-classes as UA-sheet only. r=birtles
authorL. David Baron <dbaron@dbaron.org>
Thu, 23 Oct 2014 12:57:28 -0400
changeset 211911 6925c2f5d70156de2e7ed5b47c64b05a4590bdb2
parent 211910 c66f58d9a4013772821357e91ebe1ccefb68a06a
child 211912 858d2174b9c1044cf3ee4c612de7755a6fc62076
push id50852
push userdbaron@mozilla.com
push dateThu, 23 Oct 2014 16:58:05 +0000
treeherdermozilla-inbound@1ac58452ef7d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbirtles
bugs1082899
milestone36.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1082899 patch 3 - Add flag for marking pseudo-classes as UA-sheet only. r=birtles
layout/style/nsCSSParser.cpp
layout/style/nsCSSPseudoClasses.h
--- a/layout/style/nsCSSParser.cpp
+++ b/layout/style/nsCSSParser.cpp
@@ -5389,19 +5389,21 @@ CSSParserImpl::ParsePseudoSelector(int32
   nsCSSPseudoElements::Type pseudoElementType =
     nsCSSPseudoElements::GetPseudoType(pseudo);
   nsCSSPseudoClasses::Type pseudoClassType =
     nsCSSPseudoClasses::GetPseudoType(pseudo);
   bool pseudoClassIsUserAction =
     nsCSSPseudoClasses::IsUserActionPseudoClass(pseudoClassType);
 
   if (!mUnsafeRulesEnabled &&
-      pseudoElementType < nsCSSPseudoElements::ePseudo_PseudoElementCount &&
-      nsCSSPseudoElements::PseudoElementIsChromeOnly(pseudoElementType)) {
-    // This pseudo-element is not exposed to content.
+      ((pseudoElementType < nsCSSPseudoElements::ePseudo_PseudoElementCount &&
+        nsCSSPseudoElements::PseudoElementIsChromeOnly(pseudoElementType)) ||
+       (pseudoClassType != nsCSSPseudoClasses::ePseudoClass_NotPseudoClass &&
+        nsCSSPseudoClasses::PseudoClassIsUASheetOnly(pseudoClassType)))) {
+    // This pseudo-element or pseudo-class is not exposed to content.
     REPORT_UNEXPECTED_TOKEN(PEPseudoSelUnknown);
     UngetToken();
     return eSelectorParsingStatus_Error;
   }
 
   // We currently allow :-moz-placeholder and ::-moz-placeholder. We have to
   // be a bit stricter regarding the pseudo-element parsing rules.
   if (pseudoElementType == nsCSSPseudoElements::ePseudo_mozPlaceholder &&
--- a/layout/style/nsCSSPseudoClasses.h
+++ b/layout/style/nsCSSPseudoClasses.h
@@ -5,16 +5,19 @@
 
 /* atom list for CSS pseudo-classes */
 
 #ifndef nsCSSPseudoClasses_h___
 #define nsCSSPseudoClasses_h___
 
 #include "nsStringFwd.h"
 
+// This pseudo-element is accepted only in UA style sheets.
+#define CSS_PSEUDO_CLASS_UA_SHEET_ONLY                 (1<<0)
+
 class nsIAtom;
 
 class nsCSSPseudoClasses {
 public:
 
   static void AddRefAtoms();
 
   enum Type {
@@ -30,16 +33,20 @@ public:
   static Type GetPseudoType(nsIAtom* aAtom);
   static bool HasStringArg(Type aType);
   static bool HasNthPairArg(Type aType);
   static bool HasSelectorListArg(Type aType) {
     return aType == ePseudoClass_any;
   }
   static bool IsUserActionPseudoClass(Type aType);
 
+  static bool PseudoClassIsUASheetOnly(Type aType) {
+    return PseudoClassHasFlags(aType, CSS_PSEUDO_CLASS_UA_SHEET_ONLY);
+  }
+
   // Should only be used on types other than Count and NotPseudoClass
   static void PseudoTypeToString(Type aType, nsAString& aString);
 
 private:
   static uint32_t FlagsForPseudoClass(const Type aType);
 
   // Does the given pseudo-class have all of the flags given?
   static bool PseudoClassHasFlags(const Type aType, uint32_t aFlags)