script/dom/html/
htmlmenuelement.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::codegen::Bindings::HTMLMenuElementBinding::HTMLMenuElementMethods;
10use crate::dom::bindings::root::DomRoot;
11use crate::dom::document::Document;
12use crate::dom::html::htmlelement::HTMLElement;
13use crate::dom::node::Node;
14
15#[dom_struct]
16pub(crate) struct HTMLMenuElement {
17    htmlelement: HTMLElement,
18}
19
20impl HTMLMenuElement {
21    fn new_inherited(
22        local_name: LocalName,
23        prefix: Option<Prefix>,
24        document: &Document,
25    ) -> HTMLMenuElement {
26        HTMLMenuElement {
27            htmlelement: HTMLElement::new_inherited(local_name, prefix, document),
28        }
29    }
30
31    pub(crate) fn new(
32        cx: &mut js::context::JSContext,
33        local_name: LocalName,
34        prefix: Option<Prefix>,
35        document: &Document,
36        proto: Option<HandleObject>,
37    ) -> DomRoot<HTMLMenuElement> {
38        Node::reflect_node_with_proto(
39            cx,
40            Box::new(HTMLMenuElement::new_inherited(local_name, prefix, document)),
41            document,
42            proto,
43        )
44    }
45}
46
47impl HTMLMenuElementMethods<crate::DomTypeHolder> for HTMLMenuElement {
48    // spec just mandates that compact reflects the content attribute,
49    // with no other semantics. Layout could use it to
50    // change line spacing, but nothing requires it to do so.
51
52    // https://html.spec.whatwg.org/multipage/#dom-menu-compact
53    make_bool_setter!(SetCompact, "compact");
54
55    // https://html.spec.whatwg.org/multipage/#dom-menu-compact
56    make_bool_getter!(Compact, "compact");
57}