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

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

Issue 594213002: Inline exception handling code into PrivateScriptRunner helpers (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 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
« no previous file with comments | « Source/bindings/core/v8/PrivateScriptRunner.cpp ('k') | Source/bindings/templates/methods.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 {##############################################################################} 1 {##############################################################################}
2 {% macro attribute_getter(attribute, world_suffix) %} 2 {% macro attribute_getter(attribute, world_suffix) %}
3 {% filter conditional(attribute.conditional_string) %} 3 {% filter conditional(attribute.conditional_string) %}
4 static void {{attribute.name}}AttributeGetter{{world_suffix}}( 4 static void {{attribute.name}}AttributeGetter{{world_suffix}}(
5 {%- if attribute.is_expose_js_accessors %} 5 {%- if attribute.is_expose_js_accessors %}
6 const v8::FunctionCallbackInfo<v8::Value>& info 6 const v8::FunctionCallbackInfo<v8::Value>& info
7 {%- else %} 7 {%- else %}
8 const v8::PropertyCallbackInfo<v8::Value>& info 8 const v8::PropertyCallbackInfo<v8::Value>& info
9 {%- endif %}) 9 {%- endif %})
10 { 10 {
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 return false; 343 return false;
344 ScriptState* scriptState = ScriptState::from(contextInPrivateScript); 344 ScriptState* scriptState = ScriptState::from(contextInPrivateScript);
345 ScriptState* scriptStateInUserScript = ScriptState::forMainWorld(frame); 345 ScriptState* scriptStateInUserScript = ScriptState::forMainWorld(frame);
346 if (!scriptState->executionContext()) 346 if (!scriptState->executionContext())
347 return false; 347 return false;
348 348
349 ScriptState::Scope scope(scriptState); 349 ScriptState::Scope scope(scriptState);
350 v8::Handle<v8::Value> holder = toV8(holderImpl, scriptState->context()->Glob al(), scriptState->isolate()); 350 v8::Handle<v8::Value> holder = toV8(holderImpl, scriptState->context()->Glob al(), scriptState->isolate());
351 351
352 ExceptionState exceptionState(ExceptionState::GetterContext, "{{attribute.na me}}", "{{cpp_class}}", scriptState->context()->Global(), scriptState->isolate() ); 352 ExceptionState exceptionState(ExceptionState::GetterContext, "{{attribute.na me}}", "{{cpp_class}}", scriptState->context()->Global(), scriptState->isolate() );
353 v8::TryCatch block; 353 v8::Handle<v8::Value> v8Value = PrivateScriptRunner::runDOMAttributeGetter(s criptState, scriptStateInUserScript, "{{cpp_class}}", "{{attribute.name}}", hold er);
354 v8::Handle<v8::Value> v8Value = PrivateScriptRunner::runDOMAttributeGetter(s criptState, "{{cpp_class}}", "{{attribute.name}}", holder); 354 if (v8Value.IsEmpty())
355 if (block.HasCaught()) {
356 PrivateScriptRunner::rethrowExceptionInPrivateScript(scriptState->isolat e(), block, scriptStateInUserScript, ExceptionState::GetterContext, "{{attribute .name}}", "{{cpp_class}}");
357 block.ReThrow();
358 return false; 355 return false;
359 }
360 {{attribute.private_script_v8_value_to_local_cpp_value}}; 356 {{attribute.private_script_v8_value_to_local_cpp_value}};
361 RELEASE_ASSERT(!exceptionState.hadException()); 357 RELEASE_ASSERT(!exceptionState.hadException());
362 *result = cppValue; 358 *result = cppValue;
363 return true; 359 return true;
364 } 360 }
365 {% endmacro %} 361 {% endmacro %}
366 362
367 363
368 {% macro attribute_setter_implemented_in_private_script(attribute) %} 364 {% macro attribute_setter_implemented_in_private_script(attribute) %}
369 bool {{v8_class}}::PrivateScript::{{attribute.name}}AttributeSetter(LocalFrame* frame, {{cpp_class}}* holderImpl, {{attribute.argument_cpp_type}} cppValue) 365 bool {{v8_class}}::PrivateScript::{{attribute.name}}AttributeSetter(LocalFrame* frame, {{cpp_class}}* holderImpl, {{attribute.argument_cpp_type}} cppValue)
370 { 366 {
371 if (!frame) 367 if (!frame)
372 return false; 368 return false;
373 v8::HandleScope handleScope(toIsolate(frame)); 369 v8::HandleScope handleScope(toIsolate(frame));
374 ScriptForbiddenScope::AllowUserAgentScript script; 370 ScriptForbiddenScope::AllowUserAgentScript script;
375 v8::Handle<v8::Context> contextInPrivateScript = toV8Context(frame, DOMWrapp erWorld::privateScriptIsolatedWorld()); 371 v8::Handle<v8::Context> contextInPrivateScript = toV8Context(frame, DOMWrapp erWorld::privateScriptIsolatedWorld());
376 if (contextInPrivateScript.IsEmpty()) 372 if (contextInPrivateScript.IsEmpty())
377 return false; 373 return false;
378 ScriptState* scriptState = ScriptState::from(contextInPrivateScript); 374 ScriptState* scriptState = ScriptState::from(contextInPrivateScript);
379 ScriptState* scriptStateInUserScript = ScriptState::forMainWorld(frame); 375 ScriptState* scriptStateInUserScript = ScriptState::forMainWorld(frame);
380 if (!scriptState->executionContext()) 376 if (!scriptState->executionContext())
381 return false; 377 return false;
382 378
383 ScriptState::Scope scope(scriptState); 379 ScriptState::Scope scope(scriptState);
384 v8::Handle<v8::Value> holder = toV8(holderImpl, scriptState->context()->Glob al(), scriptState->isolate()); 380 v8::Handle<v8::Value> holder = toV8(holderImpl, scriptState->context()->Glob al(), scriptState->isolate());
385 381
386 ExceptionState exceptionState(ExceptionState::SetterContext, "{{attribute.na me}}", "{{cpp_class}}", scriptState->context()->Global(), scriptState->isolate() ); 382 ExceptionState exceptionState(ExceptionState::SetterContext, "{{attribute.na me}}", "{{cpp_class}}", scriptState->context()->Global(), scriptState->isolate() );
387 v8::TryCatch block; 383 return PrivateScriptRunner::runDOMAttributeSetter(scriptState, scriptStateIn UserScript, "{{cpp_class}}", "{{attribute.name}}", holder, {{attribute.private_s cript_cpp_value_to_v8_value}});
388 PrivateScriptRunner::runDOMAttributeSetter(scriptState, "{{cpp_class}}", "{{ attribute.name}}", holder, {{attribute.private_script_cpp_value_to_v8_value}});
389 if (block.HasCaught()) {
390 PrivateScriptRunner::rethrowExceptionInPrivateScript(scriptState->isolat e(), block, scriptStateInUserScript, ExceptionState::SetterContext, "{{attribute .name}}", "{{cpp_class}}");
391 block.ReThrow();
392 return false;
393 }
394 return true;
395 } 384 }
396 {% endmacro %} 385 {% endmacro %}
397 386
398 387
399 {##############################################################################} 388 {##############################################################################}
400 {% macro attribute_configuration(attribute) %} 389 {% macro attribute_configuration(attribute) %}
401 {% set getter_callback = 390 {% set getter_callback =
402 '%sV8Internal::%sAttributeGetterCallback' % 391 '%sV8Internal::%sAttributeGetterCallback' %
403 (cpp_class, attribute.name) 392 (cpp_class, attribute.name)
404 if not attribute.constructor_type else 393 if not attribute.constructor_type else
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 access_control, 427 access_control,
439 property_attribute, 428 property_attribute,
440 only_exposed_to_private_script, 429 only_exposed_to_private_script,
441 ] %} 430 ] %}
442 {% if not attribute.is_expose_js_accessors %} 431 {% if not attribute.is_expose_js_accessors %}
443 {% set attribute_configuration_list = attribute_configuration_list 432 {% set attribute_configuration_list = attribute_configuration_list
444 + [on_prototype] %} 433 + [on_prototype] %}
445 {% endif %} 434 {% endif %}
446 {{'{'}}{{attribute_configuration_list | join(', ')}}{{'}'}} 435 {{'{'}}{{attribute_configuration_list | join(', ')}}{{'}'}}
447 {%- endmacro %} 436 {%- endmacro %}
OLDNEW
« no previous file with comments | « Source/bindings/core/v8/PrivateScriptRunner.cpp ('k') | Source/bindings/templates/methods.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698