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

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

Issue 1008353002: bindings: Reduces the binary size by reducing # of callback functions. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Addressed a review comment. Created 5 years, 9 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/interface_base.cpp
diff --git a/Source/bindings/templates/interface_base.cpp b/Source/bindings/templates/interface_base.cpp
index be36312858b3e19abaa21ee71c068f0887e38f82..1777a9a5a52b2c5dade51116af42ea085cf8c725 100644
--- a/Source/bindings/templates/interface_base.cpp
+++ b/Source/bindings/templates/interface_base.cpp
@@ -25,7 +25,7 @@ namespace blink {
{% set wrapper_type_info_const = '' if has_partial_interface else 'const ' %}
{% if not is_partial %}
-{{wrapper_type_info_const}}WrapperTypeInfo {{v8_class}}::wrapperTypeInfo = { gin::kEmbedderBlink, {{dom_template}}, {{v8_class}}::refObject, {{v8_class}}::derefObject, {{v8_class}}::trace, {{to_active_dom_object}}, {{visit_dom_wrapper}}, {{v8_class}}::installConditionallyEnabledMethods, {{v8_class}}::installConditionallyEnabledProperties, {{parent_wrapper_type_info}}, WrapperTypeInfo::{{wrapper_type_prototype}}, WrapperTypeInfo::{{wrapper_class_id}}, WrapperTypeInfo::{{event_target_inheritance}}, WrapperTypeInfo::{{lifetime}}, WrapperTypeInfo::{{gc_type}} };
+{{wrapper_type_info_const}}WrapperTypeInfo {{v8_class}}::wrapperTypeInfo = { gin::kEmbedderBlink, {{dom_template}}, {{v8_class}}::refObject, {{v8_class}}::derefObject, {{v8_class}}::trace, {{to_active_dom_object}}, {{visit_dom_wrapper}}, {{v8_class}}::installConditionallyEnabledMethods, {{v8_class}}::installConditionallyEnabledProperties, "{{interface_name}}", {{parent_wrapper_type_info}}, WrapperTypeInfo::{{wrapper_type_prototype}}, WrapperTypeInfo::{{wrapper_class_id}}, WrapperTypeInfo::{{event_target_inheritance}}, WrapperTypeInfo::{{lifetime}}, WrapperTypeInfo::{{gc_type}} };
// This static member must be declared by DEFINE_WRAPPERTYPEINFO in {{cpp_class}}.h.
// For details, see the comment of DEFINE_WRAPPERTYPEINFO in
@@ -69,6 +69,55 @@ static void {{cpp_class}}ForceSetAttributeOnThis(v8::Local<v8::String> name, v8:
v8::Local<v8::Object>::Cast(info.This())->ForceSet(name, v8Value);
}
+{% for attribute in attributes
+ if (attribute.constructor_type and
+ attribute.name == attribute.constructor_type and
+ not attribute.is_expose_js_accessors) %}
+{% if loop.first %}
haraken 2015/03/17 00:06:07 Instead of using loop.first, can we introduce has_
Yuki 2015/03/17 08:35:19 Done.
+static void {{cpp_class}}ConstructorAttributeSetterCallbackAsProperty(v8::Local<v8::String>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
haraken 2015/03/17 00:06:07 I'm just curious, but how many constructor attribu
Yuki 2015/03/17 08:35:19 We've not yet moved any of constructor attribute t
+{
+ TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter");
+ do {
haraken 2015/03/17 00:06:08 What is the do...while for?
Yuki 2015/03/17 08:35:19 Added a comment. It's for use of 'break'. We need
+ v8::Local<v8::Value> data = info.Data();
haraken 2015/03/17 00:06:08 Not related to your CL, we want to deprecate info.
Yuki 2015/03/17 08:35:19 We could use "hidden value" instead of info.Data()
+ ASSERT(data->IsExternal());
+ V8PerContextData* perContextData = V8PerContextData::from(info.Holder()->CreationContext());
+ if (!perContextData)
+ break;
+ const WrapperTypeInfo* wrapperTypeInfo = WrapperTypeInfo::unwrap(data);
+ if (!wrapperTypeInfo)
+ break;
+ {{cpp_class}}ForceSetAttributeOnThis(v8String(info.GetIsolate(), wrapperTypeInfo->interfaceName), v8Value, info);
haraken 2015/03/17 00:06:07 Not related to your CL, I want to understand why t
Yuki 2015/03/17 08:35:19 My understanding is: Set = regular assignment, w
+ } while (false);
+ TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
+}
+
+{% endif %}
+{% endfor %}
+{% for attribute in attributes
+ if (attribute.constructor_type and
+ attribute.name == attribute.constructor_type and
+ attribute.is_expose_js_accessors) %}
+{% if loop.first %}
haraken 2015/03/17 00:06:08 Ditto. I'd prefer has_constructor_attribute_setter
Yuki 2015/03/17 08:35:19 Done.
+static void {{cpp_class}}ConstructorAttributeSetterCallbackAsAccessor(const v8::FunctionCallbackInfo<v8::Value>& info)
+{
+ TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter");
+ do {
haraken 2015/03/17 00:06:07 What is the do...while for?
Yuki 2015/03/17 08:35:19 Done.
+ v8::Local<v8::Value> v8Value = info[0];
+ v8::Local<v8::Value> data = info.Data();
+ ASSERT(data->IsExternal());
+ V8PerContextData* perContextData = V8PerContextData::from(info.Holder()->CreationContext());
+ if (!perContextData)
+ break;
+ const WrapperTypeInfo* wrapperTypeInfo = WrapperTypeInfo::unwrap(data);
+ if (!wrapperTypeInfo)
+ break;
+ {{cpp_class}}ForceSetAttributeOnThis(v8String(info.GetIsolate(), wrapperTypeInfo->interfaceName), v8Value, info);
+ } while (false);
+ TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
+}
+
+{% endif %}
+{% endfor %}
{% endif %}
{% endblock %}
{##############################################################################}
@@ -87,11 +136,14 @@ static void {{cpp_class}}ForceSetAttributeOnThis(v8::Local<v8::String> name, v8:
{{attribute_getter_callback(attribute, world_suffix)}}
{% endif %}
{% if attribute.has_setter %}
-{% if not attribute.has_custom_setter %}
+{% if not (attribute.has_custom_setter or
+ (attribute.constructor_type and attribute.name == attribute.constructor_type)) %}
haraken 2015/03/17 00:06:08 Maybe I'm wrong, but can we avoid introducing the
Yuki 2015/03/17 08:35:19 No, we cannot. At least there is case that 1) the
{{attribute_setter(attribute, world_suffix)}}
{% endif %}
+{% if not (attribute.constructor_type and attribute.name == attribute.constructor_type) %}
{{attribute_setter_callback(attribute, world_suffix)}}
{% endif %}
+{% endif %}
{% endfor %}
{% endfor %}
{##############################################################################}

Powered by Google App Engine
This is Rietveld 408576698