diff --git a/src/components/script/dom/node.rs b/src/components/script/dom/node.rs index f323421a8d7..4efa6ddbf9a 100644 --- a/src/components/script/dom/node.rs +++ b/src/components/script/dom/node.rs @@ -840,6 +840,7 @@ impl Node { // http://dom.spec.whatwg.org/#dom-node-baseuri pub fn GetBaseURI(&self) -> Option { + // FIXME (#1824) implement. None } @@ -873,6 +874,20 @@ impl Node { self.first_child.is_some() } + // http://dom.spec.whatwg.org/#dom-node-childnodes + pub fn ChildNodes(&mut self, abstract_self: &JS) -> JS { + match self.child_list { + None => { + let doc = self.owner_doc(); + let doc = doc.get(); + let list = NodeList::new_child_list(&doc.window, abstract_self); + self.child_list = Some(list.clone()); + list + } + Some(ref list) => list.clone() + } + } + // http://dom.spec.whatwg.org/#dom-node-firstchild pub fn GetFirstChild(&self) -> Option> { self.first_child.clone() @@ -911,7 +926,7 @@ impl Node { // http://dom.spec.whatwg.org/#dom-node-nodevalue pub fn SetNodeValue(&mut self, _abstract_self: &JS, _val: Option) -> ErrorResult { - // FIXME: Stub - https://github.com/mozilla/servo/issues/1655 + // FIXME (#1825) implement. Ok(()) } @@ -942,18 +957,39 @@ impl Node { } } - // http://dom.spec.whatwg.org/#dom-node-childnodes - pub fn ChildNodes(&mut self, abstract_self: &JS) -> JS { - match self.child_list { - None => { - let doc = self.owner_doc(); - let doc = doc.get(); - let list = NodeList::new_child_list(&doc.window, abstract_self); - self.child_list = Some(list.clone()); - list + // http://dom.spec.whatwg.org/#dom-node-textcontent + pub fn SetTextContent(&mut self, abstract_self: &mut JS, value: Option) + -> ErrorResult { + let value = null_str_as_empty(&value); + match self.type_id { + DocumentFragmentNodeTypeId | + ElementNodeTypeId(..) => { + // Step 1-2. + let node = if value.len() == 0 { + None + } else { + let document = self.owner_doc(); + Some(NodeCast::from(&document.get().CreateTextNode(&document, value))) + }; + // Step 3. + Node::replace_all(node, abstract_self); } - Some(ref list) => list.clone() + CommentNodeTypeId | + TextNodeTypeId | + ProcessingInstructionNodeTypeId => { + self.wait_until_safe_to_modify_dom(); + + let mut characterdata: JS = CharacterDataCast::to(abstract_self); + characterdata.get_mut().data = value.clone(); + + // Notify the document that the content of this node is different + let document = self.owner_doc(); + document.get().content_changed(); + } + DoctypeNodeTypeId | + DocumentNodeTypeId => {} } + Ok(()) } // http://dom.spec.whatwg.org/#concept-node-adopt @@ -1227,41 +1263,6 @@ impl Node { } } - // http://dom.spec.whatwg.org/#dom-node-textcontent - pub fn SetTextContent(&mut self, abstract_self: &mut JS, value: Option) - -> ErrorResult { - let value = null_str_as_empty(&value); - match self.type_id { - DocumentFragmentNodeTypeId | - ElementNodeTypeId(..) => { - // Step 1-2. - let node = if value.len() == 0 { - None - } else { - let document = self.owner_doc(); - Some(NodeCast::from(&document.get().CreateTextNode(&document, value))) - }; - // Step 3. - Node::replace_all(node, abstract_self); - } - CommentNodeTypeId | - TextNodeTypeId | - ProcessingInstructionNodeTypeId => { - self.wait_until_safe_to_modify_dom(); - - let mut characterdata: JS = CharacterDataCast::to(abstract_self); - characterdata.get_mut().data = value.clone(); - - // Notify the document that the content of this node is different - let document = self.owner_doc(); - document.get().content_changed(); - } - DoctypeNodeTypeId | - DocumentNodeTypeId => {} - } - Ok(()) - } - // http://dom.spec.whatwg.org/#dom-node-insertbefore pub fn InsertBefore(&self, abstract_self: &mut JS, node: &mut JS, child: Option>) -> Fallible> { @@ -1415,7 +1416,7 @@ impl Node { // http://dom.spec.whatwg.org/#dom-node-normalize pub fn Normalize(&mut self) { - // FIXME: stub - https://github.com/mozilla/servo/issues/1655 + // FIXME (#1823) implement. } // http://dom.spec.whatwg.org/#dom-node-clonenode @@ -1500,7 +1501,7 @@ impl Node { // http://dom.spec.whatwg.org/#dom-node-comparedocumentposition pub fn CompareDocumentPosition(&self, _other: &JS) -> u16 { - // FIXME: stub - https://github.com/mozilla/servo/issues/1655 + // FIXME (#1794) implement. 0 } @@ -1514,19 +1515,19 @@ impl Node { // http://dom.spec.whatwg.org/#dom-node-lookupprefix pub fn LookupPrefix(&self, _prefix: Option) -> Option { - // FIXME: stub - https://github.com/mozilla/servo/issues/1655 + // FIXME (#1826) implement. None } // http://dom.spec.whatwg.org/#dom-node-lookupnamespaceuri pub fn LookupNamespaceURI(&self, _namespace: Option) -> Option { - // FIXME: stub - https://github.com/mozilla/servo/issues/1655 + // FIXME (#1826) implement. None } // http://dom.spec.whatwg.org/#dom-node-isdefaultnamespace pub fn IsDefaultNamespace(&self, _namespace: Option) -> bool { - // FIXME: stub - https://github.com/mozilla/servo/issues/1655 + // FIXME (#1826) implement. false } diff --git a/src/components/script/dom/webidls/Node.webidl b/src/components/script/dom/webidls/Node.webidl index f21d528be26..bc1c45ade9f 100644 --- a/src/components/script/dom/webidls/Node.webidl +++ b/src/components/script/dom/webidls/Node.webidl @@ -50,14 +50,6 @@ interface Node : EventTarget { attribute DOMString? nodeValue; [SetterThrows, Pure] attribute DOMString? textContent; - [Throws] - Node insertBefore(Node node, Node? child); - [Throws] - Node appendChild(Node node); - [Throws] - Node replaceChild(Node node, Node child); - [Throws] - Node removeChild(Node child); void normalize(); [Throws] @@ -69,7 +61,7 @@ interface Node : EventTarget { const unsigned short DOCUMENT_POSITION_FOLLOWING = 0x04; const unsigned short DOCUMENT_POSITION_CONTAINS = 0x08; const unsigned short DOCUMENT_POSITION_CONTAINED_BY = 0x10; - const unsigned short DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 0x20; // historical + const unsigned short DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 0x20; unsigned short compareDocumentPosition(Node other); boolean contains(Node? other); @@ -77,6 +69,15 @@ interface Node : EventTarget { DOMString? lookupNamespaceURI(DOMString? prefix); boolean isDefaultNamespace(DOMString? namespace); + [Throws] + Node insertBefore(Node node, Node? child); + [Throws] + Node appendChild(Node node); + [Throws] + Node replaceChild(Node node, Node child); + [Throws] + Node removeChild(Node child); + // Mozilla-specific stuff // These have been moved to Element in the spec. // If we move namespaceURI, prefix and localName to Element they should return