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

Unified Diff: Source/bindings/core/v8/DictionaryHelperForCore.cpp

Issue 386963003: [WIP][NotForLand] IDL dictionary support (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: sequence and array support Created 6 years, 5 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 | « LayoutTests/fast/dom/some-dictionary-expected.txt ('k') | Source/bindings/core/v8/generated.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/core/v8/DictionaryHelperForCore.cpp
diff --git a/Source/bindings/core/v8/DictionaryHelperForCore.cpp b/Source/bindings/core/v8/DictionaryHelperForCore.cpp
index dc872c6d5e129a1df9fc5d1439d05f6fe2339fc4..33f3ccd9fe2919b6655cd2e04c9bf79a871972f8 100644
--- a/Source/bindings/core/v8/DictionaryHelperForCore.cpp
+++ b/Source/bindings/core/v8/DictionaryHelperForCore.cpp
@@ -390,6 +390,36 @@ bool DictionaryHelper::get(const Dictionary& dictionary, const String& key, Vect
return true;
}
+// FIXME: Remove this special casing. We should either remove DictionaryHelper
+// completely, or auto-generate DictionaryHelper::get<T>() if needed.
+template <>
+bool DictionaryHelper::get(const Dictionary& dictionary, const String& key, RefPtrWillBeMember<Element>& value)
+{
+ v8::Local<v8::Value> v8Value;
+ if (!dictionary.get(key, v8Value))
+ return false;
+
+ value = V8Element::toNativeWithTypeCheck(dictionary.isolate(), v8Value);
+ return true;
+}
+
+// FIXME: Remove this. See above comment.
+template <>
+bool DictionaryHelper::get(const Dictionary& dictionary, const String& key, WillBeHeapVector<RefPtrWillBeMember<Element> >& value)
+{
+ v8::Local<v8::Value> v8Value;
+ if (!dictionary.get(key, v8Value))
+ return false;
+ if (!v8Value->IsArray())
+ return false;
+ v8::Local<v8::Array> v8Array = v8::Local<v8::Array>::Cast(v8Value);
+ for (size_t i = 0; i < v8Array->Length(); ++i) {
+ v8::Local<v8::Value> indexedValue = v8Array->Get(v8::Uint32::New(dictionary.isolate(), i));
+ value.append(V8Element::toNativeWithTypeCheck(dictionary.isolate(), indexedValue));
+ }
+ return true;
+}
+
template <>
bool DictionaryHelper::convert(const Dictionary& dictionary, Dictionary::ConversionContext& context, const String& key, Vector<String>& value)
{
« no previous file with comments | « LayoutTests/fast/dom/some-dictionary-expected.txt ('k') | Source/bindings/core/v8/generated.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698