Bug 949651 - Serialize all pseudo-elements with the two-colon syntax, even those that allow one colon. r=dbaron
☠☠ backed out by 21caa5dfb494 ☠ ☠
authorBruno Peres <brunomperes1@gmail.com>
Wed, 15 Oct 2014 14:50:58 -0700
changeset 237058 f7e1426249f2e2847229cc6962beec76e0be9323
parent 237057 c621d0e5e5e2335d797056679c867c74b851a9df
child 237059 b39cff5628dfb2460cc464e3424de9c1f2230e0f
push id660
push userraliiev@mozilla.com
push dateWed, 18 Feb 2015 20:30:48 +0000
treeherdermozilla-release@49e493494178 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron
bugs949651
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 949651 - Serialize all pseudo-elements with the two-colon syntax, even those that allow one colon. r=dbaron
layout/style/StyleRule.cpp
layout/style/test/test_selectors.html
--- a/layout/style/StyleRule.cpp
+++ b/layout/style/StyleRule.cpp
@@ -672,19 +672,20 @@ nsCSSSelector::AppendToStringWithoutComb
     nsAutoString tag;
     (isPseudoElement ? mLowercaseTag : mCasedTag)->ToString(tag);
     if (isPseudoElement) {
       if (!mNext) {
         // Lone pseudo-element selector -- toss in a wildcard type selector
         // XXXldb Why?
         aString.Append(char16_t('*'));
       }
-      if (!nsCSSPseudoElements::IsCSS2PseudoElement(mLowercaseTag)) {
-        aString.Append(char16_t(':'));
-      }
+      // While our atoms use one colon, most pseudo-elements require two
+      // colons (those not in CSS level 2) and all pseudo-elements allow
+      // two colons. So serialize to the non-deprecated two colon syntax.
+      aString.Append(char16_t(':'));
       // This should not be escaped since (a) the pseudo-element string
       // has a ":" that can't be escaped and (b) all pseudo-elements at
       // this point are known, and therefore we know they don't need
       // escaping.
       aString.Append(tag);
     } else {
       nsStyleUtil::AppendEscapedCSSIdent(tag, aString);
     }
--- a/layout/style/test/test_selectors.html
+++ b/layout/style/test/test_selectors.html
@@ -862,19 +862,23 @@ function run() {
     test_selector_in_html(".a > .b ~ .nomatch", '<div class="a"><div><div class="b"></div><div class="nomatch"></div></div><div class="nomatch"></div></div>',
                          emptyset, classset(["a", "b", "nomatch"]));
     test_selector_in_html(".a > .b ~ .nomatch", '<div class="a"><div class="b"></div><div><div class="nomatch"></div></div><div></div></div>',
                          emptyset, classset(["a", "b", "nomatch"]));
     test_selector_in_html(".a > .b ~ .nomatch", '<div class="a"><div class="b"></div></div><div class="nomatch"></div>',
                          emptyset, classset(["a", "b", "nomatch"]));
 
     // Test serialization of pseudo-elements.
-    should_serialize_to("p:first-letter", "p:first-letter");
-    should_serialize_to("div>p:first-letter", "div > p:first-letter");
-    should_serialize_to("span +div:first-line", "span + div:first-line");
+    should_serialize_to("p::first-letter", "p::first-letter");
+    should_serialize_to("p:first-letter", "p::first-letter");
+    should_serialize_to("div>p:first-letter", "div > p::first-letter");
+    should_serialize_to("span +div:first-line", "span + div::first-line");
+
+    // Test serialization of non CSS2 pseudo-element.
+    should_serialize_to("input::-moz-placeholder", "input::-moz-placeholder");
 
     // Test default namespaces, including inside :not().
     var html_default_ns = "@namespace url(http://www.w3.org/1999/xhtml);";
     var html_ns = "@namespace html url(http://www.w3.org/1999/xhtml);";
     var xul_default_ns = "@namespace url(http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul);";
     var single_a = "<a id='a' href='data:text/plain,this_better_be_unvisited'></a>";
     var set_single = idset(['a']);
     var empty_set = idset([]);