From 9c054819233e53cc21fab68bbf7b6a8128d886ac Mon Sep 17 00:00:00 2001 From: Hiroyuki Ikezoe Date: Tue, 18 Jul 2017 19:14:22 +0900 Subject: [PATCH] Skip snapshot handling during animation-only restyle. --- components/style/data.rs | 5 +++++ components/style/traversal.rs | 11 ++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/components/style/data.rs b/components/style/data.rs index 5d2771121a1..9ddd20c0dce 100644 --- a/components/style/data.rs +++ b/components/style/data.rs @@ -241,6 +241,11 @@ impl ElementData { element: E, shared_context: &SharedStyleContext) { + // In animation-only restyle we shouldn't touch snapshot at all. + if shared_context.traversal_flags.for_animation_only() { + return; + } + use invalidation::element::invalidator::TreeStyleInvalidator; debug!("invalidate_style_if_needed: {:?}, flags: {:?}, has_snapshot: {}, \ diff --git a/components/style/traversal.rs b/components/style/traversal.rs index 663ae72a433..689967da295 100644 --- a/components/style/traversal.rs +++ b/components/style/traversal.rs @@ -235,7 +235,9 @@ pub trait DomTraversal : Sync { // Look at whether there has been any attribute or state change, and // invalidate our style, and the one of our siblings and descendants as // needed. - data.invalidate_style_if_needed(root, shared_context); + if !flags.for_animation_only() { + data.invalidate_style_if_needed(root, shared_context); + } let parent = root.traversal_parent(); let parent_data = match parent { @@ -523,7 +525,8 @@ where { context.thread_local.begin_element(element, data); context.thread_local.statistics.elements_traversed += 1; - debug_assert!(!element.has_snapshot() || element.handled_snapshot(), + debug_assert!(context.shared.traversal_flags.for_animation_only() || + !element.has_snapshot() || element.handled_snapshot(), "Should've handled snapshots here already"); let compute_self = @@ -810,7 +813,9 @@ where // as needed. // // NB: This will be a no-op if there's no snapshot. - child_data.invalidate_style_if_needed(child, &context.shared); + if !flags.for_animation_only() { + child_data.invalidate_style_if_needed(child, &context.shared); + } if D::element_needs_traversal(child, flags, &*child_data, Some(data)) { note_child(child_node);