Commit b0030aa7 authored by Hitoshi Yoshida's avatar Hitoshi Yoshida Committed by Commit Bot

bindings: Make generated dictionary compilable (4/N)

- Define NativeValueTraits<IDLNullable<DOMArrayBuffer>>'s body
- Use NativeValueTraits to convert IDL dictionaries in tests
- Replace a setXxxToNull to setXxx
- Define V8SetReturnValue for bindings::DictionaryBase


Bug: 839389
Change-Id: I672bdf0bd9b5bf6e6a0b8d3b910d5712f4476cdf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2087243Reviewed-by: default avatarYuki Shiino <yukishiino@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Hitoshi Yoshida <peria@chromium.org>
Cr-Commit-Position: refs/heads/master@{#747599}
parent 2e7a63c6
...@@ -264,6 +264,25 @@ DOMArrayBuffer* NativeValueTraits<DOMArrayBuffer>::ArgumentValue( ...@@ -264,6 +264,25 @@ DOMArrayBuffer* NativeValueTraits<DOMArrayBuffer>::ArgumentValue(
isolate, argument_index, value, exception_state); isolate, argument_index, value, exception_state);
} }
DOMArrayBuffer* NativeValueTraits<IDLNullable<DOMArrayBuffer>>::NativeValue(
v8::Isolate* isolate,
v8::Local<v8::Value> value,
ExceptionState& exception_state) {
return NativeValueTraitsBufferSourcePtrNativeValue<
DOMArrayBuffer, V8ArrayBuffer, IDLBufferSourceTypeConvMode::kNullable>(
isolate, value, exception_state);
}
DOMArrayBuffer* NativeValueTraits<IDLNullable<DOMArrayBuffer>>::ArgumentValue(
v8::Isolate* isolate,
int argument_index,
v8::Local<v8::Value> value,
ExceptionState& exception_state) {
return NativeValueTraitsBufferSourcePtrArgumentValue<
DOMArrayBuffer, V8ArrayBuffer, IDLBufferSourceTypeConvMode::kNullable>(
isolate, argument_index, value, exception_state);
}
#define DEFINE_NATIVE_VALUE_TRAITS_BUFFER_SOURCE_TYPE_NOT_SHARED(T, V8T) \ #define DEFINE_NATIVE_VALUE_TRAITS_BUFFER_SOURCE_TYPE_NOT_SHARED(T, V8T) \
template <> \ template <> \
CORE_EXPORT NotShared<T> NativeValueTraits<NotShared<T>>::NativeValue( \ CORE_EXPORT NotShared<T> NativeValueTraits<NotShared<T>>::NativeValue( \
......
...@@ -163,9 +163,8 @@ TEST_F(AnimationKeyframeEffectV8Test, SetAndRetrieveEffectComposite) { ...@@ -163,9 +163,8 @@ TEST_F(AnimationKeyframeEffectV8Test, SetAndRetrieveEffectComposite) {
SetV8ObjectPropertyAsString(scope.GetIsolate(), effect_options, "composite", SetV8ObjectPropertyAsString(scope.GetIsolate(), effect_options, "composite",
"add"); "add");
KeyframeEffectOptions* effect_options_dictionary = KeyframeEffectOptions* effect_options_dictionary =
KeyframeEffectOptions::Create(); NativeValueTraits<KeyframeEffectOptions>::NativeValue(
V8KeyframeEffectOptions::ToImpl(scope.GetIsolate(), effect_options, scope.GetIsolate(), effect_options, exception_state);
effect_options_dictionary, exception_state);
EXPECT_FALSE(exception_state.HadException()); EXPECT_FALSE(exception_state.HadException());
ScriptValue js_keyframes = ScriptValue::CreateNull(scope.GetIsolate()); ScriptValue js_keyframes = ScriptValue::CreateNull(scope.GetIsolate());
...@@ -189,9 +188,8 @@ TEST_F(AnimationKeyframeEffectV8Test, KeyframeCompositeOverridesEffect) { ...@@ -189,9 +188,8 @@ TEST_F(AnimationKeyframeEffectV8Test, KeyframeCompositeOverridesEffect) {
SetV8ObjectPropertyAsString(scope.GetIsolate(), effect_options, "composite", SetV8ObjectPropertyAsString(scope.GetIsolate(), effect_options, "composite",
"add"); "add");
KeyframeEffectOptions* effect_options_dictionary = KeyframeEffectOptions* effect_options_dictionary =
KeyframeEffectOptions::Create(); NativeValueTraits<KeyframeEffectOptions>::NativeValue(
V8KeyframeEffectOptions::ToImpl(scope.GetIsolate(), effect_options, scope.GetIsolate(), effect_options, exception_state);
effect_options_dictionary, exception_state);
EXPECT_FALSE(exception_state.HadException()); EXPECT_FALSE(exception_state.HadException());
HeapVector<ScriptValue> blink_keyframes = { HeapVector<ScriptValue> blink_keyframes = {
...@@ -258,11 +256,10 @@ TEST_F(AnimationKeyframeEffectV8Test, SpecifiedGetters) { ...@@ -258,11 +256,10 @@ TEST_F(AnimationKeyframeEffectV8Test, SpecifiedGetters) {
"reverse"); "reverse");
SetV8ObjectPropertyAsString(scope.GetIsolate(), timing_input, "easing", SetV8ObjectPropertyAsString(scope.GetIsolate(), timing_input, "easing",
"ease-in-out"); "ease-in-out");
KeyframeEffectOptions* timing_input_dictionary =
KeyframeEffectOptions::Create();
DummyExceptionStateForTesting exception_state; DummyExceptionStateForTesting exception_state;
V8KeyframeEffectOptions::ToImpl(scope.GetIsolate(), timing_input, KeyframeEffectOptions* timing_input_dictionary =
timing_input_dictionary, exception_state); NativeValueTraits<KeyframeEffectOptions>::NativeValue(
scope.GetIsolate(), timing_input, exception_state);
EXPECT_FALSE(exception_state.HadException()); EXPECT_FALSE(exception_state.HadException());
KeyframeEffect* animation = CreateAnimationFromOption( KeyframeEffect* animation = CreateAnimationFromOption(
...@@ -287,12 +284,10 @@ TEST_F(AnimationKeyframeEffectV8Test, SpecifiedDurationGetter) { ...@@ -287,12 +284,10 @@ TEST_F(AnimationKeyframeEffectV8Test, SpecifiedDurationGetter) {
v8::Object::New(scope.GetIsolate()); v8::Object::New(scope.GetIsolate());
SetV8ObjectPropertyAsNumber(scope.GetIsolate(), timing_input_with_duration, SetV8ObjectPropertyAsNumber(scope.GetIsolate(), timing_input_with_duration,
"duration", 2.5); "duration", 2.5);
KeyframeEffectOptions* timing_input_dictionary_with_duration =
KeyframeEffectOptions::Create();
DummyExceptionStateForTesting exception_state; DummyExceptionStateForTesting exception_state;
V8KeyframeEffectOptions::ToImpl( KeyframeEffectOptions* timing_input_dictionary_with_duration =
scope.GetIsolate(), timing_input_with_duration, NativeValueTraits<KeyframeEffectOptions>::NativeValue(
timing_input_dictionary_with_duration, exception_state); scope.GetIsolate(), timing_input_with_duration, exception_state);
EXPECT_FALSE(exception_state.HadException()); EXPECT_FALSE(exception_state.HadException());
KeyframeEffect* animation_with_duration = KeyframeEffect* animation_with_duration =
...@@ -308,10 +303,8 @@ TEST_F(AnimationKeyframeEffectV8Test, SpecifiedDurationGetter) { ...@@ -308,10 +303,8 @@ TEST_F(AnimationKeyframeEffectV8Test, SpecifiedDurationGetter) {
v8::Local<v8::Object> timing_input_no_duration = v8::Local<v8::Object> timing_input_no_duration =
v8::Object::New(scope.GetIsolate()); v8::Object::New(scope.GetIsolate());
KeyframeEffectOptions* timing_input_dictionary_no_duration = KeyframeEffectOptions* timing_input_dictionary_no_duration =
KeyframeEffectOptions::Create(); NativeValueTraits<KeyframeEffectOptions>::NativeValue(
V8KeyframeEffectOptions::ToImpl(scope.GetIsolate(), timing_input_no_duration, scope.GetIsolate(), timing_input_no_duration, exception_state);
timing_input_dictionary_no_duration,
exception_state);
EXPECT_FALSE(exception_state.HadException()); EXPECT_FALSE(exception_state.HadException());
KeyframeEffect* animation_no_duration = KeyframeEffect* animation_no_duration =
...@@ -334,11 +327,10 @@ TEST_F(AnimationKeyframeEffectV8Test, SetKeyframesAdditiveCompositeOperation) { ...@@ -334,11 +327,10 @@ TEST_F(AnimationKeyframeEffectV8Test, SetKeyframesAdditiveCompositeOperation) {
ScriptState* script_state = scope.GetScriptState(); ScriptState* script_state = scope.GetScriptState();
ScriptValue js_keyframes = ScriptValue::CreateNull(scope.GetIsolate()); ScriptValue js_keyframes = ScriptValue::CreateNull(scope.GetIsolate());
v8::Local<v8::Object> timing_input = v8::Object::New(scope.GetIsolate()); v8::Local<v8::Object> timing_input = v8::Object::New(scope.GetIsolate());
KeyframeEffectOptions* timing_input_dictionary =
KeyframeEffectOptions::Create();
DummyExceptionStateForTesting exception_state; DummyExceptionStateForTesting exception_state;
V8KeyframeEffectOptions::ToImpl(scope.GetIsolate(), timing_input, KeyframeEffectOptions* timing_input_dictionary =
timing_input_dictionary, exception_state); NativeValueTraits<KeyframeEffectOptions>::NativeValue(
scope.GetIsolate(), timing_input, exception_state);
ASSERT_FALSE(exception_state.HadException()); ASSERT_FALSE(exception_state.HadException());
// Since there are no CSS-targeting keyframes, we can create a KeyframeEffect // Since there are no CSS-targeting keyframes, we can create a KeyframeEffect
......
...@@ -83,18 +83,16 @@ Timing AnimationTimingInputTest::ApplyTimingInputString( ...@@ -83,18 +83,16 @@ Timing AnimationTimingInputTest::ApplyTimingInputString(
Timing result; Timing result;
if (is_keyframeeffectoptions) { if (is_keyframeeffectoptions) {
KeyframeEffectOptions* timing_input_dictionary = KeyframeEffectOptions* timing_input_dictionary =
KeyframeEffectOptions::Create(); NativeValueTraits<KeyframeEffectOptions>::NativeValue(
V8KeyframeEffectOptions::ToImpl(isolate, timing_input, isolate, timing_input, exception_state);
timing_input_dictionary, exception_state);
UnrestrictedDoubleOrKeyframeEffectOptions timing_input = UnrestrictedDoubleOrKeyframeEffectOptions timing_input =
UnrestrictedDoubleOrKeyframeEffectOptions::FromKeyframeEffectOptions( UnrestrictedDoubleOrKeyframeEffectOptions::FromKeyframeEffectOptions(
timing_input_dictionary); timing_input_dictionary);
result = TimingInput::Convert(timing_input, GetDocument(), exception_state); result = TimingInput::Convert(timing_input, GetDocument(), exception_state);
} else { } else {
KeyframeAnimationOptions* timing_input_dictionary = KeyframeAnimationOptions* timing_input_dictionary =
KeyframeAnimationOptions::Create(); NativeValueTraits<KeyframeAnimationOptions>::NativeValue(
V8KeyframeAnimationOptions::ToImpl( isolate, timing_input, exception_state);
isolate, timing_input, timing_input_dictionary, exception_state);
UnrestrictedDoubleOrKeyframeAnimationOptions timing_input = UnrestrictedDoubleOrKeyframeAnimationOptions timing_input =
UnrestrictedDoubleOrKeyframeAnimationOptions:: UnrestrictedDoubleOrKeyframeAnimationOptions::
FromKeyframeAnimationOptions(timing_input_dictionary); FromKeyframeAnimationOptions(timing_input_dictionary);
......
...@@ -98,7 +98,7 @@ static HeapVector<Member<MediaKeySystemMediaCapability>> ConvertCapabilities( ...@@ -98,7 +98,7 @@ static HeapVector<Member<MediaKeySystemMediaCapability>> ConvertCapabilities(
// accumulated configuration MUST still contain a encryptionScheme // accumulated configuration MUST still contain a encryptionScheme
// field with a value of null, so that polyfills can detect the user // field with a value of null, so that polyfills can detect the user
// agent's support for the field without specifying specific values." // agent's support for the field without specifying specific values."
capability->setEncryptionSchemeToNull(); capability->setEncryptionScheme(String());
break; break;
case WebMediaKeySystemMediaCapability::EncryptionScheme::kCenc: case WebMediaKeySystemMediaCapability::EncryptionScheme::kCenc:
capability->setEncryptionScheme("cenc"); capability->setEncryptionScheme("cenc");
......
...@@ -814,8 +814,7 @@ class RTCPeerConnectionCallSetupStateTest : public RTCPeerConnectionTest { ...@@ -814,8 +814,7 @@ class RTCPeerConnectionCallSetupStateTest : public RTCPeerConnectionTest {
return CallbackType::Create(v8_function); return CallbackType::Create(v8_function);
} }
ScriptValue ToScriptValue(V8TestingScope& scope, ScriptValue ToScriptValue(V8TestingScope& scope, RTCOfferOptions* value) {
const IDLDictionaryBase* value) {
v8::Isolate* isolate = scope.GetIsolate(); v8::Isolate* isolate = scope.GetIsolate();
return ScriptValue(isolate, return ScriptValue(isolate,
ToV8(value, scope.GetContext()->Global(), isolate)); ToV8(value, scope.GetContext()->Global(), isolate));
......
...@@ -46,6 +46,10 @@ ...@@ -46,6 +46,10 @@
namespace blink { namespace blink {
namespace bindings {
class DictionaryBase;
}
// This file contains bindings helper functions that do not have dependencies // This file contains bindings helper functions that do not have dependencies
// to core/ or bindings/core. For core-specific helper functions, see // to core/ or bindings/core. For core-specific helper functions, see
// bindings/core/v8/V8BindingForCore.h. // bindings/core/v8/V8BindingForCore.h.
...@@ -212,6 +216,14 @@ inline void V8SetReturnValueFast(const CallbackInfo& callback_info, ...@@ -212,6 +216,14 @@ inline void V8SetReturnValueFast(const CallbackInfo& callback_info,
V8SetReturnValue(callback_info, handle); V8SetReturnValue(callback_info, handle);
} }
// Dictionary
template <class CallbackInfo>
void V8SetReturnValue(const CallbackInfo& info,
bindings::DictionaryBase* value,
v8::Local<v8::Object> creation_context) {
V8SetReturnValue(info, ToV8(value, creation_context, info.GetIsolate()));
}
// Convert v8::String to a WTF::String. If the V8 string is not already // Convert v8::String to a WTF::String. If the V8 string is not already
// an external string then it is transformed into an external string at this // an external string then it is transformed into an external string at this
// point to avoid repeated conversions. // point to avoid repeated conversions.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment