Bug 1383998 - Increase animation generation if attributes are changed. r=heycam a=gchang
authorBoris Chiou <boris.chiou@gmail.com>
Wed, 02 Aug 2017 11:43:41 +0800
changeset 423437 5c06aca00aaeed0a4edb7cd2bd4355ded2dae8d6
parent 423436 c3e9ce491b38700e1379ab061f7062f701cfcf3e
child 423438 9bc2711015128804682ade612b929a1989ca8ada
push id1517
push userjlorenzo@mozilla.com
push dateThu, 14 Sep 2017 16:50:54 +0000
treeherdermozilla-release@3b41fd564418 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam, gchang
bugs1383998
milestone56.0
Bug 1383998 - Increase animation generation if attributes are changed. r=heycam a=gchang 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