Drop [UsePointersEvenForNonNullableObjectArguments] from Document
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 22 Apr 2016 06:19:41 +0000 (06:19 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 22 Apr 2016 06:19:41 +0000 (06:19 +0000)
https://bugs.webkit.org/show_bug.cgi?id=156881

Reviewed by Darin Adler.

LayoutTests/imported/w3c:

Rebaseline now that more checks are passing.

* web-platform-tests/dom/interfaces-expected.txt:
* web-platform-tests/html/dom/interfaces-expected.txt:

Source/WebCore:

Drop [UsePointersEvenForNonNullableObjectArguments] from Document. There
is no major Web-exposed behavior change but the type of the exception
being thrown when passing null or not enough parameters has changed for
some of the API (It is now always a TypeError as per the Web IDL
specification).

Tests: fast/dom/Document/adoptNode-null.html
       fast/dom/Document/importNode-null.html

* dom/ContainerNode.cpp:
(WebCore::ContainerNode::takeAllChildrenFrom):
(WebCore::ContainerNode::parserInsertBefore):
(WebCore::ContainerNode::parserAppendChild):
* dom/Document.cpp:
(WebCore::Document::importNode):
(WebCore::Document::adoptNode):
(WebCore::Document::createNodeIterator):
(WebCore::Document::createTreeWalker):
(WebCore::Document::setBodyOrFrameset):
(WebCore::Document::hasValidNamespaceForElements): Deleted.
(WebCore::Document::scheduleForcedStyleRecalc): Deleted.
(WebCore::Document::scheduleStyleRecalc): Deleted.
(WebCore::Document::unscheduleStyleRecalc): Deleted.
(WebCore::Document::hasPendingStyleRecalc): Deleted.
(WebCore::Document::hasPendingForcedStyleRecalc): Deleted.
(WebCore::Document::recalcStyle): Deleted.
(WebCore::Document::explicitClose): Deleted.
* dom/Document.h:
(WebCore::Document::importNode):
* dom/Document.idl:
* dom/NodeIterator.cpp:
(WebCore::NodeIterator::NodeIterator):
* dom/NodeIterator.h:
(WebCore::NodeIterator::create):

LayoutTests:

Add test cases for cases where the type of the exception being thrown
has changed.

* fast/dom/Document/adoptNode-null-expected.txt: Added.
* fast/dom/Document/adoptNode-null.html: Added.
* fast/dom/Document/importNode-null-expected.txt: Added.
* fast/dom/Document/importNode-null.html: Added.
* fast/dom/importNode-null-expected.txt: Removed.
* fast/dom/importNode-null.html: Removed.

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

18 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/dom/Document/adoptNode-null-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/Document/adoptNode-null.html [new file with mode: 0644]
LayoutTests/fast/dom/Document/importNode-null-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/Document/importNode-null.html [new file with mode: 0644]
LayoutTests/fast/dom/importNode-null-expected.txt [deleted file]
LayoutTests/fast/dom/importNode-null.html [deleted file]
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/dom/interfaces-expected.txt
LayoutTests/imported/w3c/web-platform-tests/html/dom/interfaces-expected.txt
LayoutTests/platform/ios-simulator/imported/w3c/web-platform-tests/html/dom/interfaces-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/dom/ContainerNode.cpp
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Document.h
Source/WebCore/dom/Document.idl
Source/WebCore/dom/NodeIterator.cpp
Source/WebCore/dom/NodeIterator.h

index 72a414d..a851fbe 100644 (file)
@@ -1,3 +1,20 @@
+2016-04-21  Chris Dumez  <cdumez@apple.com>
+
+        Drop [UsePointersEvenForNonNullableObjectArguments] from Document
+        https://bugs.webkit.org/show_bug.cgi?id=156881
+
+        Reviewed by Darin Adler.
+
+        Add test cases for cases where the type of the exception being thrown
+        has changed.
+
+        * fast/dom/Document/adoptNode-null-expected.txt: Added.
+        * fast/dom/Document/adoptNode-null.html: Added.
+        * fast/dom/Document/importNode-null-expected.txt: Added.
+        * fast/dom/Document/importNode-null.html: Added.
+        * fast/dom/importNode-null-expected.txt: Removed.
+        * fast/dom/importNode-null.html: Removed.
+
 2016-04-21  Dean Jackson  <dino@apple.com>
 
         Backdrop Filter should not be visible if element has visibility:hidden
diff --git a/LayoutTests/fast/dom/Document/adoptNode-null-expected.txt b/LayoutTests/fast/dom/Document/adoptNode-null-expected.txt
new file mode 100644 (file)
index 0000000..cae0a66
--- /dev/null
@@ -0,0 +1,11 @@
+Tests that document.adoptNode(null) throws a TypeError
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS document.adoptNode(null) threw exception TypeError: Type error.
+PASS document.adoptNode() threw exception TypeError: Not enough arguments.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/dom/Document/adoptNode-null.html b/LayoutTests/fast/dom/Document/adoptNode-null.html
new file mode 100644 (file)
index 0000000..b083b84
--- /dev/null
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src="../../../resources/js-test-pre.js"></script>
+<script>
+description("Tests that document.adoptNode(null) throws a TypeError");
+
+shouldThrow("document.adoptNode(null)", "'TypeError: Type error'");
+shouldThrow("document.adoptNode()", "'TypeError: Not enough arguments'");
+</script>
+<script src="../../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/dom/Document/importNode-null-expected.txt b/LayoutTests/fast/dom/Document/importNode-null-expected.txt
new file mode 100644 (file)
index 0000000..46d190a
--- /dev/null
@@ -0,0 +1,11 @@
+Tests that document.importNode(null) throws a TypeError
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS document.importNode(null) threw exception TypeError: Type error.
+PASS document.importNode() threw exception TypeError: Not enough arguments.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/dom/Document/importNode-null.html b/LayoutTests/fast/dom/Document/importNode-null.html
new file mode 100644 (file)
index 0000000..c8a8671
--- /dev/null
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src="../../../resources/js-test-pre.js"></script>
+<script>
+description("Tests that document.importNode(null) throws a TypeError");
+
+shouldThrow("document.importNode(null)", "'TypeError: Type error'");
+shouldThrow("document.importNode()", "'TypeError: Not enough arguments'");
+</script>
+<script src="../../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/dom/importNode-null-expected.txt b/LayoutTests/fast/dom/importNode-null-expected.txt
deleted file mode 100644 (file)
index 00e2e03..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-This page tests calling document.importNode(null). If it passes, you'll see a "PASS" message below.
-
-caught exception: Error: NotSupportedError: DOM Exception 9
-PASS: importNode(null) didn't crash
diff --git a/LayoutTests/fast/dom/importNode-null.html b/LayoutTests/fast/dom/importNode-null.html
deleted file mode 100644 (file)
index 485a8be..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-<html>
-<head>
-<script>
-function print(message, color) 
-{
-    var paragraph = document.createElement("div");
-    paragraph.appendChild(document.createTextNode(message));
-    paragraph.style.fontFamily = "monospace";
-    if (color)
-        paragraph.style.color = color;
-    document.getElementById("console").appendChild(paragraph);
-}
-
-function test() 
-{
-    if (window.testRunner)
-        testRunner.dumpAsText();
-        
-    try {
-        document.importNode(null);
-    } catch(e) {
-        print("caught exception: " + e);
-    } finally {
-        print("PASS: importNode(null) didn't crash", "green");
-    }
-}
-</script>
-</head>
-<body onload="test();">
-<p>This page tests calling document.importNode(null). If it passes, you'll 
-   see a "PASS" message below.</p>
-<hr>
-<div id='console'></div>
-</body>
-</html>
index 75c76d3..ff25694 100644 (file)
@@ -1,3 +1,15 @@
+2016-04-21  Chris Dumez  <cdumez@apple.com>
+
+        Drop [UsePointersEvenForNonNullableObjectArguments] from Document
+        https://bugs.webkit.org/show_bug.cgi?id=156881
+
+        Reviewed by Darin Adler.
+
+        Rebaseline now that more checks are passing.
+
+        * web-platform-tests/dom/interfaces-expected.txt:
+        * web-platform-tests/html/dom/interfaces-expected.txt:
+
 2016-04-21  Youenn Fablet  <youenn.fablet@crf.canon.fr>
 
         [Fetch API] Improve some fetch response streams tests
index f193538..0e9d1c1 100644 (file)
@@ -262,8 +262,8 @@ PASS Document interface: operation createDocumentFragment()
 FAIL Document interface: operation createTextNode(DOMString) assert_equals: property has wrong .length expected 1 but got 0
 FAIL Document interface: operation createComment(DOMString) assert_equals: property has wrong .length expected 1 but got 0
 FAIL Document interface: operation createProcessingInstruction(DOMString,DOMString) assert_equals: property has wrong .length expected 2 but got 0
-FAIL Document interface: operation importNode(Node,boolean) assert_equals: property has wrong .length expected 1 but got 0
-FAIL Document interface: operation adoptNode(Node) assert_equals: property has wrong .length expected 1 but got 0
+PASS Document interface: operation importNode(Node,boolean) 
+PASS Document interface: operation adoptNode(Node) 
 FAIL Document interface: operation createAttribute(DOMString) assert_equals: property has wrong .length expected 1 but got 0
 FAIL Document interface: operation createAttributeNS(DOMString,DOMString) assert_equals: property has wrong .length expected 2 but got 0
 FAIL Document interface: operation createEvent(DOMString) assert_equals: property has wrong .length expected 1 but got 0
@@ -331,13 +331,9 @@ FAIL Document interface: calling createProcessingInstruction(DOMString,DOMString
             fn.apply(obj, args);
         }" did not throw
 PASS Document interface: xmlDoc must inherit property "importNode" with the proper type (20) 
-FAIL Document interface: calling importNode(Node,boolean) on xmlDoc with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
-            fn.apply(obj, args);
-        }" threw object "Error: NotSupportedError: DOM Exception 9" ("NotSupportedError") expected object "TypeError" ("TypeError")
+PASS Document interface: calling importNode(Node,boolean) on xmlDoc with too few arguments must throw TypeError 
 PASS Document interface: xmlDoc must inherit property "adoptNode" with the proper type (21) 
-FAIL Document interface: calling adoptNode(Node) on xmlDoc with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
-            fn.apply(obj, args);
-        }" threw object "Error: NotSupportedError: DOM Exception 9" ("NotSupportedError") expected object "TypeError" ("TypeError")
+PASS Document interface: calling adoptNode(Node) on xmlDoc with too few arguments must throw TypeError 
 PASS Document interface: xmlDoc must inherit property "createAttribute" with the proper type (22) 
 FAIL Document interface: calling createAttribute(DOMString) on xmlDoc with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
             fn.apply(obj, args);
index 10aeb84..562021d 100644 (file)
@@ -167,13 +167,9 @@ FAIL Document interface: calling createProcessingInstruction(DOMString,DOMString
             fn.apply(obj, args);
         }" did not throw
 PASS Document interface: iframe.contentDocument must inherit property "importNode" with the proper type (20) 
-FAIL Document interface: calling importNode(Node,boolean) on iframe.contentDocument with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
-            fn.apply(obj, args);
-        }" threw object "Error: NotSupportedError: DOM Exception 9" ("NotSupportedError") expected object "TypeError" ("TypeError")
+PASS Document interface: calling importNode(Node,boolean) on iframe.contentDocument with too few arguments must throw TypeError 
 PASS Document interface: iframe.contentDocument must inherit property "adoptNode" with the proper type (21) 
-FAIL Document interface: calling adoptNode(Node) on iframe.contentDocument with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
-            fn.apply(obj, args);
-        }" threw object "Error: NotSupportedError: DOM Exception 9" ("NotSupportedError") expected object "TypeError" ("TypeError")
+PASS Document interface: calling adoptNode(Node) on iframe.contentDocument with too few arguments must throw TypeError 
 PASS Document interface: iframe.contentDocument must inherit property "createAttribute" with the proper type (22) 
 FAIL Document interface: calling createAttribute(DOMString) on iframe.contentDocument with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
             fn.apply(obj, args);
@@ -482,13 +478,9 @@ FAIL Document interface: calling createProcessingInstruction(DOMString,DOMString
             fn.apply(obj, args);
         }" did not throw
 PASS Document interface: document.implementation.createDocument(null, "", null) must inherit property "importNode" with the proper type (20) 
-FAIL Document interface: calling importNode(Node,boolean) on document.implementation.createDocument(null, "", null) with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
-            fn.apply(obj, args);
-        }" threw object "Error: NotSupportedError: DOM Exception 9" ("NotSupportedError") expected object "TypeError" ("TypeError")
+PASS Document interface: calling importNode(Node,boolean) on document.implementation.createDocument(null, "", null) with too few arguments must throw TypeError 
 PASS Document interface: document.implementation.createDocument(null, "", null) must inherit property "adoptNode" with the proper type (21) 
-FAIL Document interface: calling adoptNode(Node) on document.implementation.createDocument(null, "", null) with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
-            fn.apply(obj, args);
-        }" threw object "Error: NotSupportedError: DOM Exception 9" ("NotSupportedError") expected object "TypeError" ("TypeError")
+PASS Document interface: calling adoptNode(Node) on document.implementation.createDocument(null, "", null) with too few arguments must throw TypeError 
 PASS Document interface: document.implementation.createDocument(null, "", null) must inherit property "createAttribute" with the proper type (22) 
 FAIL Document interface: calling createAttribute(DOMString) on document.implementation.createDocument(null, "", null) with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
             fn.apply(obj, args);
index 8d2ac9b..b63b824 100644 (file)
@@ -167,13 +167,9 @@ FAIL Document interface: calling createProcessingInstruction(DOMString,DOMString
             fn.apply(obj, args);
         }" did not throw
 PASS Document interface: iframe.contentDocument must inherit property "importNode" with the proper type (20) 
-FAIL Document interface: calling importNode(Node,boolean) on iframe.contentDocument with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
-            fn.apply(obj, args);
-        }" threw object "Error: NotSupportedError: DOM Exception 9" ("NotSupportedError") expected object "TypeError" ("TypeError")
+PASS Document interface: calling importNode(Node,boolean) on iframe.contentDocument with too few arguments must throw TypeError 
 PASS Document interface: iframe.contentDocument must inherit property "adoptNode" with the proper type (21) 
-FAIL Document interface: calling adoptNode(Node) on iframe.contentDocument with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
-            fn.apply(obj, args);
-        }" threw object "Error: NotSupportedError: DOM Exception 9" ("NotSupportedError") expected object "TypeError" ("TypeError")
+PASS Document interface: calling adoptNode(Node) on iframe.contentDocument with too few arguments must throw TypeError 
 PASS Document interface: iframe.contentDocument must inherit property "createAttribute" with the proper type (22) 
 FAIL Document interface: calling createAttribute(DOMString) on iframe.contentDocument with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
             fn.apply(obj, args);
@@ -482,13 +478,9 @@ FAIL Document interface: calling createProcessingInstruction(DOMString,DOMString
             fn.apply(obj, args);
         }" did not throw
 PASS Document interface: document.implementation.createDocument(null, "", null) must inherit property "importNode" with the proper type (20) 
-FAIL Document interface: calling importNode(Node,boolean) on document.implementation.createDocument(null, "", null) with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
-            fn.apply(obj, args);
-        }" threw object "Error: NotSupportedError: DOM Exception 9" ("NotSupportedError") expected object "TypeError" ("TypeError")
+PASS Document interface: calling importNode(Node,boolean) on document.implementation.createDocument(null, "", null) with too few arguments must throw TypeError 
 PASS Document interface: document.implementation.createDocument(null, "", null) must inherit property "adoptNode" with the proper type (21) 
-FAIL Document interface: calling adoptNode(Node) on document.implementation.createDocument(null, "", null) with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
-            fn.apply(obj, args);
-        }" threw object "Error: NotSupportedError: DOM Exception 9" ("NotSupportedError") expected object "TypeError" ("TypeError")
+PASS Document interface: calling adoptNode(Node) on document.implementation.createDocument(null, "", null) with too few arguments must throw TypeError 
 PASS Document interface: document.implementation.createDocument(null, "", null) must inherit property "createAttribute" with the proper type (22) 
 FAIL Document interface: calling createAttribute(DOMString) on document.implementation.createDocument(null, "", null) with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
             fn.apply(obj, args);
index 4672504..10acf4e 100644 (file)
@@ -1,3 +1,45 @@
+2016-04-21  Chris Dumez  <cdumez@apple.com>
+
+        Drop [UsePointersEvenForNonNullableObjectArguments] from Document
+        https://bugs.webkit.org/show_bug.cgi?id=156881
+
+        Reviewed by Darin Adler.
+
+        Drop [UsePointersEvenForNonNullableObjectArguments] from Document. There
+        is no major Web-exposed behavior change but the type of the exception
+        being thrown when passing null or not enough parameters has changed for
+        some of the API (It is now always a TypeError as per the Web IDL
+        specification).
+
+        Tests: fast/dom/Document/adoptNode-null.html
+               fast/dom/Document/importNode-null.html
+
+        * dom/ContainerNode.cpp:
+        (WebCore::ContainerNode::takeAllChildrenFrom):
+        (WebCore::ContainerNode::parserInsertBefore):
+        (WebCore::ContainerNode::parserAppendChild):
+        * dom/Document.cpp:
+        (WebCore::Document::importNode):
+        (WebCore::Document::adoptNode):
+        (WebCore::Document::createNodeIterator):
+        (WebCore::Document::createTreeWalker):
+        (WebCore::Document::setBodyOrFrameset):
+        (WebCore::Document::hasValidNamespaceForElements): Deleted.
+        (WebCore::Document::scheduleForcedStyleRecalc): Deleted.
+        (WebCore::Document::scheduleStyleRecalc): Deleted.
+        (WebCore::Document::unscheduleStyleRecalc): Deleted.
+        (WebCore::Document::hasPendingStyleRecalc): Deleted.
+        (WebCore::Document::hasPendingForcedStyleRecalc): Deleted.
+        (WebCore::Document::recalcStyle): Deleted.
+        (WebCore::Document::explicitClose): Deleted.
+        * dom/Document.h:
+        (WebCore::Document::importNode):
+        * dom/Document.idl:
+        * dom/NodeIterator.cpp:
+        (WebCore::NodeIterator::NodeIterator):
+        * dom/NodeIterator.h:
+        (WebCore::NodeIterator::create):
+
 2016-04-21  Frederic Wang  <fwang@igalia.com>
 
         More improvements and explanations regarding resetting CSS properties on the <math> element
index b99fd41..ae2ab1d 100644 (file)
@@ -130,7 +130,7 @@ void ContainerNode::takeAllChildrenFrom(ContainerNode* oldParent)
         destroyRenderTreeIfNeeded(child);
 
         // FIXME: We need a no mutation event version of adoptNode.
-        RefPtr<Node> adoptedChild = document().adoptNode(&child.get(), ASSERT_NO_EXCEPTION);
+        RefPtr<Node> adoptedChild = document().adoptNode(child, ASSERT_NO_EXCEPTION);
         parserAppendChild(*adoptedChild);
         // FIXME: Together with adoptNode above, the tree scope might get updated recursively twice
         // (if the document changed or oldParent was in a shadow tree, AND *this is in a shadow tree).
@@ -376,7 +376,7 @@ void ContainerNode::parserInsertBefore(Ref<Node>&& newChild, Node& nextChild)
         return;
 
     if (&document() != &newChild->document())
-        document().adoptNode(newChild.ptr(), ASSERT_NO_EXCEPTION);
+        document().adoptNode(newChild, ASSERT_NO_EXCEPTION);
 
     insertBeforeCommon(nextChild, newChild);
 
@@ -718,7 +718,7 @@ void ContainerNode::parserAppendChild(Ref<Node>&& newChild)
 #endif
 
     if (&document() != &newChild->document())
-        document().adoptNode(newChild.ptr(), ASSERT_NO_EXCEPTION);
+        document().adoptNode(newChild, ASSERT_NO_EXCEPTION);
 
     {
         NoEventDispatchAssertion assertNoEventDispatch;
index 2cebfe7..1c1e7aa 100644 (file)
@@ -992,16 +992,11 @@ Ref<CSSStyleDeclaration> Document::createCSSStyleDeclaration()
     return *propertySet->ensureCSSStyleDeclaration();
 }
 
-RefPtr<Node> Document::importNode(Node* importedNode, bool deep, ExceptionCode& ec)
+RefPtr<Node> Document::importNode(Node& nodeToImport, bool deep, ExceptionCode& ec)
 {
-    if (!importedNode) {
-        ec = NOT_SUPPORTED_ERR;
-        return nullptr;
-    }
-
-    switch (importedNode->nodeType()) {
+    switch (nodeToImport.nodeType()) {
     case DOCUMENT_FRAGMENT_NODE:
-        if (importedNode->isShadowRoot())
+        if (nodeToImport.isShadowRoot())
             break;
         FALLTHROUGH;
     case ELEMENT_NODE:
@@ -1009,11 +1004,11 @@ RefPtr<Node> Document::importNode(Node* importedNode, bool deep, ExceptionCode&
     case CDATA_SECTION_NODE:
     case PROCESSING_INSTRUCTION_NODE:
     case COMMENT_NODE:
-        return importedNode->cloneNodeInternal(document(), deep ? CloningOperation::Everything : CloningOperation::OnlySelf);
+        return nodeToImport.cloneNodeInternal(document(), deep ? CloningOperation::Everything : CloningOperation::OnlySelf);
 
     case ATTRIBUTE_NODE:
         // FIXME: This will "Attr::normalize" child nodes of Attr.
-        return Attr::create(*this, QualifiedName(nullAtom, downcast<Attr>(*importedNode).name(), nullAtom), downcast<Attr>(*importedNode).value());
+        return Attr::create(*this, QualifiedName(nullAtom, downcast<Attr>(nodeToImport).name(), nullAtom), downcast<Attr>(nodeToImport).value());
 
     case DOCUMENT_NODE: // Can't import a document into another document.
     case DOCUMENT_TYPE_NODE: // FIXME: Support cloning a DocumentType node per DOM4.
@@ -1025,48 +1020,43 @@ RefPtr<Node> Document::importNode(Node* importedNode, bool deep, ExceptionCode&
 }
 
 
-RefPtr<Node> Document::adoptNode(Node* source, ExceptionCode& ec)
+RefPtr<Node> Document::adoptNode(Node& source, ExceptionCode& ec)
 {
-    if (!source) {
-        ec = NOT_SUPPORTED_ERR;
-        return nullptr;
-    }
-
     EventQueueScope scope;
 
-    switch (source->nodeType()) {
+    switch (source.nodeType()) {
     case DOCUMENT_NODE:
         ec = NOT_SUPPORTED_ERR;
         return nullptr;
     case ATTRIBUTE_NODE: {                   
-        Attr& attr = downcast<Attr>(*source);
+        auto& attr = downcast<Attr>(source);
         if (attr.ownerElement())
             attr.ownerElement()->removeAttributeNode(&attr, ec);
         break;
     }       
     default:
-        if (source->isShadowRoot()) {
+        if (source.isShadowRoot()) {
             // ShadowRoot cannot disconnect itself from the host node.
             ec = HIERARCHY_REQUEST_ERR;
             return nullptr;
         }
-        if (is<HTMLFrameOwnerElement>(*source)) {
-            HTMLFrameOwnerElement& frameOwnerElement = downcast<HTMLFrameOwnerElement>(*source);
+        if (is<HTMLFrameOwnerElement>(source)) {
+            auto& frameOwnerElement = downcast<HTMLFrameOwnerElement>(source);
             if (frame() && frame()->tree().isDescendantOf(frameOwnerElement.contentFrame())) {
                 ec = HIERARCHY_REQUEST_ERR;
                 return nullptr;
             }
         }
-        if (source->parentNode()) {
-            source->parentNode()->removeChild(*source, ec);
+        if (source.parentNode()) {
+            source.parentNode()->removeChild(source, ec);
             if (ec)
                 return nullptr;
         }
     }
 
-    adoptIfNeeded(source);
+    adoptIfNeeded(&source);
 
-    return source;
+    return &source;
 }
 
 bool Document::hasValidNamespaceForElements(const QualifiedName& qName)
@@ -1778,52 +1768,14 @@ Ref<Range> Document::createRange()
     return Range::create(*this);
 }
 
-RefPtr<NodeIterator> Document::createNodeIterator(Node* root, unsigned long whatToShow, RefPtr<NodeFilter>&& filter, bool, ExceptionCode& ec)
+Ref<NodeIterator> Document::createNodeIterator(Node& root, unsigned long whatToShow, RefPtr<NodeFilter>&& filter, bool)
 {
-    return createNodeIterator(root, whatToShow, WTFMove(filter), ec);
-}
-
-RefPtr<NodeIterator> Document::createNodeIterator(Node* root, unsigned long whatToShow, RefPtr<NodeFilter>&& filter, ExceptionCode& ec)
-{
-    if (!root) {
-        ec = TypeError;
-        return nullptr;
-    }
     return NodeIterator::create(root, whatToShow, WTFMove(filter));
 }
 
-RefPtr<NodeIterator> Document::createNodeIterator(Node* root, unsigned long whatToShow, ExceptionCode& ec)
-{
-    return createNodeIterator(root, whatToShow, nullptr, ec);
-}
-
-RefPtr<NodeIterator> Document::createNodeIterator(Node* root, ExceptionCode& ec)
-{
-    return createNodeIterator(root, 0xFFFFFFFF, nullptr, ec);
-}
-
-RefPtr<TreeWalker> Document::createTreeWalker(Node* root, unsigned long whatToShow, RefPtr<NodeFilter>&& filter, bool, ExceptionCode& ec)
-{
-    return createTreeWalker(root, whatToShow, WTFMove(filter), ec);
-}
-
-RefPtr<TreeWalker> Document::createTreeWalker(Node* root, unsigned long whatToShow, RefPtr<NodeFilter>&& filter, ExceptionCode& ec)
-{
-    if (!root) {
-        ec = TypeError;
-        return nullptr;
-    }
-    return TreeWalker::create(*root, whatToShow, WTFMove(filter));
-}
-
-RefPtr<TreeWalker> Document::createTreeWalker(Node* root, unsigned long whatToShow, ExceptionCode& ec)
-{
-    return createTreeWalker(root, whatToShow, nullptr, ec);
-}
-
-RefPtr<TreeWalker> Document::createTreeWalker(Node* root, ExceptionCode& ec)
+Ref<TreeWalker> Document::createTreeWalker(Node& root, unsigned long whatToShow, RefPtr<NodeFilter>&& filter, bool)
 {
-    return createTreeWalker(root, 0xFFFFFFFF, nullptr, ec);
+    return TreeWalker::create(root, whatToShow, WTFMove(filter));
 }
 
 void Document::scheduleForcedStyleRecalc()
@@ -2680,7 +2632,7 @@ void Document::setBodyOrFrameset(RefPtr<HTMLElement>&& newBody, ExceptionCode& e
 
     if (&newBody->document() != this) {
         ec = 0;
-        RefPtr<Node> node = importNode(newBody.get(), true, ec);
+        RefPtr<Node> node = importNode(*newBody, true, ec);
         if (ec)
             return;
         
index ca052fe..bd6ac7e 100644 (file)
@@ -388,8 +388,8 @@ public:
     RefPtr<Attr> createAttribute(const String& name, ExceptionCode&);
     RefPtr<Attr> createAttributeNS(const String& namespaceURI, const String& qualifiedName, ExceptionCode&, bool shouldIgnoreNamespaceChecks = false);
     RefPtr<EntityReference> createEntityReference(const String& name, ExceptionCode&);
-    RefPtr<Node> importNode(Node* importedNode, ExceptionCode& ec) { return importNode(importedNode, false, ec); }
-    RefPtr<Node> importNode(Node* importedNode, bool deep, ExceptionCode&);
+    RefPtr<Node> importNode(Node& nodeToImport, ExceptionCode& ec) { return importNode(nodeToImport, false, ec); }
+    RefPtr<Node> importNode(Node& nodeToImport, bool deep, ExceptionCode&);
     WEBCORE_EXPORT RefPtr<Element> createElementNS(const String& namespaceURI, const String& qualifiedName, ExceptionCode&);
     WEBCORE_EXPORT Ref<Element> createElement(const QualifiedName&, bool createdByParser);
 
@@ -458,7 +458,7 @@ public:
     void setTimerThrottlingEnabled(bool);
     bool isTimerThrottlingEnabled() const { return m_isTimerThrottlingEnabled; }
 
-    RefPtr<Node> adoptNode(Node* source, ExceptionCode&);
+    RefPtr<Node> adoptNode(Node& source, ExceptionCode&);
 
     Ref<HTMLCollection> images();
     Ref<HTMLCollection> embeds();
@@ -548,15 +548,11 @@ public:
 
     WEBCORE_EXPORT Ref<Range> createRange();
 
-    RefPtr<NodeIterator> createNodeIterator(Node* root, unsigned long whatToShow, RefPtr<NodeFilter>&&, bool, ExceptionCode&); // For ObjC bindings.
-    RefPtr<NodeIterator> createNodeIterator(Node* root, unsigned long whatToShow, RefPtr<NodeFilter>&&, ExceptionCode&);
-    RefPtr<NodeIterator> createNodeIterator(Node* root, unsigned long whatToShow, ExceptionCode&);
-    RefPtr<NodeIterator> createNodeIterator(Node* root, ExceptionCode&);
+    // The last bool parameter is for ObjC bindings.
+    Ref<NodeIterator> createNodeIterator(Node& root, unsigned long whatToShow = 0xFFFFFFFF, RefPtr<NodeFilter>&& = nullptr, bool = false);
 
-    RefPtr<TreeWalker> createTreeWalker(Node* root, unsigned long whatToShow, RefPtr<NodeFilter>&&, bool, ExceptionCode&); // For ObjC bindings.
-    RefPtr<TreeWalker> createTreeWalker(Node* root, unsigned long whatToShow, RefPtr<NodeFilter>&&, ExceptionCode&);
-    RefPtr<TreeWalker> createTreeWalker(Node* root, unsigned long whatToShow, ExceptionCode&);
-    RefPtr<TreeWalker> createTreeWalker(Node* root, ExceptionCode&);
+    // The last bool parameter is for ObjC bindings.
+    Ref<TreeWalker> createTreeWalker(Node& root, unsigned long whatToShow = 0xFFFFFFFF, RefPtr<NodeFilter>&& = nullptr, bool = false);
 
     // Special support for editing
     Ref<CSSStyleDeclaration> createCSSStyleDeclaration();
index 19f08b0..ff54509 100644 (file)
     Constructor,
     ConstructorCallWith=ScriptExecutionContext,
     CustomToJSObject,
-    UsePointersEvenForNonNullableObjectArguments,
     JSCustomHeader,
     JSGenerateToNativeObject,
     ExportMacro=WEBCORE_EXPORT,
 ] interface Document : Node {
 
     // DOM Level 1 Core
-    readonly attribute DocumentType doctype;
+    readonly attribute DocumentType? doctype;
     readonly attribute DOMImplementation implementation;
-    readonly attribute Element documentElement;
+    readonly attribute Element? documentElement;
 
     [NewObject, RaisesException, ImplementedAs=createElementForBindings] Element createElement(DOMString tagName);
     [NewObject] DocumentFragment   createDocumentFragment();
@@ -54,8 +53,7 @@
 
     // Introduced in DOM Level 2:
 
-    [ObjCLegacyUnnamedParameters, NewObject, RaisesException] Node importNode([Default=Undefined] optional Node importedNode,
-                    optional boolean deep);
+    [ObjCLegacyUnnamedParameters, NewObject, RaisesException] Node importNode(Node importedNode, optional boolean deep);
 
     // FIXME: 'qualifiedName' should not have [TreatNullAs=EmptyString].
     [ObjCLegacyUnnamedParameters, NewObject, RaisesException] Element createElementNS([Default=Undefined] optional DOMString? namespaceURI,
@@ -79,7 +77,7 @@
     [SetterRaisesException] attribute DOMString? xmlVersion;
     [SetterRaisesException] attribute boolean xmlStandalone;
 
-    [RaisesException] Node               adoptNode([Default=Undefined] optional Node source);
+    [RaisesException] Node adoptNode(Node source);
 
 #if defined(LANGUAGE_OBJECTIVE_C) && LANGUAGE_OBJECTIVE_C || defined(LANGUAGE_GOBJECT) && LANGUAGE_GOBJECT
     // document.documentURI was writable in DOM3 Core, but is read-only in DOM4
     // DOM Level 2 Tranversal and Range (DocumentTraversal interface)
 
 #if defined(LANGUAGE_OBJECTIVE_C) && LANGUAGE_OBJECTIVE_C || defined(LANGUAGE_GOBJECT) && LANGUAGE_GOBJECT
-    [ObjCLegacyUnnamedParameters, RaisesException] NodeIterator createNodeIterator(Node root,
+    [ObjCLegacyUnnamedParameters] NodeIterator createNodeIterator(Node root,
         optional unsigned long whatToShow = 0xFFFFFFFF,
         optional NodeFilter? filter,
         optional boolean expandEntityReferences);
-    [ObjCLegacyUnnamedParameters, RaisesException] TreeWalker createTreeWalker(Node root,
+    [ObjCLegacyUnnamedParameters] TreeWalker createTreeWalker(Node root,
         optional unsigned long whatToShow = 0xFFFFFFFF,
         optional NodeFilter? filter,
         optional boolean expandEntityReferences);
 #else
-    [RaisesException, NewObject] NodeIterator createNodeIterator(Node root,
+    [NewObject] NodeIterator createNodeIterator(Node root,
         optional unsigned long whatToShow = 0xFFFFFFFF,
         optional NodeFilter? filter);
-    [RaisesException, NewObject] TreeWalker createTreeWalker(Node root,
+    [NewObject] TreeWalker createTreeWalker(Node root,
         optional unsigned long whatToShow = 0xFFFFFFFF,
         optional NodeFilter? filter);
 #endif
 
     // DOM Level 2 Style (DocumentCSS interface)
 
-    [ObjCLegacyUnnamedParameters] CSSStyleDeclaration getOverrideStyle([Default=Undefined] optional Element element,
+    [ObjCLegacyUnnamedParameters] CSSStyleDeclaration getOverrideStyle([Default=Undefined] optional Element? element,
                                                         [Default=Undefined] optional DOMString pseudoElement);
 
     readonly attribute DOMString contentType;
 
     // DOM Level 3 XPath (XPathEvaluator interface)
     [ObjCLegacyUnnamedParameters, RaisesException] XPathExpression createExpression([Default=Undefined] optional DOMString expression,
-                                                    [Default=Undefined] optional XPathNSResolver resolver);
-    XPathNSResolver    createNSResolver(Node nodeResolver);
+                                                    [Default=Undefined] optional XPathNSResolver? resolver);
+    XPathNSResolver    createNSResolver(Node? nodeResolver);
     [ObjCLegacyUnnamedParameters, RaisesException] XPathResult evaluate([Default=Undefined] optional DOMString expression,
-                                                  [Default=Undefined] optional Node contextNode,
-                                                  [Default=Undefined] optional XPathNSResolver resolver,
+                                                  [Default=Undefined] optional Node? contextNode,
+                                                  [Default=Undefined] optional XPathNSResolver? resolver,
                                                   [Default=Undefined] optional unsigned short type,
-                                                  [Default=Undefined] optional XPathResult inResult);
+                                                  [Default=Undefined] optional XPathResult? inResult);
 
     // Common extensions
     boolean            execCommand([Default=Undefined] optional DOMString command,
     // FIXME: Should not have [TreatNullAs=EmptyString].
     [TreatNullAs=EmptyString, GetterRaisesException, SetterRaisesException] attribute DOMString cookie;
 
-    [SetterRaisesException, ImplementedAs=bodyOrFrameset, StrictTypeChecking] attribute HTMLElement body;
+    [SetterRaisesException, ImplementedAs=bodyOrFrameset, StrictTypeChecking] attribute HTMLElement? body;
 
-    readonly attribute HTMLHeadElement head;
+    readonly attribute HTMLHeadElement? head;
     readonly attribute HTMLCollection images;
     readonly attribute HTMLCollection applets;
     readonly attribute HTMLCollection links;
 
 #if defined(LANGUAGE_OBJECTIVE_C) && LANGUAGE_OBJECTIVE_C
     // DOM Level 2 Style Interface
-    [ObjCLegacyUnnamedParameters, ObjCUseDefaultView] CSSStyleDeclaration getComputedStyle(Element element,
+    [ObjCLegacyUnnamedParameters, ObjCUseDefaultView] CSSStyleDeclaration getComputedStyle(Element? element,
                                                                   DOMString pseudoElement);
 
     // WebKit extension
     // FIXME: remove the first version once optional is implemented for Objective-C.
-    [ObjCUseDefaultView] CSSRuleList getMatchedCSSRules(Element element,
+    [ObjCUseDefaultView] CSSRuleList getMatchedCSSRules(Element? element,
                                               DOMString pseudoElement);
-    [ObjCUseDefaultView] CSSRuleList getMatchedCSSRules(Element element,
+    [ObjCUseDefaultView] CSSRuleList getMatchedCSSRules(Element? element,
                                               DOMString pseudoElement,
                                               optional boolean authorOnly);
                                               
     HTMLCollection getElementsByClassName([Default=Undefined] optional DOMString classNames);
 #endif
 
-    readonly attribute Element activeElement;
+    readonly attribute Element? activeElement;
     boolean hasFocus();
 
     readonly attribute DOMString compatMode;
 
     // W3C version
     readonly attribute boolean webkitFullscreenEnabled;
-    readonly attribute Element webkitFullscreenElement;
+    readonly attribute Element? webkitFullscreenElement;
     void webkitExitFullscreen();
 #endif
 
     [Conditional=POINTER_LOCK] void exitPointerLock();
-    [Conditional=POINTER_LOCK] readonly attribute Element pointerLockElement;
+    [Conditional=POINTER_LOCK] readonly attribute Element? pointerLockElement;
 
     [Conditional=CSS_REGIONS] DOMNamedFlowCollection webkitGetNamedFlows();
 
 #if defined(ENABLE_IOS_TOUCH_EVENTS) && ENABLE_IOS_TOUCH_EVENTS
 #include <WebKitAdditions/DocumentIOS.idl>
 #elif defined(ENABLE_TOUCH_EVENTS) && ENABLE_TOUCH_EVENTS
-    [NewObject, RaisesException] Touch createTouch([Default=Undefined] optional DOMWindow window,
-                                                     [Default=Undefined] optional EventTarget target,
+    [NewObject, RaisesException] Touch createTouch([Default=Undefined] optional DOMWindow? window,
+                                                     [Default=Undefined] optional EventTarget? target,
                                                      [Default=Undefined] optional long identifier,
                                                      [Default=Undefined] optional long pageX,
                                                      [Default=Undefined] optional long pageY,
     readonly attribute boolean hidden;
 
     // currentscript API: http://www.whatwg.org/specs/web-apps/current-work/multipage/dom.html#dom-document-currentscript
-    readonly attribute HTMLScriptElement currentScript;
+    readonly attribute HTMLScriptElement? currentScript;
 
     // http://www.w3.org/TR/2014/WD-dom-20140204/#dom-document-origin
     readonly attribute DOMString origin;
 
     // http://dev.w3.org/csswg/cssom-view/#dom-document-scrollingelement
-    readonly attribute Element scrollingElement;
+    readonly attribute Element? scrollingElement;
 
 
     // Event Handlers
index 86dbd0f..74290a9 100644 (file)
@@ -76,8 +76,8 @@ bool NodeIterator::NodePointer::moveToPrevious(Node* root)
     return node;
 }
 
-NodeIterator::NodeIterator(Node* rootNode, unsigned long whatToShow, RefPtr<NodeFilter>&& filter)
-    : NodeIteratorBase(*rootNode, whatToShow, WTFMove(filter))
+NodeIterator::NodeIterator(Node& rootNode, unsigned long whatToShow, RefPtr<NodeFilter>&& filter)
+    : NodeIteratorBase(rootNode, whatToShow, WTFMove(filter))
     , m_referenceNode(root(), true)
 {
     root()->document().attachNodeIterator(this);
index f85d757..f6bba32 100644 (file)
@@ -36,7 +36,7 @@ namespace WebCore {
 
     class NodeIterator : public ScriptWrappable, public RefCounted<NodeIterator>, public NodeIteratorBase {
     public:
-        static Ref<NodeIterator> create(Node* rootNode, unsigned long whatToShow, RefPtr<NodeFilter>&& filter)
+        static Ref<NodeIterator> create(Node& rootNode, unsigned long whatToShow, RefPtr<NodeFilter>&& filter)
         {
             return adoptRef(*new NodeIterator(rootNode, whatToShow, WTFMove(filter)));
         }
@@ -53,7 +53,7 @@ namespace WebCore {
         void nodeWillBeRemoved(Node&);
 
     private:
-        NodeIterator(Node*, unsigned long whatToShow, RefPtr<NodeFilter>&&);
+        NodeIterator(Node&, unsigned long whatToShow, RefPtr<NodeFilter>&&);
 
         struct NodePointer {
             RefPtr<Node> node;