Bug 1245748 - Use Keyframe-based utility functions when constructing KeyframeEffect(ReadOnly); r=heycam
MozReview-Commit-ID: 72vLatkFqMq
--- 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();
}