[WebIDL] Add support for default parameter values
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 18 Sep 2015 01:48:17 +0000 (01:48 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 18 Sep 2015 01:48:17 +0000 (01:48 +0000)
https://bugs.webkit.org/show_bug.cgi?id=149263
<rdar://problem/22545600>

Reviewed by Ryosuke Niwa.

LayoutTests/imported/w3c:

Rebaseline several W3C tests now that more NodeIterator / TreeWalker
checks are passing.

* web-platform-tests/dom/traversal/NodeIterator-expected.txt:
* web-platform-tests/dom/traversal/TreeWalker-basic-expected.txt:

Source/WebCore:

Add support for default parameter values to our Web IDL parser and JS
bindings generator. This allows the bindings to convert undefined to
the parameter's default value for optional parameters:
https://heycam.github.io/webidl/#dfn-optional-argument-default-value

Previously, our bindings generator would just convert undefined to
0 / false / "undefined" for optional parameters, depending on the
parameter type.

This patch uses the new default parameter support to fix a bug in
document.createNodeIterator() / document.createTreeWalker()'s handling
of the whatToShow parameter:
https://dom.spec.whatwg.org/#document

WebKit currently was undefined to 0 in this case, even though it should
use the parameter's default value: OxFFFFFFFF.

I am planning to go through other optional parameters in a follow-up
patch and add default values where needed.

No new tests, already covered by existing layout tests and
added bindings tests coverage.

* bindings/scripts/CodeGeneratorJS.pm:
(GenerateParametersCheck):
* bindings/scripts/IDLParser.pm:
(parseOptionalOrRequiredArgument):
* bindings/scripts/test/GObject/WebKitDOMTestObj.cpp:
(webkit_dom_test_obj_method_with_optional_arg_and_default_value):
(webkit_dom_test_obj_method_with_optional_string_and_default_value):
* bindings/scripts/test/GObject/WebKitDOMTestObj.h:
* bindings/scripts/test/JS/JSTestObj.cpp:
(WebCore::jsTestObjPrototypeFunctionMethodWithOptionalArgAndDefaultValue):
(WebCore::jsTestObjPrototypeFunctionMethodWithOptionalStringAndDefaultValue):
* bindings/scripts/test/ObjC/DOMTestObj.h:
* bindings/scripts/test/ObjC/DOMTestObj.mm:
(-[DOMTestObj methodWithOptionalArgAndDefaultValue:]):
(-[DOMTestObj methodWithOptionalStringAndDefaultValue:]):
* bindings/scripts/test/TestObj.idl:
* dom/Document.idl:

LayoutTests:

Rebaseline several NodeIterator / TreeWalker tests now that more checks
are passing.

* fast/dom/createNodeIterator-parameters-expected.txt:
* fast/dom/createTreeWalker-parameters-expected.txt:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@189957 268f45cc-cd09-0410-ab3c-d52691b4dbfc

16 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/dom/createNodeIterator-parameters-expected.txt
LayoutTests/fast/dom/createTreeWalker-parameters-expected.txt
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/dom/traversal/NodeIterator-expected.txt
LayoutTests/imported/w3c/web-platform-tests/dom/traversal/TreeWalker-basic-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
Source/WebCore/bindings/scripts/IDLParser.pm
Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp
Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.h
Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.h
Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm
Source/WebCore/bindings/scripts/test/TestObj.idl
Source/WebCore/dom/Document.idl

index 4baf65cc1ee54127f71ae0b4810f0179d6901f0c..5b4f9b145b1ebda546d34dbc232e90ad29988d44 100644 (file)
@@ -1,3 +1,17 @@
+2015-09-17  Chris Dumez  <cdumez@apple.com>
+
+        [WebIDL] Add support for default parameter values
+        https://bugs.webkit.org/show_bug.cgi?id=149263
+        <rdar://problem/22545600>
+
+        Reviewed by Ryosuke Niwa.
+
+        Rebaseline several NodeIterator / TreeWalker tests now that more checks
+        are passing.
+
+        * fast/dom/createNodeIterator-parameters-expected.txt:
+        * fast/dom/createTreeWalker-parameters-expected.txt:
+
 2015-09-17  Saam barati  <sbarati@apple.com>
 
         add a regress test for richards with try/catch.
index a9493437fc7b17d4a138d4aae6be60bc38cc9ab7..648aef018d559a3b348558450d0497dffb73d903 100644 (file)
@@ -29,7 +29,7 @@ Passing undefined for optional parameters
 iterator = document.createNodeIterator(document, undefined, undefined)
 PASS iterator.root is document
 PASS iterator.referenceNode is document
-FAIL iterator.whatToShow should be 4294967295. Was 0.
+PASS iterator.whatToShow is 0xFFFFFFFF
 PASS iterator.filter is null
 PASS iterator.pointerBeforeReferenceNode is true
 PASS successfullyParsed is true
index af6448aad3d3aa0b2428902d49110a5d9c578d7f..c6427b85083444d31c18696e7a724b152b8e83a1 100644 (file)
@@ -27,7 +27,7 @@ Passing undefined for optional parameters
 walker = document.createTreeWalker(document, undefined, undefined)
 PASS walker.root is document
 PASS walker.currentNode is document
-FAIL walker.whatToShow should be 4294967295. Was 0.
+PASS walker.whatToShow is 0xFFFFFFFF
 PASS walker.filter is null
 PASS successfullyParsed is true
 
index 3e3c75597210c8bd832e8c5a40c78833c0ce1ac9..17e6fb66e2f15d43b239f39f3dbd0a61102b7592 100644 (file)
@@ -1,3 +1,17 @@
+2015-09-17  Chris Dumez  <cdumez@apple.com>
+
+        [WebIDL] Add support for default parameter values
+        https://bugs.webkit.org/show_bug.cgi?id=149263
+        <rdar://problem/22545600>
+
+        Reviewed by Ryosuke Niwa.
+
+        Rebaseline several W3C tests now that more NodeIterator / TreeWalker
+        checks are passing.
+
+        * web-platform-tests/dom/traversal/NodeIterator-expected.txt:
+        * web-platform-tests/dom/traversal/TreeWalker-basic-expected.txt:
+
 2015-09-17  Zalan Bujtas  <zalan@apple.com>
 
         CSS WG multicol-1 tests failures with 1px differences due to baseline difference.
index 8a56d7a4252d2df1eea9c73968242d9fa31ee64e..26b7c6a712b8ff0dfa0f53bb6d0dff462f393ea6 100644 (file)
@@ -2,7 +2,7 @@
 PASS detach() should be a no-op 
 PASS createNodeIterator() parameter defaults 
 PASS createNodeIterator() with null as arguments 
-FAIL createNodeIterator() with undefined as arguments assert_equals: whatToShow expected 4294967295 but got 0
+PASS createNodeIterator() with undefined as arguments 
 PASS Propagate exception from filter function 
 PASS document.createNodeIterator(paras[0], 0, null) 
 PASS document.createNodeIterator(paras[0], 0, (function(node) { return true })) 
index cb7a767b898a431f3e0ffec5dc978d7e38484f79..f9492c9e008a42437d4cd5eecb5353cb666a7c60 100644 (file)
@@ -3,7 +3,7 @@ This test checks the basic functionality of TreeWalker.
 
 PASS Construct a TreeWalker by document.createTreeWalker(root). 
 PASS Construct a TreeWalker by document.createTreeWalker(root, null, null). 
-FAIL Construct a TreeWalker by document.createTreeWalker(root, undefined, undefined). assert_equals: whatToShow expected 4294967295 but got 0
+PASS Construct a TreeWalker by document.createTreeWalker(root, undefined, undefined). 
 PASS Give an invalid root node to document.createTreeWalker(). 
 PASS Walk over nodes. 
 PASS Optional arguments to createTreeWalker should be optional (3 passed, null). 
index 3b26314ebdbba1cdfbf530c1e466710ec7646a71..ddd7a2406578705f8d42c53742d0479abe94bdb6 100644 (file)
@@ -1,3 +1,52 @@
+2015-09-17  Chris Dumez  <cdumez@apple.com>
+
+        [WebIDL] Add support for default parameter values
+        https://bugs.webkit.org/show_bug.cgi?id=149263
+        <rdar://problem/22545600>
+
+        Reviewed by Ryosuke Niwa.
+
+        Add support for default parameter values to our Web IDL parser and JS
+        bindings generator. This allows the bindings to convert undefined to
+        the parameter's default value for optional parameters:
+        https://heycam.github.io/webidl/#dfn-optional-argument-default-value
+
+        Previously, our bindings generator would just convert undefined to
+        0 / false / "undefined" for optional parameters, depending on the
+        parameter type.
+
+        This patch uses the new default parameter support to fix a bug in
+        document.createNodeIterator() / document.createTreeWalker()'s handling
+        of the whatToShow parameter:
+        https://dom.spec.whatwg.org/#document
+
+        WebKit currently was undefined to 0 in this case, even though it should
+        use the parameter's default value: OxFFFFFFFF.
+
+        I am planning to go through other optional parameters in a follow-up
+        patch and add default values where needed.
+
+        No new tests, already covered by existing layout tests and
+        added bindings tests coverage.
+
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GenerateParametersCheck):
+        * bindings/scripts/IDLParser.pm:
+        (parseOptionalOrRequiredArgument):
+        * bindings/scripts/test/GObject/WebKitDOMTestObj.cpp:
+        (webkit_dom_test_obj_method_with_optional_arg_and_default_value):
+        (webkit_dom_test_obj_method_with_optional_string_and_default_value):
+        * bindings/scripts/test/GObject/WebKitDOMTestObj.h:
+        * bindings/scripts/test/JS/JSTestObj.cpp:
+        (WebCore::jsTestObjPrototypeFunctionMethodWithOptionalArgAndDefaultValue):
+        (WebCore::jsTestObjPrototypeFunctionMethodWithOptionalStringAndDefaultValue):
+        * bindings/scripts/test/ObjC/DOMTestObj.h:
+        * bindings/scripts/test/ObjC/DOMTestObj.mm:
+        (-[DOMTestObj methodWithOptionalArgAndDefaultValue:]):
+        (-[DOMTestObj methodWithOptionalStringAndDefaultValue:]):
+        * bindings/scripts/test/TestObj.idl:
+        * dom/Document.idl:
+
 2015-09-17  Dean Jackson  <dino@apple.com>
 
         Multi-hop reference cycles not detected.
index e8eeebbe822ce6e52cfbc29fabb7de363eb7493a..e301e80c2daa9b62a03fe281e7ffa0c42a9c82a5 100644 (file)
@@ -3404,6 +3404,9 @@ sub GenerateParametersCheck
                 if ($optional && $defaultAttribute && $defaultAttribute eq "NullString") {
                     $outer = "exec->argument($argsIndex).isUndefined() ? String() : ";
                     $inner = "exec->uncheckedArgument($argsIndex)";
+                } elsif ($optional && $parameter->default) {
+                    $outer = "exec->argument($argsIndex).isUndefined() ? " . $parameter->default  . " : ";
+                    $inner = "exec->uncheckedArgument($argsIndex)";
                 } else {
                     $outer = "";
                     $inner = "exec->argument($argsIndex)";
index 2c11b427755fce749e88f199bf74173afd127688..292a3ed19debafb91c693bb266fe45da28c35d12 100644 (file)
@@ -82,6 +82,7 @@ struct( domSignature => {
     isNullable => '$', # Is variable type Nullable (T?)
     isVariadic => '$', # Is variable variadic (long... numbers)
     isOptional => '$', # Is variable optional (optional T)
+    default => '$', # Default value for parameters
 });
 
 # Used to represent string constants
@@ -1433,7 +1434,7 @@ sub parseOptionalOrRequiredArgument
         $paramDataNode->type(identifierRemoveNullablePrefix(typeRemoveNullableSuffix($type)));
         $paramDataNode->isOptional(1);
         $paramDataNode->name($self->parseArgumentName());
-        $self->parseDefault();
+        $paramDataNode->default($self->parseDefault());
         return $paramDataNode;
     }
     if ($next->type() == IdentifierToken || $next->value() =~ /$nextExceptionField_1/) {
index e4feb8b0db94becb6a0df91796be38980ce832ff..2ef8767ab1588cf00ddffc33d7f4ca75a2d4d087 100644 (file)
@@ -1283,6 +1283,14 @@ void webkit_dom_test_obj_method_with_optional_arg(WebKitDOMTestObj* self, glong
     item->methodWithOptionalArg(opt);
 }
 
+void webkit_dom_test_obj_method_with_optional_arg_and_default_value(WebKitDOMTestObj* self, glong opt)
+{
+    WebCore::JSMainThreadNullState state;
+    g_return_if_fail(WEBKIT_DOM_IS_TEST_OBJ(self));
+    WebCore::TestObj* item = WebKit::core(self);
+    item->methodWithOptionalArgAndDefaultValue(opt);
+}
+
 void webkit_dom_test_obj_method_with_non_optional_arg_and_optional_arg(WebKitDOMTestObj* self, glong nonOpt, glong opt)
 {
     WebCore::JSMainThreadNullState state;
@@ -1309,6 +1317,16 @@ void webkit_dom_test_obj_method_with_optional_string(WebKitDOMTestObj* self, con
     item->methodWithOptionalString(convertedStr);
 }
 
+void webkit_dom_test_obj_method_with_optional_string_and_default_value(WebKitDOMTestObj* self, const gchar* str)
+{
+    WebCore::JSMainThreadNullState state;
+    g_return_if_fail(WEBKIT_DOM_IS_TEST_OBJ(self));
+    g_return_if_fail(str);
+    WebCore::TestObj* item = WebKit::core(self);
+    WTF::String convertedStr = WTF::String::fromUTF8(str);
+    item->methodWithOptionalStringAndDefaultValue(convertedStr);
+}
+
 void webkit_dom_test_obj_method_with_optional_string_is_undefined(WebKitDOMTestObj* self, const gchar* str)
 {
     WebCore::JSMainThreadNullState state;
index a437944a377fd37571dd826394f3f2ac7699a091..4577d315fb7d94b1ee55dac073e200ec6586b998 100644 (file)
@@ -383,6 +383,16 @@ webkit_dom_test_obj_with_script_execution_context_and_script_state_with_spaces(W
 WEBKIT_API void
 webkit_dom_test_obj_method_with_optional_arg(WebKitDOMTestObj* self, glong opt);
 
+/**
+ * webkit_dom_test_obj_method_with_optional_arg_and_default_value:
+ * @self: A #WebKitDOMTestObj
+ * @opt: A #glong
+ *
+ * Stability: Unstable
+**/
+WEBKIT_API void
+webkit_dom_test_obj_method_with_optional_arg_and_default_value(WebKitDOMTestObj* self, glong opt);
+
 /**
  * webkit_dom_test_obj_method_with_non_optional_arg_and_optional_arg:
  * @self: A #WebKitDOMTestObj
@@ -416,6 +426,16 @@ webkit_dom_test_obj_method_with_non_optional_arg_and_two_optional_args(WebKitDOM
 WEBKIT_API void
 webkit_dom_test_obj_method_with_optional_string(WebKitDOMTestObj* self, const gchar* str);
 
+/**
+ * webkit_dom_test_obj_method_with_optional_string_and_default_value:
+ * @self: A #WebKitDOMTestObj
+ * @str: A #gchar
+ *
+ * Stability: Unstable
+**/
+WEBKIT_API void
+webkit_dom_test_obj_method_with_optional_string_and_default_value(WebKitDOMTestObj* self, const gchar* str);
+
 /**
  * webkit_dom_test_obj_method_with_optional_string_is_undefined:
  * @self: A #WebKitDOMTestObj
index 1d78a1633ac76ed24544542dae0d292a18ff3e92..c4c57675095d47e852e7eddfe8dbd771e5facef4 100644 (file)
@@ -109,9 +109,11 @@ JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithScriptExecutionC
 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithScriptExecutionContextAndScriptStateWithSpaces(JSC::ExecState*);
 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithScriptArgumentsAndCallStack(JSC::ExecState*);
 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalArg(JSC::ExecState*);
+JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalArgAndDefaultValue(JSC::ExecState*);
 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithNonOptionalArgAndOptionalArg(JSC::ExecState*);
 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithNonOptionalArgAndTwoOptionalArgs(JSC::ExecState*);
 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalString(JSC::ExecState*);
+JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalStringAndDefaultValue(JSC::ExecState*);
 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalStringIsUndefined(JSC::ExecState*);
 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalStringIsNullString(JSC::ExecState*);
 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithCallbackArg(JSC::ExecState*);
@@ -620,9 +622,11 @@ static const HashTableValue JSTestObjPrototypeTableValues[] =
     { "withScriptExecutionContextAndScriptStateWithSpaces", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithScriptExecutionContextAndScriptStateWithSpaces), (intptr_t) (0) } },
     { "withScriptArgumentsAndCallStack", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithScriptArgumentsAndCallStack), (intptr_t) (0) } },
     { "methodWithOptionalArg", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalArg), (intptr_t) (0) } },
+    { "methodWithOptionalArgAndDefaultValue", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalArgAndDefaultValue), (intptr_t) (0) } },
     { "methodWithNonOptionalArgAndOptionalArg", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithNonOptionalArgAndOptionalArg), (intptr_t) (1) } },
     { "methodWithNonOptionalArgAndTwoOptionalArgs", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithNonOptionalArgAndTwoOptionalArgs), (intptr_t) (1) } },
     { "methodWithOptionalString", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalString), (intptr_t) (0) } },
+    { "methodWithOptionalStringAndDefaultValue", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalStringAndDefaultValue), (intptr_t) (0) } },
     { "methodWithOptionalStringIsUndefined", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalStringIsUndefined), (intptr_t) (0) } },
     { "methodWithOptionalStringIsNullString", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalStringIsNullString), (intptr_t) (0) } },
     { "methodWithCallbackArg", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithCallbackArg), (intptr_t) (1) } },
@@ -3529,6 +3533,28 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalArg(Exe
     return JSValue::encode(jsUndefined());
 }
 
+EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalArgAndDefaultValue(ExecState* exec)
+{
+    JSValue thisValue = exec->thisValue();
+    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(thisValue);
+    if (UNLIKELY(!castedThis))
+        return throwThisTypeError(*exec, "TestObj", "methodWithOptionalArgAndDefaultValue");
+    ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestObj::info());
+    auto& impl = castedThis->impl();
+
+    size_t argsCount = exec->argumentCount();
+    if (argsCount <= 0) {
+        impl.methodWithOptionalArgAndDefaultValue();
+        return JSValue::encode(jsUndefined());
+    }
+
+    int opt = exec->argument(0).isUndefined() ? 666 : toInt32(exec, exec->uncheckedArgument(0), NormalConversion);
+    if (UNLIKELY(exec->hadException()))
+        return JSValue::encode(jsUndefined());
+    impl.methodWithOptionalArgAndDefaultValue(opt);
+    return JSValue::encode(jsUndefined());
+}
+
 EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithNonOptionalArgAndOptionalArg(ExecState* exec)
 {
     JSValue thisValue = exec->thisValue();
@@ -3613,6 +3639,28 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalString(
     return JSValue::encode(jsUndefined());
 }
 
+EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalStringAndDefaultValue(ExecState* exec)
+{
+    JSValue thisValue = exec->thisValue();
+    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(thisValue);
+    if (UNLIKELY(!castedThis))
+        return throwThisTypeError(*exec, "TestObj", "methodWithOptionalStringAndDefaultValue");
+    ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestObj::info());
+    auto& impl = castedThis->impl();
+
+    size_t argsCount = exec->argumentCount();
+    if (argsCount <= 0) {
+        impl.methodWithOptionalStringAndDefaultValue();
+        return JSValue::encode(jsUndefined());
+    }
+
+    String str = exec->argument(0).isUndefined() ? "foo" : exec->uncheckedArgument(0).toString(exec)->value(exec);
+    if (UNLIKELY(exec->hadException()))
+        return JSValue::encode(jsUndefined());
+    impl.methodWithOptionalStringAndDefaultValue(str);
+    return JSValue::encode(jsUndefined());
+}
+
 EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalStringIsUndefined(ExecState* exec)
 {
     JSValue thisValue = exec->thisValue();
index 16bac31edd30e42d2d0f893bbfe266fc560f1ccb..85f6eb9c5dbac105994203bd98dbd09eed1fb25e 100644 (file)
@@ -151,9 +151,11 @@ WEBCORE_EXPORT @interface DOMTestObj : DOMObject
 - (DOMTestObj *)withScriptExecutionContextAndScriptStateWithSpaces;
 - (void)withScriptArgumentsAndCallStack;
 - (void)methodWithOptionalArg:(int)opt;
+- (void)methodWithOptionalArgAndDefaultValue:(int)opt;
 - (void)methodWithNonOptionalArgAndOptionalArg:(int)nonOpt opt:(int)opt;
 - (void)methodWithNonOptionalArgAndTwoOptionalArgs:(int)nonOpt opt1:(int)opt1 opt2:(int)opt2;
 - (void)methodWithOptionalString:(NSString *)str;
+- (void)methodWithOptionalStringAndDefaultValue:(NSString *)str;
 - (void)methodWithOptionalStringIsUndefined:(NSString *)str;
 - (void)methodWithOptionalStringIsNullString:(NSString *)str;
 - (void)classMethod;
index 2a9553523ca7ccd6955c42c581b089741377fef8..668dfcabcb3e7a31eca8ec81e8cc83b49bdc2d70 100644 (file)
     IMPL->methodWithOptionalArg(opt);
 }
 
+- (void)methodWithOptionalArgAndDefaultValue:(int)opt
+{
+    WebCore::JSMainThreadNullState state;
+    IMPL->methodWithOptionalArgAndDefaultValue(opt);
+}
+
 - (void)methodWithNonOptionalArgAndOptionalArg:(int)nonOpt opt:(int)opt
 {
     WebCore::JSMainThreadNullState state;
     IMPL->methodWithOptionalString(str);
 }
 
+- (void)methodWithOptionalStringAndDefaultValue:(NSString *)str
+{
+    WebCore::JSMainThreadNullState state;
+    IMPL->methodWithOptionalStringAndDefaultValue(str);
+}
+
 - (void)methodWithOptionalStringIsUndefined:(NSString *)str
 {
     WebCore::JSMainThreadNullState state;
index c1ff8ba9e135cd3899ff92206eaf50a0cc925462..cc9e7007c6da0ba8533969cd98e2aeccf3f4f0e0 100644 (file)
@@ -140,11 +140,13 @@ enum _optional { "", "OptionalValue1", "OptionalValue2", "OptionalValue3" };
     [CallWith=  ScriptExecutionContext  &  ScriptState  ] attribute TestObj withScriptExecutionContextAndScriptStateWithSpacesAttribute;
     [CallWith=ScriptArguments&CallStack] attribute TestObj withScriptArgumentsAndCallStackAttribute;
 
-    // 'Optional' extended attribute
+    // Optional parameters.
     void    methodWithOptionalArg(optional long opt);
+    void    methodWithOptionalArgAndDefaultValue(optional long opt = 666);
     void    methodWithNonOptionalArgAndOptionalArg(long nonOpt, optional long opt);
     void    methodWithNonOptionalArgAndTwoOptionalArgs(long nonOpt, optional long opt1, optional long opt2);
     void    methodWithOptionalString(optional DOMString str);
+    void    methodWithOptionalStringAndDefaultValue(optional DOMString str = "foo");
     void    methodWithOptionalStringIsUndefined([Default=Undefined] optional DOMString str);
     void    methodWithOptionalStringIsNullString([Default=NullString] optional DOMString str);
 
index dfd7d7a102480257a367e581980388c37acfe149..81b10ae609952ef406584d07765664e67011d514 100644 (file)
     // DOM Level 2 Tranversal and Range (DocumentTraversal interface)
 
     [ObjCLegacyUnnamedParameters, RaisesException, NewObject] NodeIterator createNodeIterator(Node root,
-        optional unsigned long whatToShow,
+        optional unsigned long whatToShow = 0xFFFFFFFF,
         optional NodeFilter? filter,
         optional boolean expandEntityReferences);
     [ObjCLegacyUnnamedParameters, RaisesException, NewObject] TreeWalker createTreeWalker(Node root,
-        optional unsigned long whatToShow,
+        optional unsigned long whatToShow = 0xFFFFFFFF,
         optional NodeFilter? filter,
         optional boolean expandEntityReferences);