Skip to content

Commit

Permalink
Make tree pseudos not precomputed since they are not really anonymous…
Browse files Browse the repository at this point in the history
… boxes.
  • Loading branch information
upsuper committed Oct 20, 2017
1 parent 4ce3dc7 commit cd52773
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 9 deletions.
20 changes: 20 additions & 0 deletions components/style/gecko/generated/pseudo_element_definition.rs
Expand Up @@ -546,6 +546,26 @@ impl PseudoElement {
PseudoElement::Before | PseudoElement::After | PseudoElement::FirstLine | PseudoElement::FirstLetter)
}

/// Whether this pseudo-element is tree pseudo-element.
#[inline]
pub fn is_tree_pseudo_element(&self) -> bool {
match *self {
PseudoElement::MozTreeColumn(..) => true,
PseudoElement::MozTreeRow(..) => true,
PseudoElement::MozTreeSeparator(..) => true,
PseudoElement::MozTreeCell(..) => true,
PseudoElement::MozTreeIndentation(..) => true,
PseudoElement::MozTreeLine(..) => true,
PseudoElement::MozTreeTwisty(..) => true,
PseudoElement::MozTreeImage(..) => true,
PseudoElement::MozTreeCellText(..) => true,
PseudoElement::MozTreeCheckbox(..) => true,
PseudoElement::MozTreeProgressmeter(..) => true,
PseudoElement::MozTreeDropFeedback(..) => true,
_ => false,
}
}

/// Gets the flags associated to this pseudo-element, or 0 if it's an
/// anonymous box.
pub fn flags(&self) -> u32 {
Expand Down
4 changes: 2 additions & 2 deletions components/style/gecko/pseudo_element.rs
Expand Up @@ -46,7 +46,7 @@ impl PseudoElement {
return PseudoElementCascadeType::Eager
}

if self.is_anon_box() {
if self.is_precomputed() {
return PseudoElementCascadeType::Precomputed
}

Expand Down Expand Up @@ -137,7 +137,7 @@ impl PseudoElement {
/// Whether this pseudo-element is precomputed.
#[inline]
pub fn is_precomputed(&self) -> bool {
self.is_anon_box()
self.is_anon_box() && !self.is_tree_pseudo_element()
}

/// Covert non-canonical pseudo-element to canonical one, and keep a
Expand Down
11 changes: 11 additions & 0 deletions components/style/gecko/pseudo_element_definition.mako.rs
Expand Up @@ -94,6 +94,17 @@ impl PseudoElement {
${" | ".join(map(lambda name: "PseudoElement::{}".format(name), EAGER_PSEUDOS))})
}

/// Whether this pseudo-element is tree pseudo-element.
#[inline]
pub fn is_tree_pseudo_element(&self) -> bool {
match *self {
% for pseudo in TREE_PSEUDOS:
${pseudo_element_variant(pseudo)} => true,
% endfor
_ => false,
}
}

/// Gets the flags associated to this pseudo-element, or 0 if it's an
/// anonymous box.
pub fn flags(&self) -> u32 {
Expand Down
9 changes: 2 additions & 7 deletions components/style/stylist.rs
Expand Up @@ -1983,13 +1983,8 @@ impl CascadeData {

let map = match selector.pseudo_element() {
Some(pseudo) if pseudo.is_precomputed() => {
if !selector.is_universal() ||
!matches!(origin, Origin::UserAgent) {
// ::-moz-tree selectors may appear in
// non-UA sheets (even though they never
// match).
continue;
}
debug_assert!(selector.is_universal());
debug_assert!(matches!(origin, Origin::UserAgent));

precomputed_pseudo_element_decls
.as_mut()
Expand Down

0 comments on commit cd52773

Please sign in to comment.