diff --git a/components/style/dom.rs b/components/style/dom.rs index d2ed5ae3d99..7df9c850fd4 100644 --- a/components/style/dom.rs +++ b/components/style/dom.rs @@ -462,6 +462,28 @@ pub trait TElement : Eq + PartialEq + Debug + Hash + Sized + Copy + Clone + data.has_styles() && !data.restyle.hint.has_non_animation_invalidations() } + /// Returns whether the element's styles are up-to-date after traversal + /// (i.e. in post traversal). + fn has_current_styles(&self, data: &ElementData) -> bool { + if self.has_snapshot() && !self.handled_snapshot() { + return false; + } + + data.has_styles() && + // TODO(hiro): When an animating element moved into subtree of + // contenteditable element, there remains animation restyle hints in + // post traversal. It's generally harmless since the hints will be + // processed in a next styling but ideally it should be processed soon. + // + // Without this, we get failures in: + // layout/style/crashtests/1383319.html + // layout/style/crashtests/1383001.html + // + // https://bugzilla.mozilla.org/show_bug.cgi?id=1389675 tracks fixing + // this. + !data.restyle.hint.has_non_animation_invalidations() + } + /// Flag that this element has a descendant for style processing. /// /// Only safe to call with exclusive access to the element. diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index fddc9676ca5..d20fce6fb13 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -2775,10 +2775,8 @@ pub extern "C" fn Servo_NoteExplicitHints(element: RawGeckoElementBorrowed, #[no_mangle] pub extern "C" fn Servo_TakeChangeHint(element: RawGeckoElementBorrowed, - raw_flags: ServoTraversalFlags, was_restyled: *mut bool) -> nsChangeHint { - let flags = TraversalFlags::from_bits_truncate(raw_flags); let mut was_restyled = unsafe { was_restyled.as_mut().unwrap() }; let element = GeckoElement(element); @@ -2787,25 +2785,7 @@ pub extern "C" fn Servo_TakeChangeHint(element: RawGeckoElementBorrowed, *was_restyled = data.restyle.is_restyle(); let damage = data.restyle.damage; - if flags.for_animation_only() { - if !*was_restyled { - // Don't touch elements if the element was not restyled - // in throttled animation flush. - debug!("Skip post traversal for throttled animation flush {:?} restyle={:?}", - element, data.restyle); - return nsChangeHint(0); - } - // 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(); - } + data.clear_restyle_state(); damage } None => { @@ -2821,11 +2801,9 @@ pub extern "C" fn Servo_TakeChangeHint(element: RawGeckoElementBorrowed, #[no_mangle] pub extern "C" fn Servo_ResolveStyle(element: RawGeckoElementBorrowed, - _raw_data: RawServoStyleSetBorrowed, - raw_flags: ServoTraversalFlags) + _raw_data: RawServoStyleSetBorrowed) -> ServoStyleContextStrong { - let flags = TraversalFlags::from_bits_truncate(raw_flags); let element = GeckoElement(element); debug!("Servo_ResolveStyle: {:?}", element); let data = @@ -2833,9 +2811,7 @@ pub extern "C" fn Servo_ResolveStyle(element: RawGeckoElementBorrowed, // TODO(emilio): Downgrade to debug assertions when close to release. assert!(data.has_styles(), "Resolving style on unstyled element"); - // In the case where we process for throttled animation, there remaings - // restyle hints other than animation hints. - debug_assert!(element.has_current_styles_for_traversal(&*data, flags), + debug_assert!(element.has_current_styles(&*data), "Resolving style on {:?} without current styles: {:?}", element, data); data.styles.primary().clone().into() }