From e90b72b9db77507195e3204c1f0055395137202b Mon Sep 17 00:00:00 2001 From: "L. David Baron" Date: Tue, 31 Mar 2015 15:05:55 -0700 Subject: [PATCH] Bug 847287 patch 13 - Apply animations/transitions on the layer in the order that reflects how they override, rather than the opposite. r=birtles This independently would have fixed some of the problems fixed in this bug. It would not have fixed them fully, though, since it would not have prevented us from sending animations being covered up by !important rules to the compositor. --- gfx/layers/Layers.h | 1 + gfx/layers/composite/AsyncCompositionManager.cpp | 3 ++- layout/base/nsDisplayList.cpp | 3 +++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/gfx/layers/Layers.h b/gfx/layers/Layers.h index 56926634c797..61d4a5862747 100644 --- a/gfx/layers/Layers.h +++ b/gfx/layers/Layers.h @@ -1108,6 +1108,7 @@ public: // Call AddAnimation to add a new animation to this layer from layout code. // Caller must fill in all the properties of the returned animation. + // A later animation overrides an earlier one. Animation* AddAnimation(); // ClearAnimations clears animations on this layer. void ClearAnimations(); diff --git a/gfx/layers/composite/AsyncCompositionManager.cpp b/gfx/layers/composite/AsyncCompositionManager.cpp index 5cc6a4c008de..712b17b10366 100644 --- a/gfx/layers/composite/AsyncCompositionManager.cpp +++ b/gfx/layers/composite/AsyncCompositionManager.cpp @@ -440,7 +440,8 @@ SampleAnimations(Layer* aLayer, TimeStamp aPoint) bool activeAnimations = false; - for (uint32_t i = animations.Length(); i-- !=0; ) { + // Process in order, since later animations override earlier ones. + for (size_t i = 0, iEnd = animations.Length(); i < iEnd; ++i) { Animation& animation = animations[i]; AnimData& animData = animationData[i]; diff --git a/layout/base/nsDisplayList.cpp b/layout/base/nsDisplayList.cpp index f42895ab6d0d..8dcc4def286b 100644 --- a/layout/base/nsDisplayList.cpp +++ b/layout/base/nsDisplayList.cpp @@ -413,6 +413,7 @@ AddAnimationsForProperty(nsIFrame* aFrame, nsCSSProperty aProperty, CSS_PROPERTY_CAN_ANIMATE_ON_COMPOSITOR), "inconsistent property flags"); + // Add from first to last (since last overrides) for (size_t playerIdx = 0; playerIdx < aPlayers.Length(); playerIdx++) { AnimationPlayer* player = aPlayers[playerIdx]; if (!player->IsPlaying()) { @@ -560,6 +561,8 @@ nsDisplayListBuilder::AddAnimationsAndTransitionsToLayer(Layer* aLayer, data = null_t(); } + // When both are running, animations override transitions. We want + // to add the ones that override last. if (transitions) { AddAnimationsForProperty(aFrame, aProperty, transitions->mPlayers, aLayer, data, pending);