script/dom/html/
htmllielement.rs1use dom_struct::dom_struct;
6use html5ever::{LocalName, Prefix, local_name};
7use js::rust::HandleObject;
8use style::attr::AttrValue;
9
10use crate::dom::bindings::codegen::Bindings::HTMLLIElementBinding::HTMLLIElementMethods;
11use crate::dom::bindings::inheritance::Castable;
12use crate::dom::bindings::root::DomRoot;
13use crate::dom::bindings::str::DOMString;
14use crate::dom::document::Document;
15use crate::dom::html::htmlelement::HTMLElement;
16use crate::dom::node::Node;
17use crate::dom::virtualmethods::VirtualMethods;
18use crate::script_runtime::CanGc;
19
20#[dom_struct]
21pub(crate) struct HTMLLIElement {
22 htmlelement: HTMLElement,
23}
24
25impl HTMLLIElement {
26 fn new_inherited(
27 local_name: LocalName,
28 prefix: Option<Prefix>,
29 document: &Document,
30 ) -> HTMLLIElement {
31 HTMLLIElement {
32 htmlelement: HTMLElement::new_inherited(local_name, prefix, document),
33 }
34 }
35
36 #[cfg_attr(crown, allow(crown::unrooted_must_root))]
37 pub(crate) fn new(
38 local_name: LocalName,
39 prefix: Option<Prefix>,
40 document: &Document,
41 proto: Option<HandleObject>,
42 can_gc: CanGc,
43 ) -> DomRoot<HTMLLIElement> {
44 Node::reflect_node_with_proto(
45 Box::new(HTMLLIElement::new_inherited(local_name, prefix, document)),
46 document,
47 proto,
48 can_gc,
49 )
50 }
51}
52
53impl HTMLLIElementMethods<crate::DomTypeHolder> for HTMLLIElement {
54 make_int_getter!(Value, "value");
56
57 make_int_setter!(SetValue, "value");
59}
60
61impl VirtualMethods for HTMLLIElement {
62 fn super_type(&self) -> Option<&dyn VirtualMethods> {
63 Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods)
64 }
65
66 fn parse_plain_attribute(&self, name: &LocalName, value: DOMString) -> AttrValue {
67 match name {
68 &local_name!("value") => AttrValue::from_i32(value.into(), 0),
69 _ => self
70 .super_type()
71 .unwrap()
72 .parse_plain_attribute(name, value),
73 }
74 }
75}