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

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

Issue 1100223003: bindings: Add empty checks for toV8() (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase Created 5 years, 7 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 'conversions.cpp' import declare_enum_validation_variable, v8_value_to_l ocal_cpp_value %} 1 {% from 'conversions.cpp' import declare_enum_validation_variable, v8_value_to_l ocal_cpp_value %}
2 2
3 3
4 {##############################################################################} 4 {##############################################################################}
5 {% macro attribute_getter(attribute, world_suffix) %} 5 {% macro attribute_getter(attribute, world_suffix) %}
6 {% filter conditional(attribute.conditional_string) %} 6 {% filter conditional(attribute.conditional_string) %}
7 static void {{attribute.name}}AttributeGetter{{world_suffix}}( 7 static void {{attribute.name}}AttributeGetter{{world_suffix}}(
8 {%- if attribute.is_expose_js_accessors %} 8 {%- if attribute.is_expose_js_accessors %}
9 const v8::FunctionCallbackInfo<v8::Value>& info 9 const v8::FunctionCallbackInfo<v8::Value>& info
10 {%- else %} 10 {%- else %}
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 v8::Local<v8::Context> contextInPrivateScript = toV8Context(frame, DOMWrappe rWorld::privateScriptIsolatedWorld()); 428 v8::Local<v8::Context> contextInPrivateScript = toV8Context(frame, DOMWrappe rWorld::privateScriptIsolatedWorld());
429 if (contextInPrivateScript.IsEmpty()) 429 if (contextInPrivateScript.IsEmpty())
430 return false; 430 return false;
431 ScriptState* scriptState = ScriptState::from(contextInPrivateScript); 431 ScriptState* scriptState = ScriptState::from(contextInPrivateScript);
432 ScriptState* scriptStateInUserScript = ScriptState::forMainWorld(frame); 432 ScriptState* scriptStateInUserScript = ScriptState::forMainWorld(frame);
433 if (!scriptState->executionContext()) 433 if (!scriptState->executionContext())
434 return false; 434 return false;
435 435
436 ScriptState::Scope scope(scriptState); 436 ScriptState::Scope scope(scriptState);
437 v8::Local<v8::Value> holder = toV8(holderImpl, scriptState->context()->Globa l(), scriptState->isolate()); 437 v8::Local<v8::Value> holder = toV8(holderImpl, scriptState->context()->Globa l(), scriptState->isolate());
438 if (holder.IsEmpty())
439 return false;
438 440
439 ExceptionState exceptionState(ExceptionState::GetterContext, "{{attribute.na me}}", "{{cpp_class}}", scriptState->context()->Global(), scriptState->isolate() ); 441 ExceptionState exceptionState(ExceptionState::GetterContext, "{{attribute.na me}}", "{{cpp_class}}", scriptState->context()->Global(), scriptState->isolate() );
440 v8::Local<v8::Value> v8Value = PrivateScriptRunner::runDOMAttributeGetter(sc riptState, scriptStateInUserScript, "{{cpp_class}}", "{{attribute.name}}", holde r); 442 v8::Local<v8::Value> v8Value = PrivateScriptRunner::runDOMAttributeGetter(sc riptState, scriptStateInUserScript, "{{cpp_class}}", "{{attribute.name}}", holde r);
441 if (v8Value.IsEmpty()) 443 if (v8Value.IsEmpty())
442 return false; 444 return false;
443 {{v8_value_to_local_cpp_value(attribute.private_script_v8_value_to_local_cpp _value) | indent}} 445 {{v8_value_to_local_cpp_value(attribute.private_script_v8_value_to_local_cpp _value) | indent}}
444 RELEASE_ASSERT(!exceptionState.hadException()); 446 RELEASE_ASSERT(!exceptionState.hadException());
445 *result = cppValue; 447 *result = cppValue;
446 return true; 448 return true;
447 } 449 }
(...skipping 10 matching lines...) Expand all
458 v8::Local<v8::Context> contextInPrivateScript = toV8Context(frame, DOMWrappe rWorld::privateScriptIsolatedWorld()); 460 v8::Local<v8::Context> contextInPrivateScript = toV8Context(frame, DOMWrappe rWorld::privateScriptIsolatedWorld());
459 if (contextInPrivateScript.IsEmpty()) 461 if (contextInPrivateScript.IsEmpty())
460 return false; 462 return false;
461 ScriptState* scriptState = ScriptState::from(contextInPrivateScript); 463 ScriptState* scriptState = ScriptState::from(contextInPrivateScript);
462 ScriptState* scriptStateInUserScript = ScriptState::forMainWorld(frame); 464 ScriptState* scriptStateInUserScript = ScriptState::forMainWorld(frame);
463 if (!scriptState->executionContext()) 465 if (!scriptState->executionContext())
464 return false; 466 return false;
465 467
466 ScriptState::Scope scope(scriptState); 468 ScriptState::Scope scope(scriptState);
467 v8::Local<v8::Value> holder = toV8(holderImpl, scriptState->context()->Globa l(), scriptState->isolate()); 469 v8::Local<v8::Value> holder = toV8(holderImpl, scriptState->context()->Globa l(), scriptState->isolate());
470 if (holder.IsEmpty())
471 return false;
468 472
469 ExceptionState exceptionState(ExceptionState::SetterContext, "{{attribute.na me}}", "{{cpp_class}}", scriptState->context()->Global(), scriptState->isolate() ); 473 ExceptionState exceptionState(ExceptionState::SetterContext, "{{attribute.na me}}", "{{cpp_class}}", scriptState->context()->Global(), scriptState->isolate() );
470 return PrivateScriptRunner::runDOMAttributeSetter(scriptState, scriptStateIn UserScript, "{{cpp_class}}", "{{attribute.name}}", holder, {{attribute.private_s cript_cpp_value_to_v8_value}}); 474 return PrivateScriptRunner::runDOMAttributeSetter(scriptState, scriptStateIn UserScript, "{{cpp_class}}", "{{attribute.name}}", holder, {{attribute.private_s cript_cpp_value_to_v8_value}});
471 } 475 }
472 {% endmacro %} 476 {% endmacro %}
473 477
474 478
475 {##############################################################################} 479 {##############################################################################}
476 {% macro attribute_configuration(attribute) %} 480 {% macro attribute_configuration(attribute) %}
477 {% if attribute.constructor_type %} 481 {% if attribute.constructor_type %}
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 access_control, 525 access_control,
522 property_attribute, 526 property_attribute,
523 only_exposed_to_private_script, 527 only_exposed_to_private_script,
524 ] %} 528 ] %}
525 {% if not attribute.is_expose_js_accessors %} 529 {% if not attribute.is_expose_js_accessors %}
526 {% set attribute_configuration_list = attribute_configuration_list 530 {% set attribute_configuration_list = attribute_configuration_list
527 + [on_prototype] %} 531 + [on_prototype] %}
528 {% endif %} 532 {% endif %}
529 {{'{'}}{{attribute_configuration_list | join(', ')}}{{'}'}} 533 {{'{'}}{{attribute_configuration_list | join(', ')}}{{'}'}}
530 {%- endmacro %} 534 {%- endmacro %}
OLDNEW
« no previous file with comments | « Source/bindings/modules/v8/ScriptValueSerializerForModules.cpp ('k') | Source/bindings/templates/methods.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698