| 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 { |
| 11 {% set dom_template = '%s::domTemplate' % v8_class if not is_array_buffer_or_vie
w else '0' %} | 11 {% set dom_template = '%s::domTemplate' % v8_class if not is_array_buffer_or_vie
w else '0' %} |
| 12 {% set has_prepare_prototype_and_interface_object = | 12 {% set has_prepare_prototype_and_interface_object = |
| 13 unscopables or has_conditional_attributes_on_prototype or | 13 unscopables or has_conditional_attributes_on_prototype or |
| 14 methods | conditionally_exposed(is_partial) %} | 14 methods | conditionally_exposed(is_partial) %} |
| 15 {% set prepare_prototype_and_interface_object_func = | 15 {% set prepare_prototype_and_interface_object_func = |
| 16 '%s::preparePrototypeAndInterfaceObject' % v8_class | 16 '%s::preparePrototypeAndInterfaceObject' % v8_class |
| 17 if has_prepare_prototype_and_interface_object | 17 if has_prepare_prototype_and_interface_object |
| 18 else 'nullptr' %} | 18 else 'nullptr' %} |
| 19 {% set parent_wrapper_type_info = '&V8%s::wrapperTypeInfo' % parent_interface | 19 {% set parent_wrapper_type_info = '&V8%s::wrapperTypeInfo' % parent_interface |
| 20 if parent_interface else '0' %} | 20 if parent_interface else '0' %} |
| 21 {% set wrapper_type_prototype = 'WrapperTypeExceptionPrototype' if is_exception
else | 21 {% set wrapper_type_prototype = 'kWrapperTypeExceptionPrototype' if is_exception
else |
| 22 'WrapperTypeObjectPrototype' %} | 22 'kWrapperTypeObjectPrototype' %} |
| 23 {% set active_scriptwrappable_inheritance = | 23 {% set active_scriptwrappable_inheritance = |
| 24 'InheritFromActiveScriptWrappable' | 24 'kInheritFromActiveScriptWrappable' |
| 25 if active_scriptwrappable else | 25 if active_scriptwrappable else |
| 26 'NotInheritFromActiveScriptWrappable' %} | 26 'kNotInheritFromActiveScriptWrappable' %} |
| 27 | 27 |
| 28 {% set wrapper_type_info_const = '' if has_partial_interface else 'const ' %} | 28 {% set wrapper_type_info_const = '' if has_partial_interface else 'const ' %} |
| 29 {% if not is_partial %} | 29 {% if not is_partial %} |
| 30 // Suppress warning: global constructors, because struct WrapperTypeInfo is triv
ial | 30 // Suppress warning: global constructors, because struct WrapperTypeInfo is triv
ial |
| 31 // and does not depend on another global objects. | 31 // and does not depend on another global objects. |
| 32 #if defined(COMPONENT_BUILD) && defined(WIN32) && COMPILER(CLANG) | 32 #if defined(COMPONENT_BUILD) && defined(WIN32) && COMPILER(CLANG) |
| 33 #pragma clang diagnostic push | 33 #pragma clang diagnostic push |
| 34 #pragma clang diagnostic ignored "-Wglobal-constructors" | 34 #pragma clang diagnostic ignored "-Wglobal-constructors" |
| 35 #endif | 35 #endif |
| 36 {{wrapper_type_info_const}}WrapperTypeInfo {{v8_class}}::wrapperTypeInfo = { gin
::kEmbedderBlink, {{dom_template}}, {{v8_class}}::trace, {{v8_class}}::traceWrap
pers, {{prepare_prototype_and_interface_object_func}}, "{{interface_name}}", {{p
arent_wrapper_type_info}}, WrapperTypeInfo::{{wrapper_type_prototype}}, WrapperT
ypeInfo::{{wrapper_class_id}}, WrapperTypeInfo::{{active_scriptwrappable_inherit
ance}}, WrapperTypeInfo::{{event_target_inheritance}}, WrapperTypeInfo::{{lifeti
me}} }; | 36 {{wrapper_type_info_const}}WrapperTypeInfo {{v8_class}}::wrapperTypeInfo = { gin
::kEmbedderBlink, {{dom_template}}, {{v8_class}}::Trace, {{v8_class}}::TraceWrap
pers, {{prepare_prototype_and_interface_object_func}}, "{{interface_name}}", {{p
arent_wrapper_type_info}}, WrapperTypeInfo::{{wrapper_type_prototype}}, WrapperT
ypeInfo::{{wrapper_class_id}}, WrapperTypeInfo::{{active_scriptwrappable_inherit
ance}}, WrapperTypeInfo::{{event_target_inheritance}}, WrapperTypeInfo::{{lifeti
me}} }; |
| 37 #if defined(COMPONENT_BUILD) && defined(WIN32) && COMPILER(CLANG) | 37 #if defined(COMPONENT_BUILD) && defined(WIN32) && COMPILER(CLANG) |
| 38 #pragma clang diagnostic pop | 38 #pragma clang diagnostic pop |
| 39 #endif | 39 #endif |
| 40 | 40 |
| 41 {% if not is_typed_array_type %} | 41 {% if not is_typed_array_type %} |
| 42 // This static member must be declared by DEFINE_WRAPPERTYPEINFO in {{cpp_class}
}.h. | 42 // This static member must be declared by DEFINE_WRAPPERTYPEINFO in {{cpp_class}
}.h. |
| 43 // For details, see the comment of DEFINE_WRAPPERTYPEINFO in | 43 // For details, see the comment of DEFINE_WRAPPERTYPEINFO in |
| 44 // bindings/core/v8/ScriptWrappable.h. | 44 // bindings/core/v8/ScriptWrappable.h. |
| 45 const WrapperTypeInfo& {{cpp_class}}::s_wrapperTypeInfo = {{v8_class}}::wrapperT
ypeInfo; | 45 const WrapperTypeInfo& {{cpp_class}}::wrapper_type_info_ = {{v8_class}}::wrapper
TypeInfo; |
| 46 {% endif %} | 46 {% endif %} |
| 47 | 47 |
| 48 {% if active_scriptwrappable %} | 48 {% if active_scriptwrappable %} |
| 49 // [ActiveScriptWrappable] | 49 // [ActiveScriptWrappable] |
| 50 static_assert( | 50 static_assert( |
| 51 std::is_base_of<ActiveScriptWrappableBase, {{cpp_class}}>::value, | 51 std::is_base_of<ActiveScriptWrappableBase, {{cpp_class}}>::value, |
| 52 "{{cpp_class}} does not inherit from ActiveScriptWrappable<>, but specifying
" | 52 "{{cpp_class}} does not inherit from ActiveScriptWrappable<>, but specifying
" |
| 53 "[ActiveScriptWrappable] extended attribute in the IDL file. " | 53 "[ActiveScriptWrappable] extended attribute in the IDL file. " |
| 54 "Be consistent."); | 54 "Be consistent."); |
| 55 static_assert( | 55 static_assert( |
| 56 !std::is_same<decltype(&{{cpp_class}}::hasPendingActivity), | 56 !std::is_same<decltype(&{{cpp_class}}::HasPendingActivity), |
| 57 decltype(&ScriptWrappable::hasPendingActivity)>::value, | 57 decltype(&ScriptWrappable::HasPendingActivity)>::value, |
| 58 "{{cpp_class}} is not overriding hasPendingActivity(), but is specifying " | 58 "{{cpp_class}} is not overriding hasPendingActivity(), but is specifying " |
| 59 "[ActiveScriptWrappable] extended attribute in the IDL file. " | 59 "[ActiveScriptWrappable] extended attribute in the IDL file. " |
| 60 "Be consistent."); | 60 "Be consistent."); |
| 61 {% else %} | 61 {% else %} |
| 62 // not [ActiveScriptWrappable] | 62 // not [ActiveScriptWrappable] |
| 63 static_assert( | 63 static_assert( |
| 64 !std::is_base_of<ActiveScriptWrappableBase, {{cpp_class}}>::value, | 64 !std::is_base_of<ActiveScriptWrappableBase, {{cpp_class}}>::value, |
| 65 "{{cpp_class}} inherits from ActiveScriptWrappable<>, but is not specifying
" | 65 "{{cpp_class}} inherits from ActiveScriptWrappable<>, but is not specifying
" |
| 66 "[ActiveScriptWrappable] extended attribute in the IDL file. " | 66 "[ActiveScriptWrappable] extended attribute in the IDL file. " |
| 67 "Be consistent."); | 67 "Be consistent."); |
| 68 static_assert( | 68 static_assert( |
| 69 std::is_same<decltype(&{{cpp_class}}::hasPendingActivity), | 69 std::is_same<decltype(&{{cpp_class}}::HasPendingActivity), |
| 70 decltype(&ScriptWrappable::hasPendingActivity)>::value, | 70 decltype(&ScriptWrappable::HasPendingActivity)>::value, |
| 71 "{{cpp_class}} is overriding hasPendingActivity(), but is not specifying " | 71 "{{cpp_class}} is overriding hasPendingActivity(), but is not specifying " |
| 72 "[ActiveScriptWrappable] extended attribute in the IDL file. " | 72 "[ActiveScriptWrappable] extended attribute in the IDL file. " |
| 73 "Be consistent."); | 73 "Be consistent."); |
| 74 {% endif %} | 74 {% endif %} |
| 75 | 75 |
| 76 {% endif %}{# not is_partial #} | 76 {% endif %}{# not is_partial #} |
| 77 {% if not is_array_buffer_or_view %} | 77 {% if not is_array_buffer_or_view %} |
| 78 namespace {{cpp_class_or_partial}}V8Internal { | 78 namespace {{cpp_class_or_partial}}V8Internal { |
| 79 {% if has_partial_interface %} | 79 {% if has_partial_interface %} |
| 80 {% for method in methods if method.overloads and method.overloads.has_partial_ov
erloads %} | 80 {% for method in methods if method.overloads and method.overloads.has_partial_ov
erloads %} |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 | 244 |
| 245 {% if has_access_check_callbacks and not is_partial %} | 245 {% if has_access_check_callbacks and not is_partial %} |
| 246 bool {{v8_class_or_partial}}::securityCheck(v8::Local<v8::Context> accessingCont
ext, v8::Local<v8::Object> accessedObject, v8::Local<v8::Value> data) { | 246 bool {{v8_class_or_partial}}::securityCheck(v8::Local<v8::Context> accessingCont
ext, v8::Local<v8::Object> accessedObject, v8::Local<v8::Value> data) { |
| 247 {% if interface_name == 'Window' %} | 247 {% if interface_name == 'Window' %} |
| 248 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 248 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 249 v8::Local<v8::Object> window = V8Window::findInstanceInPrototypeChain(accessed
Object, isolate); | 249 v8::Local<v8::Object> window = V8Window::findInstanceInPrototypeChain(accessed
Object, isolate); |
| 250 if (window.IsEmpty()) | 250 if (window.IsEmpty()) |
| 251 return false; // the frame is gone. | 251 return false; // the frame is gone. |
| 252 | 252 |
| 253 const DOMWindow* targetWindow = V8Window::toImpl(window); | 253 const DOMWindow* targetWindow = V8Window::toImpl(window); |
| 254 return BindingSecurity::shouldAllowAccessTo(toLocalDOMWindow(toDOMWindow(acces
singContext)), targetWindow, BindingSecurity::ErrorReportOption::DoNotReport); | 254 return BindingSecurity::ShouldAllowAccessTo(ToLocalDOMWindow(ToDOMWindow(acces
singContext)), targetWindow, BindingSecurity::ErrorReportOption::kDoNotReport); |
| 255 {% elif interface_name == 'Location' %} | 255 {% elif interface_name == 'Location' %} |
| 256 {{cpp_class}}* impl = {{v8_class}}::toImpl(accessedObject); | 256 {{cpp_class}}* impl = {{v8_class}}::toImpl(accessedObject); |
| 257 return BindingSecurity::shouldAllowAccessTo(toLocalDOMWindow(toDOMWindow(acces
singContext)), impl, BindingSecurity::ErrorReportOption::DoNotReport); | 257 return BindingSecurity::ShouldAllowAccessTo(ToLocalDOMWindow(ToDOMWindow(acces
singContext)), impl, BindingSecurity::ErrorReportOption::kDoNotReport); |
| 258 {% else %} | 258 {% else %} |
| 259 #error "Unexpected security check for interface {{interface_name}}" | 259 #error "Unexpected security check for interface {{interface_name}}" |
| 260 {% endif %} | 260 {% endif %} |
| 261 } | 261 } |
| 262 | 262 |
| 263 {% if has_cross_origin_named_getter %} | 263 {% if has_cross_origin_named_getter %} |
| 264 void {{v8_class_or_partial}}::crossOriginNamedGetter(v8::Local<v8::Name> name, c
onst v8::PropertyCallbackInfo<v8::Value>& info) { | 264 void {{v8_class_or_partial}}::crossOriginNamedGetter(v8::Local<v8::Name> name, c
onst v8::PropertyCallbackInfo<v8::Value>& info) { |
| 265 if (!name->IsString()) | 265 if (!name->IsString()) |
| 266 return; | 266 return; |
| 267 const AtomicString& propertyName = toCoreAtomicString(name.As<v8::String>()); | 267 const AtomicString& propertyName = ToCoreAtomicString(name.As<v8::String>()); |
| 268 | 268 |
| 269 for (const auto& attribute : {{cpp_class_or_partial}}V8Internal::kCrossOriginA
ttributeTable) { | 269 for (const auto& attribute : {{cpp_class_or_partial}}V8Internal::kCrossOriginA
ttributeTable) { |
| 270 if (propertyName == attribute.name && attribute.getter) { | 270 if (propertyName == attribute.name && attribute.getter) { |
| 271 attribute.getter(info); | 271 attribute.getter(info); |
| 272 return; | 272 return; |
| 273 } | 273 } |
| 274 } | 274 } |
| 275 | 275 |
| 276 {% if named_property_getter and named_property_getter.is_cross_origin %} | 276 {% if named_property_getter and named_property_getter.is_cross_origin %} |
| 277 {% if named_property_getter.is_custom %} | 277 {% if named_property_getter.is_custom %} |
| 278 {{v8_class}}::namedPropertyGetterCustom(propertyName, info); | 278 {{v8_class}}::namedPropertyGetterCustom(propertyName, info); |
| 279 {% else %} | 279 {% else %} |
| 280 {{cpp_class}}V8Internal::namedPropertyGetter(propertyName, info); | 280 {{cpp_class}}V8Internal::namedPropertyGetter(propertyName, info); |
| 281 {% endif %} | 281 {% endif %} |
| 282 {% else %} | 282 {% else %} |
| 283 BindingSecurity::failedAccessCheckFor( | 283 BindingSecurity::FailedAccessCheckFor( |
| 284 info.GetIsolate(), | 284 info.GetIsolate(), |
| 285 {{v8_class}}::toImpl(info.Holder())->frame()); | 285 {{v8_class}}::toImpl(info.Holder())->GetFrame()); |
| 286 {% endif %} | 286 {% endif %} |
| 287 } | 287 } |
| 288 {% endif %} | 288 {% endif %} |
| 289 | 289 |
| 290 {% if has_cross_origin_named_setter %} | 290 {% if has_cross_origin_named_setter %} |
| 291 void {{v8_class_or_partial}}::crossOriginNamedSetter(v8::Local<v8::Name> name, v
8::Local<v8::Value> value, const v8::PropertyCallbackInfo<v8::Value>& info) { | 291 void {{v8_class_or_partial}}::crossOriginNamedSetter(v8::Local<v8::Name> name, v
8::Local<v8::Value> value, const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 292 if (!name->IsString()) | 292 if (!name->IsString()) |
| 293 return; | 293 return; |
| 294 const AtomicString& propertyName = toCoreAtomicString(name.As<v8::String>()); | 294 const AtomicString& propertyName = ToCoreAtomicString(name.As<v8::String>()); |
| 295 | 295 |
| 296 for (const auto& attribute : {{cpp_class_or_partial}}V8Internal::kCrossOriginA
ttributeTable) { | 296 for (const auto& attribute : {{cpp_class_or_partial}}V8Internal::kCrossOriginA
ttributeTable) { |
| 297 if (propertyName == attribute.name && attribute.setter) { | 297 if (propertyName == attribute.name && attribute.setter) { |
| 298 attribute.setter(value, V8CrossOriginSetterInfo(info.GetIsolate(), info.Ho
lder())); | 298 attribute.setter(value, V8CrossOriginSetterInfo(info.GetIsolate(), info.Ho
lder())); |
| 299 return; | 299 return; |
| 300 } | 300 } |
| 301 } | 301 } |
| 302 | 302 |
| 303 {# If there were no matches in the cross-origin attribute table, consider it | 303 {# If there were no matches in the cross-origin attribute table, consider it |
| 304 an access check failure: there are no custom named setters that are | 304 an access check failure: there are no custom named setters that are |
| 305 accessible from a cross-origin context. #} | 305 accessible from a cross-origin context. #} |
| 306 | 306 |
| 307 BindingSecurity::failedAccessCheckFor( | 307 BindingSecurity::FailedAccessCheckFor( |
| 308 info.GetIsolate(), | 308 info.GetIsolate(), |
| 309 {{v8_class}}::toImpl(info.Holder())->frame()); | 309 {{v8_class}}::toImpl(info.Holder())->GetFrame()); |
| 310 } | 310 } |
| 311 {% endif %} | 311 {% endif %} |
| 312 | 312 |
| 313 {% if has_cross_origin_named_enumerator %} | 313 {% if has_cross_origin_named_enumerator %} |
| 314 void {{v8_class_or_partial}}::crossOriginNamedEnumerator(const v8::PropertyCallb
ackInfo<v8::Array>& info) { | 314 void {{v8_class_or_partial}}::crossOriginNamedEnumerator(const v8::PropertyCallb
ackInfo<v8::Array>& info) { |
| 315 Vector<String> names; | 315 Vector<String> names; |
| 316 for (const auto& attribute : {{cpp_class_or_partial}}V8Internal::kCrossOriginA
ttributeTable) | 316 for (const auto& attribute : {{cpp_class_or_partial}}V8Internal::kCrossOriginA
ttributeTable) |
| 317 names.push_back(attribute.name); | 317 names.push_back(attribute.name); |
| 318 | 318 |
| 319 // Use the current context as the creation context, as a cross-origin access | 319 // Use the current context as the creation context, as a cross-origin access |
| 320 // may involve an object that does not have a creation context. | 320 // may involve an object that does not have a creation context. |
| 321 v8SetReturnValue(info, | 321 V8SetReturnValue(info, |
| 322 ToV8(names, info.GetIsolate()->GetCurrentContext()->Global(), | 322 ToV8(names, info.GetIsolate()->GetCurrentContext()->Global(), |
| 323 info.GetIsolate()).As<v8::Array>()); | 323 info.GetIsolate()).As<v8::Array>()); |
| 324 } | 324 } |
| 325 {% endif %} | 325 {% endif %} |
| 326 | 326 |
| 327 {% if has_cross_origin_indexed_getter %} | 327 {% if has_cross_origin_indexed_getter %} |
| 328 void {{v8_class_or_partial}}::crossOriginIndexedGetter(uint32_t index, const v8:
:PropertyCallbackInfo<v8::Value>& info) { | 328 void {{v8_class_or_partial}}::crossOriginIndexedGetter(uint32_t index, const v8:
:PropertyCallbackInfo<v8::Value>& info) { |
| 329 {% if indexed_property_getter.is_custom %} | 329 {% if indexed_property_getter.is_custom %} |
| 330 {{v8_class}}::indexedPropertyGetterCustom(index, info); | 330 {{v8_class}}::indexedPropertyGetterCustom(index, info); |
| 331 {% else %} | 331 {% else %} |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 // Initialize the interface object's template. | 421 // Initialize the interface object's template. |
| 422 {% if is_partial %} | 422 {% if is_partial %} |
| 423 {{v8_class}}::install{{v8_class}}Template(isolate, world, interfaceTemplate); | 423 {{v8_class}}::install{{v8_class}}Template(isolate, world, interfaceTemplate); |
| 424 {% else %} | 424 {% else %} |
| 425 {% set parent_interface_template = | 425 {% set parent_interface_template = |
| 426 '%s::domTemplateForNamedPropertiesObject(isolate, world)' % v8_class | 426 '%s::domTemplateForNamedPropertiesObject(isolate, world)' % v8_class |
| 427 if has_named_properties_object else | 427 if has_named_properties_object else |
| 428 'V8%s::domTemplate(isolate, world)' % parent_interface | 428 'V8%s::domTemplate(isolate, world)' % parent_interface |
| 429 if parent_interface else | 429 if parent_interface else |
| 430 'v8::Local<v8::FunctionTemplate>()' %} | 430 'v8::Local<v8::FunctionTemplate>()' %} |
| 431 V8DOMConfiguration::initializeDOMInterfaceTemplate(isolate, interfaceTemplate,
{{v8_class}}::wrapperTypeInfo.interfaceName, {{parent_interface_template}}, {{v
8_class}}::internalFieldCount); | 431 V8DOMConfiguration::InitializeDOMInterfaceTemplate(isolate, interfaceTemplate,
{{v8_class}}::wrapperTypeInfo.interface_name, {{parent_interface_template}}, {{
v8_class}}::internalFieldCount); |
| 432 {% if constructors or has_custom_constructor or has_event_constructor or has_h
tml_constructor %} | 432 {% if constructors or has_custom_constructor or has_event_constructor or has_h
tml_constructor %} |
| 433 interfaceTemplate->SetCallHandler({{v8_class}}::constructorCallback); | 433 interfaceTemplate->SetCallHandler({{v8_class}}::constructorCallback); |
| 434 interfaceTemplate->SetLength({{interface_length}}); | 434 interfaceTemplate->SetLength({{interface_length}}); |
| 435 {% endif %} | 435 {% endif %} |
| 436 {% endif %}{# is_partial #} | 436 {% endif %}{# is_partial #} |
| 437 | 437 |
| 438 {% if runtime_enabled_feature_name %} | 438 {% if runtime_enabled_feature_name %} |
| 439 if (!{{runtime_enabled_feature_name | runtime_enabled_function}}) { | 439 if (!{{runtime_enabled_feature_name | runtime_enabled_function}}) { |
| 440 return; | 440 return; |
| 441 } | 441 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 460 {% if is_global %} | 460 {% if is_global %} |
| 461 // Global objects are Immutable Prototype Exotic Objects | 461 // Global objects are Immutable Prototype Exotic Objects |
| 462 instanceTemplate->SetImmutableProto(); | 462 instanceTemplate->SetImmutableProto(); |
| 463 {% endif %} | 463 {% endif %} |
| 464 | 464 |
| 465 // Register DOM constants, attributes and operations. | 465 // Register DOM constants, attributes and operations. |
| 466 {% if constants %} | 466 {% if constants %} |
| 467 {{install_constants() | indent(2)}} | 467 {{install_constants() | indent(2)}} |
| 468 {% endif %} | 468 {% endif %} |
| 469 {% if data_attributes %} | 469 {% if data_attributes %} |
| 470 V8DOMConfiguration::installAttributes(isolate, world, instanceTemplate, protot
ypeTemplate, {{'%sAttributes' % v8_class}}, {{'WTF_ARRAY_LENGTH(%sAttributes)' %
v8_class}}); | 470 V8DOMConfiguration::InstallAttributes(isolate, world, instanceTemplate, protot
ypeTemplate, {{'%sAttributes' % v8_class}}, {{'WTF_ARRAY_LENGTH(%sAttributes)' %
v8_class}}); |
| 471 {% endif %} | 471 {% endif %} |
| 472 {% if lazy_data_attributes %} | 472 {% if lazy_data_attributes %} |
| 473 V8DOMConfiguration::installLazyDataAttributes(isolate, world, instanceTemplate
, prototypeTemplate, {{'%sLazyDataAttributes' % v8_class}}, {{'WTF_ARRAY_LENGTH(
%sLazyDataAttributes)' % v8_class}}); | 473 V8DOMConfiguration::InstallLazyDataAttributes(isolate, world, instanceTemplate
, prototypeTemplate, {{'%sLazyDataAttributes' % v8_class}}, {{'WTF_ARRAY_LENGTH(
%sLazyDataAttributes)' % v8_class}}); |
| 474 {% endif %} | 474 {% endif %} |
| 475 {% if accessors %} | 475 {% if accessors %} |
| 476 V8DOMConfiguration::installAccessors(isolate, world, instanceTemplate, prototy
peTemplate, interfaceTemplate, signature, {{'%sAccessors' % v8_class}}, {{'WTF_A
RRAY_LENGTH(%sAccessors)' % v8_class}}); | 476 V8DOMConfiguration::InstallAccessors(isolate, world, instanceTemplate, prototy
peTemplate, interfaceTemplate, signature, {{'%sAccessors' % v8_class}}, {{'WTF_A
RRAY_LENGTH(%sAccessors)' % v8_class}}); |
| 477 {% endif %} | 477 {% endif %} |
| 478 {% if methods | has_method_configuration(is_partial) %} | 478 {% if methods | has_method_configuration(is_partial) %} |
| 479 V8DOMConfiguration::installMethods(isolate, world, instanceTemplate, prototype
Template, interfaceTemplate, signature, {{'%sMethods' % v8_class}}, {{'WTF_ARRAY
_LENGTH(%sMethods)' % v8_class}}); | 479 V8DOMConfiguration::InstallMethods(isolate, world, instanceTemplate, prototype
Template, interfaceTemplate, signature, {{'%sMethods' % v8_class}}, {{'WTF_ARRAY
_LENGTH(%sMethods)' % v8_class}}); |
| 480 {% endif %} | 480 {% endif %} |
| 481 | 481 |
| 482 {% if has_access_check_callbacks and not is_partial %} | 482 {% if has_access_check_callbacks and not is_partial %} |
| 483 // Cross-origin access check | 483 // Cross-origin access check |
| 484 {% set cross_origin_named_getter = '%s::crossOriginNamedGetter' % v8_class_or_
partial if has_cross_origin_named_getter else 'nullptr' %} | 484 {% set cross_origin_named_getter = '%s::crossOriginNamedGetter' % v8_class_or_
partial if has_cross_origin_named_getter else 'nullptr' %} |
| 485 {% set cross_origin_named_setter = '%s::crossOriginNamedSetter' % v8_class_or_
partial if has_cross_origin_named_setter else 'nullptr' %} | 485 {% set cross_origin_named_setter = '%s::crossOriginNamedSetter' % v8_class_or_
partial if has_cross_origin_named_setter else 'nullptr' %} |
| 486 {% set cross_origin_named_enumerator = '%s::crossOriginNamedEnumerator' % v8_c
lass_or_partial if has_cross_origin_named_enumerator else 'nullptr' %} | 486 {% set cross_origin_named_enumerator = '%s::crossOriginNamedEnumerator' % v8_c
lass_or_partial if has_cross_origin_named_enumerator else 'nullptr' %} |
| 487 {% set cross_origin_indexed_getter = '%s::crossOriginIndexedGetter' % v8_class
_or_partial if has_cross_origin_indexed_getter else 'nullptr' %} | 487 {% set cross_origin_indexed_getter = '%s::crossOriginIndexedGetter' % v8_class
_or_partial if has_cross_origin_indexed_getter else 'nullptr' %} |
| 488 instanceTemplate->SetAccessCheckCallbackAndHandler({{v8_class_or_partial}}::se
curityCheck, v8::NamedPropertyHandlerConfiguration({{cross_origin_named_getter}}
, {{cross_origin_named_setter}}, nullptr, nullptr, {{cross_origin_named_enumerat
or}}), v8::IndexedPropertyHandlerConfiguration({{cross_origin_indexed_getter}}),
v8::External::New(isolate, const_cast<WrapperTypeInfo*>(&{{v8_class}}::wrapperT
ypeInfo))); | 488 instanceTemplate->SetAccessCheckCallbackAndHandler({{v8_class_or_partial}}::se
curityCheck, v8::NamedPropertyHandlerConfiguration({{cross_origin_named_getter}}
, {{cross_origin_named_setter}}, nullptr, nullptr, {{cross_origin_named_enumerat
or}}), v8::IndexedPropertyHandlerConfiguration({{cross_origin_indexed_getter}}),
v8::External::New(isolate, const_cast<WrapperTypeInfo*>(&{{v8_class}}::wrapperT
ypeInfo))); |
| 489 {% endif %} | 489 {% endif %} |
| 490 | 490 |
| 491 {% for feature_name, attribute_list in runtime_enabled_attributes | groupby('r
untime_enabled_feature_name') %} | 491 {% for feature_name, attribute_list in runtime_enabled_attributes | groupby('r
untime_enabled_feature_name') %} |
| 492 {% filter runtime_enabled(feature_name) %} | 492 {% filter runtime_enabled(feature_name) %} |
| 493 {% for attribute in attribute_list | unique_by('name') | sort %} | 493 {% for attribute in attribute_list | unique_by('name') | sort %} |
| 494 {% if attribute.is_data_type_property %} | 494 {% if attribute.is_data_type_property %} |
| 495 const V8DOMConfiguration::AttributeConfiguration attribute{{attribute.name}}Co
nfiguration = {{attribute_configuration(attribute)}}; | 495 const V8DOMConfiguration::AttributeConfiguration attribute{{attribute.name}}Co
nfiguration = {{attribute_configuration(attribute)}}; |
| 496 V8DOMConfiguration::installAttribute(isolate, world, instanceTemplate, prototy
peTemplate, attribute{{attribute.name}}Configuration); | 496 V8DOMConfiguration::InstallAttribute(isolate, world, instanceTemplate, prototy
peTemplate, attribute{{attribute.name}}Configuration); |
| 497 {% else %} | 497 {% else %} |
| 498 const V8DOMConfiguration::AccessorConfiguration accessor{{attribute.name}}Conf
iguration = {{attribute_configuration(attribute)}}; | 498 const V8DOMConfiguration::AccessorConfiguration accessor{{attribute.name}}Conf
iguration = {{attribute_configuration(attribute)}}; |
| 499 V8DOMConfiguration::installAccessor(isolate, world, instanceTemplate, prototyp
eTemplate, interfaceTemplate, signature, accessor{{attribute.name}}Configuration
); | 499 V8DOMConfiguration::InstallAccessor(isolate, world, instanceTemplate, prototyp
eTemplate, interfaceTemplate, signature, accessor{{attribute.name}}Configuration
); |
| 500 {% endif %} | 500 {% endif %} |
| 501 {% endfor %} | 501 {% endfor %} |
| 502 {% endfilter %} | 502 {% endfilter %} |
| 503 {% endfor %} | 503 {% endfor %} |
| 504 | 504 |
| 505 {% if (indexed_property_getter or named_property_getter) and not is_partial %} | 505 {% if (indexed_property_getter or named_property_getter) and not is_partial %} |
| 506 // Indexed properties | 506 // Indexed properties |
| 507 {{install_indexed_property_handler('instanceTemplate') | indent(2)}} | 507 {{install_indexed_property_handler('instanceTemplate') | indent(2)}} |
| 508 {% endif %} | 508 {% endif %} |
| 509 {% if named_property_getter and not is_partial and not has_named_properties_ob
ject %} | 509 {% if named_property_getter and not is_partial and not has_named_properties_ob
ject %} |
| 510 // Named properties | 510 // Named properties |
| 511 {{install_named_property_handler('instanceTemplate') | indent(2)}} | 511 {{install_named_property_handler('instanceTemplate') | indent(2)}} |
| 512 {% endif %} | 512 {% endif %} |
| 513 | 513 |
| 514 {% if has_array_iterator and not is_partial %} | 514 {% if has_array_iterator and not is_partial %} |
| 515 // Array iterator (@@iterator) | 515 // Array iterator (@@iterator) |
| 516 {%+ if is_global %}instanceTemplate{% else %}prototypeTemplate{% endif %}->Set
IntrinsicDataProperty(v8::Symbol::GetIterator(isolate), v8::kArrayProto_values,
v8::DontEnum); | 516 {%+ if is_global %}instanceTemplate{% else %}prototypeTemplate{% endif %}->Set
IntrinsicDataProperty(v8::Symbol::GetIterator(isolate), v8::kArrayProto_values,
v8::DontEnum); |
| 517 {% endif %} | 517 {% endif %} |
| 518 | 518 |
| 519 {% if iterator_method %} | 519 {% if iterator_method %} |
| 520 {% filter exposed(iterator_method.exposed_test) %} | 520 {% filter exposed(iterator_method.exposed_test) %} |
| 521 {% filter runtime_enabled(iterator_method.runtime_enabled_feature_name) %} | 521 {% filter runtime_enabled(iterator_method.runtime_enabled_feature_name) %} |
| 522 // Iterator (@@iterator) | 522 // Iterator (@@iterator) |
| 523 const V8DOMConfiguration::SymbolKeyedMethodConfiguration symbolKeyedIteratorCo
nfiguration = { v8::Symbol::GetIterator, {{v8_class_or_partial}}::iteratorMethod
Callback, 0, v8::DontEnum, V8DOMConfiguration::OnPrototype }; | 523 const V8DOMConfiguration::SymbolKeyedMethodConfiguration symbolKeyedIteratorCo
nfiguration = { v8::Symbol::GetIterator, {{v8_class_or_partial}}::iteratorMethod
Callback, 0, v8::DontEnum, V8DOMConfiguration::kOnPrototype }; |
| 524 V8DOMConfiguration::installMethod(isolate, world, prototypeTemplate, signature
, symbolKeyedIteratorConfiguration); | 524 V8DOMConfiguration::InstallMethod(isolate, world, prototypeTemplate, signature
, symbolKeyedIteratorConfiguration); |
| 525 {% endfilter %} | 525 {% endfilter %} |
| 526 {% endfilter %} | 526 {% endfilter %} |
| 527 {% endif %} | 527 {% endif %} |
| 528 | 528 |
| 529 {% if interface_name == 'Location' %} | 529 {% if interface_name == 'Location' %} |
| 530 // Symbol.toPrimitive | 530 // Symbol.toPrimitive |
| 531 // Prevent author scripts to inject Symbol.toPrimitive property into location | 531 // Prevent author scripts to inject Symbol.toPrimitive property into location |
| 532 // objects, also prevent the look-up of Symbol.toPrimitive through the | 532 // objects, also prevent the look-up of Symbol.toPrimitive through the |
| 533 // prototype chain. | 533 // prototype chain. |
| 534 instanceTemplate->Set(v8::Symbol::GetToPrimitive(isolate), | 534 instanceTemplate->Set(v8::Symbol::GetToPrimitive(isolate), |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 v8::Local<v8::Signature> signature = v8::Signature::New(isolate, interfaceTemp
late); | 589 v8::Local<v8::Signature> signature = v8::Signature::New(isolate, interfaceTemp
late); |
| 590 ALLOW_UNUSED_LOCAL(signature); | 590 ALLOW_UNUSED_LOCAL(signature); |
| 591 | 591 |
| 592 {# TODO(peria): Generate code to install constants. It depends on runtime_enab
led_feaure of this interface. #} | 592 {# TODO(peria): Generate code to install constants. It depends on runtime_enab
led_feaure of this interface. #} |
| 593 | 593 |
| 594 {% for feature_name, attrs in runtime_enabled_attributes | groupby('runtime_en
abled_feature_name') %} | 594 {% for feature_name, attrs in runtime_enabled_attributes | groupby('runtime_en
abled_feature_name') %} |
| 595 {% filter runtime_enabled(feature_name) %} | 595 {% filter runtime_enabled(feature_name) %} |
| 596 {% for attribute in attrs | unique_by('name') | sort %} | 596 {% for attribute in attrs | unique_by('name') | sort %} |
| 597 {% if attribute.is_data_type_property %} | 597 {% if attribute.is_data_type_property %} |
| 598 const V8DOMConfiguration::AttributeConfiguration attribute{{attribute.name}}Co
nfiguration = {{attribute_configuration(attribute)}}; | 598 const V8DOMConfiguration::AttributeConfiguration attribute{{attribute.name}}Co
nfiguration = {{attribute_configuration(attribute)}}; |
| 599 V8DOMConfiguration::installAttribute(isolate, world, instance, prototype, attr
ibute{{attribute.name}}Configuration); | 599 V8DOMConfiguration::InstallAttribute(isolate, world, instance, prototype, attr
ibute{{attribute.name}}Configuration); |
| 600 {% else %} | 600 {% else %} |
| 601 const V8DOMConfiguration::AccessorConfiguration accessor{{attribute.name}}Conf
iguration = {{attribute_configuration(attribute)}}; | 601 const V8DOMConfiguration::AccessorConfiguration accessor{{attribute.name}}Conf
iguration = {{attribute_configuration(attribute)}}; |
| 602 V8DOMConfiguration::installAccessor(isolate, world, instance, prototype, inter
face, signature, accessor{{attribute.name}}Configuration); | 602 V8DOMConfiguration::InstallAccessor(isolate, world, instance, prototype, inter
face, signature, accessor{{attribute.name}}Configuration); |
| 603 {% endif %} | 603 {% endif %} |
| 604 {% endfor %} | 604 {% endfor %} |
| 605 {% endfilter %} | 605 {% endfilter %} |
| 606 {% endfor %} | 606 {% endfor %} |
| 607 | 607 |
| 608 {% if iterator_method and iterator_method.runtime_enabled_feature_name %} | 608 {% if iterator_method and iterator_method.runtime_enabled_feature_name %} |
| 609 {% filter exposed(iterator_method.exposed_test) %} | 609 {% filter exposed(iterator_method.exposed_test) %} |
| 610 {% filter runtime_enabled(iterator_method.runtime_enabled_feature_name) %} | 610 {% filter runtime_enabled(iterator_method.runtime_enabled_feature_name) %} |
| 611 // Runtime enabled iterator (@@iterator) | 611 // Runtime enabled iterator (@@iterator) |
| 612 #error "{{v8_class_or_partial}} should not have runtime enabled iterators." | 612 #error "{{v8_class_or_partial}} should not have runtime enabled iterators." |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 645 void {{v8_class_or_partial}}::install{{feature.name}}(v8::Isolate* isolate, cons
t DOMWrapperWorld& world, v8::Local<v8::Object> instance, v8::Local<v8::Object>
prototype, v8::Local<v8::Function> interface) { | 645 void {{v8_class_or_partial}}::install{{feature.name}}(v8::Isolate* isolate, cons
t DOMWrapperWorld& world, v8::Local<v8::Object> instance, v8::Local<v8::Object>
prototype, v8::Local<v8::Function> interface) { |
| 646 {% if feature.attributes or feature.methods %} | 646 {% if feature.attributes or feature.methods %} |
| 647 v8::Local<v8::FunctionTemplate> interfaceTemplate = {{v8_class}}::wrapperTypeI
nfo.domTemplate(isolate, world); | 647 v8::Local<v8::FunctionTemplate> interfaceTemplate = {{v8_class}}::wrapperTypeI
nfo.domTemplate(isolate, world); |
| 648 v8::Local<v8::Signature> signature = v8::Signature::New(isolate, interfaceTemp
late); | 648 v8::Local<v8::Signature> signature = v8::Signature::New(isolate, interfaceTemp
late); |
| 649 ALLOW_UNUSED_LOCAL(signature); | 649 ALLOW_UNUSED_LOCAL(signature); |
| 650 {% endif %} | 650 {% endif %} |
| 651 {# Origin-Trial-enabled attributes #} | 651 {# Origin-Trial-enabled attributes #} |
| 652 {% for attribute in feature.attributes %} | 652 {% for attribute in feature.attributes %} |
| 653 {% if attribute.is_data_type_property %} | 653 {% if attribute.is_data_type_property %} |
| 654 const V8DOMConfiguration::AttributeConfiguration attribute{{attribute.name}}Co
nfiguration = {{attribute_configuration(attribute)}}; | 654 const V8DOMConfiguration::AttributeConfiguration attribute{{attribute.name}}Co
nfiguration = {{attribute_configuration(attribute)}}; |
| 655 V8DOMConfiguration::installAttribute(isolate, world, instance, prototype, attr
ibute{{attribute.name}}Configuration); | 655 V8DOMConfiguration::InstallAttribute(isolate, world, instance, prototype, attr
ibute{{attribute.name}}Configuration); |
| 656 {% else %} | 656 {% else %} |
| 657 const V8DOMConfiguration::AccessorConfiguration accessor{{attribute.name}}Conf
iguration = {{attribute_configuration(attribute)}}; | 657 const V8DOMConfiguration::AccessorConfiguration accessor{{attribute.name}}Conf
iguration = {{attribute_configuration(attribute)}}; |
| 658 V8DOMConfiguration::installAccessor(isolate, world, instance, prototype, inter
face, signature, accessor{{attribute.name}}Configuration); | 658 V8DOMConfiguration::InstallAccessor(isolate, world, instance, prototype, inter
face, signature, accessor{{attribute.name}}Configuration); |
| 659 {% endif %} | 659 {% endif %} |
| 660 {% endfor %} | 660 {% endfor %} |
| 661 {# Origin-Trial-enabled constants #} | 661 {# Origin-Trial-enabled constants #} |
| 662 {% for constant in feature.constants %} | 662 {% for constant in feature.constants %} |
| 663 {% set constant_name = constant.name.title().replace('_', '') %} | 663 {% set constant_name = constant.name.title().replace('_', '') %} |
| 664 const V8DOMConfiguration::ConstantConfiguration constant{{constant_name}}Confi
guration = {{constant_configuration(constant)}}; | 664 const V8DOMConfiguration::ConstantConfiguration constant{{constant_name}}Confi
guration = {{constant_configuration(constant)}}; |
| 665 V8DOMConfiguration::installConstant(isolate, interface, prototype, constant{{c
onstant_name}}Configuration); | 665 V8DOMConfiguration::InstallConstant(isolate, interface, prototype, constant{{c
onstant_name}}Configuration); |
| 666 {% endfor %} | 666 {% endfor %} |
| 667 {# Origin-Trial-enabled methods (no overloads) #} | 667 {# Origin-Trial-enabled methods (no overloads) #} |
| 668 {% for method in feature.methods %} | 668 {% for method in feature.methods %} |
| 669 {% set method_name = method.name.title().replace('_', '') %} | 669 {% set method_name = method.name.title().replace('_', '') %} |
| 670 const V8DOMConfiguration::MethodConfiguration method{{method_name}}Configurati
on = {{method_configuration(method)}}; | 670 const V8DOMConfiguration::MethodConfiguration method{{method_name}}Configurati
on = {{method_configuration(method)}}; |
| 671 V8DOMConfiguration::installMethod(isolate, world, instance, prototype, interfa
ce, signature, method{{method_name}}Configuration); | 671 V8DOMConfiguration::InstallMethod(isolate, world, instance, prototype, interfa
ce, signature, method{{method_name}}Configuration); |
| 672 {% endfor %} | 672 {% endfor %} |
| 673 } | 673 } |
| 674 | 674 |
| 675 void {{v8_class_or_partial}}::install{{feature.name}}(ScriptState* scriptState,
v8::Local<v8::Object> instance) { | 675 void {{v8_class_or_partial}}::install{{feature.name}}(ScriptState* scriptState,
v8::Local<v8::Object> instance) { |
| 676 V8PerContextData* perContextData = V8PerContextData::from(scriptState->context
()); | 676 V8PerContextData* perContextData = V8PerContextData::From(scriptState->GetCont
ext()); |
| 677 v8::Local<v8::Object> prototype = perContextData->prototypeForType(&{{v8_class
}}::wrapperTypeInfo); | 677 v8::Local<v8::Object> prototype = perContextData->PrototypeForType(&{{v8_class
}}::wrapperTypeInfo); |
| 678 v8::Local<v8::Function> interface = perContextData->constructorForType(&{{v8_c
lass}}::wrapperTypeInfo); | 678 v8::Local<v8::Function> interface = perContextData->ConstructorForType(&{{v8_c
lass}}::wrapperTypeInfo); |
| 679 ALLOW_UNUSED_LOCAL(interface); | 679 ALLOW_UNUSED_LOCAL(interface); |
| 680 install{{feature.name}}(scriptState->isolate(), scriptState->world(), instance
, prototype, interface); | 680 install{{feature.name}}(scriptState->GetIsolate(), scriptState->World(), insta
nce, prototype, interface); |
| 681 } | 681 } |
| 682 {% if not feature.needs_instance %} | 682 {% if not feature.needs_instance %} |
| 683 | 683 |
| 684 void {{v8_class_or_partial}}::install{{feature.name}}(ScriptState* scriptState)
{ | 684 void {{v8_class_or_partial}}::install{{feature.name}}(ScriptState* scriptState)
{ |
| 685 install{{feature.name}}(scriptState, v8::Local<v8::Object>()); | 685 install{{feature.name}}(scriptState, v8::Local<v8::Object>()); |
| 686 } | 686 } |
| 687 {% endif %} | 687 {% endif %} |
| 688 | 688 |
| 689 {% endfor %}{# feature #} | 689 {% endfor %}{# feature #} |
| 690 {% endblock %} | 690 {% endblock %} |
| 691 {##############################################################################} | 691 {##############################################################################} |
| 692 {% block get_dom_template %}{% endblock %} | 692 {% block get_dom_template %}{% endblock %} |
| 693 {% block get_dom_template_for_named_properties_object %}{% endblock %} | 693 {% block get_dom_template_for_named_properties_object %}{% endblock %} |
| 694 {% block has_instance %}{% endblock %} | 694 {% block has_instance %}{% endblock %} |
| 695 {% block to_impl %}{% endblock %} | 695 {% block to_impl %}{% endblock %} |
| 696 {% block to_impl_with_type_check %}{% endblock %} | 696 {% block to_impl_with_type_check %}{% endblock %} |
| 697 {##############################################################################} | 697 {##############################################################################} |
| 698 {% block prepare_prototype_and_interface_object %}{% endblock %} | 698 {% block prepare_prototype_and_interface_object %}{% endblock %} |
| 699 {##############################################################################} | 699 {##############################################################################} |
| 700 {% block partial_interface %}{% endblock %} | 700 {% block partial_interface %}{% endblock %} |
| 701 } // namespace blink | 701 } // namespace blink |
| 702 | 702 |
| 703 {% endfilter %}{# format_blink_cpp_source_code #} | 703 {% endfilter %}{# format_blink_cpp_source_code #} |
| OLD | NEW |