| Index: Source/core/animation/EffectInput.cpp
|
| diff --git a/Source/core/animation/EffectInput.cpp b/Source/core/animation/EffectInput.cpp
|
| index 8e29bd8af94b7cc39935f1424c521f9e612da42e..af3232f52da9771a32933e1dcba6f4c51b465fc0 100644
|
| --- a/Source/core/animation/EffectInput.cpp
|
| +++ b/Source/core/animation/EffectInput.cpp
|
| @@ -38,9 +38,20 @@
|
| #include "core/css/parser/BisonCSSParser.h"
|
| #include "core/css/resolver/StyleResolver.h"
|
| #include "core/dom/Element.h"
|
| +#include "wtf/NonCopyingSort.h"
|
|
|
| namespace WebCore {
|
|
|
| +namespace {
|
| +
|
| +bool compareOffsets(const RefPtrWillBeMember<StringKeyframe>& keyframe1, const RefPtrWillBeMember<StringKeyframe>& keyframe2)
|
| +{
|
| + ASSERT(keyframe1 && keyframe2);
|
| + return keyframe1->offset() < keyframe2->offset();
|
| +}
|
| +
|
| +}
|
| +
|
| // FIXME: Remove this once we've removed the dependency on Element.
|
| static bool checkDocumentAndRenderer(Element* element)
|
| {
|
| @@ -59,14 +70,23 @@ PassRefPtrWillBeRawPtr<AnimationEffect> EffectInput::convert(Element* element, c
|
|
|
| StyleSheetContents* styleSheetContents = element->document().elementSheet().contents();
|
| StringKeyframeVector keyframes;
|
| + bool everyFrameHasOffset = true;
|
| + bool looselySortedByOffset = true;
|
| + double lastOffset = -std::numeric_limits<double>::infinity();
|
|
|
| for (size_t i = 0; i < keyframeDictionaryVector.size(); ++i) {
|
| RefPtrWillBeRawPtr<StringKeyframe> keyframe = StringKeyframe::create();
|
| keyframes.append(keyframe);
|
|
|
| double offset;
|
| - if (keyframeDictionaryVector[i].get("offset", offset))
|
| + if (keyframeDictionaryVector[i].get("offset", offset)) {
|
| keyframe->setOffset(offset);
|
| + if (offset < lastOffset)
|
| + looselySortedByOffset = false;
|
| + lastOffset = offset;
|
| + } else {
|
| + everyFrameHasOffset = false;
|
| + }
|
|
|
| String compositeString;
|
| keyframeDictionaryVector[i].get("composite", compositeString);
|
| @@ -93,6 +113,14 @@ PassRefPtrWillBeRawPtr<AnimationEffect> EffectInput::convert(Element* element, c
|
| }
|
| }
|
|
|
| + if (!looselySortedByOffset) {
|
| + if (!everyFrameHasOffset) {
|
| + exceptionState.throwDOMException(InvalidModificationError, "Keyframes are not loosely sorted by offset.");
|
| + return nullptr;
|
| + }
|
| + nonCopyingSort(keyframes.begin(), keyframes.end(), compareOffsets);
|
| + }
|
| +
|
| RefPtrWillBeRawPtr<StringKeyframeEffectModel> keyframeEffectModel = StringKeyframeEffectModel::create(keyframes);
|
| if (!keyframeEffectModel->isReplaceOnly()) {
|
| exceptionState.throwDOMException(NotSupportedError, "Partial keyframes are not supported.");
|
|
|