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

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

Issue 2061113002: Remove ExceptionState::throwIfNeeded Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: temp Created 4 years, 5 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 {% endif %} 75 {% endif %}
76 {% if attribute.is_implemented_in_private_script %} 76 {% if attribute.is_implemented_in_private_script %}
77 {{attribute.cpp_type}} result{{attribute.cpp_type_initializer}}; 77 {{attribute.cpp_type}} result{{attribute.cpp_type_initializer}};
78 if (!{{attribute.cpp_value_original}}) 78 if (!{{attribute.cpp_value_original}})
79 return; 79 return;
80 {% elif attribute.cpp_value_original %} 80 {% elif attribute.cpp_value_original %}
81 {{attribute.cpp_type}} {{attribute.cpp_value}}({{attribute.cpp_value_origina l}}); 81 {{attribute.cpp_type}} {{attribute.cpp_value}}({{attribute.cpp_value_origina l}});
82 {% endif %} 82 {% endif %}
83 {# Checks #} 83 {# Checks #}
84 {% if attribute.is_getter_raises_exception %} 84 {% if attribute.is_getter_raises_exception %}
85 if (UNLIKELY(exceptionState.throwIfNeeded())) 85 if (UNLIKELY(exceptionState.hadException()))
86 return; 86 return;
87 {% endif %} 87 {% endif %}
88 {# Security checks #} 88 {# Security checks #}
89 {% if not attribute.is_data_type_property %} 89 {% if not attribute.is_data_type_property %}
90 {% if attribute.is_check_security_for_receiver %} 90 {% if attribute.is_check_security_for_receiver %}
91 if (!BindingSecurity::shouldAllowAccessTo(info.GetIsolate(), currentDOMWindo w(info.GetIsolate()), impl, exceptionState)) { 91 if (!BindingSecurity::shouldAllowAccessTo(info.GetIsolate(), currentDOMWindo w(info.GetIsolate()), impl, exceptionState)) {
92 v8SetReturnValueNull(info); 92 v8SetReturnValueNull(info);
93 exceptionState.throwIfNeeded();
94 return; 93 return;
95 } 94 }
96 {% endif %} 95 {% endif %}
97 {% endif %} 96 {% endif %}
98 {% if attribute.is_check_security_for_return_value %} 97 {% if attribute.is_check_security_for_return_value %}
99 if (!BindingSecurity::shouldAllowAccessTo(info.GetIsolate(), currentDOMWindo w(info.GetIsolate()), {{attribute.cpp_value}}, exceptionState)) { 98 if (!BindingSecurity::shouldAllowAccessTo(info.GetIsolate(), currentDOMWindo w(info.GetIsolate()), {{attribute.cpp_value}}, exceptionState)) {
100 v8SetReturnValueNull(info); 99 v8SetReturnValueNull(info);
101 exceptionState.throwIfNeeded();
102 return; 100 return;
103 } 101 }
104 {% endif %} 102 {% endif %}
105 {% if attribute.reflect_only %} 103 {% if attribute.reflect_only %}
106 {{release_only_check(attribute.reflect_only, attribute.reflect_missing, 104 {{release_only_check(attribute.reflect_only, attribute.reflect_missing,
107 attribute.reflect_invalid, attribute.reflect_empty, 105 attribute.reflect_invalid, attribute.reflect_empty,
108 attribute.cpp_value) 106 attribute.cpp_value)
109 | indent}} 107 | indent}}
110 {% endif %} 108 {% endif %}
111 {% if attribute.is_explicit_nullable %} 109 {% if attribute.is_explicit_nullable %}
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 if (!impl->document()) 281 if (!impl->document())
284 return; 282 return;
285 {% endif %} 283 {% endif %}
286 {# Security checks #} 284 {# Security checks #}
287 {% if not attribute.is_replaceable and 285 {% if not attribute.is_replaceable and
288 not attribute.constructor_type %} 286 not attribute.constructor_type %}
289 {% if not attribute.is_data_type_property %} 287 {% if not attribute.is_data_type_property %}
290 {% if attribute.is_check_security_for_receiver %} 288 {% if attribute.is_check_security_for_receiver %}
291 if (!BindingSecurity::shouldAllowAccessTo(info.GetIsolate(), currentDOMWindo w(info.GetIsolate()), impl, exceptionState)) { 289 if (!BindingSecurity::shouldAllowAccessTo(info.GetIsolate(), currentDOMWindo w(info.GetIsolate()), impl, exceptionState)) {
292 v8SetReturnValue(info, v8Value); 290 v8SetReturnValue(info, v8Value);
293 exceptionState.throwIfNeeded();
294 return; 291 return;
295 } 292 }
296 {% endif %} 293 {% endif %}
297 {% endif %} 294 {% endif %}
298 {% if attribute.is_check_security_for_return_value %} 295 {% if attribute.is_check_security_for_return_value %}
299 #error Attribute setter with the security check for the return value is not supp orted. 296 #error Attribute setter with the security check for the return value is not supp orted.
300 {% endif %} 297 {% endif %}
301 {% endif %}{# not attribute.is_replaceable and 298 {% endif %}{# not attribute.is_replaceable and
302 not attribute.constructor_type #} 299 not attribute.constructor_type #}
303 {# Convert JS value to C++ value #} 300 {# Convert JS value to C++ value #}
304 {% if attribute.idl_type != 'EventHandler' %} 301 {% if attribute.idl_type != 'EventHandler' %}
305 {% if v8_value_to_local_cpp_value(attribute) %} 302 {% if v8_value_to_local_cpp_value(attribute) %}
306 {{v8_value_to_local_cpp_value(attribute) | indent}} 303 {{v8_value_to_local_cpp_value(attribute) | indent}}
307 {% endif %} 304 {% endif %}
308 {% elif not is_node %}{# EventHandler hack #} 305 {% elif not is_node %}{# EventHandler hack #}
309 moveEventListenerToNewWrapper(info.GetIsolate(), holder, {{attribute.event_h andler_getter_expression}}, v8Value, {{v8_class}}::eventListenerCacheIndex); 306 moveEventListenerToNewWrapper(info.GetIsolate(), holder, {{attribute.event_h andler_getter_expression}}, v8Value, {{v8_class}}::eventListenerCacheIndex);
310 {% endif %} 307 {% endif %}
311 {# Type checking, possibly throw a TypeError, per: 308 {# Type checking, possibly throw a TypeError, per:
312 http://www.w3.org/TR/WebIDL/#es-type-mapping #} 309 http://www.w3.org/TR/WebIDL/#es-type-mapping #}
313 {% if attribute.has_type_checking_interface %} 310 {% if attribute.has_type_checking_interface %}
314 {# Type checking for interface types (if interface not implemented, throw 311 {# Type checking for interface types (if interface not implemented, throw
315 TypeError), per http://www.w3.org/TR/WebIDL/#es-interface #} 312 TypeError), per http://www.w3.org/TR/WebIDL/#es-interface #}
316 if (!cppValue{% if attribute.is_nullable %} && !isUndefinedOrNull(v8Value){% endif %}) { 313 if (!cppValue{% if attribute.is_nullable %} && !isUndefinedOrNull(v8Value){% endif %}) {
317 exceptionState.throwTypeError("The provided value is not of type '{{attr ibute.idl_type}}'."); 314 exceptionState.throwTypeError("The provided value is not of type '{{attr ibute.idl_type}}'.");
318 exceptionState.throwIfNeeded();
319 return; 315 return;
320 } 316 }
321 {% elif attribute.enum_values %} 317 {% elif attribute.enum_values %}
322 {# Setter ignores invalid enum values: 318 {# Setter ignores invalid enum values:
323 http://www.w3.org/TR/WebIDL/#idl-enums #} 319 http://www.w3.org/TR/WebIDL/#idl-enums #}
324 {% if not attribute.has_setter_exception_state %} 320 {% if not attribute.has_setter_exception_state %}
325 NonThrowableExceptionState exceptionState; 321 NonThrowableExceptionState exceptionState;
326 {% endif %} 322 {% endif %}
327 {{declare_enum_validation_variable(attribute.enum_values) | indent}} 323 {{declare_enum_validation_variable(attribute.enum_values) | indent}}
328 if (!isValidEnum(cppValue, validValues, WTF_ARRAY_LENGTH(validValues), "{{at tribute.enum_type}}", exceptionState)) { 324 if (!isValidEnum(cppValue, validValues, WTF_ARRAY_LENGTH(validValues), "{{at tribute.enum_type}}", exceptionState)) {
(...skipping 13 matching lines...) Expand all
342 ExecutionContext* executionContext = currentExecutionContext(info.GetIsolate ()); 338 ExecutionContext* executionContext = currentExecutionContext(info.GetIsolate ());
343 {% endif %} 339 {% endif %}
344 {% if attribute.is_call_with_script_state %} 340 {% if attribute.is_call_with_script_state %}
345 ScriptState* scriptState = ScriptState::current(info.GetIsolate()); 341 ScriptState* scriptState = ScriptState::current(info.GetIsolate());
346 {% endif %} 342 {% endif %}
347 {# Set #} 343 {# Set #}
348 {% if attribute.cpp_setter %} 344 {% if attribute.cpp_setter %}
349 {{attribute.cpp_setter}}; 345 {{attribute.cpp_setter}};
350 {% endif %} 346 {% endif %}
351 {# Post-set #} 347 {# Post-set #}
352 {% if attribute.is_setter_raises_exception %}
353 exceptionState.throwIfNeeded();
354 {% endif %}
355 {% if attribute.cached_attribute_validation_method %} 348 {% if attribute.cached_attribute_validation_method %}
356 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.
357 {% endif %} 350 {% endif %}
358 } 351 }
359 {% endmacro %} 352 {% endmacro %}
360 353
361 354
362 {##############################################################################} 355 {##############################################################################}
363 {% macro attribute_setter_callback(attribute, world_suffix) %} 356 {% macro attribute_setter_callback(attribute, world_suffix) %}
364 static void {{attribute.name}}AttributeSetterCallback{{world_suffix}}( 357 static void {{attribute.name}}AttributeSetterCallback{{world_suffix}}(
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 setter_callback_for_main_world, 502 setter_callback_for_main_world,
510 wrapper_type_info, 503 wrapper_type_info,
511 access_control, 504 access_control,
512 property_attribute, 505 property_attribute,
513 only_exposed_to_private_script, 506 only_exposed_to_private_script,
514 property_location(attribute), 507 property_location(attribute),
515 holder_check, 508 holder_check,
516 ] %} 509 ] %}
517 {{'{'}}{{attribute_configuration_list | join(', ')}}{{'}'}} 510 {{'{'}}{{attribute_configuration_list | join(', ')}}{{'}'}}
518 {%- endmacro %} 511 {%- endmacro %}
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/bindings/scripts/v8_types.py ('k') | third_party/WebKit/Source/bindings/templates/interface.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698