OLD | NEW |
1 {% from 'utilities.cpp' import declare_enum_validation_variable, v8_value_to_loc
al_cpp_value %} | 1 {% from 'utilities.cpp' import declare_enum_validation_variable, v8_value_to_loc
al_cpp_value %} |
2 | 2 |
3 {##############################################################################} | 3 {##############################################################################} |
4 {% macro attribute_getter(attribute, world_suffix) %} | 4 {% macro attribute_getter(attribute, world_suffix) %} |
5 static void {{attribute.name}}AttributeGetter{{world_suffix}}( | 5 static void {{attribute.name}}AttributeGetter{{world_suffix}}( |
6 {%- if attribute.is_data_type_property %} | 6 {%- if attribute.is_data_type_property %} |
7 const v8::PropertyCallbackInfo<v8::Value>& info | 7 const v8::PropertyCallbackInfo<v8::Value>& info |
8 {%- else %} | 8 {%- else %} |
9 const v8::FunctionCallbackInfo<v8::Value>& info | 9 const v8::FunctionCallbackInfo<v8::Value>& info |
10 {%- endif %}) | 10 {%- endif %}) |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 {% endif %} | 70 {% endif %} |
71 {% if attribute.is_implemented_in_private_script %} | 71 {% if attribute.is_implemented_in_private_script %} |
72 {{attribute.cpp_type}} result{{attribute.cpp_type_initializer}}; | 72 {{attribute.cpp_type}} result{{attribute.cpp_type_initializer}}; |
73 if (!{{attribute.cpp_value_original}}) | 73 if (!{{attribute.cpp_value_original}}) |
74 return; | 74 return; |
75 {% elif attribute.cpp_value_original %} | 75 {% elif attribute.cpp_value_original %} |
76 {{attribute.cpp_type}} {{attribute.cpp_value}}({{attribute.cpp_value_origina
l}}); | 76 {{attribute.cpp_type}} {{attribute.cpp_value}}({{attribute.cpp_value_origina
l}}); |
77 {% endif %} | 77 {% endif %} |
78 {# Checks #} | 78 {# Checks #} |
79 {% if attribute.is_getter_raises_exception %} | 79 {% if attribute.is_getter_raises_exception %} |
80 if (UNLIKELY(exceptionState.throwIfNeeded())) | 80 if (UNLIKELY(exceptionState.hadException())) |
81 return; | 81 return; |
82 {% endif %} | 82 {% endif %} |
83 {# Security checks #} | 83 {# Security checks #} |
84 {% if not attribute.is_data_type_property %} | 84 {% if not attribute.is_data_type_property %} |
85 {% if attribute.is_check_security_for_receiver %} | 85 {% if attribute.is_check_security_for_receiver %} |
86 if (!BindingSecurity::shouldAllowAccessTo(currentDOMWindow(info.GetIsolate()
), impl, exceptionState)) { | 86 if (!BindingSecurity::shouldAllowAccessTo(currentDOMWindow(info.GetIsolate()
), impl, exceptionState)) { |
87 v8SetReturnValueNull(info); | 87 v8SetReturnValueNull(info); |
88 exceptionState.throwIfNeeded(); | |
89 return; | 88 return; |
90 } | 89 } |
91 {% endif %} | 90 {% endif %} |
92 {% endif %} | 91 {% endif %} |
93 {% if attribute.is_check_security_for_return_value %} | 92 {% if attribute.is_check_security_for_return_value %} |
94 if (!BindingSecurity::shouldAllowAccessTo(currentDOMWindow(info.GetIsolate()
), {{attribute.cpp_value}}, exceptionState)) { | 93 if (!BindingSecurity::shouldAllowAccessTo(currentDOMWindow(info.GetIsolate()
), {{attribute.cpp_value}}, exceptionState)) { |
95 v8SetReturnValueNull(info); | 94 v8SetReturnValueNull(info); |
96 exceptionState.throwIfNeeded(); | |
97 return; | 95 return; |
98 } | 96 } |
99 {% endif %} | 97 {% endif %} |
100 {% if attribute.reflect_only %} | 98 {% if attribute.reflect_only %} |
101 {{release_only_check(attribute.reflect_only, attribute.reflect_missing, | 99 {{release_only_check(attribute.reflect_only, attribute.reflect_missing, |
102 attribute.reflect_invalid, attribute.reflect_empty, | 100 attribute.reflect_invalid, attribute.reflect_empty, |
103 attribute.cpp_value) | 101 attribute.cpp_value) |
104 | indent}} | 102 | indent}} |
105 {% endif %} | 103 {% endif %} |
106 {% if attribute.is_explicit_nullable %} | 104 {% if attribute.is_explicit_nullable %} |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 not attribute.constructor_type %} | 270 not attribute.constructor_type %} |
273 {{cpp_class}}* impl = {{v8_class}}::toImpl(holder); | 271 {{cpp_class}}* impl = {{v8_class}}::toImpl(holder); |
274 {% endif %} | 272 {% endif %} |
275 {# Security checks #} | 273 {# Security checks #} |
276 {% if not attribute.is_replaceable and | 274 {% if not attribute.is_replaceable and |
277 not attribute.constructor_type %} | 275 not attribute.constructor_type %} |
278 {% if not attribute.is_data_type_property %} | 276 {% if not attribute.is_data_type_property %} |
279 {% if attribute.is_check_security_for_receiver %} | 277 {% if attribute.is_check_security_for_receiver %} |
280 if (!BindingSecurity::shouldAllowAccessTo(currentDOMWindow(info.GetIsolate()
), impl, exceptionState)) { | 278 if (!BindingSecurity::shouldAllowAccessTo(currentDOMWindow(info.GetIsolate()
), impl, exceptionState)) { |
281 v8SetReturnValue(info, v8Value); | 279 v8SetReturnValue(info, v8Value); |
282 exceptionState.throwIfNeeded(); | |
283 return; | 280 return; |
284 } | 281 } |
285 {% endif %} | 282 {% endif %} |
286 {% endif %} | 283 {% endif %} |
287 {% if attribute.is_check_security_for_return_value %} | 284 {% if attribute.is_check_security_for_return_value %} |
288 #error Attribute setter with the security check for the return value is not supp
orted. | 285 #error Attribute setter with the security check for the return value is not supp
orted. |
289 {% endif %} | 286 {% endif %} |
290 {% endif %}{# not attribute.is_replaceable and | 287 {% endif %}{# not attribute.is_replaceable and |
291 not attribute.constructor_type #} | 288 not attribute.constructor_type #} |
292 {# Convert JS value to C++ value #} | 289 {# Convert JS value to C++ value #} |
293 {% if attribute.idl_type != 'EventHandler' %} | 290 {% if attribute.idl_type != 'EventHandler' %} |
294 {% if v8_value_to_local_cpp_value(attribute) %} | 291 {% if v8_value_to_local_cpp_value(attribute) %} |
295 {{v8_value_to_local_cpp_value(attribute) | indent}} | 292 {{v8_value_to_local_cpp_value(attribute) | indent}} |
296 {% endif %} | 293 {% endif %} |
297 {% elif not is_node %}{# EventHandler hack #} | 294 {% elif not is_node %}{# EventHandler hack #} |
298 moveEventListenerToNewWrapper(info.GetIsolate(), holder, {{attribute.event_h
andler_getter_expression}}, v8Value, {{v8_class}}::eventListenerCacheIndex); | 295 moveEventListenerToNewWrapper(info.GetIsolate(), holder, {{attribute.event_h
andler_getter_expression}}, v8Value, {{v8_class}}::eventListenerCacheIndex); |
299 {% endif %} | 296 {% endif %} |
300 {# Type checking, possibly throw a TypeError, per: | 297 {# Type checking, possibly throw a TypeError, per: |
301 http://www.w3.org/TR/WebIDL/#es-type-mapping #} | 298 http://www.w3.org/TR/WebIDL/#es-type-mapping #} |
302 {% if attribute.has_type_checking_interface %} | 299 {% if attribute.has_type_checking_interface %} |
303 {# Type checking for interface types (if interface not implemented, throw | 300 {# Type checking for interface types (if interface not implemented, throw |
304 TypeError), per http://www.w3.org/TR/WebIDL/#es-interface #} | 301 TypeError), per http://www.w3.org/TR/WebIDL/#es-interface #} |
305 if (!cppValue{% if attribute.is_nullable %} && !isUndefinedOrNull(v8Value){%
endif %}) { | 302 if (!cppValue{% if attribute.is_nullable %} && !isUndefinedOrNull(v8Value){%
endif %}) { |
306 exceptionState.throwTypeError("The provided value is not of type '{{attr
ibute.idl_type}}'."); | 303 exceptionState.throwTypeError("The provided value is not of type '{{attr
ibute.idl_type}}'."); |
307 exceptionState.throwIfNeeded(); | |
308 return; | 304 return; |
309 } | 305 } |
310 {% elif attribute.enum_values %} | 306 {% elif attribute.enum_values %} |
311 {# Setter ignores invalid enum values: | 307 {# Setter ignores invalid enum values: |
312 http://www.w3.org/TR/WebIDL/#idl-enums #} | 308 http://www.w3.org/TR/WebIDL/#idl-enums #} |
313 {% if not attribute.has_setter_exception_state %} | 309 {% if not attribute.has_setter_exception_state %} |
314 NonThrowableExceptionState exceptionState; | 310 NonThrowableExceptionState exceptionState; |
315 {% endif %} | 311 {% endif %} |
316 {{declare_enum_validation_variable(attribute.enum_values) | indent}} | 312 {{declare_enum_validation_variable(attribute.enum_values) | indent}} |
317 if (!isValidEnum(cppValue, validValues, WTF_ARRAY_LENGTH(validValues), "{{at
tribute.enum_type}}", exceptionState)) { | 313 if (!isValidEnum(cppValue, validValues, WTF_ARRAY_LENGTH(validValues), "{{at
tribute.enum_type}}", exceptionState)) { |
318 currentExecutionContext(info.GetIsolate())->addConsoleMessage(ConsoleMes
sage::create(JSMessageSource, WarningMessageLevel, exceptionState.message())); | 314 currentExecutionContext(info.GetIsolate())->addConsoleMessage(ConsoleMes
sage::create(JSMessageSource, WarningMessageLevel, exceptionState.message())); |
| 315 // http://heycam.github.io/webidl/#idl-enums |
| 316 // Assignment of an invalid string value to an attribute is ignored, |
| 317 // while passing such a value as an operation argument results in |
| 318 // an exception being thrown. |
| 319 exceptionState.clearException(); |
319 return; | 320 return; |
320 } | 321 } |
321 {% endif %} | 322 {% endif %} |
322 {# Pre-set context #} | 323 {# Pre-set context #} |
323 {% if attribute.is_custom_element_callbacks or | 324 {% if attribute.is_custom_element_callbacks or |
324 (attribute.is_reflect and | 325 (attribute.is_reflect and |
325 not(attribute.idl_type == 'DOMString' and is_node)) %} | 326 not(attribute.idl_type == 'DOMString' and is_node)) %} |
326 {# Skip on compact node DOMString getters #} | 327 {# Skip on compact node DOMString getters #} |
327 V0CustomElementProcessingStack::CallbackDeliveryScope deliveryScope; | 328 V0CustomElementProcessingStack::CallbackDeliveryScope deliveryScope; |
328 {% endif %} | 329 {% endif %} |
329 {% if attribute.is_call_with_execution_context or | 330 {% if attribute.is_call_with_execution_context or |
330 attribute.is_setter_call_with_execution_context %} | 331 attribute.is_setter_call_with_execution_context %} |
331 ExecutionContext* executionContext = currentExecutionContext(info.GetIsolate
()); | 332 ExecutionContext* executionContext = currentExecutionContext(info.GetIsolate
()); |
332 {% endif %} | 333 {% endif %} |
333 {% if attribute.is_call_with_script_state %} | 334 {% if attribute.is_call_with_script_state %} |
334 {% if attribute.is_static %} | 335 {% if attribute.is_static %} |
335 ScriptState* scriptState = ScriptState::forFunctionObject(info); | 336 ScriptState* scriptState = ScriptState::forFunctionObject(info); |
336 {% else %} | 337 {% else %} |
337 ScriptState* scriptState = ScriptState::forReceiverObject(info); | 338 ScriptState* scriptState = ScriptState::forReceiverObject(info); |
338 {% endif %} | 339 {% endif %} |
339 {% endif %} | 340 {% endif %} |
340 {# Set #} | 341 {# Set #} |
341 {% if attribute.cpp_setter %} | 342 {% if attribute.cpp_setter %} |
342 {{attribute.cpp_setter}}; | 343 {{attribute.cpp_setter}}; |
343 {% endif %} | 344 {% endif %} |
344 {# Post-set #} | 345 {# Post-set #} |
345 {% if attribute.is_setter_raises_exception %} | |
346 exceptionState.throwIfNeeded(); | |
347 {% endif %} | |
348 {% if attribute.cached_attribute_validation_method %} | 346 {% if attribute.cached_attribute_validation_method %} |
349 V8HiddenValue::deleteHiddenValue(ScriptState::current(info.GetIsolate()), ho
lder, v8AtomicString(info.GetIsolate(), "{{attribute.name}}")); // Invalidate th
e cached value. | 347 V8HiddenValue::deleteHiddenValue(ScriptState::current(info.GetIsolate()), ho
lder, v8AtomicString(info.GetIsolate(), "{{attribute.name}}")); // Invalidate th
e cached value. |
350 {% endif %} | 348 {% endif %} |
351 } | 349 } |
352 {% endmacro %} | 350 {% endmacro %} |
353 | 351 |
354 | 352 |
355 {##############################################################################} | 353 {##############################################################################} |
356 {% macro attribute_setter_callback(attribute, world_suffix) %} | 354 {% macro attribute_setter_callback(attribute, world_suffix) %} |
357 static void {{attribute.name}}AttributeSetterCallback{{world_suffix}}( | 355 static void {{attribute.name}}AttributeSetterCallback{{world_suffix}}( |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 setter_callback_for_main_world, | 497 setter_callback_for_main_world, |
500 wrapper_type_info, | 498 wrapper_type_info, |
501 access_control, | 499 access_control, |
502 property_attribute, | 500 property_attribute, |
503 only_exposed_to_private_script, | 501 only_exposed_to_private_script, |
504 property_location(attribute), | 502 property_location(attribute), |
505 holder_check, | 503 holder_check, |
506 ] %} | 504 ] %} |
507 {{'{'}}{{attribute_configuration_list | join(', ')}}{{'}'}} | 505 {{'{'}}{{attribute_configuration_list | join(', ')}}{{'}'}} |
508 {%- endmacro %} | 506 {%- endmacro %} |
OLD | NEW |