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 = | 6 {% set getter_callback = |
7 '%sV8Internal::%sAttributeGetterCallback' % | 7 '%sV8Internal::%sAttributeGetterCallback' % |
8 (cpp_class, attribute.name) | 8 (cpp_class, 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(cpp_class) %} |
11 {% set getter_callback_for_main_world = | 11 {% set getter_callback_for_main_world = |
12 '%sV8Internal::%sAttributeGetterCallbackForMainWorld' % | 12 '%sV8Internal::%sAttributeGetterCallbackForMainWorld' % |
13 (cpp_class, attribute.name) | 13 (cpp_class, attribute.name) |
14 if attribute.is_per_world_bindings else '0' %} | 14 if attribute.is_per_world_bindings else '0' %} |
15 {% set setter_callback = attribute.setter_callback %} | 15 {% set setter_callback = attribute.setter_callback %} |
16 {% set setter_callback_for_main_world = | 16 {% set setter_callback_for_main_world = |
17 '%sV8Internal::%sAttributeSetterCallbackForMainWorld' % | 17 '%sV8Internal::%sAttributeSetterCallbackForMainWorld' % |
18 (cpp_class, attribute.name) | 18 (cpp_class, attribute.name) |
19 if attribute.is_per_world_bindings and | 19 if attribute.is_per_world_bindings and |
20 (not attribute.is_read_only or attribute.put_forwards) else '0' %} | 20 (not attribute.is_read_only or attribute.put_forwards) else '0' %} |
21 {% set wrapper_type_info = | 21 {% set wrapper_type_info = |
22 'const_cast<WrapperTypeInfo*>(&V8%s::wrapperTypeInfo)' % | 22 'const_cast<WrapperTypeInfo*>(&V8%s::wrapperTypeInfo)' % |
23 attribute.constructor_type | 23 attribute.constructor_type |
24 if attribute.constructor_type else '0' %} | 24 if attribute.constructor_type else '0' %} |
25 {% set access_control = 'static_cast<v8::AccessControl>(%s)' % | 25 {% set access_control = 'static_cast<v8::AccessControl>(%s)' % |
26 ' | '.join(attribute.access_control_list) %} | 26 ' | '.join(attribute.access_control_list) %} |
27 {% set property_attribute = 'static_cast<v8::PropertyAttribute>(%s)' % | 27 {% set property_attribute = 'static_cast<v8::PropertyAttribute>(%s)' % |
28 ' | '.join(attribute.property_attributes) %} | 28 ' | '.join(attribute.property_attributes) %} |
29 {% set on_prototype = ', 0 /* on instance */' | 29 {% set on_prototype = '1 /* on prototype */' |
30 if not attribute.is_expose_js_accessors else '' %} | 30 if interface_name == 'Window' and attribute.idl_type == 'EventHandler' |
31 {"{{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 else '0 /* on instance */' %} |
| 32 {% set attribute_configuration_list = [ |
| 33 '"%s"' % attribute.name, |
| 34 getter_callback, |
| 35 setter_callback, |
| 36 getter_callback_for_main_world, |
| 37 setter_callback_for_main_world, |
| 38 wrapper_type_info, |
| 39 access_control, |
| 40 property_attribute, |
| 41 ] %} |
| 42 {% if not attribute.is_expose_js_accessors %} |
| 43 {% set attribute_configuration_list = attribute_configuration_list |
| 44 + [on_prototype] %} |
| 45 {% endif %} |
| 46 {{'{'}}{{attribute_configuration_list|join(', ')}}{{'}'}} |
32 {%- endmacro %} | 47 {%- endmacro %} |
33 | 48 |
34 | 49 |
35 {##############################################################################} | 50 {##############################################################################} |
36 {% macro method_configuration(method) %} | 51 {% macro method_configuration(method) %} |
37 {% set method_callback = | 52 {% set method_callback = |
38 '%sV8Internal::%sMethodCallback' % (cpp_class, method.name) %} | 53 '%sV8Internal::%sMethodCallback' % (cpp_class, method.name) %} |
39 {% set method_callback_for_main_world = | 54 {% set method_callback_for_main_world = |
40 '%sV8Internal::%sMethodCallbackForMainWorld' % (cpp_class, method.name) | 55 '%sV8Internal::%sMethodCallbackForMainWorld' % (cpp_class, method.name) |
41 if method.is_per_world_bindings else '0' %} | 56 if method.is_per_world_bindings else '0' %} |
42 {"{{method.name}}", {{method_callback}}, {{method_callback_for_main_world}}, {{m
ethod.number_of_required_or_variadic_arguments}}} | 57 {"{{method.name}}", {{method_callback}}, {{method_callback_for_main_world}}, {{m
ethod.number_of_required_or_variadic_arguments}}} |
43 {%- endmacro %} | 58 {%- endmacro %} |
44 | 59 |
45 | 60 |
46 {##############################################################################} | 61 {##############################################################################} |
47 {% block constructor_getter %} | 62 {% block constructor_getter %} |
48 {% if has_constructor_attributes %} | 63 {% if has_constructor_attributes %} |
49 static void {{interface_name}}ConstructorGetter(v8::Local<v8::String>, const v8:
:PropertyCallbackInfo<v8::Value>& info) | 64 static void {{cpp_class}}ConstructorGetter(v8::Local<v8::String>, const v8::Prop
ertyCallbackInfo<v8::Value>& info) |
50 { | 65 { |
51 v8::Handle<v8::Value> data = info.Data(); | 66 v8::Handle<v8::Value> data = info.Data(); |
52 ASSERT(data->IsExternal()); | 67 ASSERT(data->IsExternal()); |
53 V8PerContextData* perContextData = V8PerContextData::from(info.Holder()->Cre
ationContext()); | 68 V8PerContextData* perContextData = V8PerContextData::from(info.Holder()->Cre
ationContext()); |
54 if (!perContextData) | 69 if (!perContextData) |
55 return; | 70 return; |
56 v8SetReturnValue(info, perContextData->constructorForType(WrapperTypeInfo::u
nwrap(data))); | 71 v8SetReturnValue(info, perContextData->constructorForType(WrapperTypeInfo::u
nwrap(data))); |
57 } | 72 } |
58 | 73 |
59 {% endif %} | 74 {% endif %} |
60 {% endblock %} | 75 {% endblock %} |
61 | 76 |
62 | 77 |
63 {##############################################################################} | 78 {##############################################################################} |
64 {% block replaceable_attribute_setter_and_callback %} | 79 {% block replaceable_attribute_setter_and_callback %} |
65 {% if has_replaceable_attributes or has_constructor_attributes %} | 80 {% if has_replaceable_attributes or has_constructor_attributes %} |
66 {# FIXME: rename to ForceSetAttributeOnThis, since also used for Constructors #} | 81 {# FIXME: rename to ForceSetAttributeOnThis, since also used for Constructors #} |
67 static void {{interface_name}}ReplaceableAttributeSetter(v8::Local<v8::String> n
ame, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info) | 82 static void {{cpp_class}}ReplaceableAttributeSetter(v8::Local<v8::String> name,
v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info) |
68 { | 83 { |
| 84 {% if is_check_security %} |
| 85 {{cpp_class}}* imp = {{v8_class}}::toNative(info.Holder()); |
| 86 v8::String::Utf8Value attributeName(name); |
| 87 ExceptionState exceptionState(ExceptionState::SetterContext, *attributeName,
"{{interface_name}}", info.Holder(), info.GetIsolate()); |
| 88 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), imp->frame
(), exceptionState)) { |
| 89 exceptionState.throwIfNeeded(); |
| 90 return; |
| 91 } |
| 92 {% endif %} |
69 info.This()->ForceSet(name, jsValue); | 93 info.This()->ForceSet(name, jsValue); |
70 } | 94 } |
71 | 95 |
72 {# FIXME: rename to ForceSetAttributeOnThisCallback, since also used for Constru
ctors #} | 96 {# FIXME: rename to ForceSetAttributeOnThisCallback, since also used for Constru
ctors #} |
73 static void {{interface_name}}ReplaceableAttributeSetterCallback(v8::Local<v8::S
tring> name, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>&
info) | 97 static void {{cpp_class}}ReplaceableAttributeSetterCallback(v8::Local<v8::String
> name, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info
) |
74 { | 98 { |
75 {{interface_name}}V8Internal::{{interface_name}}ReplaceableAttributeSetter(n
ame, jsValue, info); | 99 {{cpp_class}}V8Internal::{{cpp_class}}ReplaceableAttributeSetter(name, jsVal
ue, info); |
76 } | 100 } |
77 | 101 |
78 {% endif %} | 102 {% endif %} |
79 {% endblock %} | 103 {% endblock %} |
80 | 104 |
81 | 105 |
82 {##############################################################################} | 106 {##############################################################################} |
83 {% block security_check_functions %} | 107 {% block security_check_functions %} |
84 {% if is_check_security and interface_name != 'Window' %} | 108 {% if is_check_security and interface_name != 'Window' %} |
85 bool indexedSecurityCheck(v8::Local<v8::Object> host, uint32_t index, v8::Access
Type type, v8::Local<v8::Value>) | 109 bool indexedSecurityCheck(v8::Local<v8::Object> host, uint32_t index, v8::Access
Type type, v8::Local<v8::Value>) |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 } | 399 } |
376 | 400 |
377 {% endif %} | 401 {% endif %} |
378 {% endblock %} | 402 {% endblock %} |
379 | 403 |
380 | 404 |
381 {##############################################################################} | 405 {##############################################################################} |
382 {% block named_property_query %} | 406 {% block named_property_query %} |
383 {% if named_property_getter and named_property_getter.is_enumerable and | 407 {% if named_property_getter and named_property_getter.is_enumerable and |
384 not named_property_getter.is_custom_property_query %} | 408 not named_property_getter.is_custom_property_query %} |
| 409 {# If there is an enumerator, there MUST be a query method to properly |
| 410 communicate property attributes. #} |
385 static void namedPropertyQuery(v8::Local<v8::String> name, const v8::PropertyCal
lbackInfo<v8::Integer>& info) | 411 static void namedPropertyQuery(v8::Local<v8::String> name, const v8::PropertyCal
lbackInfo<v8::Integer>& info) |
386 { | 412 { |
387 {{cpp_class}}* collection = {{v8_class}}::toNative(info.Holder()); | 413 {{cpp_class}}* collection = {{v8_class}}::toNative(info.Holder()); |
388 AtomicString propertyName = toCoreAtomicString(name); | 414 AtomicString propertyName = toCoreAtomicString(name); |
389 ExceptionState exceptionState(info.Holder(), info.GetIsolate()); | 415 ExceptionState exceptionState(info.Holder(), info.GetIsolate()); |
390 bool result = collection->namedPropertyQuery(propertyName, exceptionState); | 416 bool result = collection->namedPropertyQuery(propertyName, exceptionState); |
391 if (exceptionState.throwIfNeeded()) | 417 if (exceptionState.throwIfNeeded()) |
392 return; | 418 return; |
393 if (!result) | 419 if (!result) |
394 return; | 420 return; |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
692 } | 718 } |
693 {% endif %} | 719 {% endif %} |
694 setObjectGroup(object, wrapper, isolate); | 720 setObjectGroup(object, wrapper, isolate); |
695 } | 721 } |
696 | 722 |
697 {% endif %} | 723 {% endif %} |
698 {% endblock %} | 724 {% endblock %} |
699 | 725 |
700 | 726 |
701 {##############################################################################} | 727 {##############################################################################} |
| 728 {% block shadow_attributes %} |
| 729 {% if interface_name == 'Window' %} |
| 730 static const V8DOMConfiguration::AttributeConfiguration shadowAttributes[] = { |
| 731 {% for attribute in attributes if attribute.is_unforgeable %} |
| 732 {{attribute_configuration(attribute)}}, |
| 733 {% endfor %} |
| 734 }; |
| 735 |
| 736 {% endif %} |
| 737 {% endblock %} |
| 738 |
| 739 |
| 740 {##############################################################################} |
702 {% block class_attributes %} | 741 {% block class_attributes %} |
703 {# FIXME: rename to install_attributes and put into configure_class_template #} | 742 {# FIXME: rename to install_attributes and put into configure_class_template #} |
704 {% if has_attribute_configuration %} | 743 {% if has_attribute_configuration %} |
705 static const V8DOMConfiguration::AttributeConfiguration {{v8_class}}Attributes[]
= { | 744 static const V8DOMConfiguration::AttributeConfiguration {{v8_class}}Attributes[]
= { |
706 {% for attribute in attributes | 745 {% for attribute in attributes |
707 if not (attribute.is_expose_js_accessors or | 746 if not (attribute.is_expose_js_accessors or |
708 attribute.is_static or | 747 attribute.is_static or |
709 attribute.runtime_enabled_function or | 748 attribute.runtime_enabled_function or |
710 attribute.per_context_enabled_function) %} | 749 attribute.per_context_enabled_function or |
| 750 (interface_name == 'Window' and attribute.is_unforgeable)) %} |
711 {% filter conditional(attribute.conditional_string) %} | 751 {% filter conditional(attribute.conditional_string) %} |
712 {{attribute_configuration(attribute)}}, | 752 {{attribute_configuration(attribute)}}, |
713 {% endfilter %} | 753 {% endfilter %} |
714 {% endfor %} | 754 {% endfor %} |
715 }; | 755 }; |
716 | 756 |
717 {% endif %} | 757 {% endif %} |
718 {% endblock %} | 758 {% endblock %} |
719 | 759 |
720 | 760 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
806 {% else %} | 846 {% else %} |
807 {{cpp_class}}V8Internal::constructor(info); | 847 {{cpp_class}}V8Internal::constructor(info); |
808 {% endif %} | 848 {% endif %} |
809 } | 849 } |
810 | 850 |
811 {% endif %} | 851 {% endif %} |
812 {% endblock %} | 852 {% endblock %} |
813 | 853 |
814 | 854 |
815 {##############################################################################} | 855 {##############################################################################} |
| 856 {% block configure_shadow_object_template %} |
| 857 {% if interface_name == 'Window' %} |
| 858 static void configureShadowObjectTemplate(v8::Handle<v8::ObjectTemplate> templ,
v8::Isolate* isolate, WrapperWorldType currentWorldType) |
| 859 { |
| 860 V8DOMConfiguration::installAttributes(templ, v8::Handle<v8::ObjectTemplate>(
), shadowAttributes, WTF_ARRAY_LENGTH(shadowAttributes), isolate, currentWorldTy
pe); |
| 861 |
| 862 // Install a security handler with V8. |
| 863 templ->SetAccessCheckCallbacks(V8Window::namedSecurityCheckCustom, V8Window:
:indexedSecurityCheckCustom, v8::External::New(isolate, const_cast<WrapperTypeIn
fo*>(&V8Window::wrapperTypeInfo))); |
| 864 templ->SetInternalFieldCount(V8Window::internalFieldCount); |
| 865 } |
| 866 |
| 867 {% endif %} |
| 868 {% endblock %} |
| 869 |
| 870 |
| 871 {##############################################################################} |
816 {% block configure_class_template %} | 872 {% block configure_class_template %} |
817 {# FIXME: rename to install_dom_template and Install{{v8_class}}DOMTemplate #} | 873 {# FIXME: rename to install_dom_template and Install{{v8_class}}DOMTemplate #} |
818 static void configure{{v8_class}}Template(v8::Handle<v8::FunctionTemplate> funct
ionTemplate, v8::Isolate* isolate, WrapperWorldType currentWorldType) | 874 static void configure{{v8_class}}Template(v8::Handle<v8::FunctionTemplate> funct
ionTemplate, v8::Isolate* isolate, WrapperWorldType currentWorldType) |
819 { | 875 { |
820 functionTemplate->ReadOnlyPrototype(); | 876 functionTemplate->ReadOnlyPrototype(); |
821 | 877 |
822 v8::Local<v8::Signature> defaultSignature; | 878 v8::Local<v8::Signature> defaultSignature; |
823 {% set parent_template = | 879 {% set parent_template = |
824 'V8%s::domTemplate(isolate, currentWorldType)' % parent_interface | 880 'V8%s::domTemplate(isolate, currentWorldType)' % parent_interface |
825 if parent_interface else 'v8::Local<v8::FunctionTemplate>()' %} | 881 if parent_interface else 'v8::Local<v8::FunctionTemplate>()' %} |
(...skipping 27 matching lines...) Expand all Loading... |
853 {% if constructors or has_custom_constructor or has_event_constructor %} | 909 {% if constructors or has_custom_constructor or has_event_constructor %} |
854 functionTemplate->SetCallHandler({{v8_class}}::constructorCallback); | 910 functionTemplate->SetCallHandler({{v8_class}}::constructorCallback); |
855 functionTemplate->SetLength({{interface_length}}); | 911 functionTemplate->SetLength({{interface_length}}); |
856 {% endif %} | 912 {% endif %} |
857 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED instanceTemplate = functionTempla
te->InstanceTemplate(); | 913 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED instanceTemplate = functionTempla
te->InstanceTemplate(); |
858 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED prototypeTemplate = functionTempl
ate->PrototypeTemplate(); | 914 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED prototypeTemplate = functionTempl
ate->PrototypeTemplate(); |
859 {% if is_check_security and interface_name != 'Window' %} | 915 {% if is_check_security and interface_name != 'Window' %} |
860 instanceTemplate->SetAccessCheckCallbacks({{cpp_class}}V8Internal::namedSecu
rityCheck, {{cpp_class}}V8Internal::indexedSecurityCheck, v8::External::New(isol
ate, const_cast<WrapperTypeInfo*>(&{{v8_class}}::wrapperTypeInfo))); | 916 instanceTemplate->SetAccessCheckCallbacks({{cpp_class}}V8Internal::namedSecu
rityCheck, {{cpp_class}}V8Internal::indexedSecurityCheck, v8::External::New(isol
ate, const_cast<WrapperTypeInfo*>(&{{v8_class}}::wrapperTypeInfo))); |
861 {% endif %} | 917 {% endif %} |
862 {% for attribute in attributes | 918 {% for attribute in attributes |
863 if attribute.runtime_enabled_function and not attribute.is_static %} | 919 if attribute.runtime_enabled_function and |
| 920 not attribute.per_context_enabled_function and |
| 921 not attribute.is_static %} |
864 {% filter conditional(attribute.conditional_string) %} | 922 {% filter conditional(attribute.conditional_string) %} |
865 if ({{attribute.runtime_enabled_function}}()) { | 923 if ({{attribute.runtime_enabled_function}}()) { |
866 static const V8DOMConfiguration::AttributeConfiguration attributeConfigu
ration =\ | 924 static const V8DOMConfiguration::AttributeConfiguration attributeConfigu
ration =\ |
867 {{attribute_configuration(attribute)}}; | 925 {{attribute_configuration(attribute)}}; |
868 V8DOMConfiguration::installAttribute(instanceTemplate, prototypeTemplate
, attributeConfiguration, isolate, currentWorldType); | 926 V8DOMConfiguration::installAttribute(instanceTemplate, prototypeTemplate
, attributeConfiguration, isolate, currentWorldType); |
869 } | 927 } |
870 {% endfilter %} | 928 {% endfilter %} |
871 {% endfor %} | 929 {% endfor %} |
872 {% if constants %} | 930 {% if constants %} |
873 {{install_constants() | indent}} | 931 {{install_constants() | indent}} |
874 {% endif %} | 932 {% endif %} |
| 933 {# Special operations #} |
| 934 {# V8 has access-check callback API and it's used on Window instead of |
| 935 deleters or enumerators; see ObjectTemplate::SetAccessCheckCallbacks. |
| 936 In addition, the getter should be set on the prototype template, to get |
| 937 the implementation straight out of the Window prototype, regardless of |
| 938 what prototype is actually set on the object. #} |
| 939 {% set set_on_template = 'PrototypeTemplate' if interface_name == 'Window' |
| 940 else 'InstanceTemplate' %} |
875 {% if indexed_property_getter %} | 941 {% if indexed_property_getter %} |
876 {# if have indexed properties, MUST have an indexed property getter #} | 942 {# if have indexed properties, MUST have an indexed property getter #} |
877 {% set indexed_property_getter_callback = | 943 {% set indexed_property_getter_callback = |
878 '%sV8Internal::indexedPropertyGetterCallback' % cpp_class %} | 944 '%sV8Internal::indexedPropertyGetterCallback' % cpp_class %} |
879 {% set indexed_property_setter_callback = | 945 {% set indexed_property_setter_callback = |
880 '%sV8Internal::indexedPropertySetterCallback' % cpp_class | 946 '%sV8Internal::indexedPropertySetterCallback' % cpp_class |
881 if indexed_property_setter else '0' %} | 947 if indexed_property_setter else '0' %} |
882 {% set indexed_property_query_callback = '0' %}{# Unused #} | 948 {% set indexed_property_query_callback = '0' %}{# Unused #} |
883 {% set indexed_property_deleter_callback = | 949 {% set indexed_property_deleter_callback = |
884 '%sV8Internal::indexedPropertyDeleterCallback' % cpp_class | 950 '%sV8Internal::indexedPropertyDeleterCallback' % cpp_class |
885 if indexed_property_deleter else '0' %} | 951 if indexed_property_deleter else '0' %} |
886 {% set indexed_property_enumerator_callback = | 952 {% set indexed_property_enumerator_callback = |
887 'indexedPropertyEnumerator<%s>' % cpp_class | 953 'indexedPropertyEnumerator<%s>' % cpp_class |
888 if indexed_property_getter.is_enumerable else '0' %} | 954 if indexed_property_getter.is_enumerable else '0' %} |
889 functionTemplate->InstanceTemplate()->SetIndexedPropertyHandler({{indexed_pr
operty_getter_callback}}, {{indexed_property_setter_callback}}, {{indexed_proper
ty_query_callback}}, {{indexed_property_deleter_callback}}, {{indexed_property_e
numerator_callback}}); | 955 functionTemplate->{{set_on_template}}()->SetIndexedPropertyHandler({{indexed
_property_getter_callback}}, {{indexed_property_setter_callback}}, {{indexed_pro
perty_query_callback}}, {{indexed_property_deleter_callback}}, {{indexed_propert
y_enumerator_callback}}); |
890 {% endif %} | 956 {% endif %} |
891 {% if named_property_getter %} | 957 {% if named_property_getter %} |
892 {# if have named properties, MUST have a named property getter #} | 958 {# if have named properties, MUST have a named property getter #} |
893 {% set named_property_getter_callback = | 959 {% set named_property_getter_callback = |
894 '%sV8Internal::namedPropertyGetterCallback' % cpp_class %} | 960 '%sV8Internal::namedPropertyGetterCallback' % cpp_class %} |
895 {% set named_property_setter_callback = | 961 {% set named_property_setter_callback = |
896 '%sV8Internal::namedPropertySetterCallback' % cpp_class | 962 '%sV8Internal::namedPropertySetterCallback' % cpp_class |
897 if named_property_setter else '0' %} | 963 if named_property_setter else '0' %} |
898 {% set named_property_query_callback = | 964 {% set named_property_query_callback = |
899 '%sV8Internal::namedPropertyQueryCallback' % cpp_class | 965 '%sV8Internal::namedPropertyQueryCallback' % cpp_class |
900 if named_property_getter.is_enumerable else '0' %} | 966 if named_property_getter.is_enumerable else '0' %} |
901 {% set named_property_deleter_callback = | 967 {% set named_property_deleter_callback = |
902 '%sV8Internal::namedPropertyDeleterCallback' % cpp_class | 968 '%sV8Internal::namedPropertyDeleterCallback' % cpp_class |
903 if named_property_deleter else '0' %} | 969 if named_property_deleter else '0' %} |
904 {% set named_property_enumerator_callback = | 970 {% set named_property_enumerator_callback = |
905 '%sV8Internal::namedPropertyEnumeratorCallback' % cpp_class | 971 '%sV8Internal::namedPropertyEnumeratorCallback' % cpp_class |
906 if named_property_getter.is_enumerable else '0' %} | 972 if named_property_getter.is_enumerable else '0' %} |
907 functionTemplate->InstanceTemplate()->SetNamedPropertyHandler({{named_proper
ty_getter_callback}}, {{named_property_setter_callback}}, {{named_property_query
_callback}}, {{named_property_deleter_callback}}, {{named_property_enumerator_ca
llback}}); | 973 functionTemplate->{{set_on_template}}()->SetNamedPropertyHandler({{named_pro
perty_getter_callback}}, {{named_property_setter_callback}}, {{named_property_qu
ery_callback}}, {{named_property_deleter_callback}}, {{named_property_enumerator
_callback}}); |
908 {% endif %} | 974 {% endif %} |
| 975 {# End special operations #} |
909 {% if has_custom_legacy_call_as_function %} | 976 {% if has_custom_legacy_call_as_function %} |
910 functionTemplate->InstanceTemplate()->SetCallAsFunctionHandler({{v8_class}}:
:legacyCallCustom); | 977 functionTemplate->InstanceTemplate()->SetCallAsFunctionHandler({{v8_class}}:
:legacyCallCustom); |
911 {% endif %} | 978 {% endif %} |
912 {% if interface_name == 'HTMLAllCollection' %} | 979 {% if interface_name == 'HTMLAllCollection' %} |
913 {# Needed for legacy support of document.all #} | 980 {# Needed for legacy support of document.all #} |
914 functionTemplate->InstanceTemplate()->MarkAsUndetectable(); | 981 functionTemplate->InstanceTemplate()->MarkAsUndetectable(); |
915 {% endif %} | 982 {% endif %} |
916 {% for method in methods if not method.do_not_check_signature %} | 983 {% for method in methods if not method.do_not_check_signature %} |
917 {# install_custom_signature #} | 984 {# install_custom_signature #} |
918 {% if not method.overload_index or method.overload_index == 1 %} | 985 {% if not method.overload_index or method.overload_index == 1 %} |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1124 EventTarget* {{v8_class}}::toEventTarget(v8::Handle<v8::Object> object) | 1191 EventTarget* {{v8_class}}::toEventTarget(v8::Handle<v8::Object> object) |
1125 { | 1192 { |
1126 return toNative(object); | 1193 return toNative(object); |
1127 } | 1194 } |
1128 | 1195 |
1129 {% endif %} | 1196 {% endif %} |
1130 {% endblock %} | 1197 {% endblock %} |
1131 | 1198 |
1132 | 1199 |
1133 {##############################################################################} | 1200 {##############################################################################} |
| 1201 {% block get_shadow_object_template %} |
| 1202 {% if interface_name == 'Window' %} |
| 1203 v8::Handle<v8::ObjectTemplate> V8Window::getShadowObjectTemplate(v8::Isolate* is
olate, WrapperWorldType currentWorldType) |
| 1204 { |
| 1205 if (currentWorldType == MainWorld) { |
| 1206 DEFINE_STATIC_LOCAL(v8::Persistent<v8::ObjectTemplate>, V8WindowShadowOb
jectCacheForMainWorld, ()); |
| 1207 if (V8WindowShadowObjectCacheForMainWorld.IsEmpty()) { |
| 1208 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate"); |
| 1209 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(isola
te); |
| 1210 configureShadowObjectTemplate(templ, isolate, currentWorldType); |
| 1211 V8WindowShadowObjectCacheForMainWorld.Reset(isolate, templ); |
| 1212 return templ; |
| 1213 } |
| 1214 return v8::Local<v8::ObjectTemplate>::New(isolate, V8WindowShadowObjectC
acheForMainWorld); |
| 1215 } else { |
| 1216 DEFINE_STATIC_LOCAL(v8::Persistent<v8::ObjectTemplate>, V8WindowShadowOb
jectCacheForNonMainWorld, ()); |
| 1217 if (V8WindowShadowObjectCacheForNonMainWorld.IsEmpty()) { |
| 1218 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate"); |
| 1219 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(isola
te); |
| 1220 configureShadowObjectTemplate(templ, isolate, currentWorldType); |
| 1221 V8WindowShadowObjectCacheForNonMainWorld.Reset(isolate, templ); |
| 1222 return templ; |
| 1223 } |
| 1224 return v8::Local<v8::ObjectTemplate>::New(isolate, V8WindowShadowObjectC
acheForNonMainWorld); |
| 1225 } |
| 1226 } |
| 1227 |
| 1228 {% endif %} |
| 1229 {% endblock %} |
| 1230 |
| 1231 |
| 1232 {##############################################################################} |
1134 {% block wrap %} | 1233 {% block wrap %} |
1135 {% if special_wrap_for or is_document %} | 1234 {% if special_wrap_for or is_document %} |
1136 v8::Handle<v8::Object> wrap({{cpp_class}}* impl, v8::Handle<v8::Object> creation
Context, v8::Isolate* isolate) | 1235 v8::Handle<v8::Object> wrap({{cpp_class}}* impl, v8::Handle<v8::Object> creation
Context, v8::Isolate* isolate) |
1137 { | 1236 { |
1138 ASSERT(impl); | 1237 ASSERT(impl); |
1139 {% for special_wrap_interface in special_wrap_for %} | 1238 {% for special_wrap_interface in special_wrap_for %} |
1140 if (impl->is{{special_wrap_interface}}()) | 1239 if (impl->is{{special_wrap_interface}}()) |
1141 return wrap(to{{special_wrap_interface}}(impl), creationContext, isolate
); | 1240 return wrap(to{{special_wrap_interface}}(impl), creationContext, isolate
); |
1142 {% endfor %} | 1241 {% endfor %} |
1143 v8::Handle<v8::Object> wrapper = {{v8_class}}::createWrapper(impl, creationC
ontext, isolate); | 1242 v8::Handle<v8::Object> wrapper = {{v8_class}}::createWrapper(impl, creationC
ontext, isolate); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1217 fromInternalPointer(object)->deref(); | 1316 fromInternalPointer(object)->deref(); |
1218 } | 1317 } |
1219 | 1318 |
1220 template<> | 1319 template<> |
1221 v8::Handle<v8::Value> toV8NoInline({{cpp_class}}* impl, v8::Handle<v8::Object> c
reationContext, v8::Isolate* isolate) | 1320 v8::Handle<v8::Value> toV8NoInline({{cpp_class}}* impl, v8::Handle<v8::Object> c
reationContext, v8::Isolate* isolate) |
1222 { | 1321 { |
1223 return toV8(impl, creationContext, isolate); | 1322 return toV8(impl, creationContext, isolate); |
1224 } | 1323 } |
1225 | 1324 |
1226 {% endblock %} | 1325 {% endblock %} |
OLD | NEW |