Preserve restyle hints after ForThrottledAnimationFlush restyle.

Those remaining restyle hints are needed for normal traversal later.
This commit is contained in:
Hiroyuki Ikezoe 2017-07-15 11:17:57 +09:00
parent b688353c82
commit e700a66e9f
2 changed files with 27 additions and 2 deletions

View file

@ -61,6 +61,12 @@ impl RestyleData {
*self = Self::new();
}
/// Clear restyle flags and damage.
fn clear_flags_and_damage(&mut self) {
self.damage = RestyleDamage::empty();
self.flags = RestyleFlags::empty();
}
/// Returns whether this element or any ancestor is going to be
/// reconstructed.
pub fn reconstructed_self_or_ancestor(&self) -> bool {
@ -331,4 +337,9 @@ impl ElementData {
pub fn clear_restyle_state(&mut self) {
self.restyle.clear();
}
/// Drops restyle flags and damage from the element.
pub fn clear_restyle_flags_and_damage(&mut self) {
self.restyle.clear_flags_and_damage();
}
}

View file

@ -2729,13 +2729,27 @@ pub extern "C" fn Servo_NoteExplicitHints(element: RawGeckoElementBorrowed,
}
#[no_mangle]
pub extern "C" fn Servo_TakeChangeHint(element: RawGeckoElementBorrowed) -> nsChangeHint
pub extern "C" fn Servo_TakeChangeHint(element: RawGeckoElementBorrowed,
restyle_behavior: structs::TraversalRestyleBehavior) -> nsChangeHint
{
let element = GeckoElement(element);
let damage = match element.mutate_data() {
Some(mut data) => {
let damage = data.restyle.damage;
data.clear_restyle_state();
if restyle_behavior == structs::TraversalRestyleBehavior::ForThrottledAnimationFlush {
debug_assert!(data.restyle.is_restyle() || damage.is_empty(),
"Restyle damage should be empty if the element was not restyled");
// In the case where we call this function for post traversal for
// flusing throttled animations (i.e. without normal restyle
// traversal), we need to preserve restyle hints for normal restyle
// traversal. Restyle hints for animations have been already
// removed during animation-only traversal.
debug_assert!(!data.restyle.hint.has_animation_hint(),
"Animation restyle hints should have been already removed");
data.clear_restyle_flags_and_damage();
} else {
data.clear_restyle_state();
}
damage
}
None => {