Auto merge of #10757 - ineol:root-node, r=Ms2ger

Implement Node::rootNode

Fixes #10747.

I don't know whether it's OK to recurse up the tree, though it is a tail call.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10757)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-04-22 12:10:52 -07:00
commit 82938547ed
4 changed files with 7 additions and 66 deletions

View file

@ -1858,6 +1858,11 @@ impl NodeMethods for Node {
}
}
// https://dom.spec.whatwg.org/#dom-node-rootnode
fn RootNode(&self) -> Root<Node> {
self.inclusive_ancestors().last().unwrap()
}
// https://dom.spec.whatwg.org/#dom-node-parentnode
fn GetParentNode(&self) -> Option<Root<Node>> {
self.parent_node.get()

View file

@ -31,6 +31,8 @@ interface Node : EventTarget {
[Pure]
readonly attribute Document? ownerDocument;
[Pure]
readonly attribute Node rootNode;
[Pure]
readonly attribute Node? parentNode;
[Pure]
readonly attribute Element? parentElement;

View file

@ -165,9 +165,6 @@
[DOMTokenList interface: calling supports(DOMString) on document.body.classList with too few arguments must throw TypeError]
expected: FAIL
[Node interface: attribute rootNode]
expected: FAIL
[Document interface: new Document() must inherit property "origin" with the proper type (3)]
expected: FAIL
@ -183,30 +180,6 @@
[Document interface: calling queryAll(DOMString) on new Document() with too few arguments must throw TypeError]
expected: FAIL
[Node interface: new Document() must inherit property "rootNode" with the proper type (16)]
expected: FAIL
[Node interface: xmlDoc must inherit property "rootNode" with the proper type (16)]
expected: FAIL
[Node interface: document.createDocumentFragment() must inherit property "rootNode" with the proper type (16)]
expected: FAIL
[Node interface: document.doctype must inherit property "rootNode" with the proper type (16)]
expected: FAIL
[Node interface: element must inherit property "rootNode" with the proper type (16)]
expected: FAIL
[Node interface: document.createTextNode("abc") must inherit property "rootNode" with the proper type (16)]
expected: FAIL
[Node interface: xmlDoc.createProcessingInstruction("abc", "def") must inherit property "rootNode" with the proper type (16)]
expected: FAIL
[Node interface: document.createComment("abc") must inherit property "rootNode" with the proper type (16)]
expected: FAIL
[Element interface: element must inherit property "query" with the proper type (36)]
expected: FAIL
@ -222,9 +195,6 @@
[Node interface: new Document() must inherit property "isConnected" with the proper type (15)]
expected: FAIL
[Node interface: new Document() must inherit property "rootNode" with the proper type (17)]
expected: FAIL
[Node interface: new Document() must inherit property "isSameNode" with the proper type (31)]
expected: FAIL
@ -234,9 +204,6 @@
[Node interface: xmlDoc must inherit property "isConnected" with the proper type (15)]
expected: FAIL
[Node interface: xmlDoc must inherit property "rootNode" with the proper type (17)]
expected: FAIL
[Node interface: xmlDoc must inherit property "isSameNode" with the proper type (31)]
expected: FAIL
@ -246,9 +213,6 @@
[Node interface: document.doctype must inherit property "isConnected" with the proper type (15)]
expected: FAIL
[Node interface: document.doctype must inherit property "rootNode" with the proper type (17)]
expected: FAIL
[Node interface: document.doctype must inherit property "isSameNode" with the proper type (31)]
expected: FAIL
@ -258,9 +222,6 @@
[Node interface: document.createDocumentFragment() must inherit property "isConnected" with the proper type (15)]
expected: FAIL
[Node interface: document.createDocumentFragment() must inherit property "rootNode" with the proper type (17)]
expected: FAIL
[Node interface: document.createDocumentFragment() must inherit property "isSameNode" with the proper type (31)]
expected: FAIL
@ -321,9 +282,6 @@
[Node interface: element must inherit property "isConnected" with the proper type (15)]
expected: FAIL
[Node interface: element must inherit property "rootNode" with the proper type (17)]
expected: FAIL
[Node interface: element must inherit property "isSameNode" with the proper type (31)]
expected: FAIL
@ -339,9 +297,6 @@
[Node interface: document.createTextNode("abc") must inherit property "isConnected" with the proper type (15)]
expected: FAIL
[Node interface: document.createTextNode("abc") must inherit property "rootNode" with the proper type (17)]
expected: FAIL
[Node interface: document.createTextNode("abc") must inherit property "isSameNode" with the proper type (31)]
expected: FAIL
@ -351,9 +306,6 @@
[Node interface: xmlDoc.createProcessingInstruction("abc", "def") must inherit property "isConnected" with the proper type (15)]
expected: FAIL
[Node interface: xmlDoc.createProcessingInstruction("abc", "def") must inherit property "rootNode" with the proper type (17)]
expected: FAIL
[Node interface: xmlDoc.createProcessingInstruction("abc", "def") must inherit property "isSameNode" with the proper type (31)]
expected: FAIL
@ -363,9 +315,6 @@
[Node interface: document.createComment("abc") must inherit property "isConnected" with the proper type (15)]
expected: FAIL
[Node interface: document.createComment("abc") must inherit property "rootNode" with the proper type (17)]
expected: FAIL
[Node interface: document.createComment("abc") must inherit property "isSameNode" with the proper type (31)]
expected: FAIL

View file

@ -1,15 +0,0 @@
[rootNode.html]
type: testharness
bug: https://github.com/servo/servo/issues/10747
[rootNode attribute must return the context object when it does not have any parent]
expected: FAIL
[rootNode attribute must return the parent node of the context object when the context object has a single ancestor not in a document]
expected: FAIL
[rootNode attribute must return the document when a node is in document]
expected: FAIL
[rootNode attribute must return a document fragment when a node is in the fragment]
expected: FAIL