| 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 = |
| 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) %} |
| 11 {% set getter_callback_name_for_main_world = | 11 {% set getter_callback_for_main_world = |
| 12 '%sV8Internal::%sAttributeGetterCallbackForMainWorld' % | 12 '%sV8Internal::%sAttributeGetterCallbackForMainWorld' % |
| 13 (interface_name, attribute.name) | 13 (interface_name, attribute.name) |
| 14 if attribute.is_per_world_bindings else '0' %} | 14 if attribute.is_per_world_bindings else '0' %} |
| 15 {% set setter_callback_name = attribute.setter_callback_name %} | 15 {% set setter_callback = attribute.setter_callback %} |
| 16 {% set setter_callback_name_for_main_world = | 16 {% set setter_callback_for_main_world = |
| 17 '%sV8Internal::%sAttributeSetterCallbackForMainWorld' % | 17 '%sV8Internal::%sAttributeSetterCallbackForMainWorld' % |
| 18 (interface_name, attribute.name) | 18 (interface_name, attribute.name) |
| 19 if attribute.is_per_world_bindings and not attribute.is_read_only else '0
' %} | 19 if attribute.is_per_world_bindings and not attribute.is_read_only else '0
' %} |
| 20 {% set wrapper_type_info = | 20 {% set wrapper_type_info = |
| 21 'const_cast<WrapperTypeInfo*>(&V8%s::wrapperTypeInfo)' % | 21 'const_cast<WrapperTypeInfo*>(&V8%s::wrapperTypeInfo)' % |
| 22 attribute.constructor_type | 22 attribute.constructor_type |
| 23 if attribute.constructor_type else '0' %} | 23 if attribute.constructor_type else '0' %} |
| 24 {% set access_control = 'static_cast<v8::AccessControl>(%s)' % | 24 {% set access_control = 'static_cast<v8::AccessControl>(%s)' % |
| 25 ' | '.join(attribute.access_control_list) %} | 25 ' | '.join(attribute.access_control_list) %} |
| 26 {% set property_attribute = 'static_cast<v8::PropertyAttribute>(%s)' % | 26 {% set property_attribute = 'static_cast<v8::PropertyAttribute>(%s)' % |
| 27 ' | '.join(attribute.property_attributes) %} | 27 ' | '.join(attribute.property_attributes) %} |
| 28 {% set on_prototype = ', 0 /* on instance */' | 28 {% set on_prototype = ', 0 /* on instance */' |
| 29 if not attribute.is_expose_js_accessors else '' %} | 29 if not attribute.is_expose_js_accessors else '' %} |
| 30 {"{{attribute.name}}", {{getter_callback_name}}, {{setter_callback_name}}, {{get
ter_callback_name_for_main_world}}, {{setter_callback_name_for_main_world}}, {{w
rapper_type_info}}, {{access_control}}, {{property_attribute}}{{on_prototype}}} | 30 {"{{attribute.name}}", {{getter_callback}}, {{setter_callback}}, {{getter_callba
ck_for_main_world}}, {{setter_callback_for_main_world}}, {{wrapper_type_info}},
{{access_control}}, {{property_attribute}}{{on_prototype}}} |
| 31 {%- endmacro %} | 31 {%- endmacro %} |
| 32 | 32 |
| 33 | 33 |
| 34 {##############################################################################} | 34 {##############################################################################} |
| 35 {% macro method_configuration(method) %} | 35 {% macro method_configuration(method) %} |
| 36 {% set method_callback_name = | 36 {% set method_callback = |
| 37 '%sV8Internal::%sMethodCallback' % (interface_name, method.name) %} | 37 '%sV8Internal::%sMethodCallback' % (interface_name, method.name) %} |
| 38 {% set method_callback_name_for_main_world = | 38 {% set method_callback_for_main_world = |
| 39 '%sV8Internal::%sMethodCallbackForMainWorld' % (interface_name, method.name) | 39 '%sV8Internal::%sMethodCallbackForMainWorld' % (interface_name, method.name) |
| 40 if method.is_per_world_bindings else '0' %} | 40 if method.is_per_world_bindings else '0' %} |
| 41 {"{{method.name}}", {{method_callback_name}}, {{method_callback_name_for_main_wo
rld}}, {{method.number_of_required_or_variadic_arguments}}} | 41 {"{{method.name}}", {{method_callback}}, {{method_callback_for_main_world}}, {{m
ethod.number_of_required_or_variadic_arguments}}} |
| 42 {%- endmacro %} | 42 {%- endmacro %} |
| 43 | 43 |
| 44 | 44 |
| 45 {##############################################################################} | 45 {##############################################################################} |
| 46 {% block constructor_getter %} | 46 {% block constructor_getter %} |
| 47 {% if has_constructor_attributes %} | 47 {% if has_constructor_attributes %} |
| 48 static void {{interface_name}}ConstructorGetter(v8::Local<v8::String>, const v8:
:PropertyCallbackInfo<v8::Value>& info) | 48 static void {{interface_name}}ConstructorGetter(v8::Local<v8::String>, const v8:
:PropertyCallbackInfo<v8::Value>& info) |
| 49 { | 49 { |
| 50 v8::Handle<v8::Value> data = info.Data(); | 50 v8::Handle<v8::Value> data = info.Data(); |
| 51 ASSERT(data->IsExternal()); | 51 ASSERT(data->IsExternal()); |
| (...skipping 39 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 origin_safe_method_setter %} |
| 102 {% if has_origin_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 {# FIXME: don't call GetIsolate 3 times #} |
| 106 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain({{
v8_class_name}}::GetTemplate(info.GetIsolate(), worldType(info.GetIsolate()))); |
| 107 if (holder.IsEmpty()) |
| 108 return; |
| 109 {{cpp_class_name}}* imp = {{v8_class_name}}::toNative(holder); |
| 110 ExceptionState exceptionState(info.Holder(), info.GetIsolate()); |
| 111 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), exceptionState)
) { |
| 112 exceptionState.throwIfNeeded(); |
| 113 return; |
| 114 } |
| 115 |
| 116 info.This()->SetHiddenValue(name, jsValue); |
| 117 } |
| 118 |
| 119 static void {{cpp_class_name}}OriginSafeMethodSetterCallback(v8::Local<v8::Strin
g> name, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& inf
o) |
| 120 { |
| 121 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter"); |
| 122 {{cpp_class_name}}V8Internal::{{cpp_class_name}}OriginSafeMethodSetter(name,
jsValue, info); |
| 123 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); |
| 124 } |
| 125 |
| 126 {% endif %} |
| 127 {% endblock %} |
| 128 |
| 129 |
| 130 {##############################################################################} |
| 101 {% block class_attributes %} | 131 {% block class_attributes %} |
| 102 {# FIXME: rename to install_attributes and put into configure_class_template #} | 132 {# FIXME: rename to install_attributes and put into configure_class_template #} |
| 103 {% if attributes %} | 133 {% if attributes %} |
| 104 static const V8DOMConfiguration::AttributeConfiguration {{v8_class_name}}Attribu
tes[] = { | 134 static const V8DOMConfiguration::AttributeConfiguration {{v8_class_name}}Attribu
tes[] = { |
| 105 {% for attribute in attributes | 135 {% for attribute in attributes |
| 106 if not (attribute.is_expose_js_accessors or | 136 if not (attribute.is_expose_js_accessors or |
| 107 attribute.is_static or | 137 attribute.is_static or |
| 108 attribute.runtime_enabled_function_name or | 138 attribute.runtime_enabled_function_name or |
| 109 attribute.per_context_enabled_function_name) %} | 139 attribute.per_context_enabled_function_name) %} |
| 110 {% filter conditional(attribute.conditional_string) %} | 140 {% filter conditional(attribute.conditional_string) %} |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 | 227 |
| 198 // Custom Signature '{{method.name}}' | 228 // Custom Signature '{{method.name}}' |
| 199 const int {{method.name}}Argc = {{method.arguments | length}}; | 229 const int {{method.name}}Argc = {{method.arguments | length}}; |
| 200 v8::Handle<v8::FunctionTemplate> {{method.name}}Argv[{{method.name}}Argc] =
{ {{method.custom_signature}} }; | 230 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); | 231 v8::Handle<v8::Signature> {{method.name}}Signature = v8::Signature::New(func
tionTemplate, {{method.name}}Argc, {{method.name}}Argv); |
| 202 {% endif %} | 232 {% endif %} |
| 203 {# install_custom_signature #} | 233 {# install_custom_signature #} |
| 204 {% if not method.overload_index or method.overload_index == 1 %} | 234 {% if not method.overload_index or method.overload_index == 1 %} |
| 205 {# For overloaded methods, only generate one accessor #} | 235 {# For overloaded methods, only generate one accessor #} |
| 206 {% filter conditional(method.conditional_string) %} | 236 {% filter conditional(method.conditional_string) %} |
| 237 {% if method.is_do_not_check_security %} |
| 238 {% if method.is_per_world_bindings %} |
| 239 if (currentWorldType == MainWorld) { |
| 240 {{install_do_not_check_security_signature(method, 'ForMainWorld')}} |
| 241 } else { |
| 242 {{install_do_not_check_security_signature(method)}} |
| 243 } |
| 244 {% else %} |
| 245 {{install_do_not_check_security_signature(method)}} |
| 246 {% endif %} |
| 247 {% else %}{# is_do_not_check_security #} |
| 207 {% if method.is_per_world_bindings %} | 248 {% if method.is_per_world_bindings %} |
| 208 if (currentWorldType == MainWorld) { | 249 if (currentWorldType == MainWorld) { |
| 209 {% filter runtime_enabled(method.runtime_enabled_function_name) %} | 250 {% filter runtime_enabled(method.runtime_enabled_function_name) %} |
| 210 {{install_custom_signature(method, 'ForMainWorld')}} | 251 {{install_custom_signature(method, 'ForMainWorld')}} |
| 211 {% endfilter %} | 252 {% endfilter %} |
| 212 } else { | 253 } else { |
| 213 {% filter runtime_enabled(method.runtime_enabled_function_name) %} | 254 {% filter runtime_enabled(method.runtime_enabled_function_name) %} |
| 214 {{install_custom_signature(method)}} | 255 {{install_custom_signature(method)}} |
| 215 {% endfilter %} | 256 {% endfilter %} |
| 216 } | 257 } |
| 217 {% else %} | 258 {% else %} |
| 218 {% filter runtime_enabled(method.runtime_enabled_function_name) %} | 259 {% filter runtime_enabled(method.runtime_enabled_function_name) %} |
| 219 {{install_custom_signature(method)}} | 260 {{install_custom_signature(method)}} |
| 220 {% endfilter %} | 261 {% endfilter %} |
| 221 {% endif %} | 262 {% endif %} |
| 263 {% endif %}{# is_do_not_check_security #} |
| 222 {% endfilter %} | 264 {% endfilter %} |
| 223 {% endif %}{# install_custom_signature #} | 265 {% endif %}{# install_custom_signature #} |
| 224 {% endfor %} | 266 {% endfor %} |
| 225 {% for attribute in attributes if attribute.is_static %} | 267 {% for attribute in attributes if attribute.is_static %} |
| 226 {% set getter_callback_name = '%sV8Internal::%sAttributeGetterCallback' % | 268 {% set getter_callback = '%sV8Internal::%sAttributeGetterCallback' % |
| 227 (interface_name, attribute.name) %} | 269 (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)); | 270 functionTemplate->SetNativeDataProperty(v8::String::NewSymbol("{{attribute.n
ame}}"), {{getter_callback}}, {{attribute.setter_callback}}, v8::External::New(i
solate, 0), static_cast<v8::PropertyAttribute>(v8::None), v8::Handle<v8::Accesso
rSignature>(), static_cast<v8::AccessControl>(v8::DEFAULT)); |
| 229 {% endfor %} | 271 {% endfor %} |
| 230 {% if constants %} | 272 {% if constants %} |
| 231 {{install_constants() | indent}} | 273 {{install_constants() | indent}} |
| 232 {% endif %} | 274 {% endif %} |
| 233 {% if has_custom_legacy_call %} | 275 {% if has_custom_legacy_call %} |
| 234 functionTemplate->InstanceTemplate()->SetCallAsFunctionHandler({{v8_class_na
me}}::legacyCallCustom); | 276 functionTemplate->InstanceTemplate()->SetCallAsFunctionHandler({{v8_class_na
me}}::legacyCallCustom); |
| 235 {% endif %} | 277 {% endif %} |
| 236 | 278 |
| 237 // Custom toString template | 279 // Custom toString template |
| 238 functionTemplate->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::c
urrent()->toStringTemplate()); | 280 functionTemplate->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::c
urrent()->toStringTemplate()); |
| 239 return functionTemplate; | 281 return functionTemplate; |
| 240 } | 282 } |
| 241 | 283 |
| 242 {% endblock %} | 284 {% endblock %} |
| 243 | 285 |
| 244 | 286 |
| 245 {######################################} | 287 {######################################} |
| 288 {% macro install_do_not_check_security_signature(method, world_suffix) %} |
| 289 {# FIXME: move to V8DOMConfiguration::installDOMCallbacksWithDoNotCheckSecurityS
ignature #} |
| 290 {# Methods that are [DoNotCheckSecurity] are always readable, but if they are |
| 291 changed and then accessed from a different origin, we do not return the |
| 292 underlying value, but instead return a new copy of the original function. |
| 293 This is achieved by storing the changed value as a hidden property. #} |
| 294 {% set getter_callback = |
| 295 '%sV8Internal::%sOriginSafeMethodGetterCallback%s' % |
| 296 (cpp_class_name, method.name, world_suffix) %} |
| 297 {% set setter_callback = |
| 298 '{0}V8Internal::{0}OriginSafeMethodSetterCallback'.format(cpp_class_name) |
| 299 if not method.is_read_only else '0' %} |
| 300 {% set property_attribute = |
| 301 'static_cast<v8::PropertyAttribute>(%s)' % |
| 302 ' | '.join(method.property_attributes or ['v8::DontDelete']) %} |
| 303 {{method.function_template}}->SetAccessor(v8::String::NewSymbol("{{method.name}}
"), {{getter_callback}}, {{setter_callback}}, v8Undefined(), v8::ALL_CAN_READ, {
{property_attribute}}); |
| 304 {%- endmacro %} |
| 305 |
| 306 |
| 307 {######################################} |
| 246 {% macro install_custom_signature(method, world_suffix) %} | 308 {% macro install_custom_signature(method, world_suffix) %} |
| 247 {# FIXME: move to V8DOMConfiguration::installDOMCallbacksWithCustomSignature #} | 309 {# FIXME: move to V8DOMConfiguration::installDOMCallbacksWithCustomSignature #} |
| 248 {% set callback_name = '%sV8Internal::%sMethodCallback%s' % | 310 {% set method_callback = '%sV8Internal::%sMethodCallback%s' % |
| 249 (interface_name, method.name, world_suffix) %} | 311 (interface_name, method.name, world_suffix) %} |
| 250 {% set property_attribute = 'static_cast<v8::PropertyAttribute>(%s)' % | 312 {% set property_attribute = 'static_cast<v8::PropertyAttribute>(%s)' % |
| 251 ' | '.join(method.property_attributes) %} | 313 ' | '.join(method.property_attributes) %} |
| 252 {{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 %}); | 314 {{method.function_template}}->Set(v8::String::NewSymbol("{{method.name}}"), v8::
FunctionTemplate::New({{method_callback}}, v8Undefined(), {{method.signature}},
{{method.number_of_required_or_variadic_arguments}}){% if method.property_attrib
utes %}, {{property_attribute}}{% endif %}); |
| 253 {%- endmacro %} | 315 {%- endmacro %} |
| 254 | 316 |
| 255 | 317 |
| 256 {######################################} | 318 {######################################} |
| 257 {% macro install_constants() %} | 319 {% macro install_constants() %} |
| 258 {# FIXME: should use reflected_name instead of name #} | 320 {# FIXME: should use reflected_name instead of name #} |
| 259 {# Normal (always enabled) constants #} | 321 {# Normal (always enabled) constants #} |
| 260 static const V8DOMConfiguration::ConstantConfiguration {{v8_class_name}}Constant
s[] = { | 322 static const V8DOMConfiguration::ConstantConfiguration {{v8_class_name}}Constant
s[] = { |
| 261 {% for constant in constants if not constant.runtime_enabled_function_name %
} | 323 {% for constant in constants if not constant.runtime_enabled_function_name %
} |
| 262 {"{{constant.name}}", {{constant.value}}}, | 324 {"{{constant.name}}", {{constant.value}}}, |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 V8DOMWrapper::associateObjectWithWrapper<{{v8_class_name}}>(impl, &wrapperTy
peInfo, wrapper, isolate, {{wrapper_configuration}}); | 457 V8DOMWrapper::associateObjectWithWrapper<{{v8_class_name}}>(impl, &wrapperTy
peInfo, wrapper, isolate, {{wrapper_configuration}}); |
| 396 return wrapper; | 458 return wrapper; |
| 397 } | 459 } |
| 398 | 460 |
| 399 void {{v8_class_name}}::derefObject(void* object) | 461 void {{v8_class_name}}::derefObject(void* object) |
| 400 { | 462 { |
| 401 fromInternalPointer(object)->deref(); | 463 fromInternalPointer(object)->deref(); |
| 402 } | 464 } |
| 403 | 465 |
| 404 {% endblock %} | 466 {% endblock %} |
| OLD | NEW |