Bug 509958: Unprefix :-moz-selection. r=dbaron,xidorn
authorEmilio Cobos Álvarez <emilio@crisal.io>
Sun, 25 Mar 2018 17:31:55 +0200
changeset 417756 70754a946fde161c04f86df1b67e3913c8ec590a
parent 417755 0e0e6097f282da9d82bc97960931922cfeb38690
child 417757 9d23e0279ecde11c1ffefd82e1d1f8c4d3d8adb8
push id33979
push userdluca@mozilla.com
push dateThu, 10 May 2018 21:59:38 +0000
treeherdermozilla-central@aabfe960ab59 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron, xidorn
bugs509958
milestone62.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 509958: Unprefix :-moz-selection. r=dbaron,xidorn Our implementation is totally not what the spec says, but totally what other UAs do, see https://github.com/w3c/csswg-drafts/issues/2474. So given this is causing webcompat pain, I think we should be pragmatic and just unprefix this. We could keep serialization and getComputedStyle with ::selection working with a bit more effort, like we do for :-moz-placeholder, but I'd prefer not doing at least the serialization bit, and just alias in nsCSSPseudoElements :-moz-selection to selection too. MozReview-Commit-ID: 6lxctozRDqv
devtools/client/inspector/rules/test/browser_rules_pseudo-element_01.js
devtools/shared/css/generated/properties-db.js
layout/generic/nsFrame.cpp
layout/inspector/tests/test_getCSSPseudoElementNames.html
layout/style/nsCSSPseudoElementList.h
layout/style/test/test_computed_style_grid_with_pseudo.html
servo/components/style/gecko/pseudo_element_definition.mako.rs
--- a/devtools/client/inspector/rules/test/browser_rules_pseudo-element_01.js
+++ b/devtools/client/inspector/rules/test/browser_rules_pseudo-element_01.js
@@ -25,17 +25,17 @@ add_task(async function() {
 
 async function testTopLeft(inspector, view) {
   let id = "#topleft";
   let rules = await assertPseudoElementRulesNumbers(id,
     inspector, view, {
       elementRulesNb: 4,
       firstLineRulesNb: 2,
       firstLetterRulesNb: 1,
-      selectionRulesNb: 0,
+      selectionRulesNb: 1,
       afterRulesNb: 1,
       beforeRulesNb: 2
     }
   );
 
   let gutters = assertGutters(view);
 
   info("Make sure that clicking on the twisty hides pseudo elements");
@@ -162,17 +162,17 @@ async function testBottomLeft(inspector,
 }
 
 async function testParagraph(inspector, view) {
   let rules =
     await assertPseudoElementRulesNumbers("#bottomleft p", inspector, view, {
       elementRulesNb: 3,
       firstLineRulesNb: 1,
       firstLetterRulesNb: 1,
-      selectionRulesNb: 1,
+      selectionRulesNb: 2,
       beforeRulesNb: 0,
       afterRulesNb: 0
     });
 
   assertGutters(view);
 
   let elementFirstLineRule = rules.firstLineRules[0];
   is(convertTextPropsToString(elementFirstLineRule.textProps),
@@ -212,17 +212,17 @@ async function assertPseudoElementRulesN
 
   let rules = {
     elementRules: elementStyle.rules.filter(rule => !rule.pseudoElement),
     firstLineRules: elementStyle.rules.filter(rule =>
       rule.pseudoElement === ":first-line"),
     firstLetterRules: elementStyle.rules.filter(rule =>
       rule.pseudoElement === ":first-letter"),
     selectionRules: elementStyle.rules.filter(rule =>
-      rule.pseudoElement === ":-moz-selection"),
+      rule.pseudoElement === ":selection"),
     beforeRules: elementStyle.rules.filter(rule =>
       rule.pseudoElement === ":before"),
     afterRules: elementStyle.rules.filter(rule =>
       rule.pseudoElement === ":after"),
   };
 
   is(rules.elementRules.length, ruleNbs.elementRulesNb,
      selector + " has the correct number of non pseudo element rules");
--- a/devtools/shared/css/generated/properties-db.js
+++ b/devtools/shared/css/generated/properties-db.js
@@ -9132,17 +9132,17 @@ exports.CSS_PROPERTIES = {
  */
 exports.PSEUDO_ELEMENTS = [
   ":after",
   ":before",
   ":backdrop",
   ":cue",
   ":first-letter",
   ":first-line",
-  ":-moz-selection",
+  ":selection",
   ":-moz-focus-inner",
   ":-moz-focus-outer",
   ":-moz-list-bullet",
   ":-moz-list-number",
   ":-moz-progress-bar",
   ":-moz-range-track",
   ":-moz-range-progress",
   ":-moz-range-thumb",
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -2272,17 +2272,17 @@ already_AddRefed<ComputedStyle>
 nsIFrame::ComputeSelectionStyle() const
 {
   Element* element = FindElementAncestorForMozSelection(GetContent());
   if (!element) {
     return nullptr;
   }
   RefPtr<ComputedStyle> sc =
     PresContext()->StyleSet()->ProbePseudoElementStyle(
-      element, CSSPseudoElementType::mozSelection, Style());
+      element, CSSPseudoElementType::selection, Style());
   return sc.forget();
 }
 
 /********************************************************
 * Refreshes each content's frame
 *********************************************************/
 
 void
--- a/layout/inspector/tests/test_getCSSPseudoElementNames.html
+++ b/layout/inspector/tests/test_getCSSPseudoElementNames.html
@@ -11,29 +11,29 @@
   let expected = new Set([
     ":after",
     ":before",
     ":backdrop",
     ":cue",
     ":first-letter",
     ":first-line",
     ":placeholder",
+    ":selection",
     ":-moz-color-swatch",
     ":-moz-focus-inner",
     ":-moz-focus-outer",
     ":-moz-list-bullet",
     ":-moz-list-number",
     ":-moz-math-anonymous",
     ":-moz-meter-bar",
     ":-moz-placeholder",
     ":-moz-progress-bar",
     ":-moz-range-progress",
     ":-moz-range-thumb",
     ":-moz-range-track",
-    ":-moz-selection",
   ]);
 
   let names = InspectorUtils.getCSSPseudoElementNames();
   for (let name of names) {
     ok(expected.has(name), name + " is included");
     expected.delete(name);
   }
 
--- a/layout/style/nsCSSPseudoElementList.h
+++ b/layout/style/nsCSSPseudoElementList.h
@@ -38,17 +38,17 @@ CSS_PSEUDO_ELEMENT(cue, ":cue", CSS_PSEU
 
 CSS_PSEUDO_ELEMENT(firstLetter, ":first-letter",
                    CSS_PSEUDO_ELEMENT_IS_CSS2 |
                    CSS_PSEUDO_ELEMENT_CONTAINS_ELEMENTS)
 CSS_PSEUDO_ELEMENT(firstLine, ":first-line",
                    CSS_PSEUDO_ELEMENT_IS_CSS2 |
                    CSS_PSEUDO_ELEMENT_CONTAINS_ELEMENTS)
 
-CSS_PSEUDO_ELEMENT(mozSelection, ":-moz-selection",
+CSS_PSEUDO_ELEMENT(selection, ":selection",
                    CSS_PSEUDO_ELEMENT_CONTAINS_ELEMENTS)
 
 // XXXbz should we really allow random content to style these?  Maybe
 // use our flags to prevent that?
 CSS_PSEUDO_ELEMENT(mozFocusInner, ":-moz-focus-inner", 0)
 CSS_PSEUDO_ELEMENT(mozFocusOuter, ":-moz-focus-outer", 0)
 
 // XXXbz should we really allow random content to style these?  Maybe
--- a/layout/style/test/test_computed_style_grid_with_pseudo.html
+++ b/layout/style/test/test_computed_style_grid_with_pseudo.html
@@ -57,17 +57,17 @@ function checkTemplateWithData(data) {
   is(computedTemplate, data.expected, message);
 
   container.removeChild(obj);
 }
 
 function runTest() {
   let dataToTest = [
     { template: "40px",
-      pseudo: "::-moz-selection",
+      pseudo: "::selection",
       expected: "none"},
     { template: "40px",
       pseudo: "::before",
       expected: "none" },
     { additionalClass: "gridBefore",
       pseudo: "::before",
       expected: "100px" },
     { additionalClass: "gridBeforeNoContent",
--- a/servo/components/style/gecko/pseudo_element_definition.mako.rs
+++ b/servo/components/style/gecko/pseudo_element_definition.mako.rs
@@ -211,34 +211,34 @@ impl PseudoElement {
                 if atom == &atom!("${pseudo.value}") {
                     return Some(PseudoElement::${pseudo.capitalized()}(args));
                 }
             % endif
         % endfor
         None
     }
 
-    /// Constructs an atom from a string of text, and whether we're in a
-    /// user-agent stylesheet.
-    ///
-    /// If we're not in a user-agent stylesheet, we will never parse anonymous
-    /// box pseudo-elements.
+    /// Constructs a pseudo-element from a string of text.
     ///
     /// Returns `None` if the pseudo-element is not recognised.
     #[inline]
     pub fn from_slice(name: &str) -> Option<Self> {
         // We don't need to support tree pseudos because functional
         // pseudo-elements needs arguments, and thus should be created
         // via other methods.
         match_ignore_ascii_case! { name,
             % for pseudo in SIMPLE_PSEUDOS:
             "${pseudo.value[1:]}" => {
                 return Some(${pseudo_element_variant(pseudo)})
             }
             % endfor
+            // Alias "-moz-selection" to "selection" at parse time.
+            "-moz-selection" => {
+                return Some(PseudoElement::Selection);
+            }
             _ => {
                 // FIXME: -moz-tree check should probably be
                 // ascii-case-insensitive.
                 if name.starts_with("-moz-tree-") {
                     return PseudoElement::tree_pseudo_element(name, Box::new([]))
                 }
             }
         }