style: Cleanup a bit the restyle hint propagation code.

This commit is contained in:
Emilio Cobos Álvarez 2017-03-27 13:30:48 +02:00
parent d77fceaf24
commit af37f7667b
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
2 changed files with 42 additions and 32 deletions

View file

@ -135,13 +135,20 @@ pub struct StoredRestyleHint(RestyleHint);
impl StoredRestyleHint {
/// Propagates this restyle hint to a child element.
pub fn propagate(&self) -> Self {
// If we have RESTYLE_CSS_ANIMATIONS restyle hint, it means we are in the
// middle of an animation only restyle. In that case, we don't need to
// propagate any restyle hints.
StoredRestyleHint(if self.0.contains(RESTYLE_CSS_ANIMATIONS) {
RestyleHint::empty()
} else if self.0.contains(RESTYLE_DESCENDANTS) {
pub fn propagate(&mut self) -> Self {
use std::mem;
// If we have RESTYLE_CSS_ANIMATIONS restyle hint, it means we are in
// the middle of an animation only restyle. In that case, we don't need
// to propagate any restyle hints, and we need to remove ourselves.
if self.0.contains(RESTYLE_CSS_ANIMATIONS) {
self.0.remove(RESTYLE_CSS_ANIMATIONS);
return Self::empty();
}
// Else we should clear ourselves, and return the propagated hint.
let hint = mem::replace(&mut self.0, RestyleHint::empty());
StoredRestyleHint(if hint.contains(RESTYLE_DESCENDANTS) {
RESTYLE_SELF | RESTYLE_DESCENDANTS
} else {
RestyleHint::empty()
@ -180,11 +187,6 @@ impl StoredRestyleHint {
self.0 |= other.0
}
/// Remove animation restyle hint.
pub fn remove_animation_hint(&mut self) {
self.0.remove(RESTYLE_CSS_ANIMATIONS)
}
/// Returns true if the hint has animation-only restyle.
pub fn has_animation_hint(&self) -> bool {
self.0.contains(RESTYLE_CSS_ANIMATIONS)