OLD | NEW |
1 {% filter format_blink_cpp_source_code %} | 1 {% filter format_blink_cpp_source_code %} |
2 | 2 |
3 {% include 'copyright_block.txt' %} | 3 {% include 'copyright_block.txt' %} |
4 #include "{{v8_class_or_partial}}.h" | 4 #include "{{v8_class_or_partial}}.h" |
5 | 5 |
6 {% for filename in cpp_includes if filename != '%s.h' % cpp_class_or_partial %} | 6 {% for filename in cpp_includes if filename != '%s.h' % cpp_class_or_partial %} |
7 #include "{{filename}}" | 7 #include "{{filename}}" |
8 {% endfor %} | 8 {% endfor %} |
9 | 9 |
10 namespace blink { | 10 namespace blink { |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 {% endif %} | 110 {% endif %} |
111 {% if attribute.has_setter %} | 111 {% if attribute.has_setter %} |
112 {% if not attribute.has_custom_setter %} | 112 {% if not attribute.has_custom_setter %} |
113 {{attribute_setter(attribute, world_suffix)}} | 113 {{attribute_setter(attribute, world_suffix)}} |
114 {% endif %} | 114 {% endif %} |
115 {{attribute_setter_callback(attribute, world_suffix)}} | 115 {{attribute_setter_callback(attribute, world_suffix)}} |
116 {% endif %} | 116 {% endif %} |
117 {% endfor %} | 117 {% endfor %} |
118 {% endfor %} | 118 {% endfor %} |
119 {##############################################################################} | 119 {##############################################################################} |
120 {% block security_check_functions %} | |
121 {% if has_access_check_callbacks and not is_partial %} | |
122 bool securityCheck(v8::Local<v8::Context> accessingContext, v8::Local<v8::Object
> accessedObject, v8::Local<v8::Value> data) { | |
123 {% if interface_name == 'Window' %} | |
124 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | |
125 v8::Local<v8::Object> window = V8Window::findInstanceInPrototypeChain(accessed
Object, isolate); | |
126 if (window.IsEmpty()) | |
127 return false; // the frame is gone. | |
128 | |
129 const DOMWindow* targetWindow = V8Window::toImpl(window); | |
130 return BindingSecurity::shouldAllowAccessTo(toLocalDOMWindow(toDOMWindow(acces
singContext)), targetWindow, BindingSecurity::ErrorReportOption::DoNotReport); | |
131 {% else %}{# if interface_name == 'Window' #} | |
132 {# Not 'Window' means it\'s Location. #} | |
133 {{cpp_class}}* impl = {{v8_class}}::toImpl(accessedObject); | |
134 return BindingSecurity::shouldAllowAccessTo(toLocalDOMWindow(toDOMWindow(acces
singContext)), impl, BindingSecurity::ErrorReportOption::DoNotReport); | |
135 {% endif %}{# if interface_name == 'Window' #} | |
136 } | |
137 | |
138 {% endif %} | |
139 {% endblock %} | |
140 {##############################################################################} | |
141 {# Methods #} | 120 {# Methods #} |
142 {% from 'methods.cpp.tmpl' import generate_method, overload_resolution_method, | 121 {% from 'methods.cpp.tmpl' import generate_method, overload_resolution_method, |
143 method_callback, origin_safe_method_getter, generate_constructor, | 122 method_callback, origin_safe_method_getter, generate_constructor, |
144 method_implemented_in_private_script, generate_post_message_impl, | 123 method_implemented_in_private_script, generate_post_message_impl, |
145 runtime_determined_length_method, runtime_determined_maxarg_method | 124 runtime_determined_length_method, runtime_determined_maxarg_method |
146 with context %} | 125 with context %} |
147 {% for method in methods if method.should_be_exposed_to_script %} | 126 {% for method in methods if method.should_be_exposed_to_script %} |
148 {% for world_suffix in method.world_suffixes %} | 127 {% for world_suffix in method.world_suffixes %} |
149 {% if not method.is_custom and not method.is_post_message and method.visible %} | 128 {% if not method.is_custom and not method.is_post_message and method.visible %} |
150 {{generate_method(method, world_suffix)}} | 129 {{generate_method(method, world_suffix)}} |
(...skipping 14 matching lines...) Expand all Loading... |
165 {# Document about the following condition: #} | 144 {# Document about the following condition: #} |
166 {# https://docs.google.com/document/d/1qBC7Therp437Jbt_QYAtNYMZs6zQ_7_tnMkNUG_AC
qs/edit?usp=sharing #} | 145 {# https://docs.google.com/document/d/1qBC7Therp437Jbt_QYAtNYMZs6zQ_7_tnMkNUG_AC
qs/edit?usp=sharing #} |
167 {% if (method.overloads and method.overloads.visible and | 146 {% if (method.overloads and method.overloads.visible and |
168 (not method.overloads.has_partial_overloads or not is_partial)) or | 147 (not method.overloads.has_partial_overloads or not is_partial)) or |
169 (not method.overloads and method.visible) %} | 148 (not method.overloads and method.visible) %} |
170 {# A single callback is generated for overloaded methods #} | 149 {# A single callback is generated for overloaded methods #} |
171 {# with considering partial overloads #} | 150 {# with considering partial overloads #} |
172 {{method_callback(method, world_suffix)}} | 151 {{method_callback(method, world_suffix)}} |
173 {% endif %} | 152 {% endif %} |
174 {% endif %} | 153 {% endif %} |
175 {% if method.is_do_not_check_security and method.visible %} | 154 {% if method.is_cross_origin and method.visible %} |
176 {{origin_safe_method_getter(method, world_suffix)}} | 155 {{origin_safe_method_getter(method, world_suffix)}} |
177 {% endif %} | 156 {% endif %} |
178 {% endfor %} | 157 {% endfor %} |
179 {% endfor %} | 158 {% endfor %} |
180 {% if iterator_method %} | 159 {% if iterator_method %} |
181 {{generate_method(iterator_method)}} | 160 {{generate_method(iterator_method)}} |
182 {{method_callback(iterator_method)}} | 161 {{method_callback(iterator_method)}} |
183 {% endif %} | 162 {% endif %} |
184 {% block origin_safe_method_setter %}{% endblock %} | |
185 {# Constructors #} | 163 {# Constructors #} |
186 {% for constructor in constructors %} | 164 {% for constructor in constructors %} |
187 {{generate_constructor(constructor)}} | 165 {{generate_constructor(constructor)}} |
188 {% endfor %} | 166 {% endfor %} |
189 {% block overloaded_constructor %}{% endblock %} | 167 {% block overloaded_constructor %}{% endblock %} |
190 {% block event_constructor %}{% endblock %} | 168 {% block event_constructor %}{% endblock %} |
191 {# Special operations (methods) #} | 169 {# Special operations (methods) #} |
192 {% block named_property_getter %}{% endblock %} | 170 {% block named_property_getter %}{% endblock %} |
193 {% block named_property_getter_callback %}{% endblock %} | 171 {% block named_property_getter_callback %}{% endblock %} |
194 {% block named_property_setter %}{% endblock %} | 172 {% block named_property_setter %}{% endblock %} |
195 {% block named_property_setter_callback %}{% endblock %} | 173 {% block named_property_setter_callback %}{% endblock %} |
196 {% block named_property_deleter %}{% endblock %} | 174 {% block named_property_deleter %}{% endblock %} |
197 {% block named_property_deleter_callback %}{% endblock %} | 175 {% block named_property_deleter_callback %}{% endblock %} |
198 {% block named_property_query %}{% endblock %} | 176 {% block named_property_query %}{% endblock %} |
199 {% block named_property_query_callback %}{% endblock %} | 177 {% block named_property_query_callback %}{% endblock %} |
200 {% block named_property_enumerator %}{% endblock %} | 178 {% block named_property_enumerator %}{% endblock %} |
201 {% block named_property_enumerator_callback %}{% endblock %} | 179 {% block named_property_enumerator_callback %}{% endblock %} |
202 {% block indexed_property_getter %}{% endblock %} | 180 {% block indexed_property_getter %}{% endblock %} |
203 {% block indexed_property_getter_callback %}{% endblock %} | 181 {% block indexed_property_getter_callback %}{% endblock %} |
204 {% block indexed_property_setter %}{% endblock %} | 182 {% block indexed_property_setter %}{% endblock %} |
205 {% block indexed_property_setter_callback %}{% endblock %} | 183 {% block indexed_property_setter_callback %}{% endblock %} |
206 {% block indexed_property_deleter %}{% endblock %} | 184 {% block indexed_property_deleter %}{% endblock %} |
207 {% block indexed_property_deleter_callback %}{% endblock %} | 185 {% block indexed_property_deleter_callback %}{% endblock %} |
| 186 {##############################################################################} |
| 187 {% block security_check_functions %} |
| 188 {% if has_access_check_callbacks and not is_partial %} |
| 189 bool securityCheck(v8::Local<v8::Context> accessingContext, v8::Local<v8::Object
> accessedObject, v8::Local<v8::Value> data) { |
| 190 {% if interface_name == 'Window' %} |
| 191 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 192 v8::Local<v8::Object> window = V8Window::findInstanceInPrototypeChain(accessed
Object, isolate); |
| 193 if (window.IsEmpty()) |
| 194 return false; // the frame is gone. |
| 195 |
| 196 const DOMWindow* targetWindow = V8Window::toImpl(window); |
| 197 return BindingSecurity::shouldAllowAccessTo(toLocalDOMWindow(toDOMWindow(acces
singContext)), targetWindow, BindingSecurity::ErrorReportOption::DoNotReport); |
| 198 {% else %}{# if interface_name == 'Window' #} |
| 199 {# Not 'Window' means it\'s Location. #} |
| 200 {{cpp_class}}* impl = {{v8_class}}::toImpl(accessedObject); |
| 201 return BindingSecurity::shouldAllowAccessTo(toLocalDOMWindow(toDOMWindow(acces
singContext)), impl, BindingSecurity::ErrorReportOption::DoNotReport); |
| 202 {% endif %}{# if interface_name == 'Window' #} |
| 203 } |
| 204 |
| 205 {% if has_cross_origin_named_getter %} |
| 206 void crossOriginNamedGetter(v8::Local<v8::Name> name, const v8::PropertyCallback
Info<v8::Value>& info) { |
| 207 if (!name->IsString()) |
| 208 return; |
| 209 const AtomicString& propertyName = toCoreAtomicString(name.As<v8::String>()); |
| 210 |
| 211 // TODO(dcheng): Can we / should we use AtomicString here? That means using DE
FINE_STATIC_LOCAL here. |
| 212 static const struct AttributeInfo { |
| 213 const char* const name; |
| 214 using GetterCallback = void(*)(const v8::PropertyCallbackInfo<v8::Value>&); |
| 215 const GetterCallback getter; |
| 216 } kAttributeInfoList[] = { |
| 217 {##### Cross-origin attributes #####} |
| 218 {% for attribute in attributes if attribute.has_cross_origin_getter %} |
| 219 {"{{attribute.name}}", &{{cpp_class}}V8Internal::{{attribute.name}}Attribute
Getter}, |
| 220 {% endfor %} |
| 221 {##### Cross-origin methods #####} |
| 222 {% for method in methods if method.is_cross_origin %} |
| 223 {"{{method.name}}", &{{cpp_class}}V8Internal::{{method.name}}OriginSafeMetho
dGetter}, |
| 224 {% endfor %} |
| 225 }; |
| 226 |
| 227 for (const auto& attribute: kAttributeInfoList) { |
| 228 if (propertyName == attribute.name) { |
| 229 attribute.getter(info); |
| 230 return; |
| 231 } |
| 232 } |
| 233 |
| 234 {% if named_property_getter and named_property_getter.is_cross_origin %} |
| 235 {% if named_property_getter.is_custom %} |
| 236 {{v8_class}}::namedPropertyGetterCustom(propertyName, info); |
| 237 {% else %} |
| 238 {{cpp_class}}V8Internal::namedPropertyGetter(propertyName, info); |
| 239 {% endif %} |
| 240 {% endif %} |
| 241 } |
| 242 {% endif %} |
| 243 |
| 244 {% if has_cross_origin_named_setter %} |
| 245 void crossOriginNamedSetter(v8::Local<v8::Name> name, v8::Local<v8::Value> value
, const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 246 if (!name->IsString()) |
| 247 return; |
| 248 const AtomicString& propertyName = toCoreAtomicString(name.As<v8::String>()); |
| 249 |
| 250 // TODO(dcheng): Can we / should we use AtomicString here? That means using DE
FINE_STATIC_LOCAL here. |
| 251 static const struct AttributeInfo { |
| 252 const char* const name; |
| 253 using SetterCallback = void(*)(v8::Local<v8::Value>, const V8CrossOriginSett
erInfo&); |
| 254 const SetterCallback setter; |
| 255 } kAttributeInfoList[] = { |
| 256 {##### Cross-origin attributes #####} |
| 257 {% for attribute in attributes if attribute.has_cross_origin_setter %} |
| 258 {"{{attribute.name}}", &{{cpp_class}}V8Internal::{{attribute.name}}Attribute
Setter}, |
| 259 {% endfor %} |
| 260 }; |
| 261 |
| 262 for (const auto& attribute: kAttributeInfoList) { |
| 263 if (propertyName == attribute.name) { |
| 264 attribute.setter(value, V8CrossOriginSetterInfo(info.GetIsolate(), info.Ho
lder())); |
| 265 return; |
| 266 } |
| 267 } |
| 268 } |
| 269 {% endif %} |
| 270 |
| 271 {% if has_cross_origin_indexed_getter %} |
| 272 void crossOriginIndexedGetter(uint32_t index, const v8::PropertyCallbackInfo<v8:
:Value>& info) { |
| 273 {% if indexed_property_getter.is_custom %} |
| 274 {{v8_class}}::indexedPropertyGetterCustom(index, info); |
| 275 {% else %} |
| 276 {{cpp_class}}V8Internal::indexedPropertyGetter(index, info); |
| 277 {% endif %} |
| 278 } |
| 279 {% endif %} |
| 280 |
| 281 {% endif %} |
| 282 {% endblock %} |
| 283 {##############################################################################} |
208 } // namespace {{cpp_class_or_partial}}V8Internal | 284 } // namespace {{cpp_class_or_partial}}V8Internal |
209 | 285 |
210 {% block visit_dom_wrapper %}{% endblock %} | 286 {% block visit_dom_wrapper %}{% endblock %} |
211 {##############################################################################} | 287 {##############################################################################} |
212 {% block install_attributes %} | 288 {% block install_attributes %} |
213 {% from 'attributes.cpp.tmpl' import attribute_configuration with context %} | 289 {% from 'attributes.cpp.tmpl' import attribute_configuration with context %} |
214 {% if attributes | has_attribute_configuration %} | 290 {% if attributes | has_attribute_configuration %} |
215 // Suppress warning: global constructors, because AttributeConfiguration is triv
ial | 291 // Suppress warning: global constructors, because AttributeConfiguration is triv
ial |
216 // and does not depend on another global objects. | 292 // and does not depend on another global objects. |
217 #if defined(COMPONENT_BUILD) && defined(WIN32) && COMPILER(CLANG) | 293 #if defined(COMPONENT_BUILD) && defined(WIN32) && COMPILER(CLANG) |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 {% endif %} | 407 {% endif %} |
332 {% if attributes | has_accessor_configuration %} | 408 {% if attributes | has_accessor_configuration %} |
333 V8DOMConfiguration::installAccessors(isolate, world, instanceTemplate, prototy
peTemplate, interfaceTemplate, signature, {{'%sAccessors' % v8_class}}, {{'WTF_A
RRAY_LENGTH(%sAccessors)' % v8_class}}); | 409 V8DOMConfiguration::installAccessors(isolate, world, instanceTemplate, prototy
peTemplate, interfaceTemplate, signature, {{'%sAccessors' % v8_class}}, {{'WTF_A
RRAY_LENGTH(%sAccessors)' % v8_class}}); |
334 {% endif %} | 410 {% endif %} |
335 {% if methods | has_method_configuration(is_partial) %} | 411 {% if methods | has_method_configuration(is_partial) %} |
336 V8DOMConfiguration::installMethods(isolate, world, instanceTemplate, prototype
Template, interfaceTemplate, signature, {{'%sMethods' % v8_class}}, {{'WTF_ARRAY
_LENGTH(%sMethods)' % v8_class}}); | 412 V8DOMConfiguration::installMethods(isolate, world, instanceTemplate, prototype
Template, interfaceTemplate, signature, {{'%sMethods' % v8_class}}, {{'WTF_ARRAY
_LENGTH(%sMethods)' % v8_class}}); |
337 {% endif %} | 413 {% endif %} |
338 {% endfilter %} | 414 {% endfilter %} |
339 {%- if has_access_check_callbacks and not is_partial %}{{newline}} | 415 {%- if has_access_check_callbacks and not is_partial %}{{newline}} |
340 // Cross-origin access check | 416 // Cross-origin access check |
341 instanceTemplate->SetAccessCheckCallback({{cpp_class}}V8Internal::securityChec
k, v8::External::New(isolate, const_cast<WrapperTypeInfo*>(&{{v8_class}}::wrappe
rTypeInfo))); | 417 {% set cross_origin_named_getter = '%sV8Internal::crossOriginNamedGetter' % cp
p_class if has_cross_origin_named_getter else 'nullptr' %} |
| 418 {% set cross_origin_named_setter = '%sV8Internal::crossOriginNamedSetter' % cp
p_class if has_cross_origin_named_setter else 'nullptr' %} |
| 419 {% set cross_origin_indexed_getter = '%sV8Internal::crossOriginIndexedGetter'
% cpp_class if has_cross_origin_indexed_getter else 'nullptr' %} |
| 420 instanceTemplate->SetAccessCheckCallbackAndHandler({{cpp_class}}V8Internal::se
curityCheck, v8::NamedPropertyHandlerConfiguration({{cross_origin_named_getter}}
, {{cross_origin_named_setter}}), v8::IndexedPropertyHandlerConfiguration({{cros
s_origin_indexed_getter}}), v8::External::New(isolate, const_cast<WrapperTypeInf
o*>(&{{v8_class}}::wrapperTypeInfo))); |
342 {% endif %} | 421 {% endif %} |
343 | 422 |
344 {%- for group in attributes | purely_runtime_enabled_attributes | groupby('run
time_feature_name') %}{{newline}} | 423 {%- for group in attributes | purely_runtime_enabled_attributes | groupby('run
time_feature_name') %}{{newline}} |
345 if ({{group.list[0].runtime_enabled_function}}()) { | 424 if ({{group.list[0].runtime_enabled_function}}()) { |
346 {% for attribute in group.list | unique_by('name') | sort %} | 425 {% for attribute in group.list | unique_by('name') | sort %} |
347 {% if attribute.is_data_type_property %} | 426 {% if attribute.is_data_type_property %} |
348 const V8DOMConfiguration::AttributeConfiguration attribute{{attribute.name}}
Configuration = {{attribute_configuration(attribute)}}; | 427 const V8DOMConfiguration::AttributeConfiguration attribute{{attribute.name}}
Configuration = {{attribute_configuration(attribute)}}; |
349 V8DOMConfiguration::installAttribute(isolate, world, instanceTemplate, proto
typeTemplate, attribute{{attribute.name}}Configuration); | 428 V8DOMConfiguration::installAttribute(isolate, world, instanceTemplate, proto
typeTemplate, attribute{{attribute.name}}Configuration); |
350 {% else %} | 429 {% else %} |
351 const V8DOMConfiguration::AccessorConfiguration accessor{{attribute.name}}Co
nfiguration = {{attribute_configuration(attribute)}}; | 430 const V8DOMConfiguration::AccessorConfiguration accessor{{attribute.name}}Co
nfiguration = {{attribute_configuration(attribute)}}; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 instanceTemplate->MarkAsUndetectable(); | 467 instanceTemplate->MarkAsUndetectable(); |
389 {% endif %} | 468 {% endif %} |
390 | 469 |
391 {%- if methods | custom_registration(is_partial) %}{{newline}} | 470 {%- if methods | custom_registration(is_partial) %}{{newline}} |
392 {% for method in methods | custom_registration(is_partial) %} | 471 {% for method in methods | custom_registration(is_partial) %} |
393 {# install_custom_signature #} | 472 {# install_custom_signature #} |
394 {% filter exposed(method.overloads.exposed_test_all | 473 {% filter exposed(method.overloads.exposed_test_all |
395 if method.overloads else method.exposed_test) %} | 474 if method.overloads else method.exposed_test) %} |
396 {% filter runtime_enabled(method.overloads.runtime_enabled_function_all | 475 {% filter runtime_enabled(method.overloads.runtime_enabled_function_all |
397 if method.overloads else method.runtime_enabled_func
tion) %} | 476 if method.overloads else method.runtime_enabled_func
tion) %} |
398 {% if method.is_do_not_check_security %} | 477 {% if method.is_cross_origin %} |
399 {{install_do_not_check_security_method(method, '', 'instanceTemplate', 'protot
ypeTemplate') | indent(2)}} | 478 {# TODO(dcheng): This shouldn't be necessary with cross-origin interceptors, |
| 479 but v8 doesn't support querying the incumbent context. For now, always |
| 480 incorrectly create per-realm representations. #} |
| 481 {{install_origin_safe_method(method, '', 'instanceTemplate', 'prototypeTemplat
e') | indent(2)}} |
400 {% else %} | 482 {% else %} |
401 {{install_custom_signature(method, 'instanceTemplate', 'prototypeTemplate', 'i
nterfaceTemplate', 'signature') | indent(2)}} | 483 {{install_custom_signature(method, 'instanceTemplate', 'prototypeTemplate', 'i
nterfaceTemplate', 'signature') | indent(2)}} |
402 {% endif %} | 484 {% endif %} |
403 {% endfilter %} | 485 {% endfilter %} |
404 {% endfilter %} | 486 {% endfilter %} |
405 {% endfor %} | 487 {% endfor %} |
406 {% endif %} | 488 {% endif %} |
407 } | 489 } |
408 | 490 |
409 {% endif %}{# not is_array_buffer_or_view #} | 491 {% endif %}{# not is_array_buffer_or_view #} |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 {% for attribute in attributes if attribute.is_implemented_in_private_script %} | 557 {% for attribute in attributes if attribute.is_implemented_in_private_script %} |
476 {{attribute_getter_implemented_in_private_script(attribute)}} | 558 {{attribute_getter_implemented_in_private_script(attribute)}} |
477 {% if attribute.has_setter %} | 559 {% if attribute.has_setter %} |
478 {{attribute_setter_implemented_in_private_script(attribute)}} | 560 {{attribute_setter_implemented_in_private_script(attribute)}} |
479 {% endif %} | 561 {% endif %} |
480 {% endfor %} | 562 {% endfor %} |
481 {% block partial_interface %}{% endblock %} | 563 {% block partial_interface %}{% endblock %} |
482 } // namespace blink | 564 } // namespace blink |
483 | 565 |
484 {% endfilter %}{# format_blink_cpp_source_code #} | 566 {% endfilter %}{# format_blink_cpp_source_code #} |
OLD | NEW |