Bug 1245748 - Use Keyframe-based utility functions when constructing KeyframeEffect(ReadOnly); r=heycam
authorBrian Birtles <birtles@gmail.com>
Tue, 22 Mar 2016 16:35:53 +0900
changeset 290214 88795391fe8b748c6aa1d7493733aa8c49a9c5c7
parent 290213 d2939b503235e1c077b014139c26b9d617f2bfb0
child 290215 5dbdbe3e4655a385663f25b7e16f85fbcf5f9207
push id30114
push usercbook@mozilla.com
push dateThu, 24 Mar 2016 15:15:54 +0000
treeherdermozilla-central@24c5fbde4488 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1245748
milestone48.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1245748 - Use Keyframe-based utility functions when constructing KeyframeEffect(ReadOnly); r=heycam MozReview-Commit-ID: 72vLatkFqMq
dom/animation/KeyframeEffect.cpp
--- a/dom/animation/KeyframeEffect.cpp
+++ b/dom/animation/KeyframeEffect.cpp
@@ -10,16 +10,17 @@
 #include "mozilla/dom/KeyframeEffectBinding.h"
 #include "mozilla/AnimationUtils.h"
 #include "mozilla/EffectCompositor.h"
 #include "mozilla/FloatingPoint.h"
 #include "mozilla/LookAndFeel.h" // For LookAndFeel::GetInt
 #include "mozilla/KeyframeUtils.h"
 #include "mozilla/StyleAnimationValue.h"
 #include "Layers.h" // For Layer
+#include "nsComputedDOMStyle.h" // nsComputedDOMStyle::GetStyleContextForElement
 #include "nsCSSPropertySet.h"
 #include "nsCSSProps.h" // For nsCSSProps::PropHasFlags
 #include "nsCSSPseudoElements.h" // For CSSPseudoElementType
 #include "nsDOMMutationObserver.h" // For nsAutoAnimationMutationBatch
 #include <algorithm> // For std::max
 
 namespace mozilla {
 
@@ -700,24 +701,42 @@ KeyframeEffectReadOnly::ConstructKeyfram
     pseudoType = target.GetAsCSSPseudoElement().GetType();
   }
 
   if (!targetElement->GetComposedDoc()) {
     aRv.Throw(NS_ERROR_DOM_ANIM_TARGET_NOT_IN_DOC_ERR);
     return nullptr;
   }
 
-  InfallibleTArray<AnimationProperty> animationProperties;
-  KeyframeUtils::BuildAnimationPropertyList(aGlobal.Context(), targetElement,
-                                            pseudoType, aFrames,
-                                            animationProperties, aRv);
-
+  nsTArray<Keyframe> keyframes =
+    KeyframeUtils::GetKeyframesFromObject(aGlobal.Context(), aFrames, aRv);
   if (aRv.Failed()) {
     return nullptr;
   }
+  KeyframeUtils::ApplyDistributeSpacing(keyframes);
+
+  RefPtr<nsStyleContext> styleContext;
+  nsIPresShell* shell = doc->GetShell();
+  if (shell && targetElement) {
+    nsIAtom* pseudo =
+      pseudoType < CSSPseudoElementType::Count ?
+      nsCSSPseudoElements::GetPseudoAtom(pseudoType) : nullptr;
+    styleContext =
+      nsComputedDOMStyle::GetStyleContextForElement(targetElement, pseudo,
+                                                    shell);
+  }
+
+  nsTArray<AnimationProperty> animationProperties;
+  if (styleContext) {
+    animationProperties =
+      KeyframeUtils::GetAnimationPropertiesFromKeyframes(styleContext,
+                                                         targetElement,
+                                                         pseudoType,
+                                                         keyframes);
+  }
 
   RefPtr<KeyframeEffectType> effect =
     new KeyframeEffectType(targetElement->OwnerDoc(), targetElement,
                            pseudoType, timingParams);
   effect->mProperties = Move(animationProperties);
   return effect.forget();
 }