Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(96)

Unified Diff: third_party/WebKit/Source/core/animation/EffectInput.cpp

Issue 2334123002: Web Animations: Support iterator protocol in property indexed keyframe values (Closed)
Patch Set: Add missing null check Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/animation/EffectInput.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..6e96572bcd4d18c327f288965507ae19d90559d2 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,45 @@ 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());
+
+ // Array of strings.
+ if (DictionaryHelper::get(keyframeDictionary, property, result))
+ return true;
+
+ Dictionary valuesDictionary;
+ if (!keyframeDictionary.get(property, valuesDictionary) || valuesDictionary.isUndefinedOrNull()) {
+ // Non-object.
+ String value;
+ DictionaryHelper::get(keyframeDictionary, property, value);
+ result.append(value);
+ return true;
+ }
+
+ DictionaryIterator iterator = valuesDictionary.getIterator(executionContext);
+ if (iterator.isNull()) {
+ // Non-iterable object.
+ String value;
+ DictionaryHelper::get(keyframeDictionary, property, value);
+ result.append(value);
+ return true;
+ }
+
+ // Iterable object.
+ 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 +289,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) {
« no previous file with comments | « third_party/WebKit/Source/core/animation/EffectInput.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698