Bug 1082899 patch 5 - Add :-moz-native-anonymous pseudo-class, exposed only to UA style sheets. r=birtles sr=bzbarsky
authorL. David Baron <dbaron@dbaron.org>
Thu, 23 Oct 2014 12:57:28 -0400
changeset 211913 550bb1f5b80183513752d3702b9fb0a011cf9cea
parent 211912 858d2174b9c1044cf3ee4c612de7755a6fc62076
child 211914 1ac58452ef7d8ee538ca922bb4cb5ff9bc54cb07
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, bzbarsky
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 5 - Add :-moz-native-anonymous pseudo-class, exposed only to UA style sheets. r=birtles sr=bzbarsky
layout/style/nsCSSPseudoClassList.h
layout/style/nsCSSRuleProcessor.cpp
layout/style/test/test_selectors.html
--- a/layout/style/nsCSSPseudoClassList.h
+++ b/layout/style/nsCSSPseudoClassList.h
@@ -85,16 +85,22 @@ CSS_PSEUDO_CLASS(onlyOfType, ":only-of-t
 CSS_PSEUDO_CLASS(nthChild, ":nth-child", 0, "")
 CSS_PSEUDO_CLASS(nthLastChild, ":nth-last-child", 0, "")
 CSS_PSEUDO_CLASS(nthOfType, ":nth-of-type", 0, "")
 CSS_PSEUDO_CLASS(nthLastOfType, ":nth-last-of-type", 0, "")
 
 // Match nodes that are HTML but not XHTML
 CSS_PSEUDO_CLASS(mozIsHTML, ":-moz-is-html", 0, "")
 
+// Matches nodes that are in a native-anonymous subtree (i.e., nodes in
+// a subtree of C++ anonymous content constructed by Gecko for its own
+// purposes).
+CSS_PSEUDO_CLASS(mozNativeAnonymous, ":-moz-native-anonymous",
+                 CSS_PSEUDO_CLASS_UA_SHEET_ONLY, "")
+
 // Matches anything when the specified look-and-feel metric is set
 CSS_PSEUDO_CLASS(mozSystemMetric, ":-moz-system-metric", 0, "")
 
 // -moz-locale-dir(ltr) and -moz-locale-dir(rtl) may be used
 // to match based on the locale's chrome direction
 CSS_PSEUDO_CLASS(mozLocaleDir, ":-moz-locale-dir", 0, "")
 
 // -moz-lwtheme may be used to match a document that has a lightweight theme
--- a/layout/style/nsCSSRuleProcessor.cpp
+++ b/layout/style/nsCSSRuleProcessor.cpp
@@ -2080,16 +2080,22 @@ static bool SelectorMatches(Element* aEl
         break;
 
       case nsCSSPseudoClasses::ePseudoClass_mozIsHTML:
         if (!aTreeMatchContext.mIsHTMLDocument || !aElement->IsHTML()) {
           return false;
         }
         break;
 
+      case nsCSSPseudoClasses::ePseudoClass_mozNativeAnonymous:
+        if (!aElement->IsInNativeAnonymousSubtree()) {
+          return false;
+        }
+        break;
+
       case nsCSSPseudoClasses::ePseudoClass_mozSystemMetric:
         {
           nsCOMPtr<nsIAtom> metric = do_GetAtom(pseudoClass->u.mString);
           if (!nsCSSRuleProcessor::HasSystemMetric(metric)) {
             return false;
           }
         }
         break;
--- a/layout/style/test/test_selectors.html
+++ b/layout/style/test/test_selectors.html
@@ -1014,16 +1014,19 @@ function run() {
     test_parseable("div p:-moz-window-inactive:hover span");
 
     // Plugin pseudoclasses
     test_parseable(":-moz-type-unsupported");
     test_parseable(":-moz-handler-disabled");
     test_parseable(":-moz-handler-blocked");
     test_parseable(":-moz-handler-crashed");
 
+    // We're not in a UA sheet, so this should be invalid.
+    test_balanced_unparseable(":-moz-native-anonymous");
+
     // Case sensitivity of tag selectors
     function setup_cased_spans(body) {
       var data = [
         { tag: "span" },
         { tag: "sPaN" },
         { tag: "Span" },
         { tag: "SPAN" },
         { ns: "http://www.w3.org/1999/xhtml", tag: "span" },