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

Side by Side 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 review comments. 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This file has been auto-generated by {{code_generator}}. DO NOT MODIFY! 5 // This file has been auto-generated by {{code_generator}}. DO NOT MODIFY!
6 6
7 #include "config.h" 7 #include "config.h"
8 {% filter conditional(conditional_string) %} 8 {% filter conditional(conditional_string) %}
9 #include "{{v8_class_or_partial}}.h" 9 #include "{{v8_class_or_partial}}.h"
10 10
11 {% for filename in cpp_includes if filename != '%s.h' % cpp_class_or_partial %} 11 {% for filename in cpp_includes if filename != '%s.h' % cpp_class_or_partial %}
12 #include "{{filename}}" 12 #include "{{filename}}"
13 {% endfor %} 13 {% endfor %}
14 14
15 namespace blink { 15 namespace blink {
16 {% set to_active_dom_object = '%s::toActiveDOMObject' % v8_class 16 {% set to_active_dom_object = '%s::toActiveDOMObject' % v8_class
17 if is_active_dom_object else '0' %} 17 if is_active_dom_object else '0' %}
18 {% set visit_dom_wrapper = '%s::visitDOMWrapper' % v8_class 18 {% set visit_dom_wrapper = '%s::visitDOMWrapper' % v8_class
19 if has_visit_dom_wrapper else '0' %} 19 if has_visit_dom_wrapper else '0' %}
20 {% set parent_wrapper_type_info = '&V8%s::wrapperTypeInfo' % parent_interface 20 {% set parent_wrapper_type_info = '&V8%s::wrapperTypeInfo' % parent_interface
21 if parent_interface else '0' %} 21 if parent_interface else '0' %}
22 {% set wrapper_type_prototype = 'WrapperTypeExceptionPrototype' if is_exception else 22 {% set wrapper_type_prototype = 'WrapperTypeExceptionPrototype' if is_exception else
23 'WrapperTypeObjectPrototype' %} 23 'WrapperTypeObjectPrototype' %}
24 {% set dom_template = '%s::domTemplate' % v8_class if not is_array_buffer_or_vie w else '0' %} 24 {% set dom_template = '%s::domTemplate' % v8_class if not is_array_buffer_or_vie w else '0' %}
25 25
26 {% set wrapper_type_info_const = '' if has_partial_interface else 'const ' %} 26 {% set wrapper_type_info_const = '' if has_partial_interface else 'const ' %}
27 {% if not is_partial %} 27 {% if not is_partial %}
28 {{wrapper_type_info_const}}WrapperTypeInfo {{v8_class}}::wrapperTypeInfo = { gin ::kEmbedderBlink, {{dom_template}}, {{v8_class}}::refObject, {{v8_class}}::deref Object, {{v8_class}}::trace, {{to_active_dom_object}}, {{visit_dom_wrapper}}, {{ v8_class}}::installConditionallyEnabledMethods, {{v8_class}}::installConditional lyEnabledProperties, {{parent_wrapper_type_info}}, WrapperTypeInfo::{{wrapper_ty pe_prototype}}, WrapperTypeInfo::{{wrapper_class_id}}, WrapperTypeInfo::{{event_ target_inheritance}}, WrapperTypeInfo::{{lifetime}}, WrapperTypeInfo::{{gc_type} } }; 28 {{wrapper_type_info_const}}WrapperTypeInfo {{v8_class}}::wrapperTypeInfo = { gin ::kEmbedderBlink, {{dom_template}}, {{v8_class}}::refObject, {{v8_class}}::deref Object, {{v8_class}}::trace, {{to_active_dom_object}}, {{visit_dom_wrapper}}, {{ v8_class}}::installConditionallyEnabledMethods, {{v8_class}}::installConditional lyEnabledProperties, "{{interface_name}}", {{parent_wrapper_type_info}}, Wrapper TypeInfo::{{wrapper_type_prototype}}, WrapperTypeInfo::{{wrapper_class_id}}, Wra pperTypeInfo::{{event_target_inheritance}}, WrapperTypeInfo::{{lifetime}}, Wrapp erTypeInfo::{{gc_type}} };
29 29
30 // This static member must be declared by DEFINE_WRAPPERTYPEINFO in {{cpp_class} }.h. 30 // This static member must be declared by DEFINE_WRAPPERTYPEINFO in {{cpp_class} }.h.
31 // For details, see the comment of DEFINE_WRAPPERTYPEINFO in 31 // For details, see the comment of DEFINE_WRAPPERTYPEINFO in
32 // bindings/core/v8/ScriptWrappable.h. 32 // bindings/core/v8/ScriptWrappable.h.
33 {% if is_typed_array_type %} 33 {% if is_typed_array_type %}
34 template<> 34 template<>
35 {% endif %} 35 {% endif %}
36 const WrapperTypeInfo& {{cpp_class}}::s_wrapperTypeInfo = {{v8_class}}::wrapperT ypeInfo; 36 const WrapperTypeInfo& {{cpp_class}}::s_wrapperTypeInfo = {{v8_class}}::wrapperT ypeInfo;
37 37
38 {% endif %} 38 {% endif %}
(...skipping 23 matching lines...) Expand all
62 ExceptionState exceptionState(ExceptionState::SetterContext, *attributeName, "{{interface_name}}", info.Holder(), info.GetIsolate()); 62 ExceptionState exceptionState(ExceptionState::SetterContext, *attributeName, "{{interface_name}}", info.Holder(), info.GetIsolate());
63 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), impl->fram e(), exceptionState)) { 63 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), impl->fram e(), exceptionState)) {
64 exceptionState.throwIfNeeded(); 64 exceptionState.throwIfNeeded();
65 return; 65 return;
66 } 66 }
67 {% endif %} 67 {% endif %}
68 ASSERT(info.This()->IsObject()); 68 ASSERT(info.This()->IsObject());
69 v8::Local<v8::Object>::Cast(info.This())->ForceSet(name, v8Value); 69 v8::Local<v8::Object>::Cast(info.This())->ForceSet(name, v8Value);
70 } 70 }
71 71
72 {% if has_constructor_attributes %}
73 static void {{cpp_class}}ConstructorAttributeSetterCallback(v8::Local<v8::Name>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
74 {
75 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter");
76 do {
77 v8::Local<v8::Value> data = info.Data();
78 ASSERT(data->IsExternal());
79 V8PerContextData* perContextData = V8PerContextData::from(info.Holder()- >CreationContext());
80 if (!perContextData)
81 break;
82 const WrapperTypeInfo* wrapperTypeInfo = WrapperTypeInfo::unwrap(data);
83 if (!wrapperTypeInfo)
84 break;
85 {{cpp_class}}ForceSetAttributeOnThis(v8String(info.GetIsolate(), wrapper TypeInfo->interfaceName), v8Value, info);
86 } while (false); // do ... while (false) just for use of break
87 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
88 }
89
90 {% endif %}
72 {% endif %} 91 {% endif %}
73 {% endblock %} 92 {% endblock %}
74 {##############################################################################} 93 {##############################################################################}
75 {% from 'attributes.cpp' import constructor_getter_callback, 94 {% from 'attributes.cpp' import constructor_getter_callback,
76 attribute_getter, attribute_getter_callback, 95 attribute_getter, attribute_getter_callback,
77 attribute_setter, attribute_setter_callback, 96 attribute_setter, attribute_setter_callback,
78 attribute_getter_implemented_in_private_script, 97 attribute_getter_implemented_in_private_script,
79 attribute_setter_implemented_in_private_script 98 attribute_setter_implemented_in_private_script
80 with context %} 99 with context %}
81 {% for attribute in attributes if attribute.should_be_exposed_to_script %} 100 {% for attribute in attributes if attribute.should_be_exposed_to_script %}
82 {% for world_suffix in attribute.world_suffixes %} 101 {% for world_suffix in attribute.world_suffixes %}
83 {% if not attribute.constructor_type %} 102 {% if not attribute.constructor_type %}
84 {% if not attribute.has_custom_getter %} 103 {% if not attribute.has_custom_getter %}
85 {{attribute_getter(attribute, world_suffix)}} 104 {{attribute_getter(attribute, world_suffix)}}
86 {% endif %} 105 {% endif %}
87 {{attribute_getter_callback(attribute, world_suffix)}} 106 {{attribute_getter_callback(attribute, world_suffix)}}
88 {% endif %} 107 {% endif %}
89 {% if attribute.has_setter %} 108 {% if attribute.has_setter %}
90 {% if not attribute.has_custom_setter %} 109 {% if not (attribute.has_custom_setter or
haraken 2015/03/17 08:48:07 not (A or (B and not C)) => not A and (not B or C)
Yuki 2015/03/17 09:10:05 Done.
110 (attribute.constructor_type and not attribute.needs_constructor_sette r_callback)) %}
91 {{attribute_setter(attribute, world_suffix)}} 111 {{attribute_setter(attribute, world_suffix)}}
92 {% endif %} 112 {% endif %}
113 {% if not (attribute.constructor_type and not attribute.needs_constructor_setter _callback) %}
haraken 2015/03/17 08:48:08 not (B and not C) => not B or C ?
Yuki 2015/03/17 09:10:05 Done.
93 {{attribute_setter_callback(attribute, world_suffix)}} 114 {{attribute_setter_callback(attribute, world_suffix)}}
94 {% endif %} 115 {% endif %}
116 {% endif %}
95 {% endfor %} 117 {% endfor %}
96 {% endfor %} 118 {% endfor %}
97 {##############################################################################} 119 {##############################################################################}
98 {% for attribute in attributes if attribute.needs_constructor_getter_callback %} 120 {% for attribute in attributes if attribute.needs_constructor_getter_callback %}
99 {% for world_suffix in attribute.world_suffixes %} 121 {% for world_suffix in attribute.world_suffixes %}
100 {{constructor_getter_callback(attribute, world_suffix)}} 122 {{constructor_getter_callback(attribute, world_suffix)}}
101 {% endfor %} 123 {% endfor %}
102 {% endfor %} 124 {% endfor %}
103 {##############################################################################} 125 {##############################################################################}
104 {% block security_check_functions %} 126 {% block security_check_functions %}
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 {% endfor %} 499 {% endfor %}
478 {% for attribute in attributes if attribute.is_implemented_in_private_script %} 500 {% for attribute in attributes if attribute.is_implemented_in_private_script %}
479 {{attribute_getter_implemented_in_private_script(attribute)}} 501 {{attribute_getter_implemented_in_private_script(attribute)}}
480 {% if attribute.has_setter %} 502 {% if attribute.has_setter %}
481 {{attribute_setter_implemented_in_private_script(attribute)}} 503 {{attribute_setter_implemented_in_private_script(attribute)}}
482 {% endif %} 504 {% endif %}
483 {% endfor %} 505 {% endfor %}
484 {% block partial_interface %}{% endblock %} 506 {% block partial_interface %}{% endblock %}
485 } // namespace blink 507 } // namespace blink
486 {% endfilter %} 508 {% endfilter %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698