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

Unified Diff: Source/bindings/tests/results/core/V8TestDictionary.cpp

Issue 724733002: Support for [Clamp] and [EnforceRange] to IDL dictionary. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 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: Source/bindings/tests/results/core/V8TestDictionary.cpp
diff --git a/Source/bindings/tests/results/core/V8TestDictionary.cpp b/Source/bindings/tests/results/core/V8TestDictionary.cpp
index 3dadcea123095bf189f91a489788eee7bd03eef9..39699824c22496c8605338df5aaf1cb08a93ae50 100644
--- a/Source/bindings/tests/results/core/V8TestDictionary.cpp
+++ b/Source/bindings/tests/results/core/V8TestDictionary.cpp
@@ -7,7 +7,6 @@
#include "config.h"
#include "V8TestDictionary.h"
-#include "bindings/core/v8/Dictionary.h"
#include "bindings/core/v8/ExceptionState.h"
#include "bindings/core/v8/ScriptValue.h"
#include "bindings/core/v8/V8Element.h"
@@ -26,46 +25,47 @@ void V8TestDictionary::toImpl(v8::Isolate* isolate, v8::Handle<v8::Value> v8Valu
return;
}
- // FIXME: Do not use Dictionary and DictionaryHelper
- // https://crbug.com/321462
- Dictionary dictionary(v8Value, isolate);
- // FIXME: Remove this v8::TryCatch once the code is switched from
- // Dictionary/DictionaryHelper to something that uses ExceptionState.
+ v8::Local<v8::Object> v8Object = v8Value->ToObject(isolate);
v8::TryCatch block;
- bool booleanMember;
- if (DictionaryHelper::getWithUndefinedOrNullCheck(dictionary, "booleanMember", booleanMember)) {
+ v8::Local<v8::Value> booleanMemberValue = v8Object->Get(v8String(isolate, "booleanMember"));
+ if (!booleanMemberValue.IsEmpty() && !isUndefinedOrNull(booleanMemberValue)) {
+ bool booleanMember = booleanMemberValue->BooleanValue();
impl.setBooleanMember(booleanMember);
} else if (block.HasCaught()) {
exceptionState.rethrowV8Exception(block.Exception());
return;
}
- bool create;
- if (DictionaryHelper::getWithUndefinedOrNullCheck(dictionary, "create", create)) {
+ v8::Local<v8::Value> createValue = v8Object->Get(v8String(isolate, "create"));
+ if (!createValue.IsEmpty() && !isUndefinedOrNull(createValue)) {
+ bool create = createValue->BooleanValue();
impl.setCreateMember(create);
} else if (block.HasCaught()) {
exceptionState.rethrowV8Exception(block.Exception());
return;
}
- double doubleOrNullMember;
- if (DictionaryHelper::getWithUndefinedOrNullCheck(dictionary, "doubleOrNullMember", doubleOrNullMember)) {
+ v8::Local<v8::Value> doubleOrNullMemberValue = v8Object->Get(v8String(isolate, "doubleOrNullMember"));
+ if (!doubleOrNullMemberValue.IsEmpty() && !isUndefinedOrNull(doubleOrNullMemberValue)) {
+ TONATIVE_VOID_EXCEPTIONSTATE(double, doubleOrNullMember, toDouble(doubleOrNullMemberValue, exceptionState), exceptionState);
impl.setDoubleOrNullMember(doubleOrNullMember);
} else if (block.HasCaught()) {
exceptionState.rethrowV8Exception(block.Exception());
return;
}
- RefPtrWillBeRawPtr<Element> elementOrNullMember;
- if (DictionaryHelper::getWithUndefinedOrNullCheck(dictionary, "elementOrNullMember", elementOrNullMember)) {
+ v8::Local<v8::Value> elementOrNullMemberValue = v8Object->Get(v8String(isolate, "elementOrNullMember"));
+ if (!elementOrNullMemberValue.IsEmpty() && !isUndefinedOrNull(elementOrNullMemberValue)) {
+ Element* elementOrNullMember = V8Element::toImplWithTypeCheck(isolate, elementOrNullMemberValue);
impl.setElementOrNullMember(elementOrNullMember);
} else if (block.HasCaught()) {
exceptionState.rethrowV8Exception(block.Exception());
return;
}
- String enumMember;
- if (DictionaryHelper::getWithUndefinedOrNullCheck(dictionary, "enumMember", enumMember)) {
+ v8::Local<v8::Value> enumMemberValue = v8Object->Get(v8String(isolate, "enumMember"));
+ if (!enumMemberValue.IsEmpty() && !isUndefinedOrNull(enumMemberValue)) {
+ TOSTRING_VOID(V8StringResource<>, enumMember, enumMemberValue);
String string = enumMember;
if (!(string == "foo" || string == "bar" || string == "baz")) {
exceptionState.throwTypeError("member enumMember ('" + string + "') is not a valid enum value.");
@@ -77,16 +77,18 @@ void V8TestDictionary::toImpl(v8::Isolate* isolate, v8::Handle<v8::Value> v8Valu
return;
}
- int longMember;
- if (DictionaryHelper::getWithUndefinedOrNullCheck(dictionary, "longMember", longMember)) {
+ v8::Local<v8::Value> longMemberValue = v8Object->Get(v8String(isolate, "longMember"));
+ if (!longMemberValue.IsEmpty() && !isUndefinedOrNull(longMemberValue)) {
+ TONATIVE_VOID_EXCEPTIONSTATE(int, longMember, toInt32(longMemberValue, exceptionState), exceptionState);
impl.setLongMember(longMember);
} else if (block.HasCaught()) {
exceptionState.rethrowV8Exception(block.Exception());
return;
}
- ScriptValue objectMember;
- if (DictionaryHelper::getWithUndefinedOrNullCheck(dictionary, "objectMember", objectMember)) {
+ v8::Local<v8::Value> objectMemberValue = v8Object->Get(v8String(isolate, "objectMember"));
+ if (!objectMemberValue.IsEmpty() && !isUndefinedOrNull(objectMemberValue)) {
+ ScriptValue objectMember = ScriptValue(ScriptState::current(isolate), objectMemberValue);
if (!objectMember.isObject()) {
exceptionState.throwTypeError("member objectMember is not an object.");
return;
@@ -97,8 +99,9 @@ void V8TestDictionary::toImpl(v8::Isolate* isolate, v8::Handle<v8::Value> v8Valu
return;
}
- ScriptValue objectOrNullMember;
- if (DictionaryHelper::getWithUndefinedOrNullCheck(dictionary, "objectOrNullMember", objectOrNullMember)) {
+ v8::Local<v8::Value> objectOrNullMemberValue = v8Object->Get(v8String(isolate, "objectOrNullMember"));
+ if (!objectOrNullMemberValue.IsEmpty() && !isUndefinedOrNull(objectOrNullMemberValue)) {
+ ScriptValue objectOrNullMember = ScriptValue(ScriptState::current(isolate), objectOrNullMemberValue);
if (!objectOrNullMember.isObject()) {
exceptionState.throwTypeError("member objectOrNullMember is not an object.");
return;
@@ -109,80 +112,90 @@ void V8TestDictionary::toImpl(v8::Isolate* isolate, v8::Handle<v8::Value> v8Valu
return;
}
- Vector<String> stringArrayMember;
- if (DictionaryHelper::getWithUndefinedOrNullCheck(dictionary, "stringArrayMember", stringArrayMember)) {
+ v8::Local<v8::Value> stringArrayMemberValue = v8Object->Get(v8String(isolate, "stringArrayMember"));
+ if (!stringArrayMemberValue.IsEmpty() && !isUndefinedOrNull(stringArrayMemberValue)) {
+ TONATIVE_VOID_EXCEPTIONSTATE(Vector<String>, stringArrayMember, toImplArray<String>(stringArrayMemberValue, 0, isolate, exceptionState), exceptionState);
impl.setStringArrayMember(stringArrayMember);
} else if (block.HasCaught()) {
exceptionState.rethrowV8Exception(block.Exception());
return;
}
- String stringMember;
- if (DictionaryHelper::getWithUndefinedOrNullCheck(dictionary, "stringMember", stringMember)) {
+ v8::Local<v8::Value> stringMemberValue = v8Object->Get(v8String(isolate, "stringMember"));
+ if (!stringMemberValue.IsEmpty() && !isUndefinedOrNull(stringMemberValue)) {
+ TOSTRING_VOID(V8StringResource<>, stringMember, stringMemberValue);
impl.setStringMember(stringMember);
} else if (block.HasCaught()) {
exceptionState.rethrowV8Exception(block.Exception());
return;
}
- String stringOrNullMember;
- if (DictionaryHelper::getWithUndefinedOrNullCheck(dictionary, "stringOrNullMember", stringOrNullMember)) {
+ v8::Local<v8::Value> stringOrNullMemberValue = v8Object->Get(v8String(isolate, "stringOrNullMember"));
+ if (!stringOrNullMemberValue.IsEmpty() && !isUndefinedOrNull(stringOrNullMemberValue)) {
+ TOSTRING_VOID(V8StringResource<>, stringOrNullMember, stringOrNullMemberValue);
impl.setStringOrNullMember(stringOrNullMember);
} else if (block.HasCaught()) {
exceptionState.rethrowV8Exception(block.Exception());
return;
}
- Vector<String> stringSequenceMember;
- if (DictionaryHelper::getWithUndefinedOrNullCheck(dictionary, "stringSequenceMember", stringSequenceMember)) {
+ v8::Local<v8::Value> stringSequenceMemberValue = v8Object->Get(v8String(isolate, "stringSequenceMember"));
+ if (!stringSequenceMemberValue.IsEmpty() && !isUndefinedOrNull(stringSequenceMemberValue)) {
+ TONATIVE_VOID_EXCEPTIONSTATE(Vector<String>, stringSequenceMember, toImplArray<String>(stringSequenceMemberValue, 0, isolate, exceptionState), exceptionState);
impl.setStringSequenceMember(stringSequenceMember);
} else if (block.HasCaught()) {
exceptionState.rethrowV8Exception(block.Exception());
return;
}
- RawPtr<TestInterfaceGarbageCollected> testInterfaceGarbageCollectedMember;
- if (DictionaryHelper::getWithUndefinedOrNullCheck(dictionary, "testInterfaceGarbageCollectedMember", testInterfaceGarbageCollectedMember)) {
+ v8::Local<v8::Value> testInterfaceGarbageCollectedMemberValue = v8Object->Get(v8String(isolate, "testInterfaceGarbageCollectedMember"));
+ if (!testInterfaceGarbageCollectedMemberValue.IsEmpty() && !isUndefinedOrNull(testInterfaceGarbageCollectedMemberValue)) {
+ TestInterfaceGarbageCollected* testInterfaceGarbageCollectedMember = V8TestInterfaceGarbageCollected::toImplWithTypeCheck(isolate, testInterfaceGarbageCollectedMemberValue);
impl.setTestInterfaceGarbageCollectedMember(testInterfaceGarbageCollectedMember);
} else if (block.HasCaught()) {
exceptionState.rethrowV8Exception(block.Exception());
return;
}
- RawPtr<TestInterfaceGarbageCollected> testInterfaceGarbageCollectedOrNullMember;
- if (DictionaryHelper::getWithUndefinedOrNullCheck(dictionary, "testInterfaceGarbageCollectedOrNullMember", testInterfaceGarbageCollectedOrNullMember)) {
+ v8::Local<v8::Value> testInterfaceGarbageCollectedOrNullMemberValue = v8Object->Get(v8String(isolate, "testInterfaceGarbageCollectedOrNullMember"));
+ if (!testInterfaceGarbageCollectedOrNullMemberValue.IsEmpty() && !isUndefinedOrNull(testInterfaceGarbageCollectedOrNullMemberValue)) {
+ TestInterfaceGarbageCollected* testInterfaceGarbageCollectedOrNullMember = V8TestInterfaceGarbageCollected::toImplWithTypeCheck(isolate, testInterfaceGarbageCollectedOrNullMemberValue);
impl.setTestInterfaceGarbageCollectedOrNullMember(testInterfaceGarbageCollectedOrNullMember);
} else if (block.HasCaught()) {
exceptionState.rethrowV8Exception(block.Exception());
return;
}
- RefPtr<TestInterfaceImplementation> testInterfaceMember;
- if (DictionaryHelper::getWithUndefinedOrNullCheck(dictionary, "testInterfaceMember", testInterfaceMember)) {
+ v8::Local<v8::Value> testInterfaceMemberValue = v8Object->Get(v8String(isolate, "testInterfaceMember"));
+ if (!testInterfaceMemberValue.IsEmpty() && !isUndefinedOrNull(testInterfaceMemberValue)) {
+ TestInterfaceImplementation* testInterfaceMember = V8TestInterface::toImplWithTypeCheck(isolate, testInterfaceMemberValue);
impl.setTestInterfaceMember(testInterfaceMember);
} else if (block.HasCaught()) {
exceptionState.rethrowV8Exception(block.Exception());
return;
}
- RefPtr<TestInterfaceImplementation> testInterfaceOrNullMember;
- if (DictionaryHelper::getWithUndefinedOrNullCheck(dictionary, "testInterfaceOrNullMember", testInterfaceOrNullMember)) {
+ v8::Local<v8::Value> testInterfaceOrNullMemberValue = v8Object->Get(v8String(isolate, "testInterfaceOrNullMember"));
+ if (!testInterfaceOrNullMemberValue.IsEmpty() && !isUndefinedOrNull(testInterfaceOrNullMemberValue)) {
+ TestInterfaceImplementation* testInterfaceOrNullMember = V8TestInterface::toImplWithTypeCheck(isolate, testInterfaceOrNullMemberValue);
impl.setTestInterfaceOrNullMember(testInterfaceOrNullMember);
} else if (block.HasCaught()) {
exceptionState.rethrowV8Exception(block.Exception());
return;
}
- RefPtrWillBeRawPtr<TestInterfaceWillBeGarbageCollected> testInterfaceWillBeGarbageCollectedMember;
- if (DictionaryHelper::getWithUndefinedOrNullCheck(dictionary, "testInterfaceWillBeGarbageCollectedMember", testInterfaceWillBeGarbageCollectedMember)) {
+ v8::Local<v8::Value> testInterfaceWillBeGarbageCollectedMemberValue = v8Object->Get(v8String(isolate, "testInterfaceWillBeGarbageCollectedMember"));
+ if (!testInterfaceWillBeGarbageCollectedMemberValue.IsEmpty() && !isUndefinedOrNull(testInterfaceWillBeGarbageCollectedMemberValue)) {
+ TestInterfaceWillBeGarbageCollected* testInterfaceWillBeGarbageCollectedMember = V8TestInterfaceWillBeGarbageCollected::toImplWithTypeCheck(isolate, testInterfaceWillBeGarbageCollectedMemberValue);
impl.setTestInterfaceWillBeGarbageCollectedMember(testInterfaceWillBeGarbageCollectedMember);
} else if (block.HasCaught()) {
exceptionState.rethrowV8Exception(block.Exception());
return;
}
- RefPtrWillBeRawPtr<TestInterfaceWillBeGarbageCollected> testInterfaceWillBeGarbageCollectedOrNullMember;
- if (DictionaryHelper::getWithUndefinedOrNullCheck(dictionary, "testInterfaceWillBeGarbageCollectedOrNullMember", testInterfaceWillBeGarbageCollectedOrNullMember)) {
+ v8::Local<v8::Value> testInterfaceWillBeGarbageCollectedOrNullMemberValue = v8Object->Get(v8String(isolate, "testInterfaceWillBeGarbageCollectedOrNullMember"));
+ if (!testInterfaceWillBeGarbageCollectedOrNullMemberValue.IsEmpty() && !isUndefinedOrNull(testInterfaceWillBeGarbageCollectedOrNullMemberValue)) {
+ TestInterfaceWillBeGarbageCollected* testInterfaceWillBeGarbageCollectedOrNullMember = V8TestInterfaceWillBeGarbageCollected::toImplWithTypeCheck(isolate, testInterfaceWillBeGarbageCollectedOrNullMemberValue);
impl.setTestInterfaceWillBeGarbageCollectedOrNullMember(testInterfaceWillBeGarbageCollectedOrNullMember);
} else if (block.HasCaught()) {
exceptionState.rethrowV8Exception(block.Exception());
« no previous file with comments | « Source/bindings/templates/dictionary_v8.cpp ('k') | Source/bindings/tests/results/core/V8TestDictionaryDerived.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698