mirror of
https://github.com/servo/servo.git
synced 2025-06-23 16:44:33 +01:00
auto merge of #1036 : Ms2ger/servo/createComment, r=jdm
This commit is contained in:
commit
bc3eeb6f1c
4 changed files with 19 additions and 4 deletions
|
@ -144,7 +144,7 @@ DOMInterfaces = {
|
||||||
'nativeType': 'AbstractDocument',
|
'nativeType': 'AbstractDocument',
|
||||||
'pointerType': '',
|
'pointerType': '',
|
||||||
'customTrace': 'trace',
|
'customTrace': 'trace',
|
||||||
'needsAbstract': ['title', 'createElement', 'createTextNode'],
|
'needsAbstract': ['title', 'createElement', 'createTextNode', 'createComment'],
|
||||||
},
|
},
|
||||||
|
|
||||||
'DOMParser': {
|
'DOMParser': {
|
||||||
|
|
|
@ -48,9 +48,9 @@ interface Document /*: Node*/ { //XXXjdm Requires servo/#623
|
||||||
DocumentFragment createDocumentFragment();*/
|
DocumentFragment createDocumentFragment();*/
|
||||||
[Creator]
|
[Creator]
|
||||||
Text createTextNode(DOMString data);
|
Text createTextNode(DOMString data);
|
||||||
/*[Creator]
|
[Creator]
|
||||||
Comment createComment(DOMString data);
|
Comment createComment(DOMString data);
|
||||||
[Creator, Throws]
|
/*[Creator, Throws]
|
||||||
ProcessingInstruction createProcessingInstruction(DOMString target, DOMString data);*/
|
ProcessingInstruction createProcessingInstruction(DOMString target, DOMString data);*/
|
||||||
|
|
||||||
/*[Throws]
|
/*[Throws]
|
||||||
|
|
|
@ -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 {
|
fn is_dom_class(clasp: *JSClass) -> bool {
|
||||||
unsafe {
|
unsafe {
|
||||||
((*clasp).flags & js::JSCLASS_IS_DOMJSCLASS) != 0
|
((*clasp).flags & js::JSCLASS_IS_DOMJSCLASS) != 0
|
||||||
|
|
|
@ -2,10 +2,11 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
use dom::comment::Comment;
|
||||||
use dom::bindings::codegen::DocumentBinding;
|
use dom::bindings::codegen::DocumentBinding;
|
||||||
use dom::bindings::utils::{DOMString, Reflector, ErrorResult, Fallible};
|
use dom::bindings::utils::{DOMString, Reflector, ErrorResult, Fallible};
|
||||||
use dom::bindings::utils::{BindingObject, Reflectable, DerivedWrapper};
|
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::{Element};
|
||||||
use dom::element::{HTMLHtmlElementTypeId, HTMLHeadElementTypeId, HTMLTitleElementTypeId};
|
use dom::element::{HTMLHtmlElementTypeId, HTMLHeadElementTypeId, HTMLTitleElementTypeId};
|
||||||
use dom::event::Event;
|
use dom::event::Event;
|
||||||
|
@ -288,6 +289,12 @@ impl Document {
|
||||||
unsafe { Node::as_abstract_node(cx, text) }
|
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> {
|
pub fn CreateEvent(&self, _interface: &DOMString) -> Fallible<@mut Event> {
|
||||||
fail!("stub")
|
fail!("stub")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue