Bug 930010 - Hide the CSS pseudo-elements for <input type=number>'s anonymous content tree from content. r=bz
authorJonathan Watt <jwatt@jwatt.org>
Fri, 22 Nov 2013 13:24:55 +0000
changeset 171652 fdb9fe9e898fab8275daac054eaa22654e7d0244
parent 171651 b6209340060858370d885b6057b6c70cd6a765ae
child 171653 8aaed2b8853807676d795241f7557b861582442a
push id3224
push userlsblakk@mozilla.com
push dateTue, 04 Feb 2014 01:06:49 +0000
treeherdermozilla-beta@60c04d0987f1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs930010
milestone28.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 930010 - Hide the CSS pseudo-elements for <input type=number>'s anonymous content tree from content. r=bz
layout/reftests/forms/input/number/number-pseudo-elements-ref.html
layout/reftests/forms/input/number/number-pseudo-elements.html
layout/reftests/forms/input/number/reftest.list
layout/style/nsCSSParser.cpp
new file mode 100644
--- /dev/null
+++ b/layout/reftests/forms/input/number/number-pseudo-elements-ref.html
@@ -0,0 +1,6 @@
+<!DOCTYPE html>
+<html>
+  <body>
+    <input type="number" style="-moz-appearance:none;">
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/forms/input/number/number-pseudo-elements.html
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <style>
+
+/* None of these selectors should match from content */
+input[type=number]::-moz-number-wrapper,
+input[type=number]::-moz-number-text,
+input[type=number]::-moz-number-spin-box,
+input[type=number]::-moz-number-spin-up,
+input[type=number]::-moz-number-spin-down {
+  background-color: red;
+}
+
+    </style>
+  </head>
+  <body>
+    <input type="number" style="-moz-appearance:none;">
+  </body>
+</html>
--- a/layout/reftests/forms/input/number/reftest.list
+++ b/layout/reftests/forms/input/number/reftest.list
@@ -15,8 +15,11 @@ fuzzy-if(/^Windows\x20NT\x205\.1/.test(h
 == from-number-to-other-type-unthemed-1.html from-number-to-other-type-unthemed-1-ref.html
 
 # dynamic value changes:
 == show-value.html show-value-ref.html
 
 # focus
 fails-if(B2G) needs-focus == focus-handling.html focus-handling-ref.html # bug 940760
 
+# pseudo-elements not usable from content:
+== number-pseudo-elements.html number-pseudo-elements-ref.html
+
--- a/layout/style/nsCSSParser.cpp
+++ b/layout/style/nsCSSParser.cpp
@@ -3656,16 +3656,28 @@ CSSParserImpl::ParsePseudoSelector(int32
 
   // stash away some info about this pseudo so we only have to get it once.
   bool isTreePseudo = false;
   nsCSSPseudoElements::Type pseudoElementType =
     nsCSSPseudoElements::GetPseudoType(pseudo);
   nsCSSPseudoClasses::Type pseudoClassType =
     nsCSSPseudoClasses::GetPseudoType(pseudo);
 
+  if (!mUnsafeRulesEnabled &&
+      (pseudoElementType == nsCSSPseudoElements::ePseudo_mozNumberWrapper ||
+       pseudoElementType == nsCSSPseudoElements::ePseudo_mozNumberText ||
+       pseudoElementType == nsCSSPseudoElements::ePseudo_mozNumberSpinBox ||
+       pseudoElementType == nsCSSPseudoElements::ePseudo_mozNumberSpinUp ||
+       pseudoElementType == nsCSSPseudoElements::ePseudo_mozNumberSpinDown)) {
+    // Hide these pseudo-elements from content until we standardize them.
+    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 &&
       pseudoClassType == nsCSSPseudoClasses::ePseudoClass_mozPlaceholder) {
     if (parsingPseudoElement) {
       pseudoClassType = nsCSSPseudoClasses::ePseudoClass_NotPseudoClass;
     } else {
       pseudoElementType = nsCSSPseudoElements::ePseudo_NotPseudoElement;