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;
18
19#[dom_struct]
20pub(crate) struct HTMLLIElement {
21 htmlelement: HTMLElement,
22}
23
24impl HTMLLIElement {
25 fn new_inherited(
26 local_name: LocalName,
27 prefix: Option<Prefix>,
28 document: &Document,
29 ) -> HTMLLIElement {
30 HTMLLIElement {
31 htmlelement: HTMLElement::new_inherited(local_name, prefix, document),
32 }
33 }
34
35 pub(crate) fn new(
36 cx: &mut js::context::JSContext,
37 local_name: LocalName,
38 prefix: Option<Prefix>,
39 document: &Document,
40 proto: Option<HandleObject>,
41 ) -> DomRoot<HTMLLIElement> {
42 Node::reflect_node_with_proto(
43 cx,
44 Box::new(HTMLLIElement::new_inherited(local_name, prefix, document)),
45 document,
46 proto,
47 )
48 }
49}
50
51impl HTMLLIElementMethods<crate::DomTypeHolder> for HTMLLIElement {
52 make_int_getter!(Value, "value");
54
55 make_int_setter!(SetValue, "value");
57}
58
59impl VirtualMethods for HTMLLIElement {
60 fn super_type(&self) -> Option<&dyn VirtualMethods> {
61 Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods)
62 }
63
64 fn parse_plain_attribute(&self, name: &LocalName, value: DOMString) -> AttrValue {
65 match name {
66 &local_name!("value") => AttrValue::from_i32(value.into(), 0),
67 _ => self
68 .super_type()
69 .unwrap()
70 .parse_plain_attribute(name, value),
71 }
72 }
73}