From 81c73a9b4bc4c1f6adbe81345a8ef7c32a8ab8f1 Mon Sep 17 00:00:00 2001 From: Brian Birtles Date: Tue, 22 Mar 2016 16:35:53 +0900 Subject: [PATCH] Bug 1245748 - Use Keyframe-based utility functions when constructing KeyframeEffect(ReadOnly); r=heycam MozReview-Commit-ID: 72vLatkFqMq --HG-- extra : rebase_source : 5b40afe6e12b3bcb3a57ed294fc582bf7e40ba18 --- dom/animation/KeyframeEffect.cpp | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/dom/animation/KeyframeEffect.cpp b/dom/animation/KeyframeEffect.cpp index 38caa9c50f08..bb9f788e6cdc 100644 --- a/dom/animation/KeyframeEffect.cpp +++ b/dom/animation/KeyframeEffect.cpp @@ -15,6 +15,7 @@ #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 @@ -705,14 +706,32 @@ KeyframeEffectReadOnly::ConstructKeyframeEffect( return nullptr; } - InfallibleTArray animationProperties; - KeyframeUtils::BuildAnimationPropertyList(aGlobal.Context(), targetElement, - pseudoType, aFrames, - animationProperties, aRv); - + nsTArray keyframes = + KeyframeUtils::GetKeyframesFromObject(aGlobal.Context(), aFrames, aRv); if (aRv.Failed()) { return nullptr; } + KeyframeUtils::ApplyDistributeSpacing(keyframes); + + RefPtr styleContext; + nsIPresShell* shell = doc->GetShell(); + if (shell && targetElement) { + nsIAtom* pseudo = + pseudoType < CSSPseudoElementType::Count ? + nsCSSPseudoElements::GetPseudoAtom(pseudoType) : nullptr; + styleContext = + nsComputedDOMStyle::GetStyleContextForElement(targetElement, pseudo, + shell); + } + + nsTArray animationProperties; + if (styleContext) { + animationProperties = + KeyframeUtils::GetAnimationPropertiesFromKeyframes(styleContext, + targetElement, + pseudoType, + keyframes); + } RefPtr effect = new KeyframeEffectType(targetElement->OwnerDoc(), targetElement,