Skip to main content

script/dom/html/document_structure/
htmlhtmlelement.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;
8use script_bindings::codegen::GenericBindings::HTMLHtmlElementBinding::HTMLHtmlElementMethods;
9
10use crate::dom::bindings::inheritance::Castable;
11use crate::dom::bindings::root::DomRoot;
12use crate::dom::bindings::str::DOMString;
13use crate::dom::document::Document;
14use crate::dom::html::htmlelement::HTMLElement;
15use crate::dom::node::Node;
16
17#[dom_struct]
18pub(crate) struct HTMLHtmlElement {
19    htmlelement: HTMLElement,
20}
21
22#[expect(non_snake_case)]
23impl HTMLHtmlElement {
24    fn new_inherited(
25        localName: LocalName,
26        prefix: Option<Prefix>,
27        document: &Document,
28    ) -> HTMLHtmlElement {
29        HTMLHtmlElement {
30            htmlelement: HTMLElement::new_inherited(localName, prefix, document),
31        }
32    }
33
34    pub(crate) fn new(
35        cx: &mut js::context::JSContext,
36        local_name: LocalName,
37        prefix: Option<Prefix>,
38        document: &Document,
39        proto: Option<HandleObject>,
40    ) -> DomRoot<HTMLHtmlElement> {
41        let n = Node::reflect_node_with_proto(
42            cx,
43            Box::new(HTMLHtmlElement::new_inherited(local_name, prefix, document)),
44            document,
45            proto,
46        );
47
48        n.upcast::<Node>().set_weird_parser_insertion_mode();
49        n
50    }
51}
52
53impl HTMLHtmlElementMethods<crate::DomTypeHolder> for HTMLHtmlElement {
54    make_getter!(Version, "version");
55    make_setter!(SetVersion, "version");
56}