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

Unified Diff: third_party/WebKit/Source/bindings/core/v8/DictionaryHelperForBindings.h

Issue 2444363002: binding: Replaces DictionaryHelper::get(ScriptValue) with get(Nullable<T>). (Closed)
Patch Set: Applied git-cl-format. Created 4 years, 1 month 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
Index: third_party/WebKit/Source/bindings/core/v8/DictionaryHelperForBindings.h
diff --git a/third_party/WebKit/Source/bindings/core/v8/DictionaryHelperForBindings.h b/third_party/WebKit/Source/bindings/core/v8/DictionaryHelperForBindings.h
index 6dca1a9d3d792232a34451ec49c2946fe9a0d944..6c9e4426015eccf779c6b7bb685c846522e12c6b 100644
--- a/third_party/WebKit/Source/bindings/core/v8/DictionaryHelperForBindings.h
+++ b/third_party/WebKit/Source/bindings/core/v8/DictionaryHelperForBindings.h
@@ -27,6 +27,7 @@
#define DictionaryHelperForBindings_h
#include "bindings/core/v8/Dictionary.h"
+#include "bindings/core/v8/Nullable.h"
#include "bindings/core/v8/V8Binding.h"
namespace blink {
@@ -43,6 +44,28 @@ bool DictionaryHelper::get(const Dictionary& dictionary,
return true;
}
+template <typename T>
+bool DictionaryHelper::get(const Dictionary& dictionary,
+ const StringView& key,
+ Nullable<T>& value) {
+ v8::Local<v8::Value> v8Value;
+ if (!dictionary.get(key, v8Value))
+ return false;
+
+ if (v8Value->IsNull()) {
+ value.set(nullptr);
+ return true;
+ }
+
+ T innerValue;
+ if (DictionaryHelper::get(dictionary, key, innerValue)) {
+ value.set(innerValue);
+ return true;
+ }
+
+ return false;
+}
+
} // namespace blink
#endif // DictionaryHelperForBindings_h

Powered by Google App Engine
This is Rietveld 408576698