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

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: 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 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 v8::Local<v8::Context> contextInPrivateScript = toV8Context(frame, DOMWrappe rWorld::privateScriptIsolatedWorld()); 425 v8::Local<v8::Context> contextInPrivateScript = toV8Context(frame, DOMWrappe rWorld::privateScriptIsolatedWorld());
426 if (contextInPrivateScript.IsEmpty()) 426 if (contextInPrivateScript.IsEmpty())
427 return false; 427 return false;
428 ScriptState* scriptState = ScriptState::from(contextInPrivateScript); 428 ScriptState* scriptState = ScriptState::from(contextInPrivateScript);
429 ScriptState* scriptStateInUserScript = ScriptState::forMainWorld(frame); 429 ScriptState* scriptStateInUserScript = ScriptState::forMainWorld(frame);
430 if (!scriptState->executionContext()) 430 if (!scriptState->executionContext())
431 return false; 431 return false;
432 432
433 ScriptState::Scope scope(scriptState); 433 ScriptState::Scope scope(scriptState);
434 v8::Local<v8::Value> holder = toV8(holderImpl, scriptState->context()->Globa l(), scriptState->isolate()); 434 v8::Local<v8::Value> holder = toV8(holderImpl, scriptState->context()->Globa l(), scriptState->isolate());
435 if (holder.IsEmpty())
436 return false;
435 437
436 ExceptionState exceptionState(ExceptionState::GetterContext, "{{attribute.na me}}", "{{cpp_class}}", scriptState->context()->Global(), scriptState->isolate() ); 438 ExceptionState exceptionState(ExceptionState::GetterContext, "{{attribute.na me}}", "{{cpp_class}}", scriptState->context()->Global(), scriptState->isolate() );
437 v8::Local<v8::Value> v8Value = PrivateScriptRunner::runDOMAttributeGetter(sc riptState, scriptStateInUserScript, "{{cpp_class}}", "{{attribute.name}}", holde r); 439 v8::Local<v8::Value> v8Value = PrivateScriptRunner::runDOMAttributeGetter(sc riptState, scriptStateInUserScript, "{{cpp_class}}", "{{attribute.name}}", holde r);
438 if (v8Value.IsEmpty()) 440 if (v8Value.IsEmpty())
439 return false; 441 return false;
440 {{v8_value_to_local_cpp_value(attribute.private_script_v8_value_to_local_cpp _value) | indent}} 442 {{v8_value_to_local_cpp_value(attribute.private_script_v8_value_to_local_cpp _value) | indent}}
441 RELEASE_ASSERT(!exceptionState.hadException()); 443 RELEASE_ASSERT(!exceptionState.hadException());
442 *result = cppValue; 444 *result = cppValue;
443 return true; 445 return true;
444 } 446 }
(...skipping 10 matching lines...) Expand all
455 v8::Local<v8::Context> contextInPrivateScript = toV8Context(frame, DOMWrappe rWorld::privateScriptIsolatedWorld()); 457 v8::Local<v8::Context> contextInPrivateScript = toV8Context(frame, DOMWrappe rWorld::privateScriptIsolatedWorld());
456 if (contextInPrivateScript.IsEmpty()) 458 if (contextInPrivateScript.IsEmpty())
457 return false; 459 return false;
458 ScriptState* scriptState = ScriptState::from(contextInPrivateScript); 460 ScriptState* scriptState = ScriptState::from(contextInPrivateScript);
459 ScriptState* scriptStateInUserScript = ScriptState::forMainWorld(frame); 461 ScriptState* scriptStateInUserScript = ScriptState::forMainWorld(frame);
460 if (!scriptState->executionContext()) 462 if (!scriptState->executionContext())
461 return false; 463 return false;
462 464
463 ScriptState::Scope scope(scriptState); 465 ScriptState::Scope scope(scriptState);
464 v8::Local<v8::Value> holder = toV8(holderImpl, scriptState->context()->Globa l(), scriptState->isolate()); 466 v8::Local<v8::Value> holder = toV8(holderImpl, scriptState->context()->Globa l(), scriptState->isolate());
467 if (holder.IsEmpty())
468 return false;
465 469
466 ExceptionState exceptionState(ExceptionState::SetterContext, "{{attribute.na me}}", "{{cpp_class}}", scriptState->context()->Global(), scriptState->isolate() ); 470 ExceptionState exceptionState(ExceptionState::SetterContext, "{{attribute.na me}}", "{{cpp_class}}", scriptState->context()->Global(), scriptState->isolate() );
467 return PrivateScriptRunner::runDOMAttributeSetter(scriptState, scriptStateIn UserScript, "{{cpp_class}}", "{{attribute.name}}", holder, {{attribute.private_s cript_cpp_value_to_v8_value}}); 471 return PrivateScriptRunner::runDOMAttributeSetter(scriptState, scriptStateIn UserScript, "{{cpp_class}}", "{{attribute.name}}", holder, {{attribute.private_s cript_cpp_value_to_v8_value}});
468 } 472 }
469 {% endmacro %} 473 {% endmacro %}
470 474
471 475
472 {##############################################################################} 476 {##############################################################################}
473 {% macro attribute_configuration(attribute) %} 477 {% macro attribute_configuration(attribute) %}
474 {% if attribute.constructor_type %} 478 {% if attribute.constructor_type %}
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 access_control, 522 access_control,
519 property_attribute, 523 property_attribute,
520 only_exposed_to_private_script, 524 only_exposed_to_private_script,
521 ] %} 525 ] %}
522 {% if not attribute.is_expose_js_accessors %} 526 {% if not attribute.is_expose_js_accessors %}
523 {% set attribute_configuration_list = attribute_configuration_list 527 {% set attribute_configuration_list = attribute_configuration_list
524 + [on_prototype] %} 528 + [on_prototype] %}
525 {% endif %} 529 {% endif %}
526 {{'{'}}{{attribute_configuration_list | join(', ')}}{{'}'}} 530 {{'{'}}{{attribute_configuration_list | join(', ')}}{{'}'}}
527 {%- endmacro %} 531 {%- endmacro %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698