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

Unified Diff: third_party/WebKit/Source/bindings/templates/methods.cpp

Issue 1476863003: bindings: Ignores the last undefined arguments when counting the args. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated layout tests. Created 5 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/bindings/templates/methods.cpp
diff --git a/third_party/WebKit/Source/bindings/templates/methods.cpp b/third_party/WebKit/Source/bindings/templates/methods.cpp
index 33c828609622cc2a0d9add39acff3b9503f8e381..a8f8b352b2c21c01182e3db5dca133274ea0dca0 100644
--- a/third_party/WebKit/Source/bindings/templates/methods.cpp
+++ b/third_party/WebKit/Source/bindings/templates/methods.cpp
@@ -70,6 +70,17 @@ static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const
{{generate_argument_var_declaration(argument)}};
{% endfor %}
{
+ {% if method.has_optional_argument_without_default_value %}
+ {# Count the effective number of arguments. (arg1, arg2, undefined) is
+ interpreted as two arguments are passed and (arg1, undefined, arg3) is
+ interpreted as three arguments are passed. #}
+ int numArgsPassed = info.Length();
+ while (numArgsPassed > 0) {
+ if (!info[numArgsPassed - 1]->IsUndefined())
+ break;
+ --numArgsPassed;
+ }
+ {% endif %}
{% for argument in method.arguments %}
{% if argument.set_default_value %}
if (!info[{{argument.index}}]->IsUndefined()) {
@@ -104,7 +115,7 @@ RefPtrWillBeRawPtr<{{argument.idl_type}}> {{argument.name}}
{# Optional arguments without a default value generate an early call with
fewer arguments if they are omitted.
Optional Dictionary arguments default to empty dictionary. #}
-if (UNLIKELY(info.Length() <= {{argument.index}})) {
+if (UNLIKELY(numArgsPassed <= {{argument.index}})) {
{% if world_suffix %}
{{cpp_method_call(method, argument.v8_set_return_value_for_main_world, argument.cpp_value) | indent}}
{% else %}

Powered by Google App Engine
This is Rietveld 408576698