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

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

Issue 819853002: [bindings] Translate all assignments in bindings/templates to use Local<> in place of Handle<>. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years 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 {##############################################################################} 1 {##############################################################################}
2 {% macro generate_method(method, world_suffix) %} 2 {% macro generate_method(method, world_suffix) %}
3 {% filter conditional(method.conditional_string) %} 3 {% filter conditional(method.conditional_string) %}
4 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const v8::FunctionCallbackInfo<v8::Value>& info) 4 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const v8::FunctionCallbackInfo<v8::Value>& info)
5 { 5 {
6 {# Local variables #} 6 {# Local variables #}
7 {% if method.has_exception_state %} 7 {% if method.has_exception_state %}
8 ExceptionState exceptionState(ExceptionState::ExecutionContext, "{{method.na me}}", "{{interface_name}}", info.Holder(), info.GetIsolate()); 8 ExceptionState exceptionState(ExceptionState::ExecutionContext, "{{method.na me}}", "{{interface_name}}", info.Holder(), info.GetIsolate());
9 {% endif %} 9 {% endif %}
10 {# Overloaded methods have length checked during overload resolution #} 10 {# Overloaded methods have length checked during overload resolution #}
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 {##############################################################################} 468 {##############################################################################}
469 {% macro origin_safe_method_getter(method, world_suffix) %} 469 {% macro origin_safe_method_getter(method, world_suffix) %}
470 static void {{method.name}}OriginSafeMethodGetter{{world_suffix}}(const v8::Prop ertyCallbackInfo<v8::Value>& info) 470 static void {{method.name}}OriginSafeMethodGetter{{world_suffix}}(const v8::Prop ertyCallbackInfo<v8::Value>& info)
471 { 471 {
472 {% set signature = 'v8::Local<v8::Signature>()' 472 {% set signature = 'v8::Local<v8::Signature>()'
473 if method.is_do_not_check_signature else 473 if method.is_do_not_check_signature else
474 'v8::Signature::New(info.GetIsolate(), %s::domTemplate(in fo.GetIsolate()))' % v8_class %} 474 'v8::Signature::New(info.GetIsolate(), %s::domTemplate(in fo.GetIsolate()))' % v8_class %}
475 static int domTemplateKey; // This address is used for a key to look up the dom template. 475 static int domTemplateKey; // This address is used for a key to look up the dom template.
476 V8PerIsolateData* data = V8PerIsolateData::from(info.GetIsolate()); 476 V8PerIsolateData* data = V8PerIsolateData::from(info.GetIsolate());
477 {# FIXME: 1 case of [DoNotCheckSignature] in Window.idl may differ #} 477 {# FIXME: 1 case of [DoNotCheckSignature] in Window.idl may differ #}
478 v8::Handle<v8::FunctionTemplate> privateTemplate = data->domTemplate(&domTem plateKey, {{cpp_class}}V8Internal::{{method.name}}MethodCallback{{world_suffix}} , v8Undefined(), {{signature}}, {{method.length}}); 478 v8::Local<v8::FunctionTemplate> privateTemplate = data->domTemplate(&domTemp lateKey, {{cpp_class}}V8Internal::{{method.name}}MethodCallback{{world_suffix}}, v8Undefined(), {{signature}}, {{method.length}});
479 479
480 v8::Handle<v8::Object> holder = {{v8_class}}::findInstanceInPrototypeChain(i nfo.This(), info.GetIsolate()); 480 v8::Local<v8::Object> holder = {{v8_class}}::findInstanceInPrototypeChain(in fo.This(), info.GetIsolate());
481 if (holder.IsEmpty()) { 481 if (holder.IsEmpty()) {
482 // This is only reachable via |object.__proto__.func|, in which case it 482 // This is only reachable via |object.__proto__.func|, in which case it
483 // has already passed the same origin security check 483 // has already passed the same origin security check
484 v8SetReturnValue(info, privateTemplate->GetFunction()); 484 v8SetReturnValue(info, privateTemplate->GetFunction());
485 return; 485 return;
486 } 486 }
487 {{cpp_class}}* impl = {{v8_class}}::toImpl(holder); 487 {{cpp_class}}* impl = {{v8_class}}::toImpl(holder);
488 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), impl->fram e(), DoNotReportSecurityError)) { 488 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), impl->fram e(), DoNotReportSecurityError)) {
489 static int sharedTemplateKey; // This address is used for a key to look up the dom template. 489 static int sharedTemplateKey; // This address is used for a key to look up the dom template.
490 v8::Handle<v8::FunctionTemplate> sharedTemplate = data->domTemplate(&sha redTemplateKey, {{cpp_class}}V8Internal::{{method.name}}MethodCallback{{world_su ffix}}, v8Undefined(), {{signature}}, {{method.length}}); 490 v8::Local<v8::FunctionTemplate> sharedTemplate = data->domTemplate(&shar edTemplateKey, {{cpp_class}}V8Internal::{{method.name}}MethodCallback{{world_suf fix}}, v8Undefined(), {{signature}}, {{method.length}});
491 v8SetReturnValue(info, sharedTemplate->GetFunction()); 491 v8SetReturnValue(info, sharedTemplate->GetFunction());
492 return; 492 return;
493 } 493 }
494 494
495 {# The findInstanceInPrototypeChain() call above only returns a non-empty ha ndle if info.This() is an Object. #} 495 {# The findInstanceInPrototypeChain() call above only returns a non-empty ha ndle if info.This() is an Object. #}
496 v8::Local<v8::Value> hiddenValue = v8::Handle<v8::Object>::Cast(info.This()) ->GetHiddenValue(v8AtomicString(info.GetIsolate(), "{{method.name}}")); 496 v8::Local<v8::Value> hiddenValue = v8::Local<v8::Object>::Cast(info.This())- >GetHiddenValue(v8AtomicString(info.GetIsolate(), "{{method.name}}"));
497 if (!hiddenValue.IsEmpty()) { 497 if (!hiddenValue.IsEmpty()) {
498 v8SetReturnValue(info, hiddenValue); 498 v8SetReturnValue(info, hiddenValue);
499 return; 499 return;
500 } 500 }
501 501
502 v8SetReturnValue(info, privateTemplate->GetFunction()); 502 v8SetReturnValue(info, privateTemplate->GetFunction());
503 } 503 }
504 504
505 static void {{method.name}}OriginSafeMethodGetterCallback{{world_suffix}}(v8::Lo cal<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 505 static void {{method.name}}OriginSafeMethodGetterCallback{{world_suffix}}(v8::Lo cal<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
506 { 506 {
507 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter"); 507 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
508 {{cpp_class}}V8Internal::{{method.name}}OriginSafeMethodGetter{{world_suffix }}(info); 508 {{cpp_class}}V8Internal::{{method.name}}OriginSafeMethodGetter{{world_suffix }}(info);
509 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 509 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
510 } 510 }
511 {% endmacro %} 511 {% endmacro %}
512 512
513 513
514 {##############################################################################} 514 {##############################################################################}
515 {% macro method_implemented_in_private_script(method) %} 515 {% macro method_implemented_in_private_script(method) %}
516 bool {{v8_class}}::PrivateScript::{{method.name}}Method({{method.argument_declar ations_for_private_script | join(', ')}}) 516 bool {{v8_class}}::PrivateScript::{{method.name}}Method({{method.argument_declar ations_for_private_script | join(', ')}})
517 { 517 {
518 if (!frame) 518 if (!frame)
519 return false; 519 return false;
520 v8::HandleScope handleScope(toIsolate(frame)); 520 v8::HandleScope handleScope(toIsolate(frame));
521 ScriptForbiddenScope::AllowUserAgentScript script; 521 ScriptForbiddenScope::AllowUserAgentScript script;
522 v8::Handle<v8::Context> contextInPrivateScript = toV8Context(frame, DOMWrapp erWorld::privateScriptIsolatedWorld()); 522 v8::Local<v8::Context> contextInPrivateScript = toV8Context(frame, DOMWrappe rWorld::privateScriptIsolatedWorld());
523 if (contextInPrivateScript.IsEmpty()) 523 if (contextInPrivateScript.IsEmpty())
524 return false; 524 return false;
525 ScriptState* scriptState = ScriptState::from(contextInPrivateScript); 525 ScriptState* scriptState = ScriptState::from(contextInPrivateScript);
526 ScriptState* scriptStateInUserScript = ScriptState::forMainWorld(frame); 526 ScriptState* scriptStateInUserScript = ScriptState::forMainWorld(frame);
527 if (!scriptState->executionContext()) 527 if (!scriptState->executionContext())
528 return false; 528 return false;
529 529
530 ScriptState::Scope scope(scriptState); 530 ScriptState::Scope scope(scriptState);
531 v8::Handle<v8::Value> holder = toV8(holderImpl, scriptState->context()->Glob al(), scriptState->isolate()); 531 v8::Local<v8::Value> holder = toV8(holderImpl, scriptState->context()->Globa l(), scriptState->isolate());
532 532
533 {% for argument in method.arguments %} 533 {% for argument in method.arguments %}
534 v8::Handle<v8::Value> {{argument.handle}} = {{argument.private_script_cpp_va lue_to_v8_value}}; 534 v8::Local<v8::Value> {{argument.handle}} = {{argument.private_script_cpp_val ue_to_v8_value}};
535 {% endfor %} 535 {% endfor %}
536 {% if method.arguments %} 536 {% if method.arguments %}
537 v8::Handle<v8::Value> argv[] = { {{method.arguments | join(', ', 'handle')}} }; 537 v8::Local<v8::Value> argv[] = { {{method.arguments | join(', ', 'handle')}} };
538 {% else %} 538 {% else %}
539 {# Empty array initializers are illegal, and don\t compile in MSVC. #} 539 {# Empty array initializers are illegal, and don\t compile in MSVC. #}
540 v8::Handle<v8::Value> *argv = 0; 540 v8::Local<v8::Value> *argv = 0;
541 {% endif %} 541 {% endif %}
542 ExceptionState exceptionState(ExceptionState::ExecutionContext, "{{method.na me}}", "{{cpp_class}}", scriptState->context()->Global(), scriptState->isolate() ); 542 ExceptionState exceptionState(ExceptionState::ExecutionContext, "{{method.na me}}", "{{cpp_class}}", scriptState->context()->Global(), scriptState->isolate() );
543 v8::Handle<v8::Value> v8Value = PrivateScriptRunner::runDOMMethod(scriptStat e, scriptStateInUserScript, "{{cpp_class}}", "{{method.name}}", holder, {{method .arguments | length}}, argv); 543 v8::Local<v8::Value> v8Value = PrivateScriptRunner::runDOMMethod(scriptState , scriptStateInUserScript, "{{cpp_class}}", "{{method.name}}", holder, {{method. arguments | length}}, argv);
544 if (v8Value.IsEmpty()) 544 if (v8Value.IsEmpty())
545 return false; 545 return false;
546 {% if method.idl_type != 'void' %} 546 {% if method.idl_type != 'void' %}
547 {{method.private_script_v8_value_to_local_cpp_value}}; 547 {{method.private_script_v8_value_to_local_cpp_value}};
548 *result = cppValue; 548 *result = cppValue;
549 {% endif %} 549 {% endif %}
550 RELEASE_ASSERT(!exceptionState.hadException()); 550 RELEASE_ASSERT(!exceptionState.hadException());
551 return true; 551 return true;
552 } 552 }
553 {% endmacro %} 553 {% endmacro %}
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 {{cpp_method_call(constructor, constructor.v8_set_return_value, constructor. cpp_value) | indent}} 587 {{cpp_method_call(constructor, constructor.v8_set_return_value, constructor. cpp_value) | indent}}
588 } 588 }
589 {% endmacro %} 589 {% endmacro %}
590 590
591 591
592 {##############################################################################} 592 {##############################################################################}
593 {% macro generate_constructor_wrapper(constructor) %} 593 {% macro generate_constructor_wrapper(constructor) %}
594 {% set constructor_class = v8_class + ('Constructor' 594 {% set constructor_class = v8_class + ('Constructor'
595 if constructor.is_named_constructor else 595 if constructor.is_named_constructor else
596 '') %} 596 '') %}
597 v8::Handle<v8::Object> wrapper = info.Holder(); 597 v8::Local<v8::Object> wrapper = info.Holder();
598 impl->associateWithWrapper(info.GetIsolate(), &{{constructor_class}}::wrapperTyp eInfo, wrapper); 598 impl->associateWithWrapper(info.GetIsolate(), &{{constructor_class}}::wrapperTyp eInfo, wrapper);
599 v8SetReturnValue(info, wrapper); 599 v8SetReturnValue(info, wrapper);
600 {% endmacro %} 600 {% endmacro %}
601 601
602 602
603 {##############################################################################} 603 {##############################################################################}
604 {% macro method_configuration(method) %} 604 {% macro method_configuration(method) %}
605 {% set method_callback = 605 {% set method_callback =
606 '%sV8Internal::%sMethodCallback' % (cpp_class_or_partial, method.name) %} 606 '%sV8Internal::%sMethodCallback' % (cpp_class_or_partial, method.name) %}
607 {% set method_callback_for_main_world = 607 {% set method_callback_for_main_world =
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 if method.overloads else 652 if method.overloads else
653 method.runtime_enabled_function) %} 653 method.runtime_enabled_function) %}
654 prototypeObject->Set(v8AtomicString(isolate, "{{method.name}}"), v8::Functio nTemplate::New(isolate, {{cpp_class_or_partial}}V8Internal::{{method.name}}Metho dCallback, v8Undefined(), defaultSignature, {{method.number_of_required_argument s}})->GetFunction()); 654 prototypeObject->Set(v8AtomicString(isolate, "{{method.name}}"), v8::Functio nTemplate::New(isolate, {{cpp_class_or_partial}}V8Internal::{{method.name}}Metho dCallback, v8Undefined(), defaultSignature, {{method.number_of_required_argument s}})->GetFunction());
655 {% endfilter %}{# runtime_enabled() #} 655 {% endfilter %}{# runtime_enabled() #}
656 {% endfilter %}{# exposed() #} 656 {% endfilter %}{# exposed() #}
657 {% endfilter %}{# per_context_enabled() #} 657 {% endfilter %}{# per_context_enabled() #}
658 {% endfor %} 658 {% endfor %}
659 {% endif %} 659 {% endif %}
660 } 660 }
661 {%- endmacro %} 661 {%- endmacro %}
OLDNEW
« no previous file with comments | « Source/bindings/templates/interface_base.cpp ('k') | Source/bindings/tests/results/core/V8DataView.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698