Auto merge of #17740 - hiikezoe:post-traversal-fix, r=emilio

Post traversal fix triggered by animation-only restyle for event handling

<!-- Please describe your changes on the following line: -->
https://bugzilla.mozilla.org/show_bug.cgi?id=1371450

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
This commit is contained in:
bors-servo 2017-07-14 21:07:38 -07:00 committed by GitHub
commit f9642b36bd
6 changed files with 2068 additions and 2399 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

@ -4900,8 +4900,6 @@ cfg_if! {
pub static nsGkAtoms_refx: *mut nsIAtom;
#[link_name = "_ZN9nsGkAtoms4refyE"]
pub static nsGkAtoms_refy: *mut nsIAtom;
#[link_name = "_ZN9nsGkAtoms7isindexE"]
pub static nsGkAtoms_isindex: *mut nsIAtom;
#[link_name = "_ZN9nsGkAtoms7fefuncaE"]
pub static nsGkAtoms_fefunca: *mut nsIAtom;
#[link_name = "_ZN9nsGkAtoms7fefuncbE"]
@ -10029,8 +10027,6 @@ cfg_if! {
pub static nsGkAtoms_refx: *mut nsIAtom;
#[link_name = "?refy@nsGkAtoms@@2PEAVnsIAtom@@EA"]
pub static nsGkAtoms_refy: *mut nsIAtom;
#[link_name = "?isindex@nsGkAtoms@@2PEAVnsIAtom@@EA"]
pub static nsGkAtoms_isindex: *mut nsIAtom;
#[link_name = "?fefunca@nsGkAtoms@@2PEAVnsIAtom@@EA"]
pub static nsGkAtoms_fefunca: *mut nsIAtom;
#[link_name = "?fefuncb@nsGkAtoms@@2PEAVnsIAtom@@EA"]
@ -15158,8 +15154,6 @@ cfg_if! {
pub static nsGkAtoms_refx: *mut nsIAtom;
#[link_name = "\x01?refy@nsGkAtoms@@2PAVnsIAtom@@A"]
pub static nsGkAtoms_refy: *mut nsIAtom;
#[link_name = "\x01?isindex@nsGkAtoms@@2PAVnsIAtom@@A"]
pub static nsGkAtoms_isindex: *mut nsIAtom;
#[link_name = "\x01?fefunca@nsGkAtoms@@2PAVnsIAtom@@A"]
pub static nsGkAtoms_fefunca: *mut nsIAtom;
#[link_name = "\x01?fefuncb@nsGkAtoms@@2PAVnsIAtom@@A"]
@ -20290,8 +20284,6 @@ macro_rules! atom {
{ unsafe { $crate::string_cache::atom_macro::atom_from_static($crate::string_cache::atom_macro::nsGkAtoms_refx as *mut _) } };
("refy") =>
{ unsafe { $crate::string_cache::atom_macro::atom_from_static($crate::string_cache::atom_macro::nsGkAtoms_refy as *mut _) } };
("isindex") =>
{ unsafe { $crate::string_cache::atom_macro::atom_from_static($crate::string_cache::atom_macro::nsGkAtoms_isindex as *mut _) } };
("fefunca") =>
{ unsafe { $crate::string_cache::atom_macro::atom_from_static($crate::string_cache::atom_macro::nsGkAtoms_fefunca as *mut _) } };
("fefuncb") =>

View file

@ -2709,8 +2709,9 @@ extern "C" {
change_hint: nsChangeHint);
}
extern "C" {
pub fn Servo_TakeChangeHint(element: RawGeckoElementBorrowed)
-> nsChangeHint;
pub fn Servo_TakeChangeHint(element: RawGeckoElementBorrowed,
restyle_behavior: TraversalRestyleBehavior,
was_restyled: *mut bool) -> nsChangeHint;
}
extern "C" {
pub fn Servo_ResolveStyle(element: RawGeckoElementBorrowed,

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -257,16 +257,16 @@ pub extern "C" fn Servo_TraverseSubtree(root: RawGeckoElementBorrowed,
debug_assert!(!snapshots.is_null());
let element = GeckoElement(root);
debug!("Servo_TraverseSubtree: {:?}", element);
debug!("Servo_TraverseSubtree: {:?} {:?}", element, restyle_behavior);
let traversal_flags = match (root_behavior, restyle_behavior) {
(Root::Normal, Restyle::Normal) |
(Root::Normal, Restyle::ForNewlyBoundElement) |
(Root::Normal, Restyle::ForAnimationOnly)
(Root::Normal, Restyle::ForThrottledAnimationFlush)
=> TraversalFlags::empty(),
(Root::UnstyledChildrenOnly, Restyle::Normal) |
(Root::UnstyledChildrenOnly, Restyle::ForNewlyBoundElement) |
(Root::UnstyledChildrenOnly, Restyle::ForAnimationOnly)
(Root::UnstyledChildrenOnly, Restyle::ForThrottledAnimationFlush)
=> UNSTYLED_CHILDREN_ONLY,
(Root::Normal, Restyle::ForCSSRuleChanges) => FOR_CSS_RULE_CHANGES,
(Root::Normal, Restyle::ForReconstruct) => FOR_RECONSTRUCT,
@ -282,8 +282,9 @@ pub extern "C" fn Servo_TraverseSubtree(root: RawGeckoElementBorrowed,
unsafe { &*snapshots });
}
if restyle_behavior == Restyle::ForAnimationOnly {
return needs_animation_only_restyle;
if restyle_behavior == Restyle::ForThrottledAnimationFlush {
return element.has_animation_only_dirty_descendants() ||
element.borrow_data().unwrap().restyle.is_restyle();
}
traverse_subtree(element,
@ -2728,17 +2729,37 @@ 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,
was_restyled: *mut bool) -> nsChangeHint
{
let mut was_restyled = unsafe { was_restyled.as_mut().unwrap() };
let element = GeckoElement(element);
let damage = match element.mutate_data() {
Some(mut data) => {
*was_restyled = data.restyle.is_restyle();
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 => {
warn!("Trying to get change hint from unstyled element");
*was_restyled = false;
GeckoRestyleDamage::empty()
}
};