script/dom/html/
htmltablecaptionelement.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;
6use html5ever::{LocalName, Prefix};
7use js::rust::HandleObject;
8
9use crate::dom::bindings::inheritance::Castable;
10use crate::dom::bindings::root::DomRoot;
11use crate::dom::document::Document;
12use crate::dom::html::htmlelement::HTMLElement;
13use crate::dom::node::Node;
14use crate::script_runtime::CanGc;
15
16#[dom_struct]
17pub(crate) struct HTMLTableCaptionElement {
18    htmlelement: HTMLElement,
19}
20
21impl HTMLTableCaptionElement {
22    fn new_inherited(
23        local_name: LocalName,
24        prefix: Option<Prefix>,
25        document: &Document,
26    ) -> HTMLTableCaptionElement {
27        HTMLTableCaptionElement {
28            htmlelement: HTMLElement::new_inherited(local_name, prefix, document),
29        }
30    }
31
32    pub(crate) fn new(
33        local_name: LocalName,
34        prefix: Option<Prefix>,
35        document: &Document,
36        proto: Option<HandleObject>,
37        can_gc: CanGc,
38    ) -> DomRoot<HTMLTableCaptionElement> {
39        let n = Node::reflect_node_with_proto(
40            Box::new(HTMLTableCaptionElement::new_inherited(
41                local_name, prefix, document,
42            )),
43            document,
44            proto,
45            can_gc,
46        );
47
48        n.upcast::<Node>().set_weird_parser_insertion_mode();
49        n
50    }
51}