Bug 1304922 - Part 2: Sort animation array before sending animations to the compositor. r?birtles draft
authorHiroyuki Ikezoe <hiikezoe@mozilla-japan.org>
Wed, 05 Oct 2016 14:26:25 +0900
changeset 421027 58d1629479317e6acd23da08b79f890c188e8dc3
parent 421026 dd2c4f52abbe74a55a8954d0f198f20f3d9df019
child 421028 1d4356d095d21dd4b4a3339e24650c46f09edb70
push id31361
push userbmo:hiikezoe@mozilla-japan.org
push dateWed, 05 Oct 2016 06:56:42 +0000
reviewersbirtles
bugs1304922
milestone52.0a1
Bug 1304922 - Part 2: Sort animation array before sending animations to the compositor. r?birtles The result animatons of FindAnimationsForCompositor() should be sorted by composite order because SampleAnimations() on the compositor expects the animations are sorted by the order. MozReview-Commit-ID: 4eI4EldFVcu
dom/animation/EffectCompositor.cpp
--- a/dom/animation/EffectCompositor.cpp
+++ b/dom/animation/EffectCompositor.cpp
@@ -4,16 +4,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "EffectCompositor.h"
 
 #include "mozilla/dom/Animation.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/KeyframeEffectReadOnly.h"
+#include "mozilla/AnimationComparator.h"
 #include "mozilla/AnimationPerformanceWarning.h"
 #include "mozilla/AnimationTarget.h"
 #include "mozilla/AnimationUtils.h"
 #include "mozilla/EffectSet.h"
 #include "mozilla/InitializerList.h"
 #include "mozilla/LayerAnimationInfo.h"
 #include "mozilla/RestyleManagerHandle.h"
 #include "mozilla/RestyleManagerHandleInlines.h"
@@ -145,16 +146,20 @@ FindAnimationsForCompositor(const nsIFra
     if (aMatches) {
       aMatches->AppendElement(animation);
     }
     foundSome = true;
   }
 
   MOZ_ASSERT(!foundSome || !aMatches || !aMatches->IsEmpty(),
              "If return value is true, matches array should be non-empty");
+
+  if (aMatches && foundSome) {
+    aMatches->Sort(AnimationPtrComparator<RefPtr<dom::Animation>>());
+  }
   return foundSome;
 }
 
 void
 EffectCompositor::RequestRestyle(dom::Element* aElement,
                                  CSSPseudoElementType aPseudoType,
                                  RestyleType aRestyleType,
                                  CascadeLevel aCascadeLevel)