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

Side by Side Diff: Source/bindings/templates/interface_base.cpp

Issue 618373003: [bindings] partial interfaces should not violate componentization (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 2 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}}.h" 9 #include "{{v8_class_or_partial}}.h"
10 10
11 {% for filename in cpp_includes if filename != '%s.h' % v8_class %} 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 {% block initialize_script_wrappable %}{% endblock %}
15 namespace blink { 16 namespace blink {
16 {% set to_active_dom_object = '%s::toActiveDOMObject' % v8_class 17 {% set to_active_dom_object = '%s::toActiveDOMObject' % v8_class
17 if is_active_dom_object else '0' %} 18 if is_active_dom_object else '0' %}
18 {% set to_event_target = '%s::toEventTarget' % v8_class 19 {% set to_event_target = '%s::toEventTarget' % v8_class
19 if is_event_target else '0' %} 20 if is_event_target else '0' %}
20 {% set visit_dom_wrapper = '%s::visitDOMWrapper' % v8_class 21 {% set visit_dom_wrapper = '%s::visitDOMWrapper' % v8_class
21 if has_visit_dom_wrapper else '0' %} 22 if has_visit_dom_wrapper else '0' %}
22 {% set parent_wrapper_type_info = '&V8%s::wrapperTypeInfo' % parent_interface 23 {% set parent_wrapper_type_info = '&V8%s::wrapperTypeInfo' % parent_interface
23 if parent_interface else '0' %} 24 if parent_interface else '0' %}
24 {% set wrapper_type_prototype = 'WrapperTypeExceptionPrototype' if is_exception else 25 {% set wrapper_type_prototype = 'WrapperTypeExceptionPrototype' if is_exception else
25 'WrapperTypeObjectPrototype' %} 26 'WrapperTypeObjectPrototype' %}
26 27
27 const WrapperTypeInfo {{v8_class}}::wrapperTypeInfo = { gin::kEmbedderBlink, {{v 8_class}}::domTemplate, {{v8_class}}::refObject, {{v8_class}}::derefObject, {{v8 _class}}::createPersistentHandle, {{to_active_dom_object}}, {{to_event_target}}, {{visit_dom_wrapper}}, {{v8_class}}::installConditionallyEnabledMethods, {{v8_c lass}}::installConditionallyEnabledProperties, {{parent_wrapper_type_info}}, Wra pperTypeInfo::{{wrapper_type_prototype}}, WrapperTypeInfo::{{wrapper_class_id}}, WrapperTypeInfo::{{lifetime}}, WrapperTypeInfo::{{gc_type}} }; 28 {% set wrapper_type_info_const = '' if has_partial_interface else 'const ' %}
29 {% if not is_partial %}
30 {{wrapper_type_info_const}}WrapperTypeInfo {{v8_class}}::wrapperTypeInfo = { gin ::kEmbedderBlink, {{v8_class}}::domTemplate, {{v8_class}}::refObject, {{v8_class }}::derefObject, {{v8_class}}::createPersistentHandle, {{to_active_dom_object}}, {{to_event_target}}, {{visit_dom_wrapper}}, {{v8_class}}::installConditionallyE nabledMethods, {{v8_class}}::installConditionallyEnabledProperties, {{parent_wra pper_type_info}}, WrapperTypeInfo::{{wrapper_type_prototype}}, WrapperTypeInfo:: {{wrapper_class_id}}, WrapperTypeInfo::{{lifetime}}, WrapperTypeInfo::{{gc_type} } };
28 31
29 {% if is_script_wrappable %} 32 {% if is_script_wrappable %}
30 // This static member must be declared by DEFINE_WRAPPERTYPEINFO in {{cpp_class} }.h. 33 // This static member must be declared by DEFINE_WRAPPERTYPEINFO in {{cpp_class} }.h.
31 // For details, see the comment of DEFINE_WRAPPERTYPEINFO in 34 // For details, see the comment of DEFINE_WRAPPERTYPEINFO in
32 // bindings/core/v8/ScriptWrappable.h. 35 // bindings/core/v8/ScriptWrappable.h.
33 const WrapperTypeInfo& {{cpp_class}}::s_wrapperTypeInfo = {{v8_class}}::wrapperT ypeInfo; 36 const WrapperTypeInfo& {{cpp_class}}::s_wrapperTypeInfo = {{v8_class}}::wrapperT ypeInfo;
34 37
35 {% endif %} 38 {% endif %}
36 namespace {{cpp_class}}V8Internal { 39 {% endif %}
40 namespace {{cpp_class_or_partial}}V8Internal {
41 {% if has_partial_interface %}
42 {% for method in methods if method.overloads and method.overloads.has_partial_ov erloads %}
43 static void (*{{method.name}}MethodForPartialInterface)(const v8::FunctionCallba ckInfo<v8::Value>&) = 0;
44 {% endfor %}
45 {% endif %}
37 46
38 {# Constants #} 47 {# Constants #}
39 {% from 'constants.cpp' import constant_getter_callback 48 {% from 'constants.cpp' import constant_getter_callback
40 with context %} 49 with context %}
41 {% for constant in special_getter_constants %} 50 {% for constant in special_getter_constants %}
42 {{constant_getter_callback(constant)}} 51 {{constant_getter_callback(constant)}}
43 {% endfor %} 52 {% endfor %}
44 {# Attributes #} 53 {# Attributes #}
45 {% from 'attributes.cpp' import constructor_getter_callback, 54 {% from 'attributes.cpp' import constructor_getter_callback,
46 attribute_getter, attribute_getter_callback, 55 attribute_getter, attribute_getter_callback,
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 exceptionState.throwIfNeeded(); 107 exceptionState.throwIfNeeded();
99 return; 108 return;
100 } 109 }
101 {% endif %} 110 {% endif %}
102 if (info.This()->IsObject()) 111 if (info.This()->IsObject())
103 v8::Handle<v8::Object>::Cast(info.This())->ForceSet(name, v8Value); 112 v8::Handle<v8::Object>::Cast(info.This())->ForceSet(name, v8Value);
104 } 113 }
105 114
106 static void {{cpp_class}}ForceSetAttributeOnThisCallback(v8::Local<v8::String> n ame, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 115 static void {{cpp_class}}ForceSetAttributeOnThisCallback(v8::Local<v8::String> n ame, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
107 { 116 {
108 {{cpp_class}}V8Internal::{{cpp_class}}ForceSetAttributeOnThis(name, v8Value, info); 117 {{cpp_class_or_partial}}V8Internal::{{cpp_class}}ForceSetAttributeOnThis(nam e, v8Value, info);
109 } 118 }
110 119
111 {% endif %} 120 {% endif %}
112 {% endblock %} 121 {% endblock %}
113 {##############################################################################} 122 {##############################################################################}
114 {% block security_check_functions %} 123 {% block security_check_functions %}
115 {% if has_access_check_callbacks %} 124 {% if has_access_check_callbacks %}
116 bool indexedSecurityCheck(v8::Local<v8::Object> host, uint32_t index, v8::Access Type type, v8::Local<v8::Value>) 125 bool indexedSecurityCheck(v8::Local<v8::Object> host, uint32_t index, v8::Access Type type, v8::Local<v8::Value>)
117 { 126 {
118 {{cpp_class}}* impl = {{v8_class}}::toImpl(host); 127 {{cpp_class}}* impl = {{v8_class}}::toImpl(host);
(...skipping 10 matching lines...) Expand all
129 {% endblock %} 138 {% endblock %}
130 {##############################################################################} 139 {##############################################################################}
131 {# Methods #} 140 {# Methods #}
132 {% from 'methods.cpp' import generate_method, overload_resolution_method, 141 {% from 'methods.cpp' import generate_method, overload_resolution_method,
133 method_callback, origin_safe_method_getter, generate_constructor, 142 method_callback, origin_safe_method_getter, generate_constructor,
134 method_implemented_in_private_script 143 method_implemented_in_private_script
135 with context %} 144 with context %}
136 {% for method in methods %} 145 {% for method in methods %}
137 {% if method.should_be_exposed_to_script %} 146 {% if method.should_be_exposed_to_script %}
138 {% for world_suffix in method.world_suffixes %} 147 {% for world_suffix in method.world_suffixes %}
139 {% if not method.is_custom %} 148 {% if not method.is_custom and method.visible %}
140 {{generate_method(method, world_suffix)}} 149 {{generate_method(method, world_suffix)}}
141 {% endif %} 150 {% endif %}
142 {% if method.overloads %} 151 {% if method.overloads and method.overloads.visible %}
143 {{overload_resolution_method(method.overloads, world_suffix)}} 152 {{overload_resolution_method(method.overloads, world_suffix)}}
144 {% endif %} 153 {% endif %}
145 {% if not method.overload_index or method.overloads %} 154 {% if not method.overload_index or method.overloads %}
155 {# Document about the following condition: #}
156 {# https://docs.google.com/document/d/1qBC7Therp437Jbt_QYAtNYMZs6zQ_7_tnMkNUG_AC qs/edit?usp=sharing #}
157 {% if (method.overloads and method.overloads.visible and
158 (not method.overloads.has_partial_overloads or not is_partial)) or
159 (not method.overloads and method.visible) %}
146 {# A single callback is generated for overloaded methods #} 160 {# A single callback is generated for overloaded methods #}
161 {# with considering partial overloads #}
147 {{method_callback(method, world_suffix)}} 162 {{method_callback(method, world_suffix)}}
148 {% endif %} 163 {% endif %}
149 {% if method.is_do_not_check_security %} 164 {% endif %}
165 {% if method.is_do_not_check_security and method.visible %}
150 {{origin_safe_method_getter(method, world_suffix)}} 166 {{origin_safe_method_getter(method, world_suffix)}}
151 {% endif %} 167 {% endif %}
152 {% endfor %} 168 {% endfor %}
153 {% endif %} 169 {% endif %}
154 {% endfor %} 170 {% endfor %}
155 {% if iterator_method %} 171 {% if iterator_method %}
156 {{generate_method(iterator_method)}} 172 {{generate_method(iterator_method)}}
157 {{method_callback(iterator_method)}} 173 {{method_callback(iterator_method)}}
158 {% endif %} 174 {% endif %}
159 {% block origin_safe_method_setter %}{% endblock %} 175 {% block origin_safe_method_setter %}{% endblock %}
(...skipping 13 matching lines...) Expand all
173 {% block named_property_getter %}{% endblock %} 189 {% block named_property_getter %}{% endblock %}
174 {% block named_property_getter_callback %}{% endblock %} 190 {% block named_property_getter_callback %}{% endblock %}
175 {% block named_property_setter %}{% endblock %} 191 {% block named_property_setter %}{% endblock %}
176 {% block named_property_setter_callback %}{% endblock %} 192 {% block named_property_setter_callback %}{% endblock %}
177 {% block named_property_query %}{% endblock %} 193 {% block named_property_query %}{% endblock %}
178 {% block named_property_query_callback %}{% endblock %} 194 {% block named_property_query_callback %}{% endblock %}
179 {% block named_property_deleter %}{% endblock %} 195 {% block named_property_deleter %}{% endblock %}
180 {% block named_property_deleter_callback %}{% endblock %} 196 {% block named_property_deleter_callback %}{% endblock %}
181 {% block named_property_enumerator %}{% endblock %} 197 {% block named_property_enumerator %}{% endblock %}
182 {% block named_property_enumerator_callback %}{% endblock %} 198 {% block named_property_enumerator_callback %}{% endblock %}
183 } // namespace {{cpp_class}}V8Internal 199 } // namespace {{cpp_class_or_partial}}V8Internal
184 200
185 {% block visit_dom_wrapper %}{% endblock %} 201 {% block visit_dom_wrapper %}{% endblock %}
186 {% block shadow_attributes %}{% endblock %} 202 {% block shadow_attributes %}{% endblock %}
187 {##############################################################################} 203 {##############################################################################}
188 {% block install_attributes %} 204 {% block install_attributes %}
205 {% from 'attributes.cpp' import attribute_configuration with context %}
189 {% if has_attribute_configuration %} 206 {% if has_attribute_configuration %}
190 static const V8DOMConfiguration::AttributeConfiguration {{v8_class}}Attributes[] = { 207 static const V8DOMConfiguration::AttributeConfiguration {{v8_class}}Attributes[] = {
191 {% for attribute in attributes 208 {% for attribute in attributes
192 if not (attribute.is_expose_js_accessors or 209 if not (attribute.is_expose_js_accessors or
193 attribute.is_static or 210 attribute.is_static or
194 attribute.runtime_enabled_function or 211 attribute.runtime_enabled_function or
195 attribute.per_context_enabled_function or 212 attribute.per_context_enabled_function or
196 attribute.exposed_test or 213 attribute.exposed_test or
197 (interface_name == 'Window' and attribute.is_unforgeable)) 214 (interface_name == 'Window' and attribute.is_unforgeable))
198 and attribute.should_be_exposed_to_script %} 215 and attribute.should_be_exposed_to_script %}
199 {% filter conditional(attribute.conditional_string) %} 216 {% filter conditional(attribute.conditional_string) %}
200 {{attribute_configuration(attribute)}}, 217 {{attribute_configuration(attribute)}},
201 {% endfilter %} 218 {% endfilter %}
202 {% endfor %} 219 {% endfor %}
203 }; 220 };
204 221
205 {% endif %} 222 {% endif %}
206 {% endblock %} 223 {% endblock %}
207 {##############################################################################} 224 {##############################################################################}
208 {% block install_accessors %} 225 {% block install_accessors %}
226 {% from 'attributes.cpp' import attribute_configuration with context %}
209 {% if has_accessors %} 227 {% if has_accessors %}
210 static const V8DOMConfiguration::AccessorConfiguration {{v8_class}}Accessors[] = { 228 static const V8DOMConfiguration::AccessorConfiguration {{v8_class}}Accessors[] = {
211 {% for attribute in attributes if attribute.is_expose_js_accessors and attri bute.should_be_exposed_to_script %} 229 {% for attribute in attributes if attribute.is_expose_js_accessors and attri bute.should_be_exposed_to_script %}
212 {{attribute_configuration(attribute)}}, 230 {{attribute_configuration(attribute)}},
213 {% endfor %} 231 {% endfor %}
214 }; 232 };
215 233
216 {% endif %} 234 {% endif %}
217 {% endblock %} 235 {% endblock %}
218 {##############################################################################} 236 {##############################################################################}
(...skipping 11 matching lines...) Expand all
230 {% endif %} 248 {% endif %}
231 {% endblock %} 249 {% endblock %}
232 {##############################################################################} 250 {##############################################################################}
233 {% block named_constructor %}{% endblock %} 251 {% block named_constructor %}{% endblock %}
234 {% block initialize_event %}{% endblock %} 252 {% block initialize_event %}{% endblock %}
235 {% block constructor_callback %}{% endblock %} 253 {% block constructor_callback %}{% endblock %}
236 {% block configure_shadow_object_template %}{% endblock %} 254 {% block configure_shadow_object_template %}{% endblock %}
237 {##############################################################################} 255 {##############################################################################}
238 {% block install_dom_template %} 256 {% block install_dom_template %}
239 {% from 'methods.cpp' import install_custom_signature with context %} 257 {% from 'methods.cpp' import install_custom_signature with context %}
258 {% from 'attributes.cpp' import attribute_configuration with context %}
240 {% from 'constants.cpp' import install_constants with context %} 259 {% from 'constants.cpp' import install_constants with context %}
260 {% if has_partial_interface or is_partial %}
261 void {{v8_class_or_partial}}::install{{v8_class}}Template(v8::Handle<v8::Functio nTemplate> functionTemplate, v8::Isolate* isolate)
262 {% else %}
241 static void install{{v8_class}}Template(v8::Handle<v8::FunctionTemplate> functio nTemplate, v8::Isolate* isolate) 263 static void install{{v8_class}}Template(v8::Handle<v8::FunctionTemplate> functio nTemplate, v8::Isolate* isolate)
264 {% endif %}
242 { 265 {
266 {% if is_partial %}
267 {{v8_class}}::install{{v8_class}}Template(functionTemplate, isolate);
268 {% else %}
243 functionTemplate->ReadOnlyPrototype(); 269 functionTemplate->ReadOnlyPrototype();
270 {% endif %}
244 271
245 v8::Local<v8::Signature> defaultSignature; 272 v8::Local<v8::Signature> defaultSignature;
246 {% set parent_template = 273 {% set parent_template =
247 'V8%s::domTemplate(isolate)' % parent_interface 274 'V8%s::domTemplate(isolate)' % parent_interface
248 if parent_interface else 'v8::Local<v8::FunctionTemplate>()' %} 275 if parent_interface else 'v8::Local<v8::FunctionTemplate>()' %}
249 {% if runtime_enabled_function %} 276 {% if runtime_enabled_function %}
250 if (!{{runtime_enabled_function}}()) 277 if (!{{runtime_enabled_function}}())
251 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionT emplate, "", {{parent_template}}, {{v8_class}}::internalFieldCount, 0, 0, 0, 0, 0, 0, isolate); 278 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionT emplate, "", {{parent_template}}, {{v8_class}}::internalFieldCount, 0, 0, 0, 0, 0, 0, isolate);
252 else 279 else
253 {% endif %} 280 {% endif %}
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 static const V8DOMConfiguration::AttributeConfiguration attributeConfigu ration =\ 326 static const V8DOMConfiguration::AttributeConfiguration attributeConfigu ration =\
300 {{attribute_configuration(attribute)}}; 327 {{attribute_configuration(attribute)}};
301 V8DOMConfiguration::installAttribute(instanceTemplate, prototypeTemplate , attributeConfiguration, isolate); 328 V8DOMConfiguration::installAttribute(instanceTemplate, prototypeTemplate , attributeConfiguration, isolate);
302 } 329 }
303 {% endfilter %} 330 {% endfilter %}
304 {% endfor %} 331 {% endfor %}
305 {% if constants %} 332 {% if constants %}
306 {{install_constants() | indent}} 333 {{install_constants() | indent}}
307 {% endif %} 334 {% endif %}
308 {# Special operations #} 335 {# Special operations #}
309 {# V8 has access-check callback API and it's used on Window instead of 336 {# V8 has access-check callback API and it\'s used on Window instead of
310 deleters or enumerators; see ObjectTemplate::SetAccessCheckCallbacks. 337 deleters or enumerators; see ObjectTemplate::SetAccessCheckCallbacks.
311 In addition, the getter should be set on the prototype template, to get 338 In addition, the getter should be set on the prototype template, to get
312 the implementation straight out of the Window prototype, regardless of 339 the implementation straight out of the Window prototype, regardless of
313 what prototype is actually set on the object. #} 340 what prototype is actually set on the object. #}
314 {% set set_on_template = 'PrototypeTemplate' if interface_name == 'Window' 341 {% set set_on_template = 'PrototypeTemplate' if interface_name == 'Window'
315 else 'InstanceTemplate' %} 342 else 'InstanceTemplate' %}
316 {% if indexed_property_getter %} 343 {% if indexed_property_getter %}
317 {# if have indexed properties, MUST have an indexed property getter #} 344 {# if have indexed properties, MUST have an indexed property getter #}
318 {% set indexed_property_getter_callback = 345 {% set indexed_property_getter_callback =
319 '%sV8Internal::indexedPropertyGetterCallback' % cpp_class %} 346 '%sV8Internal::indexedPropertyGetterCallback' % cpp_class %}
(...skipping 21 matching lines...) Expand all
341 if named_property_getter.is_enumerable else '0' %} 368 if named_property_getter.is_enumerable else '0' %}
342 {% set named_property_deleter_callback = 369 {% set named_property_deleter_callback =
343 '%sV8Internal::namedPropertyDeleterCallback' % cpp_class 370 '%sV8Internal::namedPropertyDeleterCallback' % cpp_class
344 if named_property_deleter else '0' %} 371 if named_property_deleter else '0' %}
345 {% set named_property_enumerator_callback = 372 {% set named_property_enumerator_callback =
346 '%sV8Internal::namedPropertyEnumeratorCallback' % cpp_class 373 '%sV8Internal::namedPropertyEnumeratorCallback' % cpp_class
347 if named_property_getter.is_enumerable else '0' %} 374 if named_property_getter.is_enumerable else '0' %}
348 functionTemplate->{{set_on_template}}()->SetNamedPropertyHandler({{named_pro perty_getter_callback}}, {{named_property_setter_callback}}, {{named_property_qu ery_callback}}, {{named_property_deleter_callback}}, {{named_property_enumerator _callback}}); 375 functionTemplate->{{set_on_template}}()->SetNamedPropertyHandler({{named_pro perty_getter_callback}}, {{named_property_setter_callback}}, {{named_property_qu ery_callback}}, {{named_property_deleter_callback}}, {{named_property_enumerator _callback}});
349 {% endif %} 376 {% endif %}
350 {% if iterator_method %} 377 {% if iterator_method %}
351 static const V8DOMConfiguration::SymbolKeyedMethodConfiguration symbolKeyedI teratorConfiguration = { v8::Symbol::GetIterator, {{cpp_class}}V8Internal::itera torMethodCallback, 0, V8DOMConfiguration::ExposedToAllScripts }; 378 static const V8DOMConfiguration::SymbolKeyedMethodConfiguration symbolKeyedI teratorConfiguration = { v8::Symbol::GetIterator, {{cpp_class_or_partial}}V8Inte rnal::iteratorMethodCallback, 0, V8DOMConfiguration::ExposedToAllScripts };
352 V8DOMConfiguration::installMethod(prototypeTemplate, defaultSignature, v8::D ontDelete, symbolKeyedIteratorConfiguration, isolate); 379 V8DOMConfiguration::installMethod(prototypeTemplate, defaultSignature, v8::D ontDelete, symbolKeyedIteratorConfiguration, isolate);
353 {% endif %} 380 {% endif %}
354 {# End special operations #} 381 {# End special operations #}
355 {% if has_custom_legacy_call_as_function %} 382 {% if has_custom_legacy_call_as_function %}
356 functionTemplate->InstanceTemplate()->SetCallAsFunctionHandler({{v8_class}}: :legacyCallCustom); 383 functionTemplate->InstanceTemplate()->SetCallAsFunctionHandler({{v8_class}}: :legacyCallCustom);
357 {% endif %} 384 {% endif %}
358 {% if interface_name == 'HTMLAllCollection' %} 385 {% if interface_name == 'HTMLAllCollection' %}
359 {# Needed for legacy support of document.all #} 386 {# Needed for legacy support of document.all #}
360 functionTemplate->InstanceTemplate()->MarkAsUndetectable(); 387 functionTemplate->InstanceTemplate()->MarkAsUndetectable();
361 {% endif %} 388 {% endif %}
(...skipping 12 matching lines...) Expand all
374 {% endfilter %}{# conditional() #} 401 {% endfilter %}{# conditional() #}
375 {% endfor %} 402 {% endfor %}
376 {% for attribute in attributes if attribute.is_static %} 403 {% for attribute in attributes if attribute.is_static %}
377 {% set getter_callback = '%sV8Internal::%sAttributeGetterCallback' % 404 {% set getter_callback = '%sV8Internal::%sAttributeGetterCallback' %
378 (cpp_class, attribute.name) %} 405 (cpp_class, attribute.name) %}
379 {% filter conditional(attribute.conditional_string) %} 406 {% filter conditional(attribute.conditional_string) %}
380 functionTemplate->SetNativeDataProperty(v8AtomicString(isolate, "{{attribute .name}}"), {{getter_callback}}, {{attribute.setter_callback}}, v8::External::New (isolate, 0), static_cast<v8::PropertyAttribute>(v8::None), v8::Handle<v8::Acces sorSignature>(), static_cast<v8::AccessControl>(v8::DEFAULT)); 407 functionTemplate->SetNativeDataProperty(v8AtomicString(isolate, "{{attribute .name}}"), {{getter_callback}}, {{attribute.setter_callback}}, v8::External::New (isolate, 0), static_cast<v8::PropertyAttribute>(v8::None), v8::Handle<v8::Acces sorSignature>(), static_cast<v8::AccessControl>(v8::DEFAULT));
381 {% endfilter %} 408 {% endfilter %}
382 {% endfor %} 409 {% endfor %}
383 {# Special interfaces #} 410 {# Special interfaces #}
411 {% if not is_partial %}
384 {% if interface_name == 'Window' %} 412 {% if interface_name == 'Window' %}
385 413
386 prototypeTemplate->SetInternalFieldCount(V8Window::internalFieldCount); 414 prototypeTemplate->SetInternalFieldCount(V8Window::internalFieldCount);
387 functionTemplate->SetHiddenPrototype(true); 415 functionTemplate->SetHiddenPrototype(true);
388 instanceTemplate->SetInternalFieldCount(V8Window::internalFieldCount); 416 instanceTemplate->SetInternalFieldCount(V8Window::internalFieldCount);
389 // Set access check callbacks, but turned off initially. 417 // Set access check callbacks, but turned off initially.
390 // When a context is detached from a frame, turn on the access check. 418 // When a context is detached from a frame, turn on the access check.
391 // Turning on checks also invalidates inline caches of the object. 419 // Turning on checks also invalidates inline caches of the object.
392 instanceTemplate->SetAccessCheckCallbacks(V8Window::namedSecurityCheckCustom , V8Window::indexedSecurityCheckCustom, v8::External::New(isolate, const_cast<Wr apperTypeInfo*>(&V8Window::wrapperTypeInfo)), false); 420 instanceTemplate->SetAccessCheckCallbacks(V8Window::namedSecurityCheckCustom , V8Window::indexedSecurityCheckCustom, v8::External::New(isolate, const_cast<Wr apperTypeInfo*>(&V8Window::wrapperTypeInfo)), false);
393 {% elif interface_name in [ 421 {% elif interface_name in [
394 'HTMLDocument', 'DedicatedWorkerGlobalScope', 422 'HTMLDocument', 'DedicatedWorkerGlobalScope',
395 'SharedWorkerGlobalScope', 'ServiceWorkerGlobalScope'] %} 423 'SharedWorkerGlobalScope', 'ServiceWorkerGlobalScope'] %}
396 functionTemplate->SetHiddenPrototype(true); 424 functionTemplate->SetHiddenPrototype(true);
397 {% endif %} 425 {% endif %}
398 426
399 // Custom toString template 427 // Custom toString template
400 functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData: :from(isolate)->toStringTemplate()); 428 functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData: :from(isolate)->toStringTemplate());
429 {% endif %}
401 } 430 }
402 431
403 {% endblock %} 432 {% endblock %}
404 {##############################################################################} 433 {##############################################################################}
405 {% block get_dom_template %}{% endblock %} 434 {% block get_dom_template %}{% endblock %}
406 {% block has_instance %}{% endblock %} 435 {% block has_instance %}{% endblock %}
407 {% block to_impl_with_type_check %}{% endblock %} 436 {% block to_impl_with_type_check %}{% endblock %}
437 {% block install_conditional_attributes %}{% endblock %}
408 {##############################################################################} 438 {##############################################################################}
409 {% block install_conditional_attributes %} 439 {% block install_conditional_methods %}
410 {% if has_conditional_attributes %} 440 {% from 'methods.cpp' import install_conditionally_enabled_methods
411 void {{v8_class}}::installConditionallyEnabledProperties(v8::Handle<v8::Object> instanceObject, v8::Isolate* isolate) 441 with context %}
412 { 442 {% if is_partial or conditionally_enabled_methods %}
413 v8::Local<v8::Object> prototypeObject = v8::Local<v8::Object>::Cast(instance Object->GetPrototype()); 443 {{install_conditionally_enabled_methods()}}
414 ExecutionContext* context = toExecutionContext(prototypeObject->CreationCont ext());
415
416 {% for attribute in attributes if attribute.per_context_enabled_function or attribute.exposed_test %}
417 {% filter per_context_enabled(attribute.per_context_enabled_function) %}
418 {% filter exposed(attribute.exposed_test) %}
419 static const V8DOMConfiguration::AttributeConfiguration attributeConfigurati on =\
420 {{attribute_configuration(attribute)}};
421 V8DOMConfiguration::installAttribute(instanceObject, prototypeObject, attrib uteConfiguration, isolate);
422 {% endfilter %}
423 {% endfilter %}
424 {% endfor %}
425 }
426 444
427 {% endif %} 445 {% endif %}
428 {% endblock %} 446 {% endblock %}
429 {##############################################################################}
430 {% block install_conditional_methods %}
431 {% if conditionally_enabled_methods %}
432 void {{v8_class}}::installConditionallyEnabledMethods(v8::Handle<v8::Object> pro totypeObject, v8::Isolate* isolate)
433 {
434 {# Define per-context enabled operations #}
435 v8::Local<v8::Signature> defaultSignature = v8::Signature::New(isolate, domT emplate(isolate));
436 ExecutionContext* context = toExecutionContext(prototypeObject->CreationCont ext());
437 ASSERT(context);
438
439 {% for method in conditionally_enabled_methods %}
440 {% filter per_context_enabled(method.per_context_enabled_function) %}
441 {% filter exposed(method.exposed_test) %}
442 prototypeObject->Set(v8AtomicString(isolate, "{{method.name}}"), v8::Functio nTemplate::New(isolate, {{cpp_class}}V8Internal::{{method.name}}MethodCallback, v8Undefined(), defaultSignature, {{method.number_of_required_arguments}})->GetFu nction());
443 {% endfilter %}
444 {% endfilter %}
445 {% endfor %}
446 }
447
448 {% endif %}
449 {% endblock %}
450 {##############################################################################} 447 {##############################################################################}
451 {% block to_active_dom_object %}{% endblock %} 448 {% block to_active_dom_object %}{% endblock %}
452 {% block to_event_target %}{% endblock %} 449 {% block to_event_target %}{% endblock %}
453 {% block get_shadow_object_template %}{% endblock %} 450 {% block get_shadow_object_template %}{% endblock %}
454 {% block wrap %}{% endblock %} 451 {% block wrap %}{% endblock %}
455 {% block create_wrapper %}{% endblock %} 452 {% block create_wrapper %}{% endblock %}
456 {% block deref_object_and_to_v8_no_inline %}{% endblock %} 453 {% block deref_object_and_to_v8_no_inline %}{% endblock %}
457 {% for method in methods if method.is_implemented_in_private_script %} 454 {% for method in methods if method.is_implemented_in_private_script %}
458 {{method_implemented_in_private_script(method)}} 455 {{method_implemented_in_private_script(method)}}
459 {% endfor %} 456 {% endfor %}
460 {% for attribute in attributes if attribute.is_implemented_in_private_script %} 457 {% for attribute in attributes if attribute.is_implemented_in_private_script %}
461 {{attribute_getter_implemented_in_private_script(attribute)}} 458 {{attribute_getter_implemented_in_private_script(attribute)}}
462 {% if not attribute.is_read_only or attribute.put_forwards %} 459 {% if not attribute.is_read_only or attribute.put_forwards %}
463 {{attribute_setter_implemented_in_private_script(attribute)}} 460 {{attribute_setter_implemented_in_private_script(attribute)}}
464 {% endif %} 461 {% endif %}
465 {% endfor %} 462 {% endfor %}
463 {% block partial_interface %}{% endblock %}
466 } // namespace blink 464 } // namespace blink
467 {% endfilter %} 465 {% endfilter %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698