diff options
Diffstat (limited to 'src')
4 files changed, 19 insertions, 4 deletions
diff --git a/src/components/script/dom/bindings/codegen/Bindings.conf b/src/components/script/dom/bindings/codegen/Bindings.conf index de6d5be0435..691611e870e 100644 --- a/src/components/script/dom/bindings/codegen/Bindings.conf +++ b/src/components/script/dom/bindings/codegen/Bindings.conf @@ -144,7 +144,7 @@ DOMInterfaces = { 'nativeType': 'AbstractDocument', 'pointerType': '', 'customTrace': 'trace', - 'needsAbstract': ['title', 'createElement', 'createTextNode'], + 'needsAbstract': ['title', 'createElement', 'createTextNode', 'createComment'], }, 'DOMParser': { diff --git a/src/components/script/dom/bindings/codegen/Document.webidl b/src/components/script/dom/bindings/codegen/Document.webidl index 40bc8b836a3..74670752422 100644 --- a/src/components/script/dom/bindings/codegen/Document.webidl +++ b/src/components/script/dom/bindings/codegen/Document.webidl @@ -48,9 +48,9 @@ interface Document /*: Node*/ { //XXXjdm Requires servo/#623 DocumentFragment createDocumentFragment();*/ [Creator] Text createTextNode(DOMString data); - /*[Creator] + [Creator] Comment createComment(DOMString data); - [Creator, Throws] + /*[Creator, Throws] ProcessingInstruction createProcessingInstruction(DOMString target, DOMString data);*/ /*[Throws] diff --git a/src/components/script/dom/bindings/utils.rs b/src/components/script/dom/bindings/utils.rs index bb374e9cf36..0a49bf4b37c 100644 --- a/src/components/script/dom/bindings/utils.rs +++ b/src/components/script/dom/bindings/utils.rs @@ -106,6 +106,14 @@ pub fn null_str_as_empty_ref<'a>(s: &'a DOMString) -> &'a str { } } +pub fn null_str_as_word_null(s: &DOMString) -> ~str { + // We don't use map_default because it would allocate ~"null" even for Some. + match *s { + Some(ref s) => s.clone(), + None => ~"null" + } +} + fn is_dom_class(clasp: *JSClass) -> bool { unsafe { ((*clasp).flags & js::JSCLASS_IS_DOMJSCLASS) != 0 diff --git a/src/components/script/dom/document.rs b/src/components/script/dom/document.rs index 10aa88d8e73..a8c417b986b 100644 --- a/src/components/script/dom/document.rs +++ b/src/components/script/dom/document.rs @@ -2,10 +2,11 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +use dom::comment::Comment; use dom::bindings::codegen::DocumentBinding; use dom::bindings::utils::{DOMString, Reflector, ErrorResult, Fallible}; use dom::bindings::utils::{BindingObject, Reflectable, DerivedWrapper}; -use dom::bindings::utils::{is_valid_element_name, InvalidCharacter, Traceable, null_str_as_empty}; +use dom::bindings::utils::{is_valid_element_name, InvalidCharacter, Traceable, null_str_as_empty, null_str_as_word_null}; use dom::element::{Element}; use dom::element::{HTMLHtmlElementTypeId, HTMLHeadElementTypeId, HTMLTitleElementTypeId}; use dom::event::Event; @@ -288,6 +289,12 @@ impl Document { unsafe { Node::as_abstract_node(cx, text) } } + pub fn CreateComment(&self, abstract_self: AbstractDocument, data: &DOMString) -> AbstractNode<ScriptView> { + let cx = self.get_cx(); + let comment = @Comment::new(null_str_as_word_null(data), abstract_self); + unsafe { Node::as_abstract_node(cx, comment) } + } + pub fn CreateEvent(&self, _interface: &DOMString) -> Fallible<@mut Event> { fail!("stub") } |