Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 {% extends 'interface_base.cpp.tmpl' %} | 1 {% extends 'interface_base.cpp.tmpl' %} |
| 2 | 2 |
| 3 {##############################################################################} | 3 {##############################################################################} |
| 4 {% block indexed_property_getter %} | 4 {% block indexed_property_getter %} |
| 5 {% if indexed_property_getter and not indexed_property_getter.is_custom %} | 5 {% if indexed_property_getter and not indexed_property_getter.is_custom %} |
| 6 {% set getter = indexed_property_getter %} | 6 {% set getter = indexed_property_getter %} |
| 7 static void indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo <v8::Value>& info) { | 7 static void indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo <v8::Value>& info) { |
| 8 {% if getter.is_raises_exception %} | 8 {% if getter.is_raises_exception %} |
| 9 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::kIndexedGette rContext, "{{interface_name}}"); | 9 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::kIndexedGette rContext, "{{interface_name}}"); |
| 10 {% endif %} | 10 {% endif %} |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 104 return; | 104 return; |
| 105 V8SetReturnValue(info, v8Value); | 105 V8SetReturnValue(info, v8Value); |
| 106 } | 106 } |
| 107 | 107 |
| 108 {% endif %} | 108 {% endif %} |
| 109 {% endblock %} | 109 {% endblock %} |
| 110 | 110 |
| 111 | 111 |
| 112 {##############################################################################} | 112 {##############################################################################} |
| 113 {% block indexed_property_setter_callback %} | 113 {% block indexed_property_setter_callback %} |
| 114 {% if indexed_property_setter or named_property_setter %} | 114 {% if indexed_property_getter or named_property_setter %} |
| 115 {% set setter = indexed_property_setter or named_property_setter %} | 115 {% set setter = indexed_property_setter or named_property_setter %} |
| 116 void {{v8_class_or_partial}}::indexedPropertySetterCallback(uint32_t index, v8:: Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info) { | 116 void {{v8_class_or_partial}}::indexedPropertySetterCallback(uint32_t index, v8:: Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 117 {% if setter.is_ce_reactions %} | 117 {% if setter.is_ce_reactions %} |
| 118 CEReactionsScope ceReactionsScope; | 118 CEReactionsScope ceReactionsScope; |
| 119 {% endif %} | 119 {% endif %} |
| 120 | 120 |
| 121 {% if indexed_property_setter %} | 121 {% if indexed_property_setter %} |
| 122 | 122 |
| 123 {% if setter.is_custom %} | 123 {% if setter.is_custom %} |
| 124 {{v8_class}}::indexedPropertySetterCustom(index, v8Value, info); | 124 {{v8_class}}::indexedPropertySetterCustom(index, v8Value, info); |
| 125 {% else %} | 125 {% else %} |
| 126 {{cpp_class}}V8Internal::indexedPropertySetter(index, v8Value, info); | 126 {{cpp_class}}V8Internal::indexedPropertySetter(index, v8Value, info); |
| 127 {% endif %} | 127 {% endif %} |
| 128 | 128 |
| 129 {% else %}{# otherwise, named property #} | 129 {% elif named_property_setter %} |
| 130 | 130 |
| 131 const AtomicString& propertyName = AtomicString::Number(index); | 131 const AtomicString& propertyName = AtomicString::Number(index); |
| 132 | 132 |
| 133 {% if setter.is_custom %} | 133 {% if setter.is_custom %} |
| 134 {{v8_class}}::namedPropertySetterCustom(propertyName, v8Value, info); | 134 {{v8_class}}::namedPropertySetterCustom(propertyName, v8Value, info); |
| 135 {% else %} | 135 {% else %} |
| 136 {{cpp_class}}V8Internal::namedPropertySetter(propertyName, v8Value, info); | 136 {{cpp_class}}V8Internal::namedPropertySetter(propertyName, v8Value, info); |
| 137 {% endif %} | 137 {% endif %} |
| 138 | 138 |
| 139 {% endif %}{# indexed_property_setter #} | 139 {% else %}{# neither of indexed_property_setter nor named_property_setter #} |
| 140 | |
| 141 // No indexed property setter defined. Do not fall back to the default | |
| 142 // setter. | |
| 143 V8SetReturnValue(info, v8::Null(info.GetIsolate())); | |
| 144 if (info.ShouldThrowOnError()) { | |
|
haraken
2017/07/05 11:51:13
What is info.ShouldThrowOnError()? I saw this the
Yuki
2017/07/05 12:37:42
It corresponds to "use strict"; in ES.
window[0]
| |
| 145 ExceptionState exceptionState(info.GetIsolate(), | |
| 146 ExceptionState::kIndexedSetterContext, | |
| 147 "{{interface_name}}"); | |
| 148 exceptionState.ThrowTypeError("Index property setter is not supported."); | |
| 149 } | |
| 150 | |
| 151 {% endif %}{# indexed/named_property_setter #} | |
| 140 } | 152 } |
| 141 | 153 |
| 142 {% endif %} | 154 {% endif %} |
| 143 {% endblock %} | 155 {% endblock %} |
| 144 | 156 |
| 145 | 157 |
| 146 {##############################################################################} | 158 {##############################################################################} |
| 147 {% block indexed_property_deleter %} | 159 {% block indexed_property_deleter %} |
| 148 {% if indexed_property_deleter and not indexed_property_deleter.is_custom %} | 160 {% if indexed_property_deleter and not indexed_property_deleter.is_custom %} |
| 149 {% set deleter = indexed_property_deleter %} | 161 {% set deleter = indexed_property_deleter %} |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 205 {% endif %} | 217 {% endif %} |
| 206 | 218 |
| 207 {% endif %}{# indexed_property_deleter #} | 219 {% endif %}{# indexed_property_deleter #} |
| 208 } | 220 } |
| 209 | 221 |
| 210 {% endif %} | 222 {% endif %} |
| 211 {% endblock %} | 223 {% endblock %} |
| 212 | 224 |
| 213 | 225 |
| 214 {##############################################################################} | 226 {##############################################################################} |
| 227 {% block indexed_property_definer_callback %} | |
| 228 {% if indexed_property_getter %} | |
| 229 void {{v8_class_or_partial}}::indexedPropertyDefinerCallback( | |
| 230 uint32_t index, | |
| 231 const v8::PropertyDescriptor& desc, | |
| 232 const v8::PropertyCallbackInfo<v8::Value>& info) { | |
| 233 {% if indexed_property_setter %} | |
| 234 // https://heycam.github.io/webidl/#legacy-platform-object-defineownproperty | |
| 235 // 3.9.3. [[DefineOwnProperty]] | |
| 236 // step 1.1. If the result of calling IsDataDescriptor(Desc) is false, then | |
| 237 // return false. | |
| 238 if (desc.has_get() || desc.has_set()) { | |
| 239 V8SetReturnValue(info, v8::Null(info.GetIsolate())); | |
|
haraken
2017/07/05 11:51:13
Does this mean we "return false"?
Yuki
2017/07/05 12:37:42
This V8 callback API doesn't correspond to the spe
| |
| 240 if (info.ShouldThrowOnError()) { | |
| 241 ExceptionState exceptionState(info.GetIsolate(), | |
| 242 ExceptionState::kIndexedSetterContext, | |
| 243 "{{interface_name}}"); | |
| 244 exceptionState.ThrowTypeError("Accessor properties are not allowed."); | |
| 245 } | |
| 246 return; | |
| 247 } | |
| 248 | |
| 249 // Retutn nothing and fall back to indexedPropertySetterCallback. | |
|
haraken
2017/07/05 11:51:13
Return
Yuki
2017/07/05 12:37:42
Done.
| |
| 250 {% else %}{# indexed_property_setter #} | |
| 251 // https://heycam.github.io/webidl/#legacy-platform-object-defineownproperty | |
| 252 // 3.9.3. [[DefineOwnProperty]] | |
| 253 // step 1.2. If O does not implement an interface with an indexed property | |
| 254 // setter, then return false. | |
| 255 // | |
| 256 // https://html.spec.whatwg.org/C/window-object.html#windowproxy-defineownprop erty | |
| 257 // 7.4.6 [[DefineOwnProperty]] (P, Desc) | |
| 258 // step 2.1. If P is an array index property name, return false. | |
| 259 V8SetReturnValue(info, v8::Null(info.GetIsolate())); | |
| 260 if (info.ShouldThrowOnError()) { | |
| 261 ExceptionState exceptionState(info.GetIsolate(), | |
| 262 ExceptionState::kIndexedSetterContext, | |
| 263 "{{interface_name}}"); | |
| 264 exceptionState.ThrowTypeError("Index property setter is not supported."); | |
| 265 } | |
| 266 {% endif %}{# indexed_property_setter #} | |
| 267 } | |
| 268 | |
| 269 {% endif %}{# indexed_property_getter #} | |
| 270 {% endblock %} | |
| 271 | |
| 272 | |
| 273 {##############################################################################} | |
| 215 {% block named_property_getter %} | 274 {% block named_property_getter %} |
| 216 {% if named_property_getter and not named_property_getter.is_custom %} | 275 {% if named_property_getter and not named_property_getter.is_custom %} |
| 217 {% set getter = named_property_getter %} | 276 {% set getter = named_property_getter %} |
| 218 static void namedPropertyGetter(const AtomicString& name, const v8::PropertyCall backInfo<v8::Value>& info) { | 277 static void namedPropertyGetter(const AtomicString& name, const v8::PropertyCall backInfo<v8::Value>& info) { |
| 219 {% if getter.is_raises_exception %} | 278 {% if getter.is_raises_exception %} |
| 220 const CString& nameInUtf8 = name.Utf8(); | 279 const CString& nameInUtf8 = name.Utf8(); |
| 221 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::kGetterContex t, "{{interface_name}}", nameInUtf8.data()); | 280 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::kGetterContex t, "{{interface_name}}", nameInUtf8.data()); |
| 222 {% endif %} | 281 {% endif %} |
| 223 {% if getter.is_call_with_script_state %} | 282 {% if getter.is_call_with_script_state %} |
| 224 ScriptState* scriptState = ScriptState::ForReceiverObject(info); | 283 ScriptState* scriptState = ScriptState::ForReceiverObject(info); |
| (...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 700 V8DOMConfiguration::InstallAttribute(isolate, world, {{instance_template}}, {{ prototype_template}}, attributeConfig); | 759 V8DOMConfiguration::InstallAttribute(isolate, world, {{instance_template}}, {{ prototype_template}}, attributeConfig); |
| 701 {%- endmacro %} | 760 {%- endmacro %} |
| 702 | 761 |
| 703 | 762 |
| 704 {##############################################################################} | 763 {##############################################################################} |
| 705 {% macro install_indexed_property_handler(target) %} | 764 {% macro install_indexed_property_handler(target) %} |
| 706 {% set indexed_property_getter_callback = | 765 {% set indexed_property_getter_callback = |
| 707 '%s::indexedPropertyGetterCallback' % v8_class_or_partial %} | 766 '%s::indexedPropertyGetterCallback' % v8_class_or_partial %} |
| 708 {% set indexed_property_setter_callback = | 767 {% set indexed_property_setter_callback = |
| 709 '%s::indexedPropertySetterCallback' % v8_class_or_partial | 768 '%s::indexedPropertySetterCallback' % v8_class_or_partial |
| 710 if indexed_property_setter or named_property_setter else 'nullptr' %} | 769 if indexed_property_getter or named_property_setter else 'nullptr' %} |
| 711 {% set indexed_property_query_callback = 'nullptr' %}{# Unused #} | 770 {% set indexed_property_descriptor_callback = 'nullptr' %} |
| 712 {% set indexed_property_deleter_callback = | 771 {% set indexed_property_deleter_callback = |
| 713 '%s::indexedPropertyDeleterCallback' % v8_class_or_partial | 772 '%s::indexedPropertyDeleterCallback' % v8_class_or_partial |
| 714 if indexed_property_deleter or named_property_deleter else 'nullptr' %} | 773 if indexed_property_deleter or named_property_deleter else 'nullptr' %} |
| 715 {% set indexed_property_enumerator_callback = | 774 {% set indexed_property_enumerator_callback = |
| 716 'IndexedPropertyEnumerator<%s>' % cpp_class | 775 'IndexedPropertyEnumerator<%s>' % cpp_class |
| 717 if indexed_property_getter.is_enumerable else 'nullptr' %} | 776 if indexed_property_getter.is_enumerable else 'nullptr' %} |
| 777 {% set indexed_property_definer_callback = | |
| 778 '%s::indexedPropertyDefinerCallback' % v8_class_or_partial | |
| 779 if indexed_property_getter else 'nullptr' %} | |
| 718 {% set property_handler_flags = | 780 {% set property_handler_flags = |
| 719 'v8::PropertyHandlerFlags::kNone' %} | 781 'v8::PropertyHandlerFlags::kNone' %} |
| 720 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}}); | 782 v8::IndexedPropertyHandlerConfiguration indexedPropertyHandlerConfig( |
| 783 {{indexed_property_getter_callback}}, | |
| 784 {{indexed_property_setter_callback}}, | |
| 785 {{indexed_property_descriptor_callback}}, | |
| 786 {{indexed_property_deleter_callback}}, | |
| 787 {{indexed_property_enumerator_callback}}, | |
| 788 {{indexed_property_definer_callback}}, | |
| 789 v8::Local<v8::Value>(), | |
| 790 {{property_handler_flags}}); | |
| 721 {{target}}->SetHandler(indexedPropertyHandlerConfig); | 791 {{target}}->SetHandler(indexedPropertyHandlerConfig); |
| 722 {%- endmacro %} | 792 {%- endmacro %} |
| 723 | 793 |
| 724 | 794 |
| 725 {##############################################################################} | 795 {##############################################################################} |
| 726 {% macro install_named_property_handler(target) %} | 796 {% macro install_named_property_handler(target) %} |
| 727 {% set named_property_getter_callback = | 797 {% set named_property_getter_callback = |
| 728 '%s::namedPropertyGetterCallback' % v8_class_or_partial %} | 798 '%s::namedPropertyGetterCallback' % v8_class_or_partial %} |
| 729 {% set named_property_setter_callback = | 799 {% set named_property_setter_callback = |
| 730 '%s::namedPropertySetterCallback' % v8_class_or_partial | 800 '%s::namedPropertySetterCallback' % v8_class_or_partial |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 959 } | 1029 } |
| 960 | 1030 |
| 961 {% for method in methods if method.overloads and method.overloads.has_partial_ov erloads %} | 1031 {% 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>&)) { | 1032 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; | 1033 {{cpp_class}}V8Internal::{{method.name}}MethodForPartialInterface = method; |
| 964 } | 1034 } |
| 965 | 1035 |
| 966 {% endfor %} | 1036 {% endfor %} |
| 967 {% endif %}{# has_partial_interface #} | 1037 {% endif %}{# has_partial_interface #} |
| 968 {% endblock %} | 1038 {% endblock %} |
| OLD | NEW |