Chromium Code Reviews| Index: Source/core/animation/EffectInput.cpp |
| diff --git a/Source/core/animation/EffectInput.cpp b/Source/core/animation/EffectInput.cpp |
| index 2f87c28e668d7f864803948083a75f07a80e13f9..52170d6ed8d89463996cd068a270c36e497bb73f 100644 |
| --- a/Source/core/animation/EffectInput.cpp |
| +++ b/Source/core/animation/EffectInput.cpp |
| @@ -48,7 +48,23 @@ static bool checkDocumentAndRenderer(Element* element) |
| return element->renderer(); |
| } |
| -PassRefPtrWillBeRawPtr<AnimationEffect> EffectInput::convert(Element* element, const Vector<Dictionary>& keyframeDictionaryVector, bool unsafe) |
| +static bool hasMismatchedKeyframeProperty(Vector<RefPtr<MutableStylePropertySet> > propertySetVector) |
|
dstockwell
2014/03/11 03:28:14
Instead of doing the checks here, we might be able
|
| +{ |
| + HashCountedSet<CSSPropertyID> counter; |
| + for (size_t i = 0; i < propertySetVector.size(); ++i) { |
| + for (size_t j = 0; j < propertySetVector[i]->propertyCount(); ++j) { |
| + CSSPropertyID property = propertySetVector[i]->propertyAt(j).id(); |
| + counter.add(property); |
| + } |
| + } |
| + for (HashCountedSet<CSSPropertyID>::iterator iterator = counter.begin(); iterator != counter.end(); ++iterator) { |
| + if (iterator->value == 1) |
| + return true; |
| + } |
| + return false; |
| +} |
| + |
| +PassRefPtrWillBeRawPtr<AnimationEffect> EffectInput::convert(Element* element, const Vector<Dictionary>& keyframeDictionaryVector, ExceptionState& exceptionState, bool unsafe) |
| { |
| // FIXME: This test will not be neccessary once resolution of keyframe values occurs at |
| // animation application time. |
| @@ -58,6 +74,9 @@ PassRefPtrWillBeRawPtr<AnimationEffect> EffectInput::convert(Element* element, c |
| // FIXME: Move this code into KeyframeEffectModel, it will be used by the IDL constructor for that class. |
| KeyframeEffectModel::KeyframeVector keyframes; |
| Vector<RefPtr<MutableStylePropertySet> > propertySetVector; |
| + bool hasOffsets = false; |
| + bool hasOffsetZero = false; |
| + bool hasOffsetOne = false; |
| for (size_t i = 0; i < keyframeDictionaryVector.size(); ++i) { |
| RefPtr<MutableStylePropertySet> propertySet = MutableStylePropertySet::create(); |
| @@ -67,8 +86,14 @@ PassRefPtrWillBeRawPtr<AnimationEffect> EffectInput::convert(Element* element, c |
| keyframes.append(keyframe); |
| double offset; |
| - if (keyframeDictionaryVector[i].get("offset", offset)) |
| + if (keyframeDictionaryVector[i].get("offset", offset)) { |
| keyframe->setOffset(offset); |
| + hasOffsets = true; |
| + if (!offset) |
| + hasOffsetZero = true; |
| + if (offset == 1) |
| + hasOffsetOne = true; |
| + } |
| String compositeString; |
| keyframeDictionaryVector[i].get("composite", compositeString); |
| @@ -103,6 +128,17 @@ PassRefPtrWillBeRawPtr<AnimationEffect> EffectInput::convert(Element* element, c |
| } |
| } |
| + // FIXME: Web Animations can't yet handle keyframe sets where a property appears in only one keyframe (called "partial keyframes"). |
| + // This check can be removed once support for such input is added. |
| + if (hasMismatchedKeyframeProperty(propertySetVector)) |
| + exceptionState.throwDOMException(NotSupportedError, "Keyframe effect contains properties that appear in only one keyframe."); |
| + // FIXME: Web Animations can't yet handle keyframe sets which specify offsets and don't specify keyframes at offset: 0 and offset: 1. |
| + // These checks can be removed once support for such input is added. |
| + if (hasOffsets && !hasOffsetZero) |
| + exceptionState.throwDOMException(NotSupportedError, "Keyframes specify offsets, but keyframe with offset: 0 is missing."); |
| + if (hasOffsets && !hasOffsetOne) |
| + exceptionState.throwDOMException(NotSupportedError, "Keyframes specify offsets, but keyframe with offset: 1 is missing."); |
| + |
| // FIXME: Replace this with code that just parses, when that code is available. |
| return StyleResolver::createKeyframeEffectModel(*element, propertySetVector, keyframes); |
| } |