mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
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
This commit is contained in:
parent
62419adaaa
commit
998e6f1797
4 changed files with 7 additions and 14 deletions
|
@ -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<PropertyFlags> {
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<Rule>> {
|
||||
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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue