Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -216,14 +216,14 @@ rustls-pki-types = "1.14"
rustls-platform-verifier = "0.7.0"
sea-query = { version = "1.0.1", default-features = false, features = ["backend-sqlite", "derive"] }
sea-query-rusqlite = "0.8.0"
selectors = { git = "https://github.com/servo/stylo", rev = "a64923b5d5c67313c81c5056f5e30ec0babb04d6" }
selectors = { git = "https://github.com/servo/stylo", rev = "5173fcd4455b99cc42777f81715a1bd68ed5b32c" }
seq-macro = "0.3.6"
serde = "1.0.228"
serde_bytes = "0.11"
serde_core = "1.0.226"
serde_json = "1.0"
serde_test = "1.0"
servo_arc = { git = "https://github.com/servo/stylo", rev = "a64923b5d5c67313c81c5056f5e30ec0babb04d6" }
servo_arc = { git = "https://github.com/servo/stylo", rev = "5173fcd4455b99cc42777f81715a1bd68ed5b32c" }
sha1 = "0.11"
sha2 = "0.11"
sha3 = "0.12"
Expand All @@ -233,12 +233,12 @@ smallvec = { version = "1.15", features = ["serde", "union"] }
speexdsp-resampler = "0.1.0"
string_cache = "0.9"
strum = { version = "0.28", features = ["derive"] }
stylo = { git = "https://github.com/servo/stylo", rev = "a64923b5d5c67313c81c5056f5e30ec0babb04d6" }
stylo_atoms = { git = "https://github.com/servo/stylo", rev = "a64923b5d5c67313c81c5056f5e30ec0babb04d6" }
stylo_dom = { git = "https://github.com/servo/stylo", rev = "a64923b5d5c67313c81c5056f5e30ec0babb04d6" }
stylo_malloc_size_of = { git = "https://github.com/servo/stylo", rev = "a64923b5d5c67313c81c5056f5e30ec0babb04d6" }
stylo_static_prefs = { git = "https://github.com/servo/stylo", rev = "a64923b5d5c67313c81c5056f5e30ec0babb04d6" }
stylo_traits = { git = "https://github.com/servo/stylo", rev = "a64923b5d5c67313c81c5056f5e30ec0babb04d6" }
stylo = { git = "https://github.com/servo/stylo", rev = "5173fcd4455b99cc42777f81715a1bd68ed5b32c" }
stylo_atoms = { git = "https://github.com/servo/stylo", rev = "5173fcd4455b99cc42777f81715a1bd68ed5b32c" }
stylo_dom = { git = "https://github.com/servo/stylo", rev = "5173fcd4455b99cc42777f81715a1bd68ed5b32c" }
stylo_malloc_size_of = { git = "https://github.com/servo/stylo", rev = "5173fcd4455b99cc42777f81715a1bd68ed5b32c" }
stylo_static_prefs = { git = "https://github.com/servo/stylo", rev = "5173fcd4455b99cc42777f81715a1bd68ed5b32c" }
stylo_traits = { git = "https://github.com/servo/stylo", rev = "5173fcd4455b99cc42777f81715a1bd68ed5b32c" }
surfman = { version = "0.13.0", features = ["chains"] }
swapper = "0.1"
syn = { version = "2", default-features = false, features = ["clone-impls", "derive", "parsing"] }
Expand Down
28 changes: 28 additions & 0 deletions components/script/dom/element/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,23 @@ use crate::dom::html::htmlunknownelement::HTMLUnknownElement;
use crate::dom::html::htmlvideoelement::HTMLVideoElement;
use crate::dom::html::input_element::HTMLInputElement;
use crate::dom::htmlmarqueeelement::HTMLMarqueeElement;
use crate::dom::svg::svgcircleelement::SVGCircleElement;
use crate::dom::svg::svgdefselement::SVGDefsElement;
use crate::dom::svg::svgelement::SVGElement;
use crate::dom::svg::svgellipseelement::SVGEllipseElement;
use crate::dom::svg::svggelement::SVGGElement;
use crate::dom::svg::svgimageelement::SVGImageElement;
use crate::dom::svg::svglineargradientelement::SVGLinearGradientElement;
use crate::dom::svg::svglineelement::SVGLineElement;
use crate::dom::svg::svgpathelement::SVGPathElement;
use crate::dom::svg::svgpolygonelement::SVGPolygonElement;
use crate::dom::svg::svgpolylineelement::SVGPolylineElement;
use crate::dom::svg::svgradialgradientelement::SVGRadialGradientElement;
use crate::dom::svg::svgrectelement::SVGRectElement;
use crate::dom::svg::svgstopelement::SVGStopElement;
use crate::dom::svg::svgsvgelement::SVGSVGElement;
use crate::dom::svg::svgsymbolelement::SVGSymbolElement;
use crate::dom::svg::svguseelement::SVGUseElement;
use crate::realms::enter_auto_realm;
use crate::script_thread::ScriptThread;

Expand All @@ -109,8 +123,22 @@ fn create_svg_element(
);

match name.local {
local_name!("circle") => make!(SVGCircleElement),
local_name!("defs") => make!(SVGDefsElement),
local_name!("ellipse") => make!(SVGEllipseElement),
local_name!("g") => make!(SVGGElement),
local_name!("image") => make!(SVGImageElement),
local_name!("line") => make!(SVGLineElement),
local_name!("linearGradient") => make!(SVGLinearGradientElement),
local_name!("path") => make!(SVGPathElement),
local_name!("polygon") => make!(SVGPolygonElement),
local_name!("polyline") => make!(SVGPolylineElement),
local_name!("radialGradient") => make!(SVGRadialGradientElement),
local_name!("stop") => make!(SVGStopElement),
local_name!("rect") => make!(SVGRectElement),
local_name!("svg") => make!(SVGSVGElement),
local_name!("symbol") => make!(SVGSymbolElement),
local_name!("use") => make!(SVGUseElement),
_ => make!(SVGElement),
}
}
Expand Down
67 changes: 66 additions & 1 deletion components/script/dom/node/virtualmethods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ use style::attr::AttrValue;

use crate::dom::bindings::inheritance::{
Castable, DocumentFragmentTypeId, ElementTypeId, HTMLElementTypeId, HTMLMediaElementTypeId,
NodeTypeId, SVGElementTypeId, SVGGraphicsElementTypeId,
NodeTypeId, SVGElementTypeId, SVGGeometryElementTypeId, SVGGradientElementTypeId,
SVGGraphicsElementTypeId,
};
use crate::dom::bindings::str::DOMString;
use crate::dom::document::Document;
Expand Down Expand Up @@ -66,9 +67,23 @@ use crate::dom::node::{
BindContext, ChildrenMutation, CloneChildrenFlag, MoveContext, Node, UnbindContext,
};
use crate::dom::shadowroot::ShadowRoot;
use crate::dom::svg::svgcircleelement::SVGCircleElement;
use crate::dom::svg::svgdefselement::SVGDefsElement;
use crate::dom::svg::svgelement::SVGElement;
use crate::dom::svg::svgellipseelement::SVGEllipseElement;
use crate::dom::svg::svggelement::SVGGElement;
use crate::dom::svg::svgimageelement::SVGImageElement;
use crate::dom::svg::svglineargradientelement::SVGLinearGradientElement;
use crate::dom::svg::svglineelement::SVGLineElement;
use crate::dom::svg::svgpathelement::SVGPathElement;
use crate::dom::svg::svgpolygonelement::SVGPolygonElement;
use crate::dom::svg::svgpolylineelement::SVGPolylineElement;
use crate::dom::svg::svgradialgradientelement::SVGRadialGradientElement;
use crate::dom::svg::svgrectelement::SVGRectElement;
use crate::dom::svg::svgstopelement::SVGStopElement;
use crate::dom::svg::svgsvgelement::SVGSVGElement;
use crate::dom::svg::svgsymbolelement::SVGSymbolElement;
use crate::dom::svg::svguseelement::SVGUseElement;

/// Trait to allow DOM nodes to opt-in to overriding (or adding to) common
/// behaviours. Replicates the effect of C++ virtual methods.
Expand Down Expand Up @@ -338,12 +353,62 @@ pub(crate) fn vtable_for(node: &Node) -> &dyn VirtualMethods {
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLTrackElement)) => {
node.downcast::<HTMLTrackElement>().unwrap() as &dyn VirtualMethods
},
NodeTypeId::Element(ElementTypeId::SVGElement(SVGElementTypeId::SVGGraphicsElement(
SVGGraphicsElementTypeId::SVGGeometryElement(
SVGGeometryElementTypeId::SVGCircleElement,
),
))) => node.downcast::<SVGCircleElement>().unwrap() as &dyn VirtualMethods,
NodeTypeId::Element(ElementTypeId::SVGElement(SVGElementTypeId::SVGGraphicsElement(
SVGGraphicsElementTypeId::SVGGeometryElement(
SVGGeometryElementTypeId::SVGEllipseElement,
),
))) => node.downcast::<SVGEllipseElement>().unwrap() as &dyn VirtualMethods,
NodeTypeId::Element(ElementTypeId::SVGElement(SVGElementTypeId::SVGGraphicsElement(
SVGGraphicsElementTypeId::SVGImageElement,
))) => node.downcast::<SVGImageElement>().unwrap() as &dyn VirtualMethods,
NodeTypeId::Element(ElementTypeId::SVGElement(SVGElementTypeId::SVGGraphicsElement(
SVGGraphicsElementTypeId::SVGGeometryElement(SVGGeometryElementTypeId::SVGRectElement),
))) => node.downcast::<SVGRectElement>().unwrap() as &dyn VirtualMethods,
NodeTypeId::Element(ElementTypeId::SVGElement(SVGElementTypeId::SVGGraphicsElement(
SVGGraphicsElementTypeId::SVGGeometryElement(SVGGeometryElementTypeId::SVGLineElement),
))) => node.downcast::<SVGLineElement>().unwrap() as &dyn VirtualMethods,
NodeTypeId::Element(ElementTypeId::SVGElement(SVGElementTypeId::SVGGraphicsElement(
SVGGraphicsElementTypeId::SVGGeometryElement(
SVGGeometryElementTypeId::SVGPolylineElement,
),
))) => node.downcast::<SVGPolylineElement>().unwrap() as &dyn VirtualMethods,
NodeTypeId::Element(ElementTypeId::SVGElement(SVGElementTypeId::SVGGraphicsElement(
SVGGraphicsElementTypeId::SVGGeometryElement(
SVGGeometryElementTypeId::SVGPolygonElement,
),
))) => node.downcast::<SVGPolygonElement>().unwrap() as &dyn VirtualMethods,
NodeTypeId::Element(ElementTypeId::SVGElement(SVGElementTypeId::SVGGraphicsElement(
SVGGraphicsElementTypeId::SVGGeometryElement(SVGGeometryElementTypeId::SVGPathElement),
))) => node.downcast::<SVGPathElement>().unwrap() as &dyn VirtualMethods,
NodeTypeId::Element(ElementTypeId::SVGElement(SVGElementTypeId::SVGGraphicsElement(
SVGGraphicsElementTypeId::SVGSVGElement,
))) => node.downcast::<SVGSVGElement>().unwrap() as &dyn VirtualMethods,
NodeTypeId::Element(ElementTypeId::SVGElement(SVGElementTypeId::SVGGraphicsElement(
SVGGraphicsElementTypeId::SVGGElement,
))) => node.downcast::<SVGGElement>().unwrap() as &dyn VirtualMethods,
NodeTypeId::Element(ElementTypeId::SVGElement(SVGElementTypeId::SVGGraphicsElement(
SVGGraphicsElementTypeId::SVGUseElement,
))) => node.downcast::<SVGUseElement>().unwrap() as &dyn VirtualMethods,
NodeTypeId::Element(ElementTypeId::SVGElement(SVGElementTypeId::SVGGraphicsElement(
SVGGraphicsElementTypeId::SVGSymbolElement,
))) => node.downcast::<SVGSymbolElement>().unwrap() as &dyn VirtualMethods,
NodeTypeId::Element(ElementTypeId::SVGElement(SVGElementTypeId::SVGGraphicsElement(
SVGGraphicsElementTypeId::SVGDefsElement,
))) => node.downcast::<SVGDefsElement>().unwrap() as &dyn VirtualMethods,
NodeTypeId::Element(ElementTypeId::SVGElement(SVGElementTypeId::SVGGradientElement(
SVGGradientElementTypeId::SVGLinearGradientElement,
))) => node.downcast::<SVGLinearGradientElement>().unwrap() as &dyn VirtualMethods,
NodeTypeId::Element(ElementTypeId::SVGElement(SVGElementTypeId::SVGGradientElement(
SVGGradientElementTypeId::SVGRadialGradientElement,
))) => node.downcast::<SVGRadialGradientElement>().unwrap() as &dyn VirtualMethods,
NodeTypeId::Element(ElementTypeId::SVGElement(SVGElementTypeId::SVGStopElement)) => {
node.downcast::<SVGStopElement>().unwrap() as &dyn VirtualMethods
},
NodeTypeId::Element(ElementTypeId::SVGElement(SVGElementTypeId::SVGElement)) => {
node.downcast::<SVGElement>().unwrap() as &dyn VirtualMethods
},
Expand Down
16 changes: 16 additions & 0 deletions components/script/dom/svg/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,23 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */

pub(crate) mod svgcircleelement;
pub(crate) mod svgdefselement;
pub(crate) mod svgelement;
pub(crate) mod svgellipseelement;
pub(crate) mod svggelement;
pub(crate) mod svggeometryelement;
pub(crate) mod svggradientelement;
pub(crate) mod svggraphicselement;
pub(crate) mod svgimageelement;
pub(crate) mod svglineargradientelement;
pub(crate) mod svglineelement;
pub(crate) mod svgpathelement;
pub(crate) mod svgpolygonelement;
pub(crate) mod svgpolylineelement;
pub(crate) mod svgradialgradientelement;
pub(crate) mod svgrectelement;
pub(crate) mod svgstopelement;
pub(crate) mod svgsvgelement;
pub(crate) mod svgsymbolelement;
pub(crate) mod svguseelement;
54 changes: 54 additions & 0 deletions components/script/dom/svg/svgcircleelement.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */

use dom_struct::dom_struct;
use html5ever::{LocalName, Prefix};
use js::rust::HandleObject;

use crate::dom::bindings::inheritance::Castable;
use crate::dom::bindings::root::DomRoot;
use crate::dom::document::Document;
use crate::dom::node::Node;
use crate::dom::node::virtualmethods::VirtualMethods;
use crate::dom::svg::svggeometryelement::SVGGeometryElement;

#[dom_struct]
pub(crate) struct SVGCircleElement {
svggeometryelement: SVGGeometryElement,
}

impl SVGCircleElement {
fn new_inherited(
local_name: LocalName,
prefix: Option<Prefix>,
document: &Document,
) -> SVGCircleElement {
SVGCircleElement {
svggeometryelement: SVGGeometryElement::new_inherited(local_name, prefix, document),
}
}

pub(crate) fn new(
cx: &mut js::context::JSContext,
local_name: LocalName,
prefix: Option<Prefix>,
document: &Document,
proto: Option<HandleObject>,
) -> DomRoot<SVGCircleElement> {
Node::reflect_node_with_proto(
cx,
Box::new(SVGCircleElement::new_inherited(
local_name, prefix, document,
)),
document,
proto,
)
}
}

impl VirtualMethods for SVGCircleElement {
fn super_type(&self) -> Option<&dyn VirtualMethods> {
Some(self.upcast::<SVGGeometryElement>() as &dyn VirtualMethods)
}
}
Loading
Loading