Commit 8b5bcd4b authored by nbarth@chromium.org's avatar nbarth@chromium.org

Use wrapper_configuration consistently in bindings

Currently the bindings overuse WrapperConfiguration::Dependent.
This changes it to use WrapperConfiguration::Independent
unless Dependent is actually needed, by computing it once
in the interface context.
(Fixes one FIXME and removes some hard-coding.)

This is split off as 1/2 bindings-only change from:
Implement ImageData constructors.
https://codereview.chromium.org/196343032/

BUG=345503
TBR=haraken

Review URL: https://codereview.chromium.org/199633014

git-svn-id: svn://svn.chromium.org/blink/trunk@169827 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 66e2097d
......@@ -83,11 +83,17 @@ def generate_interface(interface):
'bindings/v8/V8WindowShell.h',
'core/frame/LocalFrame.h'])
# [ActiveDOMObject]
is_active_dom_object = 'ActiveDOMObject' in extended_attributes
# [CheckSecurity]
is_check_security = 'CheckSecurity' in extended_attributes
if is_check_security:
includes.add('bindings/v8/BindingSecurity.h')
# [DependentLifetime]
is_dependent_lifetime = 'DependentLifetime' in extended_attributes
# [MeasureAs]
is_measure_as = 'MeasureAs' in extended_attributes
if is_measure_as:
......@@ -124,23 +130,25 @@ def generate_interface(interface):
# [WillBeGarbageCollected]
is_will_be_garbage_collected = 'WillBeGarbageCollected' in extended_attributes
# [Custom=Wrap], [SetWrapperReferenceFrom]
has_visit_dom_wrapper = (
has_extended_attribute_value(interface, 'Custom', 'VisitDOMWrapper') or
reachable_node_function or
set_wrapper_reference_to_list)
template_contents = {
'conditional_string': conditional_string(interface), # [Conditional]
'cpp_class': cpp_name(interface),
'has_custom_legacy_call_as_function': has_extended_attribute_value(interface, 'Custom', 'LegacyCallAsFunction'), # [Custom=LegacyCallAsFunction]
'has_custom_to_v8': has_extended_attribute_value(interface, 'Custom', 'ToV8'), # [Custom=ToV8]
'has_custom_wrap': has_extended_attribute_value(interface, 'Custom', 'Wrap'), # [Custom=Wrap]
'has_visit_dom_wrapper': (
# [Custom=Wrap], [SetWrapperReferenceFrom]
has_extended_attribute_value(interface, 'Custom', 'VisitDOMWrapper') or
reachable_node_function or
set_wrapper_reference_to_list),
'has_visit_dom_wrapper': has_visit_dom_wrapper,
'header_includes': header_includes,
'interface_name': interface.name,
'is_active_dom_object': 'ActiveDOMObject' in extended_attributes, # [ActiveDOMObject]
'is_active_dom_object': is_active_dom_object,
'is_audio_buffer': is_audio_buffer,
'is_check_security': is_check_security,
'is_dependent_lifetime': 'DependentLifetime' in extended_attributes, # [DependentLifetime]
'is_dependent_lifetime': is_dependent_lifetime,
'is_document': is_document,
'is_event_target': inherits_interface(interface.name, 'EventTarget'),
'is_exception': interface.is_exception,
......@@ -157,6 +165,11 @@ def generate_interface(interface):
'set_wrapper_reference_to_list': set_wrapper_reference_to_list,
'special_wrap_for': special_wrap_for,
'v8_class': v8_utilities.v8_class_name(interface),
'wrapper_configuration': 'WrapperConfiguration::Dependent'
if (has_visit_dom_wrapper or
is_active_dom_object or
is_dependent_lifetime)
else 'WrapperConfiguration::Independent',
}
# Constructors
......
......@@ -668,7 +668,7 @@ static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info)
{% endif %}
v8::Handle<v8::Object> wrapper = info.Holder();
V8DOMWrapper::associateObjectWithWrapper<{{v8_class}}>(event.release(), &{{v8_class}}::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguration::Dependent);
V8DOMWrapper::associateObjectWithWrapper<{{v8_class}}>(event.release(), &{{v8_class}}::wrapperTypeInfo, wrapper, info.GetIsolate(), {{wrapper_configuration}});
v8SetReturnValue(info, wrapper);
}
......@@ -1293,11 +1293,6 @@ v8::Handle<v8::Object> {{v8_class}}::createWrapper({{pass_ref_ptr}}<{{cpp_class}
}
{% endif %}
installPerContextEnabledProperties(wrapper, impl.get(), isolate);
{% set wrapper_configuration = 'WrapperConfiguration::Dependent'
if (has_visit_dom_wrapper or
is_active_dom_object or
is_dependent_lifetime) else
'WrapperConfiguration::Independent' %}
V8DOMWrapper::associateObjectWithWrapper<{{v8_class}}>(impl, &wrapperTypeInfo, wrapper, isolate, {{wrapper_configuration}});
return wrapper;
}
......
......@@ -368,7 +368,7 @@ static void constructor{{constructor.overload_index}}(const v8::FunctionCallback
ExceptionState exceptionState(ExceptionState::ConstructionContext, "{{interface_name}}", info.Holder(), info.GetIsolate());
{% endif %}
{% if interface_length and not constructor.overload_index %}
{# FIXME: remove this UNLIKELY: constructors are heavy, so no difference. #}
{# FIXME: remove UNLIKELY: constructors are expensive, so no difference. #}
if (UNLIKELY(info.Length() < {{interface_length}})) {
{{throw_type_error(constructor,
'ExceptionMessages::notEnoughArguments(%s, info.Length())' %
......@@ -392,9 +392,7 @@ static void constructor{{constructor.overload_index}}(const v8::FunctionCallback
return;
{% endif %}
{# FIXME: Should probably be Independent unless [ActiveDOMObject]
or [DependentLifetime]. #}
V8DOMWrapper::associateObjectWithWrapper<{{v8_class}}>(impl.release(), &{{v8_class}}::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguration::Dependent);
V8DOMWrapper::associateObjectWithWrapper<{{v8_class}}>(impl.release(), &{{v8_class}}::wrapperTypeInfo, wrapper, info.GetIsolate(), {{wrapper_configuration}});
v8SetReturnValue(info, wrapper);
}
{% endmacro %}
......@@ -442,7 +440,7 @@ static void {{v8_class}}ConstructorCallback(const v8::FunctionCallbackInfo<v8::V
return;
{% endif %}
V8DOMWrapper::associateObjectWithWrapper<{{v8_class}}>(impl.release(), &{{v8_class}}Constructor::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguration::Dependent);
V8DOMWrapper::associateObjectWithWrapper<{{v8_class}}>(impl.release(), &{{v8_class}}Constructor::wrapperTypeInfo, wrapper, info.GetIsolate(), {{wrapper_configuration}});
v8SetReturnValue(info, wrapper);
}
{% endmacro %}
......@@ -86,7 +86,7 @@ static void constructor1(const v8::FunctionCallbackInfo<v8::Value>& info)
if (exceptionState.throwIfNeeded())
return;
V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceConstructor>(impl.release(), &V8TestInterfaceConstructor::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguration::Dependent);
V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceConstructor>(impl.release(), &V8TestInterfaceConstructor::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguration::Independent);
v8SetReturnValue(info, wrapper);
}
......@@ -118,7 +118,7 @@ static void constructor2(const v8::FunctionCallbackInfo<v8::Value>& info)
if (exceptionState.throwIfNeeded())
return;
V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceConstructor>(impl.release(), &V8TestInterfaceConstructor::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguration::Dependent);
V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceConstructor>(impl.release(), &V8TestInterfaceConstructor::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguration::Independent);
v8SetReturnValue(info, wrapper);
}
......
......@@ -81,7 +81,7 @@ static void constructor1(const v8::FunctionCallbackInfo<v8::Value>& info)
RefPtr<TestInterfaceConstructor2> impl = TestInterfaceConstructor2::create(stringArg);
v8::Handle<v8::Object> wrapper = info.Holder();
V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceConstructor2>(impl.release(), &V8TestInterfaceConstructor2::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguration::Dependent);
V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceConstructor2>(impl.release(), &V8TestInterfaceConstructor2::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguration::Independent);
v8SetReturnValue(info, wrapper);
}
......@@ -101,7 +101,7 @@ static void constructor2(const v8::FunctionCallbackInfo<v8::Value>& info)
RefPtr<TestInterfaceConstructor2> impl = TestInterfaceConstructor2::create(testInterfaceEmptyArg, longArg, defaultUndefinedOptionalStringArg, defaultNullStringOptionalStringArg, defaultUndefinedOptionalDictionaryArg);
v8::Handle<v8::Object> wrapper = info.Holder();
V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceConstructor2>(impl.release(), &V8TestInterfaceConstructor2::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguration::Dependent);
V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceConstructor2>(impl.release(), &V8TestInterfaceConstructor2::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguration::Independent);
v8SetReturnValue(info, wrapper);
}
......
......@@ -83,7 +83,7 @@ static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info)
RefPtr<TestInterfaceConstructor3> impl = TestInterfaceConstructor3::create(stringArg);
v8::Handle<v8::Object> wrapper = info.Holder();
V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceConstructor3>(impl.release(), &V8TestInterfaceConstructor3::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguration::Dependent);
V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceConstructor3>(impl.release(), &V8TestInterfaceConstructor3::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguration::Independent);
v8SetReturnValue(info, wrapper);
}
......
......@@ -295,7 +295,7 @@ static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info)
}
v8::Handle<v8::Object> wrapper = info.Holder();
V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceEventConstructor>(event.release(), &V8TestInterfaceEventConstructor::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguration::Dependent);
V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceEventConstructor>(event.release(), &V8TestInterfaceEventConstructor::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguration::Independent);
v8SetReturnValue(info, wrapper);
}
......
......@@ -99,7 +99,7 @@ static void V8TestInterfaceEventTargetConstructorCallback(const v8::FunctionCall
RefPtr<TestInterfaceEventTarget> impl = TestInterfaceEventTarget::createForJSConstructor(*document);
v8::Handle<v8::Object> wrapper = info.Holder();
V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceEventTarget>(impl.release(), &V8TestInterfaceEventTargetConstructor::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguration::Dependent);
V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceEventTarget>(impl.release(), &V8TestInterfaceEventTargetConstructor::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguration::Independent);
v8SetReturnValue(info, wrapper);
}
......
......@@ -104,7 +104,7 @@ static void V8TestInterfaceNamedConstructor2ConstructorCallback(const v8::Functi
RefPtr<TestInterfaceNamedConstructor2> impl = TestInterfaceNamedConstructor2::createForJSConstructor(*document, stringArg);
v8::Handle<v8::Object> wrapper = info.Holder();
V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceNamedConstructor2>(impl.release(), &V8TestInterfaceNamedConstructor2Constructor::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguration::Dependent);
V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceNamedConstructor2>(impl.release(), &V8TestInterfaceNamedConstructor2Constructor::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguration::Independent);
v8SetReturnValue(info, wrapper);
}
......
......@@ -128,7 +128,7 @@ static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info)
RefPtrWillBeRawPtr<TestInterfaceWillBeGarbageCollected> impl = TestInterfaceWillBeGarbageCollected::create(str);
v8::Handle<v8::Object> wrapper = info.Holder();
V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceWillBeGarbageCollected>(impl.release(), &V8TestInterfaceWillBeGarbageCollected::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguration::Dependent);
V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceWillBeGarbageCollected>(impl.release(), &V8TestInterfaceWillBeGarbageCollected::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguration::Independent);
v8SetReturnValue(info, wrapper);
}
......
......@@ -433,7 +433,7 @@ static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info)
RefPtr<TestTypedefs> impl = TestTypedefs::create(hello);
v8::Handle<v8::Object> wrapper = info.Holder();
V8DOMWrapper::associateObjectWithWrapper<V8TestTypedefs>(impl.release(), &V8TestTypedefs::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguration::Dependent);
V8DOMWrapper::associateObjectWithWrapper<V8TestTypedefs>(impl.release(), &V8TestTypedefs::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguration::Independent);
v8SetReturnValue(info, wrapper);
}
......
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