mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
style: Cleanup a bit the restyle hint propagation code.
This commit is contained in:
parent
d77fceaf24
commit
af37f7667b
2 changed files with 42 additions and 32 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue