1use dom_struct::dom_struct;
6use js::rust::HandleObject;
7
8use crate::dom::bindings::codegen::Bindings::CommentBinding::CommentMethods;
9use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
10use crate::dom::bindings::error::Fallible;
11use crate::dom::bindings::root::DomRoot;
12use crate::dom::bindings::str::DOMString;
13use crate::dom::characterdata::CharacterData;
14use crate::dom::document::Document;
15use crate::dom::node::Node;
16use crate::dom::window::Window;
17
18#[dom_struct]
20pub(crate) struct Comment {
21 characterdata: CharacterData,
22}
23
24impl Comment {
25 fn new_inherited(text: DOMString, document: &Document) -> Comment {
26 Comment {
27 characterdata: CharacterData::new_inherited(text, document),
28 }
29 }
30
31 pub(crate) fn new(
32 cx: &mut js::context::JSContext,
33 text: DOMString,
34 document: &Document,
35 proto: Option<HandleObject>,
36 ) -> DomRoot<Comment> {
37 Node::reflect_node_with_proto(
38 cx,
39 Box::new(Comment::new_inherited(text, document)),
40 document,
41 proto,
42 )
43 }
44}
45
46impl CommentMethods<crate::DomTypeHolder> for Comment {
47 fn Constructor(
49 cx: &mut js::context::JSContext,
50 window: &Window,
51 proto: Option<HandleObject>,
52 data: DOMString,
53 ) -> Fallible<DomRoot<Comment>> {
54 let document = window.Document();
55 Ok(Comment::new(cx, data, &document, proto))
56 }
57}