style: Kill StoredRestyleHint.

Reviewed-By: bholley
Bug: 1368236
MozReview-Commit-ID: 43Cf0rJyhzO
This commit is contained in:
Emilio Cobos Álvarez 2017-06-13 12:45:04 +02:00
parent c6da6ba060
commit f9c268922d
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
4 changed files with 47 additions and 108 deletions

View file

@ -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 {