script/dom/
cdatasection.rs

1/* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4
5use dom_struct::dom_struct;
6
7use crate::dom::bindings::root::DomRoot;
8use crate::dom::bindings::str::DOMString;
9use crate::dom::document::Document;
10use crate::dom::node::Node;
11use crate::dom::text::Text;
12
13#[dom_struct]
14pub(crate) struct CDATASection {
15    text: Text,
16}
17
18impl CDATASection {
19    fn new_inherited(text: DOMString, document: &Document) -> CDATASection {
20        CDATASection {
21            text: Text::new_inherited(text, document),
22        }
23    }
24
25    pub(crate) fn new(
26        cx: &mut js::context::JSContext,
27        text: DOMString,
28        document: &Document,
29    ) -> DomRoot<CDATASection> {
30        Node::reflect_node(
31            cx,
32            Box::new(CDATASection::new_inherited(text, document)),
33            document,
34        )
35    }
36}