aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/script/dom/comment.rs
diff options
context:
space:
mode:
authorSankha Narayan Guria <sankha93@gmail.com>2014-02-27 03:31:05 +0530
committerSankha Narayan Guria <sankha93@gmail.com>2014-02-27 03:31:05 +0530
commit1e9fec9172364346937f375e315e1ce745662611 (patch)
treea55173568e6dd6a8b4cb4dfcc42ed81204d49874 /src/components/script/dom/comment.rs
parent47e6e6ec8f2dfbd56e50f9f2ec2762b85087d948 (diff)
parentda16e54243e256dee927f720ce6b9903b62ec14e (diff)
downloadservo-1e9fec9172364346937f375e315e1ce745662611.tar.gz
servo-1e9fec9172364346937f375e315e1ce745662611.zip
Merge master into this branch
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()))
}
}