aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/script/dom/comment.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/script/dom/comment.rs')
-rw-r--r--src/components/script/dom/comment.rs29
1 files changed, 21 insertions, 8 deletions
diff --git a/src/components/script/dom/comment.rs b/src/components/script/dom/comment.rs
index a94c7bb2970..5dcfde7b418 100644
--- a/src/components/script/dom/comment.rs
+++ b/src/components/script/dom/comment.rs
@@ -2,32 +2,45 @@
* 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::bindings::codegen::InheritTypes::CommentDerived;
use dom::bindings::codegen::CommentBinding;
+use dom::bindings::js::JS;
use dom::bindings::utils::Fallible;
use dom::characterdata::CharacterData;
-use dom::document::AbstractDocument;
-use dom::node::{AbstractNode, CommentNodeTypeId, Node};
+use dom::document::Document;
+use dom::eventtarget::{EventTarget, NodeTargetTypeId};
+use dom::node::{CommentNodeTypeId, Node};
use dom::window::Window;
use servo_util::str::DOMString;
/// An HTML comment.
+#[deriving(Encodable)]
pub struct Comment {
characterdata: CharacterData,
}
+impl CommentDerived for EventTarget {
+ fn is_comment(&self) -> bool {
+ match self.type_id {
+ NodeTargetTypeId(CommentNodeTypeId) => true,
+ _ => false
+ }
+ }
+}
+
impl Comment {
- pub fn new_inherited(text: DOMString, document: AbstractDocument) -> Comment {
+ pub fn new_inherited(text: DOMString, document: JS<Document>) -> Comment {
Comment {
characterdata: CharacterData::new_inherited(CommentNodeTypeId, text, document)
}
}
- pub fn new(text: DOMString, document: AbstractDocument) -> AbstractNode {
- let node = Comment::new_inherited(text, document);
- Node::reflect_node(@mut node, document, CommentBinding::Wrap)
+ pub fn new(text: DOMString, document: &JS<Document>) -> JS<Comment> {
+ let node = Comment::new_inherited(text, document.clone());
+ Node::reflect_node(~node, document, CommentBinding::Wrap)
}
- pub fn Constructor(owner: @mut Window, data: DOMString) -> Fallible<AbstractNode> {
- Ok(Comment::new(data, owner.Document()))
+ pub fn Constructor(owner: &JS<Window>, data: DOMString) -> Fallible<JS<Comment>> {
+ Ok(Comment::new(data, &owner.get().Document()))
}
}