Bug 1369187: style: Add an API to fast-reject eager pseudos. r=bholley

Also, do nothing for now (we'll hook the Gecko pieces here when the time comes).

Let me know if you want to hold-off landing this.

MozReview-Commit-ID: 6PIhfp6sxk4
This commit is contained in:
Emilio Cobos Álvarez 2017-05-31 14:04:25 +02:00
parent 12de616532
commit fe74e70a2d
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
2 changed files with 20 additions and 1 deletions

View file

@ -382,6 +382,20 @@ pub trait TElement : Eq + PartialEq + Debug + Hash + Sized + Copy + Clone +
pseudo: Option<&PseudoElement>)
-> Option<&'a PreExistingComputedValues>;
/// Whether a given element may generate a pseudo-element.
///
/// This is useful to avoid computing, for example, pseudo styles for
/// `::-first-line` or `::-first-letter`, when we know it won't affect us.
///
/// TODO(emilio, bz): actually implement the logic for it.
fn may_generate_pseudo(
&self,
_pseudo: &PseudoElement,
_primary_style: &ComputedValues,
) -> bool {
true
}
/// Returns true if this element may have a descendant needing style processing.
///
/// Note that we cannot guarantee the existence of such an element, because
@ -444,7 +458,8 @@ pub trait TElement : Eq + PartialEq + Debug + Hash + Sized + Copy + Clone +
false
}
/// Flag that this element has a descendant for animation-only restyle processing.
/// Flag that this element has a descendant for animation-only restyle
/// processing.
///
/// Only safe to call with exclusive access to the element.
unsafe fn set_animation_only_dirty_descendants(&self) {

View file

@ -1106,6 +1106,10 @@ pub trait MatchMethods : TElement {
return
}
if !self.may_generate_pseudo(&pseudo, data.styles().primary.values()) {
return;
}
debug_assert!(applicable_declarations.is_empty());
// NB: We handle animation rules for ::before and ::after when
// traversing them.