Bug 1348490 - Convert PseudoElement::mozPlaceholder to PseudoElement::Placeholder in PseudoElement::from_slice. draft
authorcku <cku@mozilla.com>
Thu, 18 May 2017 23:26:35 +0800
changeset 580487 f8456b7599158d4ff261c4cc5ac12b52b3caa8d3
parent 579879 2c783a7b6d05b4b2b417bc5f21b7e40cbf3df077
child 629305 544573f4eea67bab9f95be88db87b12bebff2ce8
push id59576
push userbmo:cku@mozilla.com
push dateThu, 18 May 2017 16:32:08 +0000
bugs1348490
milestone55.0a1
Bug 1348490 - Convert PseudoElement::mozPlaceholder to PseudoElement::Placeholder in PseudoElement::from_slice. CSSParserImpl::ParsePseudoSelector[1] calls nsCSSPseudoElements::GetPseudoType[2], which covert mozPlaceholder to placeholder. We should follow this rule in stylo side too, since gecko frame knows only placeholder. [1] https://hg.mozilla.org/mozilla-central/file/538468358017/layout/style/nsCSSParser.cpp#l5993 MozReview-Commit-ID: 7qZeg49ojnO [2] https://hg.mozilla.org/mozilla-central/file/99574da8257c/layout/style/nsCSSPseudoElements.cpp#l90
servo/components/style/gecko/pseudo_element_definition.mako.rs
--- a/servo/components/style/gecko/pseudo_element_definition.mako.rs
+++ b/servo/components/style/gecko/pseudo_element_definition.mako.rs
@@ -113,17 +113,22 @@ impl PseudoElement {
     /// Returns `None` if the pseudo-element is not recognised.
     #[inline]
     pub fn from_slice(s: &str, in_ua_stylesheet: bool) -> Option<Self> {
         use std::ascii::AsciiExt;
 
         % for pseudo in PSEUDOS:
             if in_ua_stylesheet || PseudoElement::${pseudo.capitalized()}.exposed_in_non_ua_sheets() {
                 if s.eq_ignore_ascii_case("${pseudo.value[1:]}") {
+                // ::moz-placeholder is an alias for ::placeholder
+                % if pseudo.value[1:] == "-moz-placeholder" :
+                    return Some(PseudoElement::Placeholder)
+                % else :
                     return Some(PseudoElement::${pseudo.capitalized()})
+                % endif
                 }
             }
         % endfor
 
         None
     }
 
     /// Returns the pseudo-element's definition as a string, with only one colon