Skip to content

Commit

Permalink
style: Add support for the ::marker pseudo element on list items. Ali…
Browse files Browse the repository at this point in the history
…as :-moz-list-bullet/number to that in the parser.

Bug: 205202
Reviewed-by: emilio
  • Loading branch information
Mats Palmgren authored and emilio committed Mar 27, 2019
1 parent ed74e8a commit ab8c00e
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 2 deletions.
5 changes: 5 additions & 0 deletions components/style/dom.rs
Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion components/style/gecko/pseudo_element.rs
Expand Up @@ -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
)
}

Expand Down Expand Up @@ -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;
}
Expand Down
5 changes: 4 additions & 1 deletion components/style/gecko/pseudo_element_definition.mako.rs
Expand Up @@ -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([]))
Expand Down
8 changes: 8 additions & 0 deletions components/style/gecko/wrapper.rs
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions components/style/invalidation/element/invalidator.rs
Expand Up @@ -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);
}
Expand Down

0 comments on commit ab8c00e

Please sign in to comment.