Skip to main content

script/dom/svg/
svgstopelement.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 stylo_dom::ElementState;
9
10use crate::dom::bindings::inheritance::Castable;
11use crate::dom::bindings::root::DomRoot;
12use crate::dom::document::Document;
13use crate::dom::node::Node;
14use crate::dom::node::virtualmethods::VirtualMethods;
15use crate::dom::svg::svgelement::SVGElement;
16
17#[dom_struct]
18pub(crate) struct SVGStopElement {
19    svgelement: SVGElement,
20}
21
22impl SVGStopElement {
23    fn new_inherited(
24        local_name: LocalName,
25        prefix: Option<Prefix>,
26        document: &Document,
27    ) -> SVGStopElement {
28        SVGStopElement {
29            svgelement: SVGElement::new_inherited_with_state(
30                ElementState::empty(),
31                local_name,
32                prefix,
33                document,
34            ),
35        }
36    }
37
38    pub(crate) fn new(
39        cx: &mut js::context::JSContext,
40        local_name: LocalName,
41        prefix: Option<Prefix>,
42        document: &Document,
43        proto: Option<HandleObject>,
44    ) -> DomRoot<SVGStopElement> {
45        Node::reflect_node_with_proto(
46            cx,
47            Box::new(SVGStopElement::new_inherited(local_name, prefix, document)),
48            document,
49            proto,
50        )
51    }
52}
53
54impl VirtualMethods for SVGStopElement {
55    fn super_type(&self) -> Option<&dyn VirtualMethods> {
56        Some(self.upcast::<SVGElement>() as &dyn VirtualMethods)
57    }
58}