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

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

Issue 2509713002: binding: Makes Dictionary throw an exception (constructor). (Closed)
Patch Set: 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/Dictionary.h
diff --git a/third_party/WebKit/Source/bindings/core/v8/Dictionary.h b/third_party/WebKit/Source/bindings/core/v8/Dictionary.h
index 0f0ab1fb3211d2d570cea611b230251f4b240015..d40b2cee9bd38b484226fc59537fa82064094898 100644
--- a/third_party/WebKit/Source/bindings/core/v8/Dictionary.h
+++ b/third_party/WebKit/Source/bindings/core/v8/Dictionary.h
@@ -49,24 +49,19 @@ class CORE_EXPORT Dictionary final {
public:
Dictionary() : m_isolate(nullptr) {}
- Dictionary(v8::Isolate* isolate, const v8::Local<v8::Value>& options)
- : m_options(options), m_isolate(isolate) {
- DCHECK(m_isolate);
- }
- Dictionary(const v8::Local<v8::Value>& options,
- v8::Isolate* isolate,
- ExceptionState&) // DEPRECATED
- : Dictionary(isolate, options) {}
+ Dictionary(v8::Isolate*, v8::Local<v8::Value> dictObj, ExceptionState&);
- Dictionary& operator=(const Dictionary&);
+ Dictionary& operator=(const Dictionary&) = default;
- bool isObject() const;
- bool isUndefinedOrNull() const;
+ bool isObject() const { return !m_dictObj.IsEmpty(); }
+ bool isUndefinedOrNull() const { return blink::isUndefinedOrNull(m_value); }
- bool get(const StringView&, Dictionary&) const;
- bool get(const StringView&, v8::Local<v8::Value>&) const;
+ bool get(const StringView& key, Dictionary&) const;
+ bool get(const StringView& key, v8::Local<v8::Value>& value) const {
+ return getInternal(v8String(m_isolate, key), value);
+ }
- v8::Local<v8::Value> v8Value() const { return m_options; }
+ v8::Local<v8::Value> v8Value() const { return m_value; }
bool getOwnPropertiesAsStringHashMap(HashMap<String, String>&) const;
bool getPropertyNames(Vector<String>&) const;
@@ -84,18 +79,21 @@ class CORE_EXPORT Dictionary final {
private:
bool getInternal(const v8::Local<v8::Value>& key,
v8::Local<v8::Value>& result) const;
- bool toObject(v8::Local<v8::Object>&) const;
- v8::Local<v8::Value> m_options;
v8::Isolate* m_isolate;
+ // Undefined, Null, or Object is allowed as type of dictionary.
+ v8::Local<v8::Value> m_value; // empty, undefined, null, or an Object
+ // In order to avoid converting a v8::Value to a v8::Object everytime, keep
+ // the converted object.
+ v8::Local<v8::Object> m_dictObj; // an Object (same as m_value) or empty
haraken 2016/11/16 17:28:57 Do we need m_dictObj? You're storing m_dictObj to
Yuki 2016/11/17 07:38:53 We need to distinguish undefined / null / an Objec
Yuki 2016/11/18 13:37:53 Done.
};
template <>
struct NativeValueTraits<Dictionary> {
- static inline Dictionary nativeValue(v8::Isolate* isolate,
- v8::Local<v8::Value> value,
- ExceptionState&) {
- return Dictionary(isolate, value);
+ static Dictionary nativeValue(v8::Isolate* isolate,
+ v8::Local<v8::Value> value,
+ ExceptionState& exceptionState) {
+ return Dictionary(isolate, value, exceptionState);
}
};

Powered by Google App Engine
This is Rietveld 408576698