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

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: Exception handling 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..56e829418d1144381d2a733fc9d497d7feb8ee51 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,33 @@ 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.
+ Dictionary valuesDictionary;
+ bool success = keyframeDictionary.get(property, valuesDictionary);
+ DictionaryIterator iterator(success ? valuesDictionary.getIterator(executionContext) : nullptr);
+ if (iterator.isNull()) {
suzyh_UTC10 (ex-contributor) 2016/09/13 08:21:21 This code is difficult to read/understand. IIUC, i
alancutter (OOO until 2018) 2016/09/13 09:31:28 I was avoiding code duplication. Probably not wort
+ String value;
+ DictionaryHelper::get(keyframeDictionary, property, value);
+ result.append(value);
+ return true;
+ }
+
+ while (iterator.next(executionContext, exceptionState)) {
+ String value;
+ if (!iterator.valueAsString(value))
+ return false;
+ result.append(value);
+ }
+ return !exceptionState.hadException();
+}
+
+EffectModel* EffectInput::convertObjectForm(Element& element, const Dictionary& keyframeDictionary, ExecutionContext* executionContext, ExceptionState& exceptionState)
{
StringKeyframeVector keyframes;
@@ -251,12 +277,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;
suzyh_UTC10 (ex-contributor) 2016/09/13 08:21:21 In other places where we return nullptr, it happen
alancutter (OOO until 2018) 2016/09/13 09:31:28 Added throwTypeError() call and test case.
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