Bug 1383998 - Increase animation generation if attributes are changed. draft
authorBoris Chiou <boris.chiou@gmail.com>
Wed, 02 Aug 2017 11:43:41 +0800
changeset 620160 392e6d56874c12958fd26bd73557e9c155a7b73f
parent 618757 44121dbcac6a9d3ff18ed087a09b3205e5a04db1
child 620161 ca0aabc91112bb6b07663dfa633c683b6a54904b
push id71939
push userbmo:boris.chiou@gmail.com
push dateThu, 03 Aug 2017 06:04:11 +0000
bugs1383998
milestone56.0a1
Bug 1383998 - Increase animation generation if attributes are changed. We have to set mHaveNonAnimationRestyles if we have attributes changed (note: we increase the animation generation only if mHaveNonAnimationRestyles is set). Attributes changed may create a new transition, and we use the animation generation as the order of the transition, so Element::GetAnimations() can return transitions with correct order. Besides, I think ContentStateChanged() will not trigger a new transition, so we don't need to make mHaveNonAnimationRestyles there. MozReview-Commit-ID: J5XgW8nqeLH
layout/base/ServoRestyleManager.cpp
--- a/layout/base/ServoRestyleManager.cpp
+++ b/layout/base/ServoRestyleManager.cpp
@@ -1164,16 +1164,20 @@ ServoRestyleManager::TakeSnapshotForAttr
   }
 
   // We cannot tell if the attribute change will affect the styles of
   // undisplayed elements, because we don't actually restyle those elements
   // during the restyle traversal. So just assume that the attribute change can
   // cause the style to change.
   IncrementUndisplayedRestyleGeneration();
 
+  // Some other random attribute changes may also affect the transitions,
+  // so we also set this true here.
+  mHaveNonAnimationRestyles = true;
+
   ServoElementSnapshot& snapshot = SnapshotFor(aElement);
   snapshot.AddAttrs(aElement, aNameSpaceID, aAttribute);
 
   if (influencesOtherPseudoClassState) {
     snapshot.AddOtherPseudoClassState(aElement);
   }
 
   if (Element* parent = aElement->GetFlattenedTreeParentElementForStyle()) {
@@ -1223,16 +1227,20 @@ ServoRestyleManager::AttributeChanged(El
   if (restyleHint || changeHint) {
     Servo_NoteExplicitHints(aElement, restyleHint, changeHint);
   }
 
   if (restyleHint) {
     // Assuming we need to invalidate cached style in getComputedStyle for
     // undisplayed elements, since we don't know if it is needed.
     IncrementUndisplayedRestyleGeneration();
+
+    // If we change attributes, we have to mark this to be true, so we will
+    // increase the animation generation for the new created transition if any.
+    mHaveNonAnimationRestyles = true;
   }
 }
 
 nsresult
 ServoRestyleManager::ReparentStyleContext(nsIFrame* aFrame)
 {
   // This is only called when moving frames in or out of the first-line
   // pseudo-element (or one of its inline descendants).  So aFrame's ancestors