| OLD | NEW |
| 1 {% extends 'interface_base.cpp.tmpl' %} | 1 {% extends 'interface_base.cpp.tmpl' %} |
| 2 | 2 |
| 3 {% set has_prepare_prototype_and_interface_object = | 3 {% set has_prepare_prototype_and_interface_object = |
| 4 unscopables or has_conditional_attributes_on_prototype or | 4 unscopables or has_conditional_attributes_on_prototype or |
| 5 methods | conditionally_exposed(is_partial) %} | 5 methods | conditionally_exposed(is_partial) %} |
| 6 {% set prepare_prototype_and_interface_object_func = | 6 {% set prepare_prototype_and_interface_object_func = |
| 7 '%s::preparePrototypeAndInterfaceObject' % v8_class | 7 '%s::preparePrototypeAndInterfaceObject' % v8_class |
| 8 if has_prepare_prototype_and_interface_object | 8 if has_prepare_prototype_and_interface_object |
| 9 else 'nullptr' %} | 9 else 'nullptr' %} |
| 10 | 10 |
| (...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 {% else %} | 481 {% else %} |
| 482 {{cpp_class}}V8Internal::namedPropertyEnumerator(info); | 482 {{cpp_class}}V8Internal::namedPropertyEnumerator(info); |
| 483 {% endif %} | 483 {% endif %} |
| 484 } | 484 } |
| 485 | 485 |
| 486 {% endif %} | 486 {% endif %} |
| 487 {% endblock %} | 487 {% endblock %} |
| 488 | 488 |
| 489 | 489 |
| 490 {##############################################################################} | 490 {##############################################################################} |
| 491 {% block origin_safe_method_setter %} | |
| 492 {% if has_origin_safe_method_setter %} | |
| 493 static void {{cpp_class}}OriginSafeMethodSetter(v8::Local<v8::Name> name, v8::Lo
cal<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) { | |
| 494 if (!name->IsString()) | |
| 495 return; | |
| 496 v8::Local<v8::Object> holder = {{v8_class}}::findInstanceInPrototypeChain(info
.Holder(), info.GetIsolate()); | |
| 497 if (holder.IsEmpty()) | |
| 498 return; | |
| 499 {{cpp_class}}* impl = {{v8_class}}::toImpl(holder); | |
| 500 v8::String::Utf8Value attributeName(name); | |
| 501 ExceptionState exceptionState(ExceptionState::SetterContext, *attributeName, "
{{interface_name}}", info.Holder(), info.GetIsolate()); | |
| 502 if (!BindingSecurity::shouldAllowAccessTo(currentDOMWindow(info.GetIsolate()),
impl, exceptionState)) { | |
| 503 return; | |
| 504 } | |
| 505 | |
| 506 {# The findInstanceInPrototypeChain() call above only returns a non-empty hand
le if info.Holder() is an Object. #} | |
| 507 V8HiddenValue::setHiddenValue(ScriptState::current(info.GetIsolate()), v8::Loc
al<v8::Object>::Cast(info.Holder()), name.As<v8::String>(), v8Value); | |
| 508 } | |
| 509 | |
| 510 void {{cpp_class}}OriginSafeMethodSetterCallback(v8::Local<v8::Name> name, v8::L
ocal<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) { | |
| 511 {{cpp_class}}V8Internal::{{cpp_class}}OriginSafeMethodSetter(name, v8Value, in
fo); | |
| 512 } | |
| 513 | |
| 514 {% endif %} | |
| 515 {% endblock %} | |
| 516 | |
| 517 | |
| 518 {##############################################################################} | |
| 519 {% block named_constructor %} | 491 {% block named_constructor %} |
| 520 {% from 'methods.cpp.tmpl' import generate_constructor with context %} | 492 {% from 'methods.cpp.tmpl' import generate_constructor with context %} |
| 521 {% if named_constructor %} | 493 {% if named_constructor %} |
| 522 {% set active_scriptwrappable_inheritance = | 494 {% set active_scriptwrappable_inheritance = |
| 523 'InheritFromActiveScriptWrappable' | 495 'InheritFromActiveScriptWrappable' |
| 524 if active_scriptwrappable else | 496 if active_scriptwrappable else |
| 525 'NotInheritFromActiveScriptWrappable' %} | 497 'NotInheritFromActiveScriptWrappable' %} |
| 526 // Suppress warning: global constructors, because struct WrapperTypeInfo is triv
ial | 498 // Suppress warning: global constructors, because struct WrapperTypeInfo is triv
ial |
| 527 // and does not depend on another global objects. | 499 // and does not depend on another global objects. |
| 528 #if defined(COMPONENT_BUILD) && defined(WIN32) && COMPILER(CLANG) | 500 #if defined(COMPONENT_BUILD) && defined(WIN32) && COMPILER(CLANG) |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 649 {% else %} | 621 {% else %} |
| 650 {{cpp_class}}V8Internal::constructor(info); | 622 {{cpp_class}}V8Internal::constructor(info); |
| 651 {% endif %} | 623 {% endif %} |
| 652 } | 624 } |
| 653 | 625 |
| 654 {% endif %} | 626 {% endif %} |
| 655 {% endblock %} | 627 {% endblock %} |
| 656 | 628 |
| 657 | 629 |
| 658 {##############################################################################} | 630 {##############################################################################} |
| 659 {% macro install_do_not_check_security_method(method, world_suffix, instance_tem
plate, prototype_template) %} | |
| 660 {% from 'utilities.cpp.tmpl' import property_location %} | |
| 661 {# Methods that are [DoNotCheckSecurity] are always readable, but if they are | |
| 662 changed and then accessed from a different origin, we do not return the | |
| 663 underlying value, but instead return a new copy of the original function. | |
| 664 This is achieved by storing the changed value as a hidden property. #} | |
| 665 {% set getter_callback = | |
| 666 '%sV8Internal::%sOriginSafeMethodGetterCallback%s' % | |
| 667 (cpp_class, method.name, world_suffix) %} | |
| 668 {% set setter_callback = | |
| 669 '{0}V8Internal::{0}OriginSafeMethodSetterCallback'.format(cpp_class) | |
| 670 if not method.is_unforgeable else '0' %} | |
| 671 {% if method.is_per_world_bindings %} | |
| 672 {% set getter_callback_for_main_world = '%sForMainWorld' % getter_callback %} | |
| 673 {% set setter_callback_for_main_world = '%sForMainWorld' % setter_callback | |
| 674 if not method.is_unforgeable else '0' %} | |
| 675 {% else %} | |
| 676 {% set getter_callback_for_main_world = '0' %} | |
| 677 {% set setter_callback_for_main_world = '0' %} | |
| 678 {% endif %} | |
| 679 {% set property_attribute = | |
| 680 'static_cast<v8::PropertyAttribute>(%s)' % | |
| 681 ' | '.join(method.property_attributes or ['v8::None']) %} | |
| 682 {% set only_exposed_to_private_script = 'V8DOMConfiguration::OnlyExposedToPrivat
eScript' if method.only_exposed_to_private_script else 'V8DOMConfiguration::Expo
sedToAllScripts' %} | |
| 683 {% set holder_check = 'V8DOMConfiguration::CheckHolder' %} | |
| 684 const V8DOMConfiguration::AttributeConfiguration {{method.name}}OriginSafeAttrib
uteConfiguration = { | |
| 685 "{{method.name}}", {{getter_callback}}, {{setter_callback}}, {{getter_callba
ck_for_main_world}}, {{setter_callback_for_main_world}}, &{{v8_class}}::wrapperT
ypeInfo, v8::ALL_CAN_READ, {{property_attribute}}, {{only_exposed_to_private_scr
ipt}}, {{property_location(method)}}, {{holder_check}}, | |
| 686 }; | |
| 687 V8DOMConfiguration::installAttribute(isolate, world, {{instance_template}}, {{pr
ototype_template}}, {{method.name}}OriginSafeAttributeConfiguration); | |
| 688 {%- endmacro %} | |
| 689 | |
| 690 | |
| 691 {##############################################################################} | |
| 692 {% macro install_indexed_property_handler(target) %} | 631 {% macro install_indexed_property_handler(target) %} |
| 693 {% set indexed_property_getter_callback = | 632 {% set indexed_property_getter_callback = |
| 694 '%sV8Internal::indexedPropertyGetterCallback' % cpp_class %} | 633 '%sV8Internal::indexedPropertyGetterCallback' % cpp_class %} |
| 695 {% set indexed_property_setter_callback = | 634 {% set indexed_property_setter_callback = |
| 696 '%sV8Internal::indexedPropertySetterCallback' % cpp_class | 635 '%sV8Internal::indexedPropertySetterCallback' % cpp_class |
| 697 if indexed_property_setter or named_property_setter else '0' %} | 636 if indexed_property_setter or named_property_setter else '0' %} |
| 698 {% set indexed_property_query_callback = '0' %}{# Unused #} | 637 {% set indexed_property_query_callback = '0' %}{# Unused #} |
| 699 {% set indexed_property_deleter_callback = | 638 {% set indexed_property_deleter_callback = |
| 700 '%sV8Internal::indexedPropertyDeleterCallback' % cpp_class | 639 '%sV8Internal::indexedPropertyDeleterCallback' % cpp_class |
| 701 if indexed_property_deleter or named_property_deleter else '0' %} | 640 if indexed_property_deleter or named_property_deleter else '0' %} |
| 702 {% set indexed_property_enumerator_callback = | 641 {% set indexed_property_enumerator_callback = |
| 703 'indexedPropertyEnumerator<%s>' % cpp_class | 642 'indexedPropertyEnumerator<%s>' % cpp_class |
| 704 if indexed_property_getter.is_enumerable else '0' %} | 643 if indexed_property_getter.is_enumerable else '0' %} |
| 705 {% set property_handler_flags = | 644 {% set property_handler_flags = |
| 706 'v8::PropertyHandlerFlags::kAllCanRead' | 645 'v8::PropertyHandlerFlags::kNone' %} |
| 707 if indexed_property_getter.do_not_check_security | |
| 708 else 'v8::PropertyHandlerFlags::kNone' %} | |
| 709 v8::IndexedPropertyHandlerConfiguration indexedPropertyHandlerConfig({{indexed_p
roperty_getter_callback}}, {{indexed_property_setter_callback}}, {{indexed_prope
rty_query_callback}}, {{indexed_property_deleter_callback}}, {{indexed_property_
enumerator_callback}}, v8::Local<v8::Value>(), {{property_handler_flags}}); | 646 v8::IndexedPropertyHandlerConfiguration indexedPropertyHandlerConfig({{indexed_p
roperty_getter_callback}}, {{indexed_property_setter_callback}}, {{indexed_prope
rty_query_callback}}, {{indexed_property_deleter_callback}}, {{indexed_property_
enumerator_callback}}, v8::Local<v8::Value>(), {{property_handler_flags}}); |
| 710 {{target}}->SetHandler(indexedPropertyHandlerConfig); | 647 {{target}}->SetHandler(indexedPropertyHandlerConfig); |
| 711 {%- endmacro %} | 648 {%- endmacro %} |
| 712 | 649 |
| 713 | 650 |
| 714 {##############################################################################} | 651 {##############################################################################} |
| 715 {% macro install_named_property_handler(target) %} | 652 {% macro install_named_property_handler(target) %} |
| 716 {% set named_property_getter_callback = | 653 {% set named_property_getter_callback = |
| 717 '%sV8Internal::namedPropertyGetterCallback' % cpp_class %} | 654 '%sV8Internal::namedPropertyGetterCallback' % cpp_class %} |
| 718 {% set named_property_setter_callback = | 655 {% set named_property_setter_callback = |
| 719 '%sV8Internal::namedPropertySetterCallback' % cpp_class | 656 '%sV8Internal::namedPropertySetterCallback' % cpp_class |
| 720 if named_property_setter else '0' %} | 657 if named_property_setter else '0' %} |
| 721 {% set named_property_query_callback = | 658 {% set named_property_query_callback = |
| 722 '%sV8Internal::namedPropertyQueryCallback' % cpp_class | 659 '%sV8Internal::namedPropertyQueryCallback' % cpp_class |
| 723 if named_property_getter.is_enumerable else '0' %} | 660 if named_property_getter.is_enumerable else '0' %} |
| 724 {% set named_property_deleter_callback = | 661 {% set named_property_deleter_callback = |
| 725 '%sV8Internal::namedPropertyDeleterCallback' % cpp_class | 662 '%sV8Internal::namedPropertyDeleterCallback' % cpp_class |
| 726 if named_property_deleter else '0' %} | 663 if named_property_deleter else '0' %} |
| 727 {% set named_property_enumerator_callback = | 664 {% set named_property_enumerator_callback = |
| 728 '%sV8Internal::namedPropertyEnumeratorCallback' % cpp_class | 665 '%sV8Internal::namedPropertyEnumeratorCallback' % cpp_class |
| 729 if named_property_getter.is_enumerable else '0' %} | 666 if named_property_getter.is_enumerable else '0' %} |
| 730 {% set property_handler_flags_list = | 667 {% set property_handler_flags_list = |
| 731 ['int(v8::PropertyHandlerFlags::kOnlyInterceptStrings)'] %} | 668 ['int(v8::PropertyHandlerFlags::kOnlyInterceptStrings)'] %} |
| 732 {% if named_property_getter.do_not_check_security %} | |
| 733 {% set property_handler_flags_list = | |
| 734 property_handler_flags_list + ['int(v8::PropertyHandlerFlags::kAllCanRead
)'] %} | |
| 735 {% endif %} | |
| 736 {% if not is_override_builtins %} | 669 {% if not is_override_builtins %} |
| 737 {% set property_handler_flags_list = | 670 {% set property_handler_flags_list = |
| 738 property_handler_flags_list + ['int(v8::PropertyHandlerFlags::kNonMasking
)'] %} | 671 property_handler_flags_list + ['int(v8::PropertyHandlerFlags::kNonMasking
)'] %} |
| 739 {% endif %} | 672 {% endif %} |
| 740 {% set property_handler_flags = | 673 {% set property_handler_flags = |
| 741 'static_cast<v8::PropertyHandlerFlags>(%s)' % | 674 'static_cast<v8::PropertyHandlerFlags>(%s)' % |
| 742 ' | '.join(property_handler_flags_list) %} | 675 ' | '.join(property_handler_flags_list) %} |
| 743 v8::NamedPropertyHandlerConfiguration namedPropertyHandlerConfig({{named_propert
y_getter_callback}}, {{named_property_setter_callback}}, {{named_property_query_
callback}}, {{named_property_deleter_callback}}, {{named_property_enumerator_cal
lback}}, v8::Local<v8::Value>(), {{property_handler_flags}}); | 676 v8::NamedPropertyHandlerConfiguration namedPropertyHandlerConfig({{named_propert
y_getter_callback}}, {{named_property_setter_callback}}, {{named_property_query_
callback}}, {{named_property_deleter_callback}}, {{named_property_enumerator_cal
lback}}, v8::Local<v8::Value>(), {{property_handler_flags}}); |
| 744 {{target}}->SetHandler(namedPropertyHandlerConfig); | 677 {{target}}->SetHandler(namedPropertyHandlerConfig); |
| 745 {%- endmacro %} | 678 {%- endmacro %} |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 959 } | 892 } |
| 960 | 893 |
| 961 {% for method in methods if method.overloads and method.overloads.has_partial_ov
erloads %} | 894 {% for method in methods if method.overloads and method.overloads.has_partial_ov
erloads %} |
| 962 void {{v8_class}}::register{{method.name | blink_capitalize}}MethodForPartialInt
erface(void (*method)(const v8::FunctionCallbackInfo<v8::Value>&)) { | 895 void {{v8_class}}::register{{method.name | blink_capitalize}}MethodForPartialInt
erface(void (*method)(const v8::FunctionCallbackInfo<v8::Value>&)) { |
| 963 {{cpp_class}}V8Internal::{{method.name}}MethodForPartialInterface = method; | 896 {{cpp_class}}V8Internal::{{method.name}}MethodForPartialInterface = method; |
| 964 } | 897 } |
| 965 | 898 |
| 966 {% endfor %} | 899 {% endfor %} |
| 967 {% endif %} | 900 {% endif %} |
| 968 {% endblock %} | 901 {% endblock %} |
| OLD | NEW |