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

bindings: Use NativeValueTraits instead of V8Dictionary::ToImpl

Bug: 839389
Change-Id: Ibc44ae40f3050ef9d11205811f636d4529cf6444
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2054346Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarYuki Shiino <yukishiino@chromium.org>
Commit-Queue: Hitoshi Yoshida <peria@chromium.org>
Cr-Commit-Position: refs/heads/master@{#741352}
parent f8dcd547
......@@ -4,6 +4,7 @@
#include "third_party/blink/renderer/bindings/modules/v8/v8_extendable_message_event.h"
#include "third_party/blink/renderer/bindings/core/v8/native_value_traits_impl.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_extendable_message_event_init.h"
#include "third_party/blink/renderer/core/events/message_event.h"
#include "third_party/blink/renderer/platform/bindings/exception_messages.h"
......@@ -25,16 +26,18 @@ void V8ExtendableMessageEvent::ConstructorCustom(
if (!type.Prepare())
return;
ExtendableMessageEventInit* event_init_dict =
ExtendableMessageEventInit::Create();
if (!IsUndefinedOrNull(info[1])) {
ExtendableMessageEventInit* event_init_dict = nullptr;
if (IsUndefinedOrNull(info[1])) {
event_init_dict = ExtendableMessageEventInit::Create();
} else {
if (!info[1]->IsObject()) {
exception_state.ThrowTypeError(
"parameter 2 ('eventInitDict') is not an object.");
return;
}
V8ExtendableMessageEventInit::ToImpl(isolate, info[1], event_init_dict,
exception_state);
event_init_dict =
NativeValueTraits<ExtendableMessageEventInit>::NativeValue(
isolate, info[1], exception_state);
if (exception_state.HadException())
return;
}
......
......@@ -50,18 +50,16 @@ Timing AnimationTimingInputTest::ApplyTimingInputNumber(
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);
......
......@@ -91,7 +91,7 @@ bool CSSLayoutDefinition::Instance::Layout(
const NGBoxStrut& border_scrollbar_padding,
const LayoutUnit child_percentage_resolution_block_size_for_min_max,
CustomLayoutScope* custom_layout_scope,
FragmentResultOptions* fragment_result_options,
FragmentResultOptions*& fragment_result_options,
scoped_refptr<SerializedScriptValue>* fragment_result_data) {
ScriptState* script_state = definition_->GetScriptState();
v8::Isolate* isolate = script_state->GetIsolate();
......@@ -174,8 +174,9 @@ bool CSSLayoutDefinition::Instance::Layout(
v8::Local<v8::Value> inner_value = v8_result_promise->Result();
// Attempt to convert the result.
V8FragmentResultOptions::ToImpl(isolate, inner_value, fragment_result_options,
exception_state);
fragment_result_options =
NativeValueTraits<FragmentResultOptions>::NativeValue(
isolate, inner_value, exception_state);
if (exception_state.HadException()) {
V8ScriptRunner::ReportException(isolate, exception_state.GetException());
......@@ -222,7 +223,7 @@ bool CSSLayoutDefinition::Instance::IntrinsicSizes(
const NGBoxStrut& border_scrollbar_padding,
const LayoutUnit child_percentage_resolution_block_size_for_min_max,
CustomLayoutScope* custom_layout_scope,
IntrinsicSizesResultOptions* intrinsic_sizes_result_options) {
IntrinsicSizesResultOptions*& intrinsic_sizes_result_options) {
ScriptState* script_state = definition_->GetScriptState();
v8::Isolate* isolate = script_state->GetIsolate();
......@@ -299,8 +300,9 @@ bool CSSLayoutDefinition::Instance::IntrinsicSizes(
v8::Local<v8::Value> inner_value = v8_result_promise->Result();
// Attempt to convert the result.
V8IntrinsicSizesResultOptions::ToImpl(
isolate, inner_value, intrinsic_sizes_result_options, exception_state);
intrinsic_sizes_result_options =
NativeValueTraits<IntrinsicSizesResultOptions>::NativeValue(
isolate, inner_value, exception_state);
if (exception_state.HadException()) {
V8ScriptRunner::ReportException(isolate, exception_state.GetException());
......
......@@ -63,7 +63,7 @@ class CSSLayoutDefinition final : public GarbageCollected<CSSLayoutDefinition>,
const NGBoxStrut& border_scrollbar_padding,
const LayoutUnit child_percentage_resolution_block_size_for_min_max,
CustomLayoutScope*,
FragmentResultOptions*,
FragmentResultOptions*&,
scoped_refptr<SerializedScriptValue>* fragment_result_data);
// Runs the web developer defined intrinsicSizes, returns true if everything
......@@ -76,7 +76,7 @@ class CSSLayoutDefinition final : public GarbageCollected<CSSLayoutDefinition>,
const NGBoxStrut& border_scrollbar_padding,
const LayoutUnit child_percentage_resolution_block_size_for_min_max,
CustomLayoutScope*,
IntrinsicSizesResultOptions*);
IntrinsicSizesResultOptions*&);
void Trace(Visitor*);
......
......@@ -59,8 +59,7 @@ base::Optional<MinMaxSize> NGCustomLayoutAlgorithm::ComputeMinMaxSize(
return FallbackMinMaxSize(input);
}
IntrinsicSizesResultOptions* intrinsic_sizes_result_options =
IntrinsicSizesResultOptions::Create();
IntrinsicSizesResultOptions* intrinsic_sizes_result_options = nullptr;
if (!instance->IntrinsicSizes(
ConstraintSpace(), document, Node(),
container_builder_.InitialBorderBoxSize(), border_scrollbar_padding_,
......@@ -105,8 +104,7 @@ scoped_refptr<const NGLayoutResult> NGCustomLayoutAlgorithm::Layout() {
return FallbackLayout();
}
FragmentResultOptions* fragment_result_options =
FragmentResultOptions::Create();
FragmentResultOptions* fragment_result_options = nullptr;
scoped_refptr<SerializedScriptValue> fragment_result_data;
if (!instance->Layout(
ConstraintSpace(), document, Node(),
......
......@@ -5,6 +5,7 @@
#include "third_party/blink/renderer/modules/payments/basic_card_helper.h"
#include "base/stl_util.h"
#include "third_party/blink/renderer/bindings/core/v8/native_value_traits_impl.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_basic_card_request.h"
#include "third_party/blink/renderer/modules/payments/payment_request.h"
......@@ -34,9 +35,9 @@ void BasicCardHelper::ParseBasiccardData(
ExceptionState& exception_state) {
DCHECK(!input.IsEmpty());
BasicCardRequest* basic_card = BasicCardRequest::Create();
V8BasicCardRequest::ToImpl(input.GetIsolate(), input.V8Value(), basic_card,
exception_state);
BasicCardRequest* basic_card =
NativeValueTraits<BasicCardRequest>::NativeValue(
input.GetIsolate(), input.V8Value(), exception_state);
if (exception_state.HadException())
return;
......
......@@ -17,6 +17,7 @@
#include "third_party/blink/public/mojom/web_feature/web_feature.mojom-blink.h"
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/public/platform/task_type.h"
#include "third_party/blink/renderer/bindings/core/v8/native_value_traits_impl.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_string_resource.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_address_errors.h"
......@@ -363,9 +364,9 @@ void SetAndroidPayMethodData(v8::Isolate* isolate,
const ScriptValue& input,
PaymentMethodDataPtr& output,
ExceptionState& exception_state) {
AndroidPayMethodData* android_pay = AndroidPayMethodData::Create();
V8AndroidPayMethodData::ToImpl(isolate, input.V8Value(), android_pay,
exception_state);
AndroidPayMethodData* android_pay =
NativeValueTraits<AndroidPayMethodData>::NativeValue(
isolate, input.V8Value(), exception_state);
if (exception_state.HadException())
return;
......@@ -966,13 +967,13 @@ void PaymentRequest::OnUpdatePaymentDetails(
update_payment_details_timer_.Stop();
PaymentDetailsUpdate* details = PaymentDetailsUpdate::Create();
ExceptionState exception_state(v8::Isolate::GetCurrent(),
ExceptionState::kConstructionContext,
"PaymentDetailsUpdate");
V8PaymentDetailsUpdate::ToImpl(resolver->GetScriptState()->GetIsolate(),
details_script_value.V8Value(), details,
exception_state);
PaymentDetailsUpdate* details =
NativeValueTraits<PaymentDetailsUpdate>::NativeValue(
resolver->GetScriptState()->GetIsolate(),
details_script_value.V8Value(), exception_state);
if (exception_state.HadException()) {
resolver->Reject(exception_state.GetException());
ClearResolversAndCloseMojoConnection();
......
......@@ -138,26 +138,26 @@ WGPUVertexStateInfo GPUVertexStateAsWGPUVertexState(
continue;
}
GPUVertexBufferLayoutDescriptor vertex_buffer;
V8GPUVertexBufferLayoutDescriptor::ToImpl(isolate, value, &vertex_buffer,
exception_state);
GPUVertexBufferLayoutDescriptor* vertex_buffer =
NativeValueTraits<GPUVertexBufferLayoutDescriptor>::NativeValue(
isolate, value, exception_state);
if (exception_state.HadException()) {
return std::make_tuple(dawn_desc, std::move(dawn_vertex_buffers),
std::move(dawn_vertex_attributes));
}
WGPUVertexBufferLayoutDescriptor dawn_vertex_buffer = {};
dawn_vertex_buffer.arrayStride = vertex_buffer.arrayStride();
dawn_vertex_buffer.arrayStride = vertex_buffer->arrayStride();
dawn_vertex_buffer.stepMode =
AsDawnEnum<WGPUInputStepMode>(vertex_buffer.stepMode());
AsDawnEnum<WGPUInputStepMode>(vertex_buffer->stepMode());
dawn_vertex_buffer.attributeCount =
static_cast<uint32_t>(vertex_buffer.attributes().size());
static_cast<uint32_t>(vertex_buffer->attributes().size());
dawn_vertex_buffer.attributes = nullptr;
dawn_vertex_buffers.push_back(dawn_vertex_buffer);
for (wtf_size_t j = 0; j < vertex_buffer.attributes().size(); ++j) {
for (wtf_size_t j = 0; j < vertex_buffer->attributes().size(); ++j) {
const GPUVertexAttributeDescriptor* attribute =
vertex_buffer.attributes()[j];
vertex_buffer->attributes()[j];
WGPUVertexAttributeDescriptor dawn_vertex_attribute = {};
dawn_vertex_attribute.shaderLocation = attribute->shaderLocation();
dawn_vertex_attribute.offset = attribute->offset();
......
......@@ -8,6 +8,7 @@
#include <string>
#include <utility>
#include "third_party/blink/renderer/bindings/core/v8/native_value_traits_impl.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_array_buffer.h"
......@@ -665,10 +666,9 @@ void WebSocketStream::CloseMaybeWithReason(ScriptValue maybe_reason) {
// Exceptions thrown here are ignored.
ExceptionState exception_state(script_state_->GetIsolate(),
ExceptionState::kUnknownContext, "", "");
WebSocketCloseInfo* info = MakeGarbageCollected<WebSocketCloseInfo>();
V8WebSocketCloseInfo::ToImpl(script_state_->GetIsolate(),
maybe_reason.V8Value(), info, exception_state);
if (info->hasCode() && !exception_state.HadException()) {
WebSocketCloseInfo* info = NativeValueTraits<WebSocketCloseInfo>::NativeValue(
script_state_->GetIsolate(), maybe_reason.V8Value(), exception_state);
if (!exception_state.HadException() && info->hasCode()) {
CloseInternal(info->code(), info->reason(), exception_state);
if (!exception_state.HadException())
return;
......
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