From 998e6f179726a7a67491d78687855af599532eea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Wed, 1 Aug 2018 11:57:45 +0200 Subject: [PATCH] style: Remove the concept of 'canonical' pseudos. We only have this so that ::-moz-placeholder keeps serializing as ::-moz-placeholder, but I don't think anybody really cares. Edge aliases ::-webkit-input-placeholder to ::-ms-input-placeholder at parse time as well, as can be seen in: ``` let s = document.createElement('style'); s.innerHTML = `input::-webkit-input-placeholder { color: red };`; document.body.appendChild(s); document.body.innerHTML = s.sheet.cssRules[0].cssText; ``` And I think this is more consistent with what we do for CSS properties that are aliases. Differential Revision: https://phabricator.services.mozilla.com/D2595 --- components/style/gecko/pseudo_element.rs | 9 --------- components/style/gecko/pseudo_element_definition.mako.rs | 3 +++ components/style/gecko/wrapper.rs | 2 +- components/style/stylist.rs | 7 +++---- 4 files changed, 7 insertions(+), 14 deletions(-) diff --git a/components/style/gecko/pseudo_element.rs b/components/style/gecko/pseudo_element.rs index 296b6339857..a08da8d40f1 100644 --- a/components/style/gecko/pseudo_element.rs +++ b/components/style/gecko/pseudo_element.rs @@ -162,15 +162,6 @@ impl PseudoElement { self.is_anon_box() && !self.is_tree_pseudo_element() } - /// Covert non-canonical pseudo-element to canonical one, and keep a - /// canonical one as it is. - pub fn canonical(&self) -> PseudoElement { - match *self { - PseudoElement::MozPlaceholder => PseudoElement::Placeholder, - _ => self.clone(), - } - } - /// Property flag that properties must have to apply to this pseudo-element. #[inline] pub fn property_restriction(&self) -> Option { diff --git a/components/style/gecko/pseudo_element_definition.mako.rs b/components/style/gecko/pseudo_element_definition.mako.rs index 30f71a496d8..06323699b19 100644 --- a/components/style/gecko/pseudo_element_definition.mako.rs +++ b/components/style/gecko/pseudo_element_definition.mako.rs @@ -234,6 +234,9 @@ impl PseudoElement { "-moz-selection" => { return Some(PseudoElement::Selection); } + "-moz-placeholder" => { + return Some(PseudoElement::Placeholder); + } _ => { // FIXME: -moz-tree check should probably be // ascii-case-insensitive. diff --git a/components/style/gecko/wrapper.rs b/components/style/gecko/wrapper.rs index b00755a1d5b..85e8c4eaef5 100644 --- a/components/style/gecko/wrapper.rs +++ b/components/style/gecko/wrapper.rs @@ -2267,7 +2267,7 @@ impl<'le> ::selectors::Element for GeckoElement<'le> { // match the proper pseudo-element, given how we rulehash the stuff // based on the pseudo. match self.implemented_pseudo_element() { - Some(ref pseudo) => *pseudo == pseudo_element.canonical(), + Some(ref pseudo) => *pseudo == *pseudo_element, None => false, } } diff --git a/components/style/stylist.rs b/components/style/stylist.rs index f4614f945af..52feb19c411 100644 --- a/components/style/stylist.rs +++ b/components/style/stylist.rs @@ -898,7 +898,6 @@ impl Stylist { where E: TElement, { - let pseudo = pseudo.canonical(); debug_assert!(pseudo.is_lazy()); // Apply the selector flags. We should be in sequential mode @@ -1892,7 +1891,7 @@ impl ElementAndPseudoRules { let map = match pseudo_element { None => &mut self.element_map, Some(pseudo) => self.pseudos_map - .get_or_insert_with(&pseudo.canonical(), || Box::new(SelectorMap::new())), + .get_or_insert_with(pseudo, || Box::new(SelectorMap::new())), }; map.insert(rule, quirks_mode) @@ -1906,7 +1905,7 @@ impl ElementAndPseudoRules { #[inline] fn rules(&self, pseudo: Option<&PseudoElement>) -> Option<&SelectorMap> { match pseudo { - Some(pseudo) => self.pseudos_map.get(&pseudo.canonical()).map(|p| &**p), + Some(pseudo) => self.pseudos_map.get(pseudo).map(|p| &**p), None => Some(&self.element_map), } } @@ -2190,7 +2189,7 @@ impl CascadeData { precomputed_pseudo_element_decls .as_mut() .expect("Expected precomputed declarations for the UA level") - .get_or_insert_with(&pseudo.canonical(), Vec::new) + .get_or_insert_with(pseudo, Vec::new) .push(ApplicableDeclarationBlock::new( StyleSource::from_rule(locked.clone()), self.rules_source_order,