Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(147)

Side by Side Diff: third_party/WebKit/Source/bindings/templates/attributes.cpp

Issue 2272613003: binding: Retires ExceptionState::throwIfNeeded(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 not attribute.constructor_type %} 272 not attribute.constructor_type %}
275 {{cpp_class}}* impl = {{v8_class}}::toImpl(holder); 273 {{cpp_class}}* impl = {{v8_class}}::toImpl(holder);
276 {% endif %} 274 {% endif %}
277 {# Security checks #} 275 {# Security checks #}
278 {% if not attribute.is_replaceable and 276 {% if not attribute.is_replaceable and
279 not attribute.constructor_type %} 277 not attribute.constructor_type %}
280 {% if not attribute.is_data_type_property %} 278 {% if not attribute.is_data_type_property %}
281 {% if attribute.is_check_security_for_receiver %} 279 {% if attribute.is_check_security_for_receiver %}
282 if (!BindingSecurity::shouldAllowAccessTo(currentDOMWindow(info.GetIsolate() ), impl, exceptionState)) { 280 if (!BindingSecurity::shouldAllowAccessTo(currentDOMWindow(info.GetIsolate() ), impl, exceptionState)) {
283 v8SetReturnValue(info, v8Value); 281 v8SetReturnValue(info, v8Value);
284 exceptionState.throwIfNeeded();
285 return; 282 return;
286 } 283 }
287 {% endif %} 284 {% endif %}
288 {% endif %} 285 {% endif %}
289 {% if attribute.is_check_security_for_return_value %} 286 {% if attribute.is_check_security_for_return_value %}
290 #error Attribute setter with the security check for the return value is not supp orted. 287 #error Attribute setter with the security check for the return value is not supp orted.
291 {% endif %} 288 {% endif %}
292 {% endif %}{# not attribute.is_replaceable and 289 {% endif %}{# not attribute.is_replaceable and
293 not attribute.constructor_type #} 290 not attribute.constructor_type #}
294 {# Convert JS value to C++ value #} 291 {# Convert JS value to C++ value #}
295 {% if attribute.idl_type != 'EventHandler' %} 292 {% if attribute.idl_type != 'EventHandler' %}
296 {% if v8_value_to_local_cpp_value(attribute) %} 293 {% if v8_value_to_local_cpp_value(attribute) %}
297 {{v8_value_to_local_cpp_value(attribute) | indent}} 294 {{v8_value_to_local_cpp_value(attribute) | indent}}
298 {% endif %} 295 {% endif %}
299 {% elif not is_node %}{# EventHandler hack #} 296 {% elif not is_node %}{# EventHandler hack #}
300 moveEventListenerToNewWrapper(info.GetIsolate(), holder, {{attribute.event_h andler_getter_expression}}, v8Value, {{v8_class}}::eventListenerCacheIndex); 297 moveEventListenerToNewWrapper(info.GetIsolate(), holder, {{attribute.event_h andler_getter_expression}}, v8Value, {{v8_class}}::eventListenerCacheIndex);
301 {% endif %} 298 {% endif %}
302 {# Type checking, possibly throw a TypeError, per: 299 {# Type checking, possibly throw a TypeError, per:
303 http://www.w3.org/TR/WebIDL/#es-type-mapping #} 300 http://www.w3.org/TR/WebIDL/#es-type-mapping #}
304 {% if attribute.has_type_checking_interface %} 301 {% if attribute.has_type_checking_interface %}
305 {# Type checking for interface types (if interface not implemented, throw 302 {# Type checking for interface types (if interface not implemented, throw
306 TypeError), per http://www.w3.org/TR/WebIDL/#es-interface #} 303 TypeError), per http://www.w3.org/TR/WebIDL/#es-interface #}
307 if (!cppValue{% if attribute.is_nullable %} && !isUndefinedOrNull(v8Value){% endif %}) { 304 if (!cppValue{% if attribute.is_nullable %} && !isUndefinedOrNull(v8Value){% endif %}) {
308 exceptionState.throwTypeError("The provided value is not of type '{{attr ibute.idl_type}}'."); 305 exceptionState.throwTypeError("The provided value is not of type '{{attr ibute.idl_type}}'.");
309 exceptionState.throwIfNeeded();
310 return; 306 return;
311 } 307 }
312 {% elif attribute.enum_values %} 308 {% elif attribute.enum_values %}
313 {# Setter ignores invalid enum values: 309 {# Setter ignores invalid enum values:
314 http://www.w3.org/TR/WebIDL/#idl-enums #} 310 http://www.w3.org/TR/WebIDL/#idl-enums #}
315 {% if not attribute.has_setter_exception_state %} 311 {% if not attribute.has_setter_exception_state %}
316 NonThrowableExceptionState exceptionState; 312 NonThrowableExceptionState exceptionState;
317 {% endif %} 313 {% endif %}
318 {{declare_enum_validation_variable(attribute.enum_values) | indent}} 314 {{declare_enum_validation_variable(attribute.enum_values) | indent}}
319 if (!isValidEnum(cppValue, validValues, WTF_ARRAY_LENGTH(validValues), "{{at tribute.enum_type}}", exceptionState)) { 315 if (!isValidEnum(cppValue, validValues, WTF_ARRAY_LENGTH(validValues), "{{at tribute.enum_type}}", exceptionState)) {
320 currentExecutionContext(info.GetIsolate())->addConsoleMessage(ConsoleMes sage::create(JSMessageSource, WarningMessageLevel, exceptionState.message())); 316 currentExecutionContext(info.GetIsolate())->addConsoleMessage(ConsoleMes sage::create(JSMessageSource, WarningMessageLevel, exceptionState.message()));
317 // http://heycam.github.io/webidl/#idl-enums
318 // Assignment of an invalid string value to an attribute is ignored,
319 // while passing such a value as an operation argument results in
320 // an exception being thrown.
321 exceptionState.clearException();
321 return; 322 return;
322 } 323 }
323 {% endif %} 324 {% endif %}
324 {# Pre-set context #} 325 {# Pre-set context #}
325 {% if attribute.is_custom_element_callbacks or 326 {% if attribute.is_custom_element_callbacks or
326 (attribute.is_reflect and 327 (attribute.is_reflect and
327 not(attribute.idl_type == 'DOMString' and is_node)) %} 328 not(attribute.idl_type == 'DOMString' and is_node)) %}
328 {# Skip on compact node DOMString getters #} 329 {# Skip on compact node DOMString getters #}
329 V0CustomElementProcessingStack::CallbackDeliveryScope deliveryScope; 330 V0CustomElementProcessingStack::CallbackDeliveryScope deliveryScope;
330 {% endif %} 331 {% endif %}
331 {% if attribute.is_call_with_execution_context or 332 {% if attribute.is_call_with_execution_context or
332 attribute.is_setter_call_with_execution_context %} 333 attribute.is_setter_call_with_execution_context %}
333 ExecutionContext* executionContext = currentExecutionContext(info.GetIsolate ()); 334 ExecutionContext* executionContext = currentExecutionContext(info.GetIsolate ());
334 {% endif %} 335 {% endif %}
335 {% if attribute.is_call_with_script_state %} 336 {% if attribute.is_call_with_script_state %}
336 {% if attribute.is_static %} 337 {% if attribute.is_static %}
337 ScriptState* scriptState = ScriptState::forFunctionObject(info); 338 ScriptState* scriptState = ScriptState::forFunctionObject(info);
338 {% else %} 339 {% else %}
339 ScriptState* scriptState = ScriptState::forReceiverObject(info); 340 ScriptState* scriptState = ScriptState::forReceiverObject(info);
340 {% endif %} 341 {% endif %}
341 {% endif %} 342 {% endif %}
342 {# Set #} 343 {# Set #}
343 {% if attribute.cpp_setter %} 344 {% if attribute.cpp_setter %}
344 {{attribute.cpp_setter}}; 345 {{attribute.cpp_setter}};
345 {% endif %} 346 {% endif %}
346 {# Post-set #} 347 {# Post-set #}
347 {% if attribute.is_setter_raises_exception %}
348 exceptionState.throwIfNeeded();
349 {% endif %}
350 {% if attribute.cached_attribute_validation_method %} 348 {% if attribute.cached_attribute_validation_method %}
351 V8HiddenValue::deleteHiddenValue(ScriptState::current(info.GetIsolate()), ho lder, v8AtomicString(info.GetIsolate(), "{{attribute.name}}")); // Invalidate th e cached value. 349 V8HiddenValue::deleteHiddenValue(ScriptState::current(info.GetIsolate()), ho lder, v8AtomicString(info.GetIsolate(), "{{attribute.name}}")); // Invalidate th e cached value.
352 {% endif %} 350 {% endif %}
353 } 351 }
354 {% endmacro %} 352 {% endmacro %}
355 353
356 354
357 {##############################################################################} 355 {##############################################################################}
358 {% macro attribute_setter_callback(attribute, world_suffix) %} 356 {% macro attribute_setter_callback(attribute, world_suffix) %}
359 static void {{attribute.name}}AttributeSetterCallback{{world_suffix}}( 357 static void {{attribute.name}}AttributeSetterCallback{{world_suffix}}(
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 setter_callback_for_main_world, 506 setter_callback_for_main_world,
509 wrapper_type_info, 507 wrapper_type_info,
510 access_control, 508 access_control,
511 property_attribute, 509 property_attribute,
512 only_exposed_to_private_script, 510 only_exposed_to_private_script,
513 property_location(attribute), 511 property_location(attribute),
514 holder_check, 512 holder_check,
515 ] %} 513 ] %}
516 {{'{'}}{{attribute_configuration_list | join(', ')}}{{'}'}} 514 {{'{'}}{{attribute_configuration_list | join(', ')}}{{'}'}}
517 {%- endmacro %} 515 {%- endmacro %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698