Bug 1245748 - Use Keyframe-based utility functions when constructing KeyframeEffect(ReadOnly); r=heycam

MozReview-Commit-ID: 72vLatkFqMq

--HG--
extra : rebase_source : 5b40afe6e12b3bcb3a57ed294fc582bf7e40ba18
This commit is contained in:
Brian Birtles 2016-03-22 16:35:53 +09:00
parent 1cf303b56f
commit 81c73a9b4b

View File

@ -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<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,