Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 {% extends 'interface_base.cpp' %} | 1 {% extends 'interface_base.cpp' %} |
| 2 | 2 |
| 3 | 3 |
| 4 {##############################################################################} | 4 {##############################################################################} |
| 5 {% macro attribute_configuration(attribute) %} | 5 {% macro attribute_configuration(attribute) %} |
| 6 {% set getter_callback_name = | 6 {% set getter_callback_name = |
| 7 '%sV8Internal::%sAttributeGetterCallback' % | 7 '%sV8Internal::%sAttributeGetterCallback' % |
| 8 (interface_name, attribute.name) | 8 (interface_name, attribute.name) |
| 9 if not attribute.constructor_type else | 9 if not attribute.constructor_type else |
| 10 '{0}V8Internal::{0}ConstructorGetter'.format(interface_name) %} | 10 '{0}V8Internal::{0}ConstructorGetter'.format(interface_name) %} |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 91 { | 91 { |
| 92 {{cpp_class_name}}* imp = {{v8_class_name}}::toNative(host); | 92 {{cpp_class_name}}* imp = {{v8_class_name}}::toNative(host); |
| 93 return BindingSecurity::shouldAllowAccessToFrame(imp->frame(), DoNotReportSe curityError); | 93 return BindingSecurity::shouldAllowAccessToFrame(imp->frame(), DoNotReportSe curityError); |
| 94 } | 94 } |
| 95 | 95 |
| 96 {% endif %} | 96 {% endif %} |
| 97 {% endblock %} | 97 {% endblock %} |
| 98 | 98 |
| 99 | 99 |
| 100 {##############################################################################} | 100 {##############################################################################} |
| 101 {% block domain_safe_method_setter %} | |
|
haraken
2013/11/21 10:13:05
domain_safe_method_setter => origin_safe_method_se
| |
| 102 {% if has_domain_safe_method_setter %} | |
| 103 static void {{cpp_class_name}}OriginSafeMethodSetter(v8::Local<v8::String> name, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info) | |
| 104 { | |
| 105 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain({{ v8_class_name}}::GetTemplate(info.GetIsolate(), worldType(info.GetIsolate()))); | |
| 106 if (holder.IsEmpty()) | |
| 107 return; | |
| 108 {{cpp_class_name}}* imp = {{v8_class_name}}::toNative(holder); | |
| 109 ExceptionState exceptionState(info.Holder(), info.GetIsolate()); | |
|
haraken
2013/11/21 10:13:05
Nit: You want to avoid calling info.GetIsolate() t
Nils Barth (inactive)
2013/11/22 03:17:52
Can I just add:
v8::Isolate isolate = info.GetIsol
haraken
2013/11/22 05:53:26
Yes. We're doing it in a lot of places.
Nils Barth (inactive)
2013/11/22 06:04:05
Got it; will throughout in one followup.
| |
| 110 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), exceptionState) ) { | |
| 111 exceptionState.throwIfNeeded(); | |
| 112 return; | |
| 113 } | |
| 114 | |
| 115 info.This()->SetHiddenValue(name, jsValue); | |
| 116 } | |
| 117 | |
| 118 static void {{cpp_class_name}}OriginSafeMethodSetterCallback(v8::Local<v8::Strin g> name, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& inf o) | |
| 119 { | |
| 120 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter"); | |
| 121 {{cpp_class_name}}V8Internal::{{cpp_class_name}}OriginSafeMethodSetter(name, jsValue, info); | |
| 122 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); | |
| 123 } | |
| 124 | |
| 125 {% endif %} | |
| 126 {% endblock %} | |
| 127 | |
| 128 | |
| 129 {##############################################################################} | |
| 101 {% block class_attributes %} | 130 {% block class_attributes %} |
| 102 {# FIXME: rename to install_attributes and put into configure_class_template #} | 131 {# FIXME: rename to install_attributes and put into configure_class_template #} |
| 103 {% if attributes %} | 132 {% if attributes %} |
| 104 static const V8DOMConfiguration::AttributeConfiguration {{v8_class_name}}Attribu tes[] = { | 133 static const V8DOMConfiguration::AttributeConfiguration {{v8_class_name}}Attribu tes[] = { |
| 105 {% for attribute in attributes | 134 {% for attribute in attributes |
| 106 if not (attribute.is_expose_js_accessors or | 135 if not (attribute.is_expose_js_accessors or |
| 107 attribute.is_static or | 136 attribute.is_static or |
| 108 attribute.runtime_enabled_function_name or | 137 attribute.runtime_enabled_function_name or |
| 109 attribute.per_context_enabled_function_name) %} | 138 attribute.per_context_enabled_function_name) %} |
| 110 {% filter conditional(attribute.conditional_string) %} | 139 {% filter conditional(attribute.conditional_string) %} |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 197 | 226 |
| 198 // Custom Signature '{{method.name}}' | 227 // Custom Signature '{{method.name}}' |
| 199 const int {{method.name}}Argc = {{method.arguments | length}}; | 228 const int {{method.name}}Argc = {{method.arguments | length}}; |
| 200 v8::Handle<v8::FunctionTemplate> {{method.name}}Argv[{{method.name}}Argc] = { {{method.custom_signature}} }; | 229 v8::Handle<v8::FunctionTemplate> {{method.name}}Argv[{{method.name}}Argc] = { {{method.custom_signature}} }; |
| 201 v8::Handle<v8::Signature> {{method.name}}Signature = v8::Signature::New(func tionTemplate, {{method.name}}Argc, {{method.name}}Argv); | 230 v8::Handle<v8::Signature> {{method.name}}Signature = v8::Signature::New(func tionTemplate, {{method.name}}Argc, {{method.name}}Argv); |
| 202 {% endif %} | 231 {% endif %} |
| 203 {# install_custom_signature #} | 232 {# install_custom_signature #} |
| 204 {% if not method.overload_index or method.overload_index == 1 %} | 233 {% if not method.overload_index or method.overload_index == 1 %} |
| 205 {# For overloaded methods, only generate one accessor #} | 234 {# For overloaded methods, only generate one accessor #} |
| 206 {% filter conditional(method.conditional_string) %} | 235 {% filter conditional(method.conditional_string) %} |
| 236 {% if method.is_do_not_check_security %} | |
| 237 {% if method.is_per_world_bindings %} | |
| 238 if (currentWorldType == MainWorld) { | |
| 239 {{install_do_not_check_security_signature(method, 'ForMainWorld')}} | |
| 240 } else { | |
| 241 {{install_do_not_check_security_signature(method)}} | |
| 242 } | |
| 243 {% else %} | |
| 244 {{install_do_not_check_security_signature(method)}} | |
| 245 {% endif %} | |
| 246 {% else %}{# is_do_not_check_security #} | |
| 207 {% if method.is_per_world_bindings %} | 247 {% if method.is_per_world_bindings %} |
| 208 if (currentWorldType == MainWorld) { | 248 if (currentWorldType == MainWorld) { |
| 209 {% filter runtime_enabled(method.runtime_enabled_function_name) %} | 249 {% filter runtime_enabled(method.runtime_enabled_function_name) %} |
| 210 {{install_custom_signature(method, 'ForMainWorld')}} | 250 {{install_custom_signature(method, 'ForMainWorld')}} |
| 211 {% endfilter %} | 251 {% endfilter %} |
| 212 } else { | 252 } else { |
| 213 {% filter runtime_enabled(method.runtime_enabled_function_name) %} | 253 {% filter runtime_enabled(method.runtime_enabled_function_name) %} |
| 214 {{install_custom_signature(method)}} | 254 {{install_custom_signature(method)}} |
| 215 {% endfilter %} | 255 {% endfilter %} |
| 216 } | 256 } |
| 217 {% else %} | 257 {% else %} |
| 218 {% filter runtime_enabled(method.runtime_enabled_function_name) %} | 258 {% filter runtime_enabled(method.runtime_enabled_function_name) %} |
| 219 {{install_custom_signature(method)}} | 259 {{install_custom_signature(method)}} |
| 220 {% endfilter %} | 260 {% endfilter %} |
| 221 {% endif %} | 261 {% endif %} |
| 262 {% endif %}{# is_do_not_check_security #} | |
| 222 {% endfilter %} | 263 {% endfilter %} |
| 223 {% endif %}{# install_custom_signature #} | 264 {% endif %}{# install_custom_signature #} |
| 224 {% endfor %} | 265 {% endfor %} |
| 225 {% for attribute in attributes if attribute.is_static %} | 266 {% for attribute in attributes if attribute.is_static %} |
| 226 {% set getter_callback_name = '%sV8Internal::%sAttributeGetterCallback' % | 267 {% set getter_callback_name = '%sV8Internal::%sAttributeGetterCallback' % |
| 227 (interface_name, attribute.name) %} | 268 (interface_name, attribute.name) %} |
| 228 functionTemplate->SetNativeDataProperty(v8::String::NewSymbol("{{attribute.n ame}}"), {{getter_callback_name}}, {{attribute.setter_callback_name}}, v8::Exter nal::New(isolate, 0), static_cast<v8::PropertyAttribute>(v8::None), v8::Handle<v 8::AccessorSignature>(), static_cast<v8::AccessControl>(v8::DEFAULT)); | 269 functionTemplate->SetNativeDataProperty(v8::String::NewSymbol("{{attribute.n ame}}"), {{getter_callback_name}}, {{attribute.setter_callback_name}}, v8::Exter nal::New(isolate, 0), static_cast<v8::PropertyAttribute>(v8::None), v8::Handle<v 8::AccessorSignature>(), static_cast<v8::AccessControl>(v8::DEFAULT)); |
| 229 {% endfor %} | 270 {% endfor %} |
| 230 {% if constants %} | 271 {% if constants %} |
| 231 {{install_constants() | indent}} | 272 {{install_constants() | indent}} |
| 232 {% endif %} | 273 {% endif %} |
| 233 | 274 |
| 234 // Custom toString template | 275 // Custom toString template |
| 235 functionTemplate->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::c urrent()->toStringTemplate()); | 276 functionTemplate->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::c urrent()->toStringTemplate()); |
| 236 return functionTemplate; | 277 return functionTemplate; |
| 237 } | 278 } |
| 238 | 279 |
| 239 {% endblock %} | 280 {% endblock %} |
| 240 | 281 |
| 241 | 282 |
| 242 {######################################} | 283 {######################################} |
| 284 {% macro install_do_not_check_security_signature(method, world_suffix) %} | |
| 285 {# FIXME: move to V8DOMConfiguration::installDOMCallbacksWithDoNotCheckSecurityS ignature #} | |
| 286 {# Methods that are [DoNotCheckSecurity] are always readable, but if they are | |
| 287 changed and then accessed on a different domain, we do not return the | |
|
haraken
2013/11/21 10:13:05
domain => origin
| |
| 288 underlying value, but instead return a new copy of the original function. | |
| 289 This is achieved by storing the changed value as a hidden property. #} | |
| 290 {% set callback_name = '%sV8Internal::%sOriginSafeMethodGetterCallback%s' % | |
|
haraken
2013/11/21 10:13:05
callback_name => getter_callback
Nils Barth (inactive)
2013/11/22 03:17:52
Done.
Also renamed callback_name => callback throu
haraken
2013/11/22 05:53:26
Either is fine with me as long as it's consistent
Nils Barth (inactive)
2013/11/22 06:04:05
Got it; will do in followup.
| |
| 291 (cpp_class_name, method.name, world_suffix) %} | |
| 292 {% set setter = | |
|
haraken
2013/11/21 10:13:05
setter => setter_callback
Nils Barth (inactive)
2013/11/22 03:17:52
Done.
| |
| 293 '{0}V8Internal::{0}OriginSafeMethodSetterCallback'.format(cpp_class_name) | |
| 294 if not method.is_read_only else '0' %} | |
| 295 {% set property_attribute = | |
| 296 'static_cast<v8::PropertyAttribute>(%s)' % | |
| 297 ' | '.join(method.property_attributes or ['v8::DontDelete']) %} | |
| 298 {{method.function_template}}->SetAccessor(v8::String::NewSymbol("{{method.name}} "), {{callback_name}}, {{setter}}, v8Undefined(), v8::ALL_CAN_READ, {{property_a ttribute}}); | |
| 299 {%- endmacro %} | |
| 300 | |
| 301 | |
| 302 {######################################} | |
| 243 {% macro install_custom_signature(method, world_suffix) %} | 303 {% macro install_custom_signature(method, world_suffix) %} |
| 244 {# FIXME: move to V8DOMConfiguration::installDOMCallbacksWithCustomSignature #} | 304 {# FIXME: move to V8DOMConfiguration::installDOMCallbacksWithCustomSignature #} |
| 245 {% set callback_name = '%sV8Internal::%sMethodCallback%s' % | 305 {% set callback_name = '%sV8Internal::%sMethodCallback%s' % |
| 246 (interface_name, method.name, world_suffix) %} | 306 (interface_name, method.name, world_suffix) %} |
| 247 {% set property_attribute = 'static_cast<v8::PropertyAttribute>(%s)' % | 307 {% set property_attribute = 'static_cast<v8::PropertyAttribute>(%s)' % |
| 248 ' | '.join(method.property_attributes) %} | 308 ' | '.join(method.property_attributes) %} |
| 249 {{method.function_template}}->Set(v8::String::NewSymbol("{{method.name}}"), v8:: FunctionTemplate::New({{callback_name}}, v8Undefined(), {{method.signature}}, {{ method.number_of_required_or_variadic_arguments}}){% if method.property_attribut es %}, {{property_attribute}}{% endif %}); | 309 {{method.function_template}}->Set(v8::String::NewSymbol("{{method.name}}"), v8:: FunctionTemplate::New({{callback_name}}, v8Undefined(), {{method.signature}}, {{ method.number_of_required_or_variadic_arguments}}){% if method.property_attribut es %}, {{property_attribute}}{% endif %}); |
| 250 {%- endmacro %} | 310 {%- endmacro %} |
| 251 | 311 |
| 252 | 312 |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 390 V8DOMWrapper::associateObjectWithWrapper<{{v8_class_name}}>(impl, &wrapperTy peInfo, wrapper, isolate, {{wrapper_configuration}}); | 450 V8DOMWrapper::associateObjectWithWrapper<{{v8_class_name}}>(impl, &wrapperTy peInfo, wrapper, isolate, {{wrapper_configuration}}); |
| 391 return wrapper; | 451 return wrapper; |
| 392 } | 452 } |
| 393 | 453 |
| 394 void {{v8_class_name}}::derefObject(void* object) | 454 void {{v8_class_name}}::derefObject(void* object) |
| 395 { | 455 { |
| 396 fromInternalPointer(object)->deref(); | 456 fromInternalPointer(object)->deref(); |
| 397 } | 457 } |
| 398 | 458 |
| 399 {% endblock %} | 459 {% endblock %} |
| OLD | NEW |