Chromium Code Reviews| Index: third_party/WebKit/Source/core/animation/EffectInput.cpp |
| diff --git a/third_party/WebKit/Source/core/animation/EffectInput.cpp b/third_party/WebKit/Source/core/animation/EffectInput.cpp |
| index 940dcd77a75365adc6f6af95fb36078cc84c6bbb..fbf2e8026141077295251977033052503401d21e 100644 |
| --- a/third_party/WebKit/Source/core/animation/EffectInput.cpp |
| +++ b/third_party/WebKit/Source/core/animation/EffectInput.cpp |
| @@ -156,7 +156,7 @@ EffectModel* EffectInput::convert(Element* element, const DictionarySequenceOrDi |
| return nullptr; |
| } |
| - return convertObjectForm(*element, dictionary, exceptionState); |
| + return convertObjectForm(*element, dictionary, executionContext, exceptionState); |
| } |
| EffectModel* EffectInput::convertArrayForm(Element& element, const Vector<Dictionary>& keyframeDictionaries, ExceptionState& exceptionState) |
| @@ -220,7 +220,42 @@ EffectModel* EffectInput::convertArrayForm(Element& element, const Vector<Dictio |
| return createEffectModelFromKeyframes(element, keyframes, exceptionState); |
| } |
| -EffectModel* EffectInput::convertObjectForm(Element& element, const Dictionary& keyframeDictionary, ExceptionState& exceptionState) |
| +static bool getPropertyIndexedKeyframeValues(const Dictionary& keyframeDictionary, const String& property, ExecutionContext* executionContext, ExceptionState& exceptionState, Vector<String>& result) |
| +{ |
| + DCHECK(result.isEmpty()); |
| + if (DictionaryHelper::get(keyframeDictionary, property, result)) |
| + return true; |
| + |
| + // The above get() only works for Array objects, we still need to handle objects that satisfy the ES6 iterator protocol. |
|
suzyh_UTC10 (ex-contributor)
2016/09/14 01:07:53
Nit: As discussed in person, remove this comment a
|
| + |
| + Dictionary valuesDictionary; |
| + if (!keyframeDictionary.get(property, valuesDictionary)) { |
| + String value; |
| + DictionaryHelper::get(keyframeDictionary, property, value); |
| + result.append(value); |
| + return true; |
| + } |
| + |
| + DictionaryIterator iterator = valuesDictionary.getIterator(executionContext); |
| + if (iterator.isNull()) { |
| + String value; |
| + DictionaryHelper::get(keyframeDictionary, property, value); |
| + result.append(value); |
| + return true; |
| + } |
| + |
| + while (iterator.next(executionContext, exceptionState)) { |
| + String value; |
| + if (!iterator.valueAsString(value)) { |
| + exceptionState.throwTypeError("Unable to read keyframe value as string."); |
| + return false; |
| + } |
| + result.append(value); |
| + } |
| + return !exceptionState.hadException(); |
| +} |
| + |
| +EffectModel* EffectInput::convertObjectForm(Element& element, const Dictionary& keyframeDictionary, ExecutionContext* executionContext, ExceptionState& exceptionState) |
| { |
| StringKeyframeVector keyframes; |
| @@ -251,12 +286,8 @@ EffectModel* EffectInput::convertObjectForm(Element& element, const Dictionary& |
| } |
| Vector<String> values; |
| - bool isList = DictionaryHelper::get(keyframeDictionary, property, values); |
| - if (!isList) { |
| - String value; |
| - DictionaryHelper::get(keyframeDictionary, property, value); |
| - values.append(value); |
| - } |
| + if (!getPropertyIndexedKeyframeValues(keyframeDictionary, property, executionContext, exceptionState, values)) |
| + return nullptr; |
| size_t numKeyframes = values.size(); |
| for (size_t i = 0; i < numKeyframes; ++i) { |