| Index: lib/html/scripts/systemnative.py
|
| diff --git a/lib/html/scripts/systemnative.py b/lib/html/scripts/systemnative.py
|
| index 11514404f573ff59a3cb9ffd945e1a58d35a3af7..07abe5f674288daa11f7f5ced5fb54ca6b7dc840 100644
|
| --- a/lib/html/scripts/systemnative.py
|
| +++ b/lib/html/scripts/systemnative.py
|
| @@ -582,18 +582,12 @@ class NativeImplementationGenerator(systembase.BaseGenerator):
|
| has_optional_arguments = any(self._IsArgumentOptionalInWebCore(operation, argument) for argument in operation.arguments)
|
| needs_dispatcher = not is_custom and (len(info.operations) > 1 or has_optional_arguments)
|
|
|
| - if not needs_dispatcher:
|
| - type_renamer = self._DartType
|
| - default_value = 'null'
|
| - else:
|
| - type_renamer = lambda x: 'Dynamic'
|
| - default_value = '_null'
|
| -
|
| dart_declaration = '%s%s %s(%s)' % (
|
| 'static ' if info.IsStatic() else '',
|
| self._DartType(info.type_name),
|
| html_name,
|
| - info.ParametersImplementationDeclaration(type_renamer, default_value))
|
| + info.ParametersImplementationDeclaration(
|
| + (lambda x: 'Dynamic') if needs_dispatcher else self._DartType))
|
|
|
| if not needs_dispatcher:
|
| # Bind directly to native implementation
|
| @@ -642,7 +636,7 @@ class NativeImplementationGenerator(systembase.BaseGenerator):
|
| self._GenerateOperationNativeCallback(operation, operation.arguments[:argument_count], cpp_callback_name)
|
|
|
| def GenerateChecksAndCall(operation, argument_count):
|
| - checks = ['%s === _null' % name for name in argument_names]
|
| + checks = ['!?%s' % name for name in argument_names]
|
| for i in range(0, argument_count):
|
| argument = operation.arguments[i]
|
| argument_name = argument_names[i]
|
| @@ -663,14 +657,14 @@ class NativeImplementationGenerator(systembase.BaseGenerator):
|
| argument_count = len(operation.arguments)
|
| for position, argument in list(enumerate(operation.arguments))[::-1]:
|
| if self._IsArgumentOptionalInWebCore(operation, argument):
|
| - check = '%s !== _null' % argument_names[position]
|
| + check = '?%s' % argument_names[position]
|
| # argument_count instead of position + 1 is used here to cover one
|
| # complicated case with the effectively optional argument in the middle.
|
| # Consider foo(x, [Optional] y, [Optional=DefaultIsNullString] z)
|
| # (as of now it's modelled after HTMLMediaElement.webkitAddKey).
|
| # y is optional in WebCore, while z is not.
|
| - # In this case, if y !== _null, we'd like to emit foo(x, y, z) invocation, not
|
| - # foo(x, y).
|
| + # In this case, if y was actually passed, we'd like to emit foo(x, y, z) invocation,
|
| + # not foo(x, y).
|
| GenerateCall(operation, argument_count, [check])
|
| argument_count = position
|
| GenerateCall(operation, argument_count, [])
|
|
|