Bug 1383001: Don't try to do an animation-only restyle if we're styling newly-inserted content. r?heycam draft
authorEmilio Cobos Álvarez <emilio@crisal.io>
Sat, 22 Jul 2017 01:34:47 +0200
changeset 613453 199c62dc0df355b668b061ae98188039ea91be63
parent 613452 f8e46b0c5c8124da900022c5e62c60c198ddf182
child 613776 286907bac7aae14a13b308c5203cd581637045f9
push id69804
push userbmo:emilio+bugs@crisal.io
push dateFri, 21 Jul 2017 23:36:19 +0000
reviewersheycam
bugs1383001
milestone56.0a1
Bug 1383001: Don't try to do an animation-only restyle if we're styling newly-inserted content. r?heycam It makes just no sense, and I'd rather not complicate the logic in the traversal implementations, seems easy to just handle it here. MozReview-Commit-ID: 3PnT2Jyta8g
servo/ports/geckolib/glue.rs
--- a/servo/ports/geckolib/glue.rs
+++ b/servo/ports/geckolib/glue.rs
@@ -270,23 +270,29 @@ pub extern "C" fn Servo_TraverseSubtree(
         (Root::UnstyledChildrenOnly, Restyle::Normal) |
         (Root::UnstyledChildrenOnly, Restyle::ForNewlyBoundElement)
             => UNSTYLED_CHILDREN_ONLY,
         (Root::Normal, Restyle::ForCSSRuleChanges) => FOR_CSS_RULE_CHANGES,
         (Root::Normal, Restyle::ForReconstruct) => FOR_RECONSTRUCT,
         _ => panic!("invalid combination of TraversalRootBehavior and TraversalRestyleBehavior"),
     };
 
-    let needs_animation_only_restyle = element.has_animation_only_dirty_descendants() ||
-                                       element.has_animation_restyle_hints();
-    if needs_animation_only_restyle {
-        traverse_subtree(element,
-                         raw_data,
-                         traversal_flags | ANIMATION_ONLY,
-                         unsafe { &*snapshots });
+    // It makes no sense to do an animation restyle when we're restyling
+    // newly-inserted content.
+    if !traversal_flags.contains(UNSTYLED_CHILDREN_ONLY) {
+        let needs_animation_only_restyle =
+            element.has_animation_only_dirty_descendants() ||
+            element.has_animation_restyle_hints();
+
+        if needs_animation_only_restyle {
+            traverse_subtree(element,
+                             raw_data,
+                             traversal_flags | ANIMATION_ONLY,
+                             unsafe { &*snapshots });
+        }
     }
 
     if restyle_behavior == Restyle::ForThrottledAnimationFlush {
         return element.has_animation_only_dirty_descendants() ||
                element.borrow_data().unwrap().restyle.is_restyle();
     }
 
     traverse_subtree(element,