Skip to main content

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