Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(345)

Unified Diff: Source/bindings/templates/attributes.cpp

Issue 968593002: bindings: Supports constructor attributes on prototype chains. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/bindings/templates/attributes.cpp
diff --git a/Source/bindings/templates/attributes.cpp b/Source/bindings/templates/attributes.cpp
index 53d7b7dddefca94442ac9cfa90099a588f9d983f..cadea5867cde368e4cf7601fbe4aa3fa03519836 100644
--- a/Source/bindings/templates/attributes.cpp
+++ b/Source/bindings/templates/attributes.cpp
@@ -183,7 +183,12 @@ v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info
{##############################################################################}
{% macro constructor_getter_callback(attribute, world_suffix) %}
{% filter conditional(attribute.conditional_string) %}
-static void {{attribute.name}}ConstructorGetterCallback{{world_suffix}}(v8::Local<v8::String> property, const v8::PropertyCallbackInfo<v8::Value>& info)
+static void {{attribute.name}}ConstructorGetterCallback{{world_suffix}}(
+{%- if attribute.is_expose_js_accessors %}
+const v8::FunctionCallbackInfo<v8::Value>& info
+{%- else %}
+v8::Local<v8::String> property, const v8::PropertyCallbackInfo<v8::Value>& info
+{%- endif %})
{
TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
{% if attribute.deprecate_as %}
@@ -192,7 +197,11 @@ static void {{attribute.name}}ConstructorGetterCallback{{world_suffix}}(v8::Loca
{% if attribute.measure_as %}
UseCounter::countIfNotPrivateScript(info.GetIsolate(), callingExecutionContext(info.GetIsolate()), UseCounter::{{attribute.measure_as}});
{% endif %}
- {{cpp_class_or_partial}}V8Internal::{{cpp_class}}ConstructorGetter{{world_suffix}}(property, info);
+ {% if attribute.is_expose_js_accessors %}
+ v8ConstructorAttributeGetterAsAccessor(info);
+ {% else %}
+ v8ConstructorAttributeGetterAsProperty(property, info);
+ {% endif %}
TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}
{% endfilter %}
@@ -214,21 +223,27 @@ v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info
{% set cpp_class, v8_class = 'Element', 'V8Element' %}
{% endif %}
{# Local variables #}
- {% if not attribute.is_static and not attribute.is_replaceable %}
+ {% if not attribute.is_static and
+ not attribute.is_replaceable and
+ not attribute.constructor_type %}
v8::Local<v8::Object> holder = info.Holder();
{% endif %}
{% if attribute.has_setter_exception_state %}
ExceptionState exceptionState(ExceptionState::SetterContext, "{{attribute.name}}", "{{interface_name}}", holder, info.GetIsolate());
{% endif %}
+ {% if attribute.is_replaceable or
+ attribute.constructor_type %}
+ v8::Local<v8::String> propertyName = v8AtomicString(info.GetIsolate(), "{{attribute.name}}");
+ {% endif %}
{# impl #}
{% if attribute.is_put_forwards %}
{{cpp_class}}* proxyImpl = {{v8_class}}::toImpl(holder);
{{attribute.cpp_type}} impl = WTF::getPtr(proxyImpl->{{attribute.name}}());
if (!impl)
return;
- {% elif attribute.is_replaceable %}
- v8::Local<v8::String> propertyName = v8AtomicString(info.GetIsolate(), "{{attribute.name}}");
- {% elif not attribute.is_static %}
+ {% elif not attribute.is_static and
+ not attribute.is_replaceable and
+ not attribute.constructor_type %}
{{cpp_class}}* impl = {{v8_class}}::toImpl(holder);
{% endif %}
{% if attribute.idl_type == 'EventHandler' and interface_name == 'Window' %}
@@ -392,16 +407,21 @@ bool {{v8_class}}::PrivateScript::{{attribute.name}}AttributeSetter(LocalFrame*
{% set getter_callback =
'%sV8Internal::%sAttributeGetterCallback' %
(cpp_class_or_partial, attribute.name)
- if not attribute.constructor_type else
- ('%sV8Internal::%sConstructorGetterCallback' %
+ if not attribute.constructor_type else (
+ '%sV8Internal::%sConstructorGetterCallback' %
(cpp_class_or_partial, attribute.name)
- if attribute.needs_constructor_getter_callback else
- '%sV8Internal::%sConstructorGetter' % (cpp_class_or_partial, cpp_class)) %}
+ if attribute.needs_constructor_getter_callback else (
+ 'v8ConstructorAttributeGetterAsAccessor'
+ if attribute.is_expose_js_accessors else (
+ 'v8ConstructorAttributeGetterAsProperty'))) %}
{% set getter_callback_for_main_world =
'%sV8Internal::%sAttributeGetterCallbackForMainWorld' %
(cpp_class_or_partial, attribute.name)
if attribute.is_per_world_bindings else '0' %}
-{% set setter_callback = attribute.setter_callback %}
+{% set setter_callback =
+ '%sV8Internal::%sAttributeSetterCallback' %
+ (cpp_class_or_partial, attribute.name)
+ if attribute.has_setter else '0' %}
{% set setter_callback_for_main_world =
'%sV8Internal::%sAttributeSetterCallbackForMainWorld' %
(cpp_class_or_partial, attribute.name)

Powered by Google App Engine
This is Rietveld 408576698