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
This commit is contained in:
Mats Palmgren 2019-03-24 23:13:53 +01:00 committed by Emilio Cobos Álvarez
parent ed74e8acbb
commit ab8c00e41a
5 changed files with 24 additions and 2 deletions

View file

@ -441,6 +441,11 @@ pub trait TElement:
None
}
/// The ::marker pseudo-element of this element, if it exists.
fn marker_pseudo_element(&self) -> Option<Self> {
None
}
/// Execute `f` for each anonymous content child (apart from ::before and
/// ::after) whose originating element is `self`.
fn each_anonymous_content_child<F>(&self, _f: F)

View file

@ -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;
}

View file

@ -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([]))

View file

@ -1137,6 +1137,14 @@ impl<'le> TElement for GeckoElement<'le> {
self.before_or_after_pseudo(/* is_before = */ false)
}
fn marker_pseudo_element(&self) -> Option<Self> {
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

View file

@ -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);
}