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(
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) \
template <> \
CORE_EXPORT NotShared<T> NativeValueTraits<NotShared<T>>::NativeValue( \
......
......@@ -163,9 +163,8 @@ TEST_F(AnimationKeyframeEffectV8Test, SetAndRetrieveEffectComposite) {
SetV8ObjectPropertyAsString(scope.GetIsolate(), effect_options, "composite",
"add");
KeyframeEffectOptions* effect_options_dictionary =
KeyframeEffectOptions::Create();
V8KeyframeEffectOptions::ToImpl(scope.GetIsolate(), effect_options,
effect_options_dictionary, exception_state);
NativeValueTraits<KeyframeEffectOptions>::NativeValue(
scope.GetIsolate(), effect_options, exception_state);
EXPECT_FALSE(exception_state.HadException());
ScriptValue js_keyframes = ScriptValue::CreateNull(scope.GetIsolate());
......@@ -189,9 +188,8 @@ TEST_F(AnimationKeyframeEffectV8Test, KeyframeCompositeOverridesEffect) {
SetV8ObjectPropertyAsString(scope.GetIsolate(), effect_options, "composite",
"add");
KeyframeEffectOptions* effect_options_dictionary =
KeyframeEffectOptions::Create();
V8KeyframeEffectOptions::ToImpl(scope.GetIsolate(), effect_options,
effect_options_dictionary, exception_state);
NativeValueTraits<KeyframeEffectOptions>::NativeValue(
scope.GetIsolate(), effect_options, exception_state);
EXPECT_FALSE(exception_state.HadException());
HeapVector<ScriptValue> blink_keyframes = {
......@@ -258,11 +256,10 @@ TEST_F(AnimationKeyframeEffectV8Test, SpecifiedGetters) {
"reverse");
SetV8ObjectPropertyAsString(scope.GetIsolate(), timing_input, "easing",
"ease-in-out");
KeyframeEffectOptions* timing_input_dictionary =
KeyframeEffectOptions::Create();
DummyExceptionStateForTesting exception_state;
V8KeyframeEffectOptions::ToImpl(scope.GetIsolate(), timing_input,
timing_input_dictionary, exception_state);
KeyframeEffectOptions* timing_input_dictionary =
NativeValueTraits<KeyframeEffectOptions>::NativeValue(
scope.GetIsolate(), timing_input, exception_state);
EXPECT_FALSE(exception_state.HadException());
KeyframeEffect* animation = CreateAnimationFromOption(
......@@ -287,12 +284,10 @@ TEST_F(AnimationKeyframeEffectV8Test, SpecifiedDurationGetter) {
v8::Object::New(scope.GetIsolate());
SetV8ObjectPropertyAsNumber(scope.GetIsolate(), timing_input_with_duration,
"duration", 2.5);
KeyframeEffectOptions* timing_input_dictionary_with_duration =
KeyframeEffectOptions::Create();
DummyExceptionStateForTesting exception_state;
V8KeyframeEffectOptions::ToImpl(
scope.GetIsolate(), timing_input_with_duration,
timing_input_dictionary_with_duration, exception_state);
KeyframeEffectOptions* timing_input_dictionary_with_duration =
NativeValueTraits<KeyframeEffectOptions>::NativeValue(
scope.GetIsolate(), timing_input_with_duration, exception_state);
EXPECT_FALSE(exception_state.HadException());
KeyframeEffect* animation_with_duration =
......@@ -308,10 +303,8 @@ TEST_F(AnimationKeyframeEffectV8Test, SpecifiedDurationGetter) {
v8::Local<v8::Object> timing_input_no_duration =
v8::Object::New(scope.GetIsolate());
KeyframeEffectOptions* timing_input_dictionary_no_duration =
KeyframeEffectOptions::Create();
V8KeyframeEffectOptions::ToImpl(scope.GetIsolate(), timing_input_no_duration,
timing_input_dictionary_no_duration,
exception_state);
NativeValueTraits<KeyframeEffectOptions>::NativeValue(
scope.GetIsolate(), timing_input_no_duration, exception_state);
EXPECT_FALSE(exception_state.HadException());
KeyframeEffect* animation_no_duration =
......@@ -334,11 +327,10 @@ TEST_F(AnimationKeyframeEffectV8Test, SetKeyframesAdditiveCompositeOperation) {
ScriptState* script_state = scope.GetScriptState();
ScriptValue js_keyframes = ScriptValue::CreateNull(scope.GetIsolate());
v8::Local<v8::Object> timing_input = v8::Object::New(scope.GetIsolate());
KeyframeEffectOptions* timing_input_dictionary =
KeyframeEffectOptions::Create();
DummyExceptionStateForTesting exception_state;
V8KeyframeEffectOptions::ToImpl(scope.GetIsolate(), timing_input,
timing_input_dictionary, exception_state);
KeyframeEffectOptions* timing_input_dictionary =
NativeValueTraits<KeyframeEffectOptions>::NativeValue(
scope.GetIsolate(), timing_input, exception_state);
ASSERT_FALSE(exception_state.HadException());
// Since there are no CSS-targeting keyframes, we can create a KeyframeEffect
......
......@@ -83,18 +83,16 @@ Timing AnimationTimingInputTest::ApplyTimingInputString(
Timing result;
if (is_keyframeeffectoptions) {
KeyframeEffectOptions* timing_input_dictionary =
KeyframeEffectOptions::Create();
V8KeyframeEffectOptions::ToImpl(isolate, timing_input,
timing_input_dictionary, exception_state);
NativeValueTraits<KeyframeEffectOptions>::NativeValue(
isolate, timing_input, exception_state);
UnrestrictedDoubleOrKeyframeEffectOptions timing_input =
UnrestrictedDoubleOrKeyframeEffectOptions::FromKeyframeEffectOptions(
timing_input_dictionary);
result = TimingInput::Convert(timing_input, GetDocument(), exception_state);
} else {
KeyframeAnimationOptions* timing_input_dictionary =
KeyframeAnimationOptions::Create();
V8KeyframeAnimationOptions::ToImpl(
isolate, timing_input, timing_input_dictionary, exception_state);
NativeValueTraits<KeyframeAnimationOptions>::NativeValue(
isolate, timing_input, exception_state);
UnrestrictedDoubleOrKeyframeAnimationOptions timing_input =
UnrestrictedDoubleOrKeyframeAnimationOptions::
FromKeyframeAnimationOptions(timing_input_dictionary);
......
......@@ -98,7 +98,7 @@ static HeapVector<Member<MediaKeySystemMediaCapability>> ConvertCapabilities(
// accumulated configuration MUST still contain a encryptionScheme
// field with a value of null, so that polyfills can detect the user
// agent's support for the field without specifying specific values."
capability->setEncryptionSchemeToNull();
capability->setEncryptionScheme(String());
break;
case WebMediaKeySystemMediaCapability::EncryptionScheme::kCenc:
capability->setEncryptionScheme("cenc");
......
......@@ -814,8 +814,7 @@ class RTCPeerConnectionCallSetupStateTest : public RTCPeerConnectionTest {
return CallbackType::Create(v8_function);
}
ScriptValue ToScriptValue(V8TestingScope& scope,
const IDLDictionaryBase* value) {
ScriptValue ToScriptValue(V8TestingScope& scope, RTCOfferOptions* value) {
v8::Isolate* isolate = scope.GetIsolate();
return ScriptValue(isolate,
ToV8(value, scope.GetContext()->Global(), isolate));
......
......@@ -46,6 +46,10 @@
namespace blink {
namespace bindings {
class DictionaryBase;
}
// This file contains bindings helper functions that do not have dependencies
// to core/ or bindings/core. For core-specific helper functions, see
// bindings/core/v8/V8BindingForCore.h.
......@@ -212,6 +216,14 @@ inline void V8SetReturnValueFast(const CallbackInfo& callback_info,
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
// an external string then it is transformed into an external string at this
// 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