diff options
author | Emilio Cobos Álvarez <emilio@crisal.io> | 2017-06-13 12:45:04 +0200 |
---|---|---|
committer | Emilio Cobos Álvarez <emilio@crisal.io> | 2017-06-14 13:11:10 +0200 |
commit | f9c268922de7eacaf309437b82ea92e16a56caac (patch) | |
tree | 8a7d292993876257bf24c2a51ea23bb257ba578a /components/style/invalidation/element/restyle_hints.rs | |
parent | c6da6ba06057ec488521edb19f33592f4e98c3d4 (diff) | |
download | servo-f9c268922de7eacaf309437b82ea92e16a56caac.tar.gz servo-f9c268922de7eacaf309437b82ea92e16a56caac.zip |
style: Kill StoredRestyleHint.
Reviewed-By: bholley
Bug: 1368236
MozReview-Commit-ID: 43Cf0rJyhzO
Diffstat (limited to 'components/style/invalidation/element/restyle_hints.rs')
-rw-r--r-- | components/style/invalidation/element/restyle_hints.rs | 47 |
1 files changed, 39 insertions, 8 deletions
diff --git a/components/style/invalidation/element/restyle_hints.rs b/components/style/invalidation/element/restyle_hints.rs index 786c267f203..4b968da031f 100644 --- a/components/style/invalidation/element/restyle_hints.rs +++ b/components/style/invalidation/element/restyle_hints.rs @@ -6,6 +6,7 @@ #[cfg(feature = "gecko")] use gecko_bindings::structs::nsRestyleHint; +use traversal::TraversalFlags; bitflags! { /// The kind of restyle we need to do for a given element. @@ -57,9 +58,40 @@ impl RestyleHint { RECASCADE_SELF | RECASCADE_DESCENDANTS } + /// Returns whether this hint invalidates the element and all its + /// descendants. + pub fn contains_subtree(&self) -> bool { + self.contains(RESTYLE_SELF | RESTYLE_DESCENDANTS) + } + + /// Returns whether we need to restyle this element. + pub fn has_self_invalidations(&self) -> bool { + self.intersects(RESTYLE_SELF | RECASCADE_SELF | Self::replacements()) + } + + /// Propagates this restyle hint to a child element. + pub fn propagate(&mut self, traversal_flags: &TraversalFlags) -> Self { + use std::mem; + + // In the middle of an animation only restyle, we don't need to + // propagate any restyle hints, and we need to remove ourselves. + if traversal_flags.for_animation_only() { + self.remove_animation_hints(); + return Self::empty(); + } + + debug_assert!(!self.has_animation_hint(), + "There should not be any animation restyle hints \ + during normal traversal"); + + // Else we should clear ourselves, and return the propagated hint. + mem::replace(self, Self::empty()) + .propagate_for_non_animation_restyle() + } + /// Returns a new `CascadeHint` appropriate for children of the current /// element. - pub fn propagate_for_non_animation_restyle(&self) -> Self { + fn propagate_for_non_animation_restyle(&self) -> Self { if self.contains(RESTYLE_DESCENDANTS) { return Self::restyle_subtree() } @@ -86,13 +118,6 @@ impl RestyleHint { RESTYLE_SMIL | RESTYLE_CSS_ANIMATIONS | RESTYLE_CSS_TRANSITIONS } - /// Returns whether the hint specifies that some work must be performed on - /// the current element. - #[inline] - pub fn affects_self(&self) -> bool { - self.intersects(RESTYLE_SELF | RECASCADE_SELF | Self::replacements()) - } - /// Returns whether the hint specifies that the currently element must be /// recascaded. pub fn has_recascade_self(&self) -> bool { @@ -145,6 +170,12 @@ impl RestyleHint { } } +impl Default for RestyleHint { + fn default() -> Self { + Self::empty() + } +} + #[cfg(feature = "gecko")] impl From<nsRestyleHint> for RestyleHint { fn from(raw: nsRestyleHint) -> Self { |