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
--- 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