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

Refactor: Drop support of obsolete types in IDL

Drops support of Dictionary and SerializedScriptValue in Web IDL.
All of their use cases were already removed, and keeping support
of them is a risk to re-introduce them.


Bug: 839389, 1047081
Change-Id: I76d641d9df46755423c18276c7e940d355ecf300
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2100167Reviewed-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@{#750899}
parent 3f6e3bde
......@@ -48,10 +48,13 @@ class CORE_EXPORT Dictionary final {
explicit Dictionary(v8::Isolate*,
v8::Local<v8::Value> dictionary_object,
ExceptionState&);
// ScriptValue can refer a V8 object, and such a ScriptValue can be
// converted into Dictionary without exceptions.
explicit Dictionary(const ScriptValue& script_value)
: isolate_(script_value.GetIsolate()) {
CHECK(script_value.IsObject());
dictionary_object_ = script_value.V8Value().As<v8::Object>();
value_type_ = ValueType::kObject;
}
Dictionary& operator=(const Dictionary&) = default;
......
......@@ -652,8 +652,6 @@ def setter_expression(interface, attribute, context):
handler_type = 'kOnBeforeUnloadEventHandler'
arguments.append('JSEventHandler::CreateOrNull(' + 'v8_value, ' +
'JSEventHandler::HandlerType::' + handler_type + ')')
elif idl_type.base_type == 'SerializedScriptValue':
arguments.append('std::move(cpp_value)')
else:
arguments.append('cpp_value')
if context['is_setter_raises_exception']:
......
......@@ -159,7 +159,6 @@ def member_context(_, member, component_info):
v8_value = snake_case_name + "_value"
has_value_or_default = snake_case_name + "_has_value_or_default"
getter_name = getter_name_for_dictionary_member(member)
is_deprecated_dictionary = unwrapped_idl_type.name == 'Dictionary'
runtime_features = component_info['runtime_enabled_features']
return {
......@@ -191,14 +190,12 @@ def member_context(_, member, component_info):
idl_type.base_type,
'is_callback_function_type':
idl_type.is_callback_function,
'is_deprecated_dictionary':
is_deprecated_dictionary,
'is_interface_type':
idl_type.is_interface_type and not is_deprecated_dictionary,
idl_type.is_interface_type,
'is_nullable':
idl_type.is_nullable,
'is_object':
unwrapped_idl_type.name == 'Object' or is_deprecated_dictionary,
unwrapped_idl_type.name == 'Object',
'is_string_type':
idl_type.preprocessed_type.is_string_type,
'is_required':
......@@ -306,8 +303,6 @@ def member_impl_context(member, interfaces_info, header_includes,
if idl_type.name == 'Object':
return '!({0}_.IsEmpty() || {0}_.IsNull() || {0}_.IsUndefined())'.format(
cpp_name)
if idl_type.name == 'Dictionary':
return '!%s_.IsUndefinedOrNull()' % cpp_name
return '%s_' % cpp_name
cpp_default_value = None
......
......@@ -1482,10 +1482,9 @@ def resolution_tests_methods(effective_overloads):
# • a record type
# ...
try:
method = next(
method for idl_type, method in idl_types_methods
if idl_type.is_callback_interface or idl_type.is_dictionary
or idl_type.name == 'Dictionary' or idl_type.is_record_type)
method = next(method for idl_type, method in idl_types_methods
if idl_type.is_callback_interface
or idl_type.is_dictionary or idl_type.is_record_type)
test = '%s->IsObject()' % cpp_value
yield test, method
except StopIteration:
......@@ -1618,8 +1617,7 @@ def constructor_context(interface, constructor):
'has_exception_state':
is_constructor_raises_exception
or any(argument for argument in constructor.arguments
if argument.idl_type.name == 'SerializedScriptValue'
or argument.idl_type.v8_conversion_needs_exception_state),
if argument.idl_type.v8_conversion_needs_exception_state),
'has_optional_argument_without_default_value':
any(True for argument_context in argument_contexts
if argument_context['is_optional_without_default_value']),
......
......@@ -234,8 +234,7 @@ def method_context(interface, method, component_info, is_visible=True):
'has_exception_state':
is_raises_exception or is_check_security_for_receiver or any(
argument for argument in arguments
if (argument.idl_type.name == 'SerializedScriptValue' or
argument_conversion_needs_exception_state(method, argument))),
if argument_conversion_needs_exception_state(method, argument)),
'has_optional_argument_without_default_value':
any(True for argument_context in argument_contexts
if argument_context['is_optional_without_default_value']),
......@@ -383,7 +382,7 @@ def argument_context(interface, method, argument, index, is_visible=True):
idl_type.is_callback_interface,
# FIXME: Remove generic 'Dictionary' special-casing
'is_dictionary':
idl_type.is_dictionary or idl_type.base_type == 'Dictionary',
idl_type.is_dictionary,
'is_explicit_nullable':
idl_type.is_explicit_nullable,
'is_nullable':
......@@ -446,10 +445,7 @@ def cpp_value(interface, method, number_of_arguments):
cpp_arguments.append('*impl')
for argument in arguments:
variable_name = NameStyleConverter(argument.name).to_snake_case()
if argument.idl_type.base_type == 'SerializedScriptValue':
cpp_arguments.append('std::move(%s)' % variable_name)
else:
cpp_arguments.append(variable_name)
cpp_arguments.append(variable_name)
# If a method returns an IDL dictionary or union type, the return value is
# passed as an argument to impl classes.
......@@ -518,48 +514,12 @@ def v8_value_to_local_cpp_variadic_value(argument, index):
}
def v8_value_to_local_cpp_ssv_value(extended_attributes, idl_type, v8_value,
variable_name, for_storage):
this_cpp_type = idl_type.cpp_type_args(
extended_attributes=extended_attributes, raw_type=True)
storage_policy = 'kForStorage' if for_storage else 'kNotForStorage'
arguments = ', '.join([
'info.GetIsolate()', v8_value,
'{ssv}::SerializeOptions({ssv}::{storage_policy})', 'exception_state'
])
cpp_expression_format = 'NativeValueTraits<{ssv}>::NativeValue(%s)' % arguments
this_cpp_value = cpp_expression_format.format(
ssv='SerializedScriptValue', storage_policy=storage_policy)
return {
'assign_expression': this_cpp_value,
'check_expression': 'exception_state.HadException()',
'cpp_type': this_cpp_type,
'cpp_name': variable_name,
'declare_variable': False,
}
def v8_value_to_local_cpp_value(interface_name, method, argument, index):
extended_attributes = argument.extended_attributes
idl_type = argument.idl_type
name = NameStyleConverter(argument.name).to_snake_case()
v8_value = 'info[{index}]'.format(index=index)
# History.pushState and History.replaceState are explicitly specified as
# serializing the value for storage. The default is to not serialize for
# storage. See https://html.spec.whatwg.org/C/#dom-history-pushstate
if idl_type.name == 'SerializedScriptValue':
for_storage = (interface_name == 'History'
and method.name in ('pushState', 'replaceState'))
return v8_value_to_local_cpp_ssv_value(
extended_attributes,
idl_type,
v8_value,
name,
for_storage=for_storage)
if argument.is_variadic:
return v8_value_to_local_cpp_variadic_value(argument, index)
return idl_type.v8_value_to_local_cpp_value(
......
......@@ -57,10 +57,8 @@ from v8_utilities import binding_header_filename, extended_attribute_value_conta
################################################################################
NON_WRAPPER_TYPES = frozenset([
'Dictionary',
'EventHandler',
'NodeFilter',
'SerializedScriptValue',
])
TYPED_ARRAY_TYPES = frozenset([
'Float32Array',
......@@ -126,7 +124,6 @@ CPP_INTEGER_CONVERSION_RULES = {
'unsigned long long': 'uint64_t',
}
CPP_SPECIAL_CONVERSION_RULES = {
'Dictionary': 'Dictionary',
'EventHandler': 'EventListener*',
'Promise': 'ScriptPromise',
'ScriptValue': 'ScriptValue',
......@@ -247,8 +244,6 @@ def cpp_type(idl_type,
if base_idl_type in CPP_SPECIAL_CONVERSION_RULES:
return CPP_SPECIAL_CONVERSION_RULES[base_idl_type]
if base_idl_type == 'SerializedScriptValue':
return 'scoped_refptr<%s>' % base_idl_type
if idl_type.is_string_type:
if idl_type.has_string_context:
return 'String'
......@@ -425,8 +420,6 @@ INCLUDES_FOR_TYPE = {
'core/typed_arrays/array_buffer_view_helpers.h',
'core/typed_arrays/flexible_array_buffer_view.h'
]),
'Dictionary':
set(['bindings/core/v8/dictionary.h']),
'EventHandler':
set(['bindings/core/v8/js_event_handler.h']),
'HTMLCollection':
......@@ -447,11 +440,6 @@ INCLUDES_FOR_TYPE = {
set(['bindings/core/v8/script_promise.h']),
'ScriptValue':
set(['bindings/core/v8/script_value.h']),
'SerializedScriptValue':
set([
'bindings/core/v8/serialization/serialized_script_value.h',
'bindings/core/v8/serialization/serialized_script_value_factory.h'
]),
}
......@@ -644,8 +632,7 @@ def v8_conversion_needs_exception_state(idl_type):
or idl_type.is_dictionary
or idl_type.is_array_buffer_view_or_typed_array
or idl_type.has_string_context or
idl_type.name in ('Boolean', 'ByteString', 'Dictionary', 'Object',
'USVString', 'SerializedScriptValue'))
idl_type.name in ('Boolean', 'ByteString', 'Object', 'USVString'))
IdlType.v8_conversion_needs_exception_state = property(
......@@ -656,9 +643,8 @@ IdlArrayOrSequenceType.v8_conversion_needs_exception_state = True
IdlRecordType.v8_conversion_needs_exception_state = True
IdlUnionType.v8_conversion_needs_exception_state = True
TRIVIAL_CONVERSIONS = frozenset([
'any', 'boolean', 'Dictionary', 'NodeFilter', 'XPathNSResolver', 'Promise'
])
TRIVIAL_CONVERSIONS = frozenset(
['any', 'boolean', 'NodeFilter', 'XPathNSResolver', 'Promise'])
def v8_conversion_is_trivial(idl_type):
......@@ -736,12 +722,6 @@ def v8_value_to_cpp_value(idl_type, extended_attributes, v8_value,
if idl_type.is_integer_type:
arguments = ', '.join([v8_value, 'exception_state'])
elif base_idl_type == 'SerializedScriptValue':
arguments = ', '.join([
v8_value,
'SerializedScriptValue::SerializeOptions(SerializedScriptValue::kNotForStorage)',
'exception_state'
])
elif idl_type.v8_conversion_needs_exception_state:
arguments = ', '.join([v8_value, 'exception_state'])
else:
......@@ -983,9 +963,6 @@ def v8_conversion_type(idl_type, extended_attributes):
return base_idl_type
if base_idl_type in ['object', 'ScriptValue']:
return 'ScriptValue'
# Generic dictionary type
if base_idl_type == 'Dictionary':
return 'Dictionary'
# Data type with potential additional includes
if base_idl_type in V8_SET_RETURN_VALUE: # Special V8SetReturnValue treatment
......@@ -1046,8 +1023,6 @@ V8_SET_RETURN_VALUE = {
'V8SetReturnValue(info, {cpp_value})',
'ScriptValue':
'V8SetReturnValue(info, {cpp_value})',
'SerializedScriptValue':
'V8SetReturnValue(info, {cpp_value})',
# Records.
'Record':
'V8SetReturnValue(info, ToV8({cpp_value}, info.Holder(), info.GetIsolate()))',
......@@ -1079,11 +1054,6 @@ V8_SET_RETURN_VALUE = {
# creation context of the DOM wrapper for the return value.
'DOMWrapperStatic':
'V8SetReturnValue(info, {cpp_value}, info.GetIsolate()->GetCurrentContext()->Global())',
# Generic dictionary type
'Dictionary':
'V8SetReturnValue(info, {cpp_value})',
'DictionaryStatic':
'#error not implemented yet',
# Nullable dictionaries
'NullableDictionary':
'V8SetReturnValue(info, result)',
......@@ -1125,15 +1095,13 @@ def v8_set_return_value(idl_type,
this_v8_conversion_type = idl_type.v8_conversion_type(extended_attributes)
# SetReturn-specific overrides
if this_v8_conversion_type in ('EventHandler', 'NodeFilter', 'ScriptValue',
'SerializedScriptValue', 'sequence',
'FrozenArray'):
'sequence', 'FrozenArray'):
# Convert value to V8 and then use general V8SetReturnValue
cpp_value = idl_type.cpp_value_to_v8_value(
cpp_value, extended_attributes=extended_attributes)
if this_v8_conversion_type == 'DOMWrapper':
this_v8_conversion_type = dom_wrapper_conversion_type()
if is_static and this_v8_conversion_type in ('Dictionary',
'NullableDictionary',
if is_static and this_v8_conversion_type in ('NullableDictionary',
'DictionaryOrUnion'):
this_v8_conversion_type += 'Static'
......@@ -1182,8 +1150,6 @@ CPP_VALUE_TO_V8_VALUE = {
('({cpp_value}.IsNull() ? ' + 'v8::Null({isolate}).As<v8::Value>() : ' +
'V8String({isolate}, {cpp_value}).As<v8::Value>())'),
# Special cases
'Dictionary':
'{cpp_value}.V8Value()',
'EventHandler':
'JSEventHandler::AsV8Value({isolate}, impl, {cpp_value})',
'NodeFilter':
......@@ -1192,8 +1158,6 @@ CPP_VALUE_TO_V8_VALUE = {
'ToV8({cpp_value}, {creation_context}, {isolate})',
'ScriptValue':
'{cpp_value}.V8Value()',
'SerializedScriptValue':
'V8Deserialize({isolate}, {cpp_value}.get())',
# General
'sequence':
'ToV8({cpp_value}, {creation_context}, {isolate})',
......
......@@ -8,8 +8,6 @@
// and the *.idl files get updated to be spec conformant, almost all (if not
// really all) the followings will be gone.
dictionary Dictionary {};
typedef EventHandlerNonNull? EventHandler;
typedef DOMMatrix DOMMatrixConstructor;
......
......@@ -101,11 +101,6 @@ void {{v8_class}}::ToImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8_value, {
{{declare_enum_validation_variable(member.enum_values) | trim | indent}}
if (!IsValidEnum({{member.cpp_value}}, kValidValues, base::size(kValidValues), "{{member.enum_type}}", exception_state))
return;
{% elif member.is_deprecated_dictionary %}
if (!{{member.cpp_value}}.IsObject()) {
exception_state.ThrowTypeError("member {{member.name}} is not an object.");
return;
}
{% endif %}
impl->{{member.setter_name}}({{member.cpp_value}});
}
......
......@@ -37,7 +37,6 @@ dictionary TestDictionary {
Uint8Array uint8ArrayMember;
EventTarget eventTargetMember;
any anyMember = null;
Dictionary dictionaryMember;
[RuntimeEnabled=RuntimeFeature] boolean runtimeMember;
[RuntimeEnabled=RuntimeFeature] boolean runtimeSecondMember;
[RuntimeEnabled=FeatureName] boolean originTrialMember;
......
......@@ -37,12 +37,9 @@ interface TestInterfaceConstructor {
double doubleArg,
DOMString stringArg,
TestInterfaceEmpty testInterfaceEmptyArg,
Dictionary dictionaryArg,
sequence<DOMString> sequenceStringArg,
sequence<Dictionary> sequenceDictionaryArg,
sequence<(long or TestDictionary)> sequenceLongOrTestDictionaryArg,
optional USVString? optionalUSVStringArg,
optional Dictionary optionalDictionaryArg,
[DefaultValue=Undefined] optional TestInterfaceEmpty optionalTestInterfaceEmptyArg);
[CallWith=(ScriptState,ExecutionContext,Document), RaisesException, MeasureAs=TestFeature]
constructor(DOMString arg, optional DOMString optArg);
......
......@@ -37,15 +37,14 @@
// TestInterfaceConstructor.idl), otherwise overload resolution check string is
// extremely long and triggers a lint warning (line length).
interface TestInterfaceConstructor2 {
// 2 constructors with same type length, to test overload resolution
// 3 constructors with same type length, to test overload resolution
constructor(DOMString stringArg);
constructor(Dictionary dictionaryArg);
constructor(object objectArg);
constructor(sequence<sequence<DOMString>> stringSequenceSequenceArg);
constructor(
TestInterfaceEmpty testInterfaceEmptyArg,
long longArg,
[DefaultValue=Undefined] optional DOMString defaultUndefinedOptionalStringArg,
optional DOMString defaultNullStringOptionalStringArg = null,
[DefaultValue=Undefined] optional Dictionary defaultUndefinedOptionalDictionaryArg,
optional DOMString optionalStringArg);
};
......@@ -80,7 +80,6 @@ interface TestObject {
attribute long xmlAttribute;
// Non-wrapper types
readonly attribute NodeFilter nodeFilterAttribute;
attribute SerializedScriptValue serializedScriptValueAttribute;
attribute any anyAttribute;
// Custom type conversions
attribute Promise<any> promiseAttribute;
......@@ -331,23 +330,17 @@ interface TestObject {
void voidMethodTestEnumArg(TestEnum testEnumTypeArg);
void voidMethodTestMultipleEnumArg(TestEnum testEnumTypeArg, TestEnum2 testEnumTypeArg2);
// Exceptional types
Dictionary dictionaryMethod();
TestDictionary testDictionaryMethod();
TestDictionary? nullableTestDictionaryMethod();
static TestDictionary staticTestDictionaryMethod();
static TestDictionary? staticNullableTestDictionaryMethod();
void passPermissiveDictionaryMethod([PermissiveDictionaryConversion] optional TestDictionary arg);
NodeFilter nodeFilterMethod();
Promise<void> promiseMethod(long arg1, Dictionary arg2, DOMString arg3, DOMString... variadic);
Promise<any> promiseMethodWithoutExceptionState(Dictionary arg1);
SerializedScriptValue serializedScriptValueMethod();
Promise<void> promiseMethod(long arg1, DOMString arg2, DOMString... variadic);
XPathNSResolver xPathNSResolverMethod();
void voidMethodDictionaryArg(Dictionary dictionaryArg);
void voidMethodNodeFilterArg(NodeFilter nodeFilterArg);
void voidMethodPromiseArg(Promise<any> promiseArg);
void voidMethodSerializedScriptValueArg(SerializedScriptValue serializedScriptValueArg);
void voidMethodXPathNSResolverArg(XPathNSResolver xPathNSResolverArg);
void voidMethodDictionarySequenceArg(sequence<Dictionary> dictionarySequenceArg);
// Arguments
void voidMethodStringArgLongArg(DOMString stringArg, long longArg);
......@@ -363,8 +356,6 @@ interface TestObject {
void voidMethodLongArgOptionalLongArgOptionalLongArg(long longArg, optional long optionalLongArg1, optional long optionalLongArg2);
void voidMethodLongArgOptionalTestInterfaceEmptyArg(long longArg, optional TestInterfaceEmpty optionalTestInterfaceEmpty);
void voidMethodTestInterfaceEmptyArgOptionalLongArg(TestInterfaceEmpty optionalTestInterfaceEmpty, optional long longArg);
// Optional arguments: exceptional case
void voidMethodOptionalDictionaryArg(optional Dictionary optionalDictionaryArg);
// Optional arguments with defaults
void voidMethodDefaultByteStringArg(optional ByteString defaultByteStringArg = "foo");
......
......@@ -49,10 +49,6 @@ void TestDictionary::setCallbackFunctionMember(V8VoidCallbackFunction* value) {
callback_function_member_ = value;
}
void TestDictionary::setDictionaryMember(Dictionary value) {
dictionary_member_ = value;
}
void TestDictionary::setDoubleOrNullOrDoubleOrNullSequenceMember(const DoubleOrDoubleOrNullSequence& value) {
double_or_null_or_double_or_null_sequence_member_ = value;
}
......
......@@ -11,7 +11,6 @@
#ifndef THIRD_PARTY_BLINK_RENDERER_BINDINGS_TESTS_RESULTS_CORE_TEST_DICTIONARY_H_
#define THIRD_PARTY_BLINK_RENDERER_BINDINGS_TESTS_RESULTS_CORE_TEST_DICTIONARY_H_
#include "third_party/blink/renderer/bindings/core/v8/dictionary.h"
#include "third_party/blink/renderer/bindings/core/v8/double_or_double_or_null_sequence.h"
#include "third_party/blink/renderer/bindings/core/v8/double_or_double_sequence.h"
#include "third_party/blink/renderer/bindings/core/v8/double_or_string.h"
......@@ -94,12 +93,6 @@ class CORE_EXPORT TestDictionary : public IDLDictionaryBase {
}
inline void setCreateMember(bool);
bool hasDictionaryMember() const { return !dictionary_member_.IsUndefinedOrNull(); }
Dictionary dictionaryMember() const {
return dictionary_member_;
}
void setDictionaryMember(Dictionary);
bool hasDomStringTreatNullAsEmptyStringMember() const { return !dom_string_treat_null_as_empty_string_member_.IsNull(); }
const String& domStringTreatNullAsEmptyStringMember() const {
return dom_string_treat_null_as_empty_string_member_;
......@@ -507,7 +500,6 @@ class CORE_EXPORT TestDictionary : public IDLDictionaryBase {
bool boolean_member_;
Member<V8VoidCallbackFunction> callback_function_member_;
bool create_member_;
Dictionary dictionary_member_;
String dom_string_treat_null_as_empty_string_member_;
double double_or_null_member_;
DoubleOrDoubleOrNullSequence double_or_null_or_double_or_null_sequence_member_;
......
......@@ -13,7 +13,6 @@
#include <algorithm>
#include "base/memory/scoped_refptr.h"
#include "third_party/blink/renderer/bindings/core/v8/dictionary.h"
#include "third_party/blink/renderer/bindings/core/v8/idl_types.h"
#include "third_party/blink/renderer/bindings/core/v8/native_value_traits_impl.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_dom_configuration.h"
......@@ -102,12 +101,9 @@ static void Constructor2(const v8::FunctionCallbackInfo<v8::Value>& info) {
double double_arg;
V8StringResource<> string_arg;
TestInterfaceEmpty* test_interface_empty_arg;
Dictionary dictionary_arg;
Vector<String> sequence_string_arg;
Vector<Dictionary> sequence_dictionary_arg;
HeapVector<LongOrTestDictionary> sequence_long_or_test_dictionary_arg;
V8StringResource<kTreatNullAndUndefinedAsNullString> optional_usv_string_arg;
Dictionary optional_dictionary_arg;
TestInterfaceEmpty* optional_test_interface_empty_arg;
int num_args_passed = info.Length();
while (num_args_passed > 0) {
......@@ -129,32 +125,20 @@ static void Constructor2(const v8::FunctionCallbackInfo<v8::Value>& info) {
return;
}
if (!info[3]->IsNullOrUndefined() && !info[3]->IsObject()) {
exception_state.ThrowTypeError("parameter 4 ('dictionaryArg') is not an object.");
return;
}
dictionary_arg = NativeValueTraits<Dictionary>::NativeValue(info.GetIsolate(), info[3], exception_state);
if (exception_state.HadException())
return;
sequence_string_arg = NativeValueTraits<IDLSequence<IDLString>>::NativeValue(info.GetIsolate(), info[4], exception_state);
sequence_string_arg = NativeValueTraits<IDLSequence<IDLString>>::NativeValue(info.GetIsolate(), info[3], exception_state);
if (exception_state.HadException())
return;
sequence_dictionary_arg = NativeValueTraits<IDLSequence<Dictionary>>::NativeValue(info.GetIsolate(), info[5], exception_state);
sequence_long_or_test_dictionary_arg = NativeValueTraits<IDLSequence<LongOrTestDictionary>>::NativeValue(info.GetIsolate(), info[4], exception_state);
if (exception_state.HadException())
return;
sequence_long_or_test_dictionary_arg = NativeValueTraits<IDLSequence<LongOrTestDictionary>>::NativeValue(info.GetIsolate(), info[6], exception_state);
if (exception_state.HadException())
return;
if (UNLIKELY(num_args_passed <= 7)) {
if (UNLIKELY(num_args_passed <= 5)) {
ExecutionContext* execution_context = ToExecutionContext(
info.NewTarget().As<v8::Object>()->CreationContext());
Document& document = *Document::From(ToExecutionContext(
info.NewTarget().As<v8::Object>()->CreationContext()));
TestInterfaceConstructor* impl = TestInterfaceConstructor::Create(script_state, execution_context, document, double_arg, string_arg, test_interface_empty_arg, dictionary_arg, sequence_string_arg, sequence_dictionary_arg, sequence_long_or_test_dictionary_arg, exception_state);
TestInterfaceConstructor* impl = TestInterfaceConstructor::Create(script_state, execution_context, document, double_arg, string_arg, test_interface_empty_arg, sequence_string_arg, sequence_long_or_test_dictionary_arg, exception_state);
if (exception_state.HadException()) {
return;
}
......@@ -163,21 +147,13 @@ static void Constructor2(const v8::FunctionCallbackInfo<v8::Value>& info) {
V8SetReturnValue(info, wrapper);
return;
}
optional_usv_string_arg = NativeValueTraits<IDLUSVStringOrNull>::NativeValue(info.GetIsolate(), info[7], exception_state);
if (exception_state.HadException())
return;
if (!info[8]->IsNullOrUndefined() && !info[8]->IsObject()) {
exception_state.ThrowTypeError("parameter 9 ('optionalDictionaryArg') is not an object.");
return;
}
optional_dictionary_arg = NativeValueTraits<Dictionary>::NativeValue(info.GetIsolate(), info[8], exception_state);
optional_usv_string_arg = NativeValueTraits<IDLUSVStringOrNull>::NativeValue(info.GetIsolate(), info[5], exception_state);
if (exception_state.HadException())
return;
optional_test_interface_empty_arg = V8TestInterfaceEmpty::ToImplWithTypeCheck(info.GetIsolate(), info[9]);
optional_test_interface_empty_arg = V8TestInterfaceEmpty::ToImplWithTypeCheck(info.GetIsolate(), info[6]);
if (!optional_test_interface_empty_arg) {
exception_state.ThrowTypeError(ExceptionMessages::ArgumentNotOfType(9, "TestInterfaceEmpty"));
exception_state.ThrowTypeError(ExceptionMessages::ArgumentNotOfType(6, "TestInterfaceEmpty"));
return;
}
......@@ -185,7 +161,7 @@ static void Constructor2(const v8::FunctionCallbackInfo<v8::Value>& info) {
info.NewTarget().As<v8::Object>()->CreationContext());
Document& document = *Document::From(ToExecutionContext(
info.NewTarget().As<v8::Object>()->CreationContext()));
TestInterfaceConstructor* impl = TestInterfaceConstructor::Create(script_state, execution_context, document, double_arg, string_arg, test_interface_empty_arg, dictionary_arg, sequence_string_arg, sequence_dictionary_arg, sequence_long_or_test_dictionary_arg, optional_usv_string_arg, optional_dictionary_arg, optional_test_interface_empty_arg, exception_state);
TestInterfaceConstructor* impl = TestInterfaceConstructor::Create(script_state, execution_context, document, double_arg, string_arg, test_interface_empty_arg, sequence_string_arg, sequence_long_or_test_dictionary_arg, optional_usv_string_arg, optional_test_interface_empty_arg, exception_state);
if (exception_state.HadException()) {
return;
}
......@@ -281,7 +257,7 @@ static void Constructor4(const v8::FunctionCallbackInfo<v8::Value>& info) {
static void Constructor(const v8::FunctionCallbackInfo<v8::Value>& info) {
ExceptionState exception_state(info.GetIsolate(), ExceptionState::kConstructionContext, "TestInterfaceConstructor");
switch (std::min(10, info.Length())) {
switch (std::min(7, info.Length())) {
case 0:
if (true) {
test_interface_constructor_v8_internal::Constructor1(info);
......@@ -306,25 +282,19 @@ static void Constructor(const v8::FunctionCallbackInfo<v8::Value>& info) {
return;
}
break;
case 7:
if (true) {
test_interface_constructor_v8_internal::Constructor2(info);
return;
}
break;
case 8:
case 5:
if (true) {
test_interface_constructor_v8_internal::Constructor2(info);
return;
}
break;
case 9:
case 6:
if (true) {
test_interface_constructor_v8_internal::Constructor2(info);
return;
}
break;
case 10:
case 7:
if (true) {
test_interface_constructor_v8_internal::Constructor2(info);
return;
......@@ -332,7 +302,7 @@ static void Constructor(const v8::FunctionCallbackInfo<v8::Value>& info) {
break;
default:
if (info.Length() >= 0) {
exception_state.ThrowTypeError(ExceptionMessages::InvalidArity("[0, 1, 2, 3, 7, 8, 9, 10]", info.Length()));
exception_state.ThrowTypeError(ExceptionMessages::InvalidArity("[0, 1, 2, 3, 5, 6, 7]", info.Length()));
return;
}
exception_state.ThrowTypeError(ExceptionMessages::NotEnoughArguments(0, info.Length()));
......
......@@ -13,9 +13,9 @@
#include <algorithm>
#include "base/memory/scoped_refptr.h"
#include "third_party/blink/renderer/bindings/core/v8/dictionary.h"
#include "third_party/blink/renderer/bindings/core/v8/idl_types.h"
#include "third_party/blink/renderer/bindings/core/v8/native_value_traits_impl.h"
#include "third_party/blink/renderer/bindings/core/v8/script_value.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_dom_configuration.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_test_interface_empty.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
......@@ -87,16 +87,12 @@ static void Constructor2(const v8::FunctionCallbackInfo<v8::Value>& info) {
ExceptionState exception_state(info.GetIsolate(), ExceptionState::kConstructionContext, "TestInterfaceConstructor2");
Dictionary dictionary_arg;
if (!info[0]->IsNullOrUndefined() && !info[0]->IsObject()) {
exception_state.ThrowTypeError("parameter 1 ('dictionaryArg') is not an object.");
return;
}
dictionary_arg = NativeValueTraits<Dictionary>::NativeValue(info.GetIsolate(), info[0], exception_state);
ScriptValue object_arg;
object_arg = NativeValueTraits<IDLObject>::NativeValue(info.GetIsolate(), info[0], exception_state);
if (exception_state.HadException())
return;
TestInterfaceConstructor2* impl = TestInterfaceConstructor2::Create(dictionary_arg);
TestInterfaceConstructor2* impl = TestInterfaceConstructor2::Create(object_arg);
v8::Local<v8::Object> wrapper = info.Holder();
wrapper = impl->AssociateWithWrapper(info.GetIsolate(), V8TestInterfaceConstructor2::GetWrapperTypeInfo(), wrapper);
V8SetReturnValue(info, wrapper);
......@@ -127,7 +123,6 @@ static void Constructor4(const v8::FunctionCallbackInfo<v8::Value>& info) {
int32_t long_arg;
V8StringResource<> default_undefined_optional_string_arg;
V8StringResource<> default_null_string_optional_string_arg;
Dictionary default_undefined_optional_dictionary_arg;
V8StringResource<> optional_string_arg;
int num_args_passed = info.Length();
while (num_args_passed > 0) {
......@@ -156,26 +151,18 @@ static void Constructor4(const v8::FunctionCallbackInfo<v8::Value>& info) {
} else {
default_null_string_optional_string_arg = nullptr;
}
if (!info[4]->IsNullOrUndefined() && !info[4]->IsObject()) {
exception_state.ThrowTypeError("parameter 5 ('defaultUndefinedOptionalDictionaryArg') is not an object.");
return;
}
default_undefined_optional_dictionary_arg = NativeValueTraits<Dictionary>::NativeValue(info.GetIsolate(), info[4], exception_state);
if (exception_state.HadException())
return;
if (UNLIKELY(num_args_passed <= 5)) {
TestInterfaceConstructor2* impl = TestInterfaceConstructor2::Create(test_interface_empty_arg, long_arg, default_undefined_optional_string_arg, default_null_string_optional_string_arg, default_undefined_optional_dictionary_arg);
if (UNLIKELY(num_args_passed <= 4)) {
TestInterfaceConstructor2* impl = TestInterfaceConstructor2::Create(test_interface_empty_arg, long_arg, default_undefined_optional_string_arg, default_null_string_optional_string_arg);
v8::Local<v8::Object> wrapper = info.Holder();
wrapper = impl->AssociateWithWrapper(info.GetIsolate(), V8TestInterfaceConstructor2::GetWrapperTypeInfo(), wrapper);
V8SetReturnValue(info, wrapper);
return;
}
optional_string_arg = info[5];
optional_string_arg = info[4];
if (!optional_string_arg.Prepare())
return;
TestInterfaceConstructor2* impl = TestInterfaceConstructor2::Create(test_interface_empty_arg, long_arg, default_undefined_optional_string_arg, default_null_string_optional_string_arg, default_undefined_optional_dictionary_arg, optional_string_arg);
TestInterfaceConstructor2* impl = TestInterfaceConstructor2::Create(test_interface_empty_arg, long_arg, default_undefined_optional_string_arg, default_null_string_optional_string_arg, optional_string_arg);
v8::Local<v8::Object> wrapper = info.Holder();
wrapper = impl->AssociateWithWrapper(info.GetIsolate(), V8TestInterfaceConstructor2::GetWrapperTypeInfo(), wrapper);
V8SetReturnValue(info, wrapper);
......@@ -183,7 +170,7 @@ static void Constructor4(const v8::FunctionCallbackInfo<v8::Value>& info) {
static void Constructor(const v8::FunctionCallbackInfo<v8::Value>& info) {
ExceptionState exception_state(info.GetIsolate(), ExceptionState::kConstructionContext, "TestInterfaceConstructor2");
switch (std::min(6, info.Length())) {
switch (std::min(5, info.Length())) {
case 1:
if (info[0]->IsArray()) {
test_interface_constructor_2_v8_internal::Constructor3(info);
......@@ -197,10 +184,6 @@ static void Constructor(const v8::FunctionCallbackInfo<v8::Value>& info) {
exception_state.RethrowV8Exception(exception_state.GetException());
return;
}
if (info[0]->IsObject()) {
test_interface_constructor_2_v8_internal::Constructor2(info);
return;
}
if (true) {
test_interface_constructor_2_v8_internal::Constructor1(info);
return;
......@@ -230,12 +213,6 @@ static void Constructor(const v8::FunctionCallbackInfo<v8::Value>& info) {
return;
}
break;
case 6:
if (true) {
test_interface_constructor_2_v8_internal::Constructor4(info);
return;
}
break;
default:
exception_state.ThrowTypeError(ExceptionMessages::NotEnoughArguments(1, info.Length()));
return;
......
......@@ -135,8 +135,6 @@ class V8TestObject {
CORE_EXPORT static void XmlAttributeAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>&);
CORE_EXPORT static void XmlAttributeAttributeSetterCallback(const v8::FunctionCallbackInfo<v8::Value>&);
CORE_EXPORT static void NodeFilterAttributeAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>&);
CORE_EXPORT static void SerializedScriptValueAttributeAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>&);
CORE_EXPORT static void SerializedScriptValueAttributeAttributeSetterCallback(const v8::FunctionCallbackInfo<v8::Value>&);
CORE_EXPORT static void AnyAttributeAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>&);
CORE_EXPORT static void AnyAttributeAttributeSetterCallback(const v8::FunctionCallbackInfo<v8::Value>&);
CORE_EXPORT static void PromiseAttributeAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>&);
......@@ -460,7 +458,6 @@ class V8TestObject {
CORE_EXPORT static void TestEnumMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>&);
CORE_EXPORT static void VoidMethodTestEnumArgMethodCallback(const v8::FunctionCallbackInfo<v8::Value>&);
CORE_EXPORT static void VoidMethodTestMultipleEnumArgMethodCallback(const v8::FunctionCallbackInfo<v8::Value>&);
CORE_EXPORT static void DictionaryMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>&);
CORE_EXPORT static void TestDictionaryMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>&);
CORE_EXPORT static void NullableTestDictionaryMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>&);
CORE_EXPORT static void StaticTestDictionaryMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>&);
......@@ -468,15 +465,10 @@ class V8TestObject {
CORE_EXPORT static void PassPermissiveDictionaryMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>&);
CORE_EXPORT static void NodeFilterMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>&);
CORE_EXPORT static void PromiseMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>&);
CORE_EXPORT static void PromiseMethodWithoutExceptionStateMethodCallback(const v8::FunctionCallbackInfo<v8::Value>&);
CORE_EXPORT static void SerializedScriptValueMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>&);
CORE_EXPORT static void XPathNSResolverMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>&);
CORE_EXPORT static void VoidMethodDictionaryArgMethodCallback(const v8::FunctionCallbackInfo<v8::Value>&);
CORE_EXPORT static void VoidMethodNodeFilterArgMethodCallback(const v8::FunctionCallbackInfo<v8::Value>&);
CORE_EXPORT static void VoidMethodPromiseArgMethodCallback(const v8::FunctionCallbackInfo<v8::Value>&);
CORE_EXPORT static void VoidMethodSerializedScriptValueArgMethodCallback(const v8::FunctionCallbackInfo<v8::Value>&);
CORE_EXPORT static void VoidMethodXPathNSResolverArgMethodCallback(const v8::FunctionCallbackInfo<v8::Value>&);
CORE_EXPORT static void VoidMethodDictionarySequenceArgMethodCallback(const v8::FunctionCallbackInfo<v8::Value>&);
CORE_EXPORT static void VoidMethodStringArgLongArgMethodCallback(const v8::FunctionCallbackInfo<v8::Value>&);
CORE_EXPORT static void VoidMethodByteStringOrNullOptionalUSVStringArgMethodCallback(const v8::FunctionCallbackInfo<v8::Value>&);
CORE_EXPORT static void VoidMethodOptionalStringArgMethodCallback(const v8::FunctionCallbackInfo<v8::Value>&);
......@@ -489,7 +481,6 @@ class V8TestObject {
CORE_EXPORT static void VoidMethodLongArgOptionalLongArgOptionalLongArgMethodCallback(const v8::FunctionCallbackInfo<v8::Value>&);
CORE_EXPORT static void VoidMethodLongArgOptionalTestInterfaceEmptyArgMethodCallback(const v8::FunctionCallbackInfo<v8::Value>&);
CORE_EXPORT static void VoidMethodTestInterfaceEmptyArgOptionalLongArgMethodCallback(const v8::FunctionCallbackInfo<v8::Value>&);
CORE_EXPORT static void VoidMethodOptionalDictionaryArgMethodCallback(const v8::FunctionCallbackInfo<v8::Value>&);
CORE_EXPORT static void VoidMethodDefaultByteStringArgMethodCallback(const v8::FunctionCallbackInfo<v8::Value>&);
CORE_EXPORT static void VoidMethodDefaultStringArgMethodCallback(const v8::FunctionCallbackInfo<v8::Value>&);
CORE_EXPORT static void VoidMethodDefaultIntegerArgsMethodCallback(const v8::FunctionCallbackInfo<v8::Value>&);
......
......@@ -75,12 +75,6 @@ void DictionaryTest::set(const InternalDictionary* testing_dictionary) {
testing_dictionary->doubleOrStringSequenceMember();
}
event_target_or_null_member_ = testing_dictionary->eventTargetOrNullMember();
if (testing_dictionary->hasDictionaryMember()) {
NonThrowableExceptionState exception_state;
dictionary_member_properties_ =
testing_dictionary->dictionaryMember().GetOwnPropertiesAsStringHashMap(
exception_state);
}
if (testing_dictionary->hasInternalEnumOrInternalEnumSequenceMember()) {
internal_enum_or_internal_enum_sequence_ =
testing_dictionary->internalEnumOrInternalEnumSequenceMember();
......@@ -95,18 +89,6 @@ InternalDictionary* DictionaryTest::get() {
return result;
}
ScriptValue DictionaryTest::getDictionaryMemberProperties(
ScriptState* script_state) {
if (!dictionary_member_properties_)
return ScriptValue();
V8ObjectBuilder builder(script_state);
HashMap<String, String> properties = dictionary_member_properties_.value();
for (HashMap<String, String>::iterator it = properties.begin();
it != properties.end(); ++it)
builder.AddString(it->key, it->value);
return builder.GetScriptValue();
}
void DictionaryTest::setDerived(const InternalDictionaryDerived* derived) {
DCHECK(derived->hasRequiredBooleanMember());
set(derived);
......
......@@ -21,7 +21,6 @@ namespace blink {
class InternalDictionary;
class InternalDictionaryDerived;
class InternalDictionaryDerivedDerived;
class ScriptState;
class DictionaryTest : public ScriptWrappable {
DEFINE_WRAPPERTYPEINFO();
......@@ -34,9 +33,6 @@ class DictionaryTest : public ScriptWrappable {
void set(const InternalDictionary*);
// Sets each member of the given TestDictionary from fields
InternalDictionary* get();
// Returns properties of the latest |dictionaryMember| which was set via
// set().
ScriptValue getDictionaryMemberProperties(ScriptState*);
void setDerived(const InternalDictionaryDerived*);
InternalDictionaryDerived* getDerived();
......
......@@ -5,7 +5,6 @@
interface DictionaryTest {
void set(optional InternalDictionary testingDictionary = {});
InternalDictionary get();
[CallWith=ScriptState] object getDictionaryMemberProperties();
void setDerived(InternalDictionaryDerived derived);
InternalDictionaryDerived getDerived();
......
......@@ -31,7 +31,6 @@ dictionary InternalDictionary {
(double or DOMString) doubleOrStringMember;
sequence<(double or DOMString)> doubleOrStringSequenceMember;
EventTarget? eventTargetOrNullMember = null;
Dictionary dictionaryMember;
(InternalEnum or sequence<InternalEnum>) internalEnumOrInternalEnumSequenceMember;
any anyMember;
TestCallback callbackFunctionMember;
......
......@@ -172,15 +172,6 @@ PASS dictionaryTest.set({eventTargetOrNullMember: []}) threw exception TypeError
PASS dictionaryTest.set({eventTargetOrNullMember: {}}) threw exception TypeError: Failed to execute 'set' on 'DictionaryTest': member eventTargetOrNullMember is not of type EventTarget..
Test for passing Dictionary (not IDL dictionary)
PASS properties.foo is "x"
PASS properties.bar is "y"
PASS properties.baz is undefined.
PASS properties is {}
PASS dictionaryTest.set({dictionaryMember: 42}) threw exception TypeError: Failed to execute 'set' on 'DictionaryTest': The dictionary provided is neither undefined, null nor an Object..
PASS dictionaryTest.set({dictionaryMember: 'foo'}) threw exception TypeError: Failed to execute 'set' on 'DictionaryTest': The dictionary provided is neither undefined, null nor an Object..
Test for derived dictionary
PASS derived.longMember is undefined.
PASS derived.longMemberWithDefault is 42
......
......@@ -295,21 +295,6 @@ if (window.internals && internals.dictionaryTest) {
shouldThrow("dictionaryTest.set({eventTargetOrNullMember: {}})");
debug('');
debug('Test for passing Dictionary (not IDL dictionary)');
dictionaryTest.set({
dictionaryMember: {'foo': 'x', 'bar': 'y'}
});
properties = dictionaryTest.getDictionaryMemberProperties();
shouldBeEqualToString('properties.foo', 'x');
shouldBeEqualToString('properties.bar', 'y');
shouldBeUndefined('properties.baz');
dictionaryTest.set({dictionaryMember: undefined});
properties = dictionaryTest.getDictionaryMemberProperties();
shouldBe('properties', '{}');
shouldThrow("dictionaryTest.set({dictionaryMember: 42})");
shouldThrow("dictionaryTest.set({dictionaryMember: 'foo'})");
debug('');
debug('Test for derived dictionary');
dictionaryTest.setDerived({ requiredBooleanMember: true });
derived = dictionaryTest.getDerived();
......
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