From ab8c00e41a99cbfb72e232879c6100c96c18a40d Mon Sep 17 00:00:00 2001 From: Mats Palmgren Date: Sun, 24 Mar 2019 23:13:53 +0100 Subject: [PATCH] style: Add support for the ::marker pseudo element on list items. Alias :-moz-list-bullet/number to that in the parser. Bug: 205202 Reviewed-by: emilio --- components/style/dom.rs | 5 +++++ components/style/gecko/pseudo_element.rs | 4 +++- components/style/gecko/pseudo_element_definition.mako.rs | 5 ++++- components/style/gecko/wrapper.rs | 8 ++++++++ components/style/invalidation/element/invalidator.rs | 4 ++++ 5 files changed, 24 insertions(+), 2 deletions(-) diff --git a/components/style/dom.rs b/components/style/dom.rs index 1c64543310c..28798e280b6 100644 --- a/components/style/dom.rs +++ b/components/style/dom.rs @@ -441,6 +441,11 @@ pub trait TElement: None } + /// The ::marker pseudo-element of this element, if it exists. + fn marker_pseudo_element(&self) -> Option { + None + } + /// Execute `f` for each anonymous content child (apart from ::before and /// ::after) whose originating element is `self`. fn each_anonymous_content_child(&self, _f: F) diff --git a/components/style/gecko/pseudo_element.rs b/components/style/gecko/pseudo_element.rs index 8160ea2c9b8..c49277409e0 100644 --- a/components/style/gecko/pseudo_element.rs +++ b/components/style/gecko/pseudo_element.rs @@ -33,7 +33,7 @@ impl ::selectors::parser::PseudoElement for PseudoElement { fn valid_after_slotted(&self) -> bool { matches!( *self, - PseudoElement::Before | PseudoElement::After | PseudoElement::Placeholder + PseudoElement::Before | PseudoElement::After | PseudoElement::Marker | PseudoElement::Placeholder ) } @@ -180,6 +180,8 @@ impl PseudoElement { /// Whether this pseudo-element should actually exist if it has /// the given styles. pub fn should_exist(&self, style: &ComputedValues) -> bool { + debug_assert!(self.is_eager()); + if style.get_box().clone_display() == Display::None { return false; } diff --git a/components/style/gecko/pseudo_element_definition.mako.rs b/components/style/gecko/pseudo_element_definition.mako.rs index be156b54a14..e2dffcbdd74 100644 --- a/components/style/gecko/pseudo_element_definition.mako.rs +++ b/components/style/gecko/pseudo_element_definition.mako.rs @@ -195,13 +195,16 @@ impl PseudoElement { return Some(${pseudo_element_variant(pseudo)}) } % endfor - // Alias "-moz-selection" to "selection" at parse time. + // Alias some legacy prefixed pseudos to their standardized name at parse time: "-moz-selection" => { return Some(PseudoElement::Selection); } "-moz-placeholder" => { return Some(PseudoElement::Placeholder); } + "-moz-list-bullet" | "-moz-list-number" => { + return Some(PseudoElement::Marker); + } _ => { if starts_with_ignore_ascii_case(name, "-moz-tree-") { return PseudoElement::tree_pseudo_element(name, Box::new([])) diff --git a/components/style/gecko/wrapper.rs b/components/style/gecko/wrapper.rs index 93d3290c191..dedfe7715e8 100644 --- a/components/style/gecko/wrapper.rs +++ b/components/style/gecko/wrapper.rs @@ -1137,6 +1137,14 @@ impl<'le> TElement for GeckoElement<'le> { self.before_or_after_pseudo(/* is_before = */ false) } + fn marker_pseudo_element(&self) -> Option { + if !self.has_properties() { + return None; + } + + unsafe { bindings::Gecko_GetMarkerPseudo(self.0).as_ref().map(GeckoElement) } + } + #[inline] fn is_html_element(&self) -> bool { self.namespace_id() == structs::kNameSpaceID_XHTML as i32 diff --git a/components/style/invalidation/element/invalidator.rs b/components/style/invalidation/element/invalidator.rs index 4640c7c0442..7ed97c0b197 100644 --- a/components/style/invalidation/element/invalidator.rs +++ b/components/style/invalidation/element/invalidator.rs @@ -542,6 +542,10 @@ where any_descendant |= self.invalidate_dom_descendants_of(anon_content, invalidations); } + if let Some(marker) = self.element.marker_pseudo_element() { + any_descendant |= self.invalidate_pseudo_element_or_nac(marker, invalidations); + } + if let Some(before) = self.element.before_pseudo_element() { any_descendant |= self.invalidate_pseudo_element_or_nac(before, invalidations); }