use dom_struct::dom_struct;
use crate::dom::bindings::codegen::Bindings::DocumentTypeBinding::DocumentTypeMethods;
use crate::dom::bindings::codegen::UnionTypes::NodeOrString;
use crate::dom::bindings::error::ErrorResult;
use crate::dom::bindings::inheritance::Castable;
use crate::dom::bindings::root::DomRoot;
use crate::dom::bindings::str::DOMString;
use crate::dom::document::Document;
use crate::dom::node::Node;
use crate::script_runtime::CanGc;
#[dom_struct]
pub struct DocumentType {
node: Node,
name: DOMString,
public_id: DOMString,
system_id: DOMString,
}
impl DocumentType {
fn new_inherited(
name: DOMString,
public_id: Option<DOMString>,
system_id: Option<DOMString>,
document: &Document,
) -> DocumentType {
DocumentType {
node: Node::new_inherited(document),
name,
public_id: public_id.unwrap_or_default(),
system_id: system_id.unwrap_or_default(),
}
}
#[allow(crown::unrooted_must_root)]
pub fn new(
name: DOMString,
public_id: Option<DOMString>,
system_id: Option<DOMString>,
document: &Document,
can_gc: CanGc,
) -> DomRoot<DocumentType> {
Node::reflect_node(
Box::new(DocumentType::new_inherited(
name, public_id, system_id, document,
)),
document,
can_gc,
)
}
#[inline]
pub fn name(&self) -> &DOMString {
&self.name
}
#[inline]
pub fn public_id(&self) -> &DOMString {
&self.public_id
}
#[inline]
pub fn system_id(&self) -> &DOMString {
&self.system_id
}
}
impl DocumentTypeMethods for DocumentType {
fn Name(&self) -> DOMString {
self.name.clone()
}
fn PublicId(&self) -> DOMString {
self.public_id.clone()
}
fn SystemId(&self) -> DOMString {
self.system_id.clone()
}
fn Before(&self, nodes: Vec<NodeOrString>, can_gc: CanGc) -> ErrorResult {
self.upcast::<Node>().before(nodes, can_gc)
}
fn After(&self, nodes: Vec<NodeOrString>, can_gc: CanGc) -> ErrorResult {
self.upcast::<Node>().after(nodes, can_gc)
}
fn ReplaceWith(&self, nodes: Vec<NodeOrString>, can_gc: CanGc) -> ErrorResult {
self.upcast::<Node>().replace_with(nodes, can_gc)
}
fn Remove(&self) {
self.upcast::<Node>().remove_self();
}
}