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

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

Issue 296403007: Set correct Function.length on overloaded methods (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: addressed nits Created 6 years, 6 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/templates/interface.cpp ('k') | Source/bindings/tests/results/V8TestObject.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 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 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 {% macro origin_safe_method_getter(method, world_suffix) %} 423 {% macro origin_safe_method_getter(method, world_suffix) %}
424 static void {{method.name}}OriginSafeMethodGetter{{world_suffix}}(const v8::Prop ertyCallbackInfo<v8::Value>& info) 424 static void {{method.name}}OriginSafeMethodGetter{{world_suffix}}(const v8::Prop ertyCallbackInfo<v8::Value>& info)
425 { 425 {
426 {% set signature = 'v8::Local<v8::Signature>()' 426 {% set signature = 'v8::Local<v8::Signature>()'
427 if method.is_do_not_check_signature else 427 if method.is_do_not_check_signature else
428 'v8::Signature::New(isolate, %s::domTemplate(isolate))' % v8_class %} 428 'v8::Signature::New(isolate, %s::domTemplate(isolate))' % v8_class %}
429 v8::Isolate* isolate = info.GetIsolate(); 429 v8::Isolate* isolate = info.GetIsolate();
430 static int domTemplateKey; // This address is used for a key to look up the dom template. 430 static int domTemplateKey; // This address is used for a key to look up the dom template.
431 V8PerIsolateData* data = V8PerIsolateData::from(isolate); 431 V8PerIsolateData* data = V8PerIsolateData::from(isolate);
432 {# FIXME: 1 case of [DoNotCheckSignature] in Window.idl may differ #} 432 {# FIXME: 1 case of [DoNotCheckSignature] in Window.idl may differ #}
433 v8::Handle<v8::FunctionTemplate> privateTemplate = data->domTemplate(&domTem plateKey, {{cpp_class}}V8Internal::{{method.name}}MethodCallback{{world_suffix}} , v8Undefined(), {{signature}}, {{method.number_of_required_or_variadic_argument s}}); 433 v8::Handle<v8::FunctionTemplate> privateTemplate = data->domTemplate(&domTem plateKey, {{cpp_class}}V8Internal::{{method.name}}MethodCallback{{world_suffix}} , v8Undefined(), {{signature}}, {{method.length}});
434 434
435 v8::Handle<v8::Object> holder = {{v8_class}}::findInstanceInPrototypeChain(i nfo.This(), isolate); 435 v8::Handle<v8::Object> holder = {{v8_class}}::findInstanceInPrototypeChain(i nfo.This(), isolate);
436 if (holder.IsEmpty()) { 436 if (holder.IsEmpty()) {
437 // This is only reachable via |object.__proto__.func|, in which case it 437 // This is only reachable via |object.__proto__.func|, in which case it
438 // has already passed the same origin security check 438 // has already passed the same origin security check
439 v8SetReturnValue(info, privateTemplate->GetFunction()); 439 v8SetReturnValue(info, privateTemplate->GetFunction());
440 return; 440 return;
441 } 441 }
442 {{cpp_class}}* impl = {{v8_class}}::toNative(holder); 442 {{cpp_class}}* impl = {{v8_class}}::toNative(holder);
443 if (!BindingSecurity::shouldAllowAccessToFrame(isolate, impl->frame(), DoNot ReportSecurityError)) { 443 if (!BindingSecurity::shouldAllowAccessToFrame(isolate, impl->frame(), DoNot ReportSecurityError)) {
444 static int sharedTemplateKey; // This address is used for a key to look up the dom template. 444 static int sharedTemplateKey; // This address is used for a key to look up the dom template.
445 v8::Handle<v8::FunctionTemplate> sharedTemplate = data->domTemplate(&sha redTemplateKey, {{cpp_class}}V8Internal::{{method.name}}MethodCallback{{world_su ffix}}, v8Undefined(), {{signature}}, {{method.number_of_required_or_variadic_ar guments}}); 445 v8::Handle<v8::FunctionTemplate> sharedTemplate = data->domTemplate(&sha redTemplateKey, {{cpp_class}}V8Internal::{{method.name}}MethodCallback{{world_su ffix}}, v8Undefined(), {{signature}}, {{method.length}});
446 v8SetReturnValue(info, sharedTemplate->GetFunction()); 446 v8SetReturnValue(info, sharedTemplate->GetFunction());
447 return; 447 return;
448 } 448 }
449 449
450 {# The findInstanceInPrototypeChain() call above only returns a non-empty ha ndle if info.This() is an Object. #} 450 {# The findInstanceInPrototypeChain() call above only returns a non-empty ha ndle if info.This() is an Object. #}
451 v8::Local<v8::Value> hiddenValue = v8::Handle<v8::Object>::Cast(info.This()) ->GetHiddenValue(v8AtomicString(isolate, "{{method.name}}")); 451 v8::Local<v8::Value> hiddenValue = v8::Handle<v8::Object>::Cast(info.This()) ->GetHiddenValue(v8AtomicString(isolate, "{{method.name}}"));
452 if (!hiddenValue.IsEmpty()) { 452 if (!hiddenValue.IsEmpty()) {
453 v8SetReturnValue(info, hiddenValue); 453 v8SetReturnValue(info, hiddenValue);
454 return; 454 return;
455 } 455 }
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 {% endif %} 553 {% endif %}
554 {{constructor.cpp_type}} impl = {{cpp_class}}::createForJSConstructor({{cons tructor.argument_list | join(', ')}}); 554 {{constructor.cpp_type}} impl = {{cpp_class}}::createForJSConstructor({{cons tructor.argument_list | join(', ')}});
555 {% if is_constructor_raises_exception %} 555 {% if is_constructor_raises_exception %}
556 if (exceptionState.throwIfNeeded()) 556 if (exceptionState.throwIfNeeded())
557 return; 557 return;
558 {% endif %} 558 {% endif %}
559 559
560 {{generate_constructor_wrapper(constructor) | indent}} 560 {{generate_constructor_wrapper(constructor) | indent}}
561 } 561 }
562 {% endmacro %} 562 {% endmacro %}
OLDNEW
« no previous file with comments | « Source/bindings/templates/interface.cpp ('k') | Source/bindings/tests/results/V8TestObject.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698