Best headless browser for AI agents. Lite, Fast, High-Compatibility. Built in Rust
Rust ai-agentsai-toolsbrowserbrowser-automationcloud-browserheadlessheadless-browserkitesurfplaywrightpuppeteerrustservoweb-crawlerweb-crawlingweb-scraperweb-scraping
fix(svg): expose geometry element interfaces
ldm0e37ecb245c3a
diff --git a/moli-dom/src/native/element/interface_names.rs b/moli-dom/src/native/element/interface_names.rsindex 51c31850a..e33c7841e 100644--- a/moli-dom/src/native/element/interface_names.rs+++ b/moli-dom/src/native/element/interface_names.rs@@ -95,6 +95,7 @@ pub fn svg_element_interface_name(local_name: &str) -> &'static str {"defs" => "SVGDefsElement","desc" => "SVGDescElement","ellipse" => "SVGEllipseElement",+ "foreignObject" => "SVGForeignObjectElement","g" => "SVGGElement","image" => "SVGImageElement","line" => "SVGLineElement",@@ -112,6 +113,7 @@ pub fn svg_element_interface_name(local_name: &str) -> &'static str {"symbol" => "SVGSymbolElement","text" => "SVGTextElement","title" => "SVGTitleElement",+ "tspan" => "SVGTSpanElement","use" => "SVGUseElement",_ => "SVGElement",}diff --git a/moli-dom/src/native/element/tests.rs b/moli-dom/src/native/element/tests.rsindex 9a773a98a..170eeedc5 100644--- a/moli-dom/src/native/element/tests.rs+++ b/moli-dom/src/native/element/tests.rs@@ -183,6 +183,10 @@ fn svg_element_interface_name_specializes_standard_elements() {assert_eq!(svg_element_interface_name("defs"), "SVGDefsElement");assert_eq!(svg_element_interface_name("desc"), "SVGDescElement");assert_eq!(svg_element_interface_name("ellipse"), "SVGEllipseElement");+ assert_eq!(+ svg_element_interface_name("foreignObject"),+ "SVGForeignObjectElement"+ );assert_eq!(svg_element_interface_name("g"), "SVGGElement");assert_eq!(svg_element_interface_name("image"), "SVGImageElement");assert_eq!(svg_element_interface_name("line"), "SVGLineElement");@@ -205,6 +209,7 @@ fn svg_element_interface_name_specializes_standard_elements() {assert_eq!(svg_element_interface_name("symbol"), "SVGSymbolElement");assert_eq!(svg_element_interface_name("text"), "SVGTextElement");assert_eq!(svg_element_interface_name("title"), "SVGTitleElement");+ assert_eq!(svg_element_interface_name("tspan"), "SVGTSpanElement");assert_eq!(svg_element_interface_name("use"), "SVGUseElement");assert_eq!(svg_element_interface_name("style"), "SVGStyleElement");assert_eq!(svg_element_interface_name("custom"), "SVGElement");diff --git a/moli-renderer-v8/src/context_bootstrap/bridge_descriptor/descriptors.rs b/moli-renderer-v8/src/context_bootstrap/bridge_descriptor/descriptors.rsindex 803d22b54..b5fb567ef 100644--- a/moli-renderer-v8/src/context_bootstrap/bridge_descriptor/descriptors.rs+++ b/moli-renderer-v8/src/context_bootstrap/bridge_descriptor/descriptors.rs@@ -122,6 +122,11 @@ const NODE_BRIDGE_DESCRIPTORS: &[BridgeDescriptor] = &[SpecializedTemplateInstaller::None,SVG_GEOMETRY_RUNTIME_INSTALL_GROUPS,),+ descriptor(+ "SVGForeignObjectElement",+ Some("SVGGraphicsElement"),+ ELEMENT_GROUPS,+ ),descriptor("SVGGElement", Some("SVGGraphicsElement"), ELEMENT_GROUPS),descriptor("SVGImageElement",@@ -228,6 +233,19 @@ const NODE_BRIDGE_DESCRIPTORS: &[BridgeDescriptor] = &[svg_gradient_transform: false,},),+ specialized_descriptor(+ "SVGTSpanElement",+ Some("SVGTextPositioningElement"),+ ELEMENT_GROUPS,+ SpecializedTemplateInstaller::None,+ RuntimeInstallGroups {+ svg_geometry_path_length: false,+ svg_rect_animated_lengths: false,+ svg_text_positioning_lists: true,+ svg_pattern_transform: false,+ svg_gradient_transform: false,+ },+ ),descriptor("SVGTitleElement", Some("SVGElement"), ELEMENT_GROUPS),descriptor("SVGUseElement", Some("SVGGraphicsElement"), ELEMENT_GROUPS),specialized_descriptor(diff --git a/moli-renderer-v8/src/context_bootstrap/svg_runtime/bindings.rs b/moli-renderer-v8/src/context_bootstrap/svg_runtime/bindings.rsindex 428a6ebb6..cdca687bd 100644--- a/moli-renderer-v8/src/context_bootstrap/svg_runtime/bindings.rs+++ b/moli-renderer-v8/src/context_bootstrap/svg_runtime/bindings.rs@@ -808,6 +808,67 @@ struct SvgRectElementPrototypeAccessorsDeclaration {ry: (),}+#[derive(WebApiFunctionTemplate)]+#[webapi(name = "SVGCircleElement", enumerable)]+struct SvgCircleElementPrototypeAccessorsDeclaration {+ #[webapi(accessor_property = "cx", getter = svg_circle_animated_length_getter, data = callback_data_index_value(scope, 0))]+ cx: (),++ #[webapi(accessor_property = "cy", getter = svg_circle_animated_length_getter, data = callback_data_index_value(scope, 1))]+ cy: (),++ #[webapi(accessor_property = "r", getter = svg_circle_animated_length_getter, data = callback_data_index_value(scope, 2))]+ r: (),+}++#[derive(WebApiFunctionTemplate)]+#[webapi(name = "SVGEllipseElement", enumerable)]+struct SvgEllipseElementPrototypeAccessorsDeclaration {+ #[webapi(accessor_property = "cx", getter = svg_ellipse_animated_length_getter, data = callback_data_index_value(scope, 0))]+ cx: (),++ #[webapi(accessor_property = "cy", getter = svg_ellipse_animated_length_getter, data = callback_data_index_value(scope, 1))]+ cy: (),++ #[webapi(accessor_property = "rx", getter = svg_ellipse_animated_length_getter, data = callback_data_index_value(scope, 2))]+ rx: (),++ #[webapi(accessor_property = "ry", getter = svg_ellipse_animated_length_getter, data = callback_data_index_value(scope, 3))]+ ry: (),+}++#[derive(WebApiFunctionTemplate)]+#[webapi(name = "SVGLineElement", enumerable)]+struct SvgLineElementPrototypeAccessorsDeclaration {+ #[webapi(accessor_property = "x1", getter = svg_line_animated_length_getter, data = callback_data_index_value(scope, 0))]+ x1: (),++ #[webapi(accessor_property = "y1", getter = svg_line_animated_length_getter, data = callback_data_index_value(scope, 1))]+ y1: (),++ #[webapi(accessor_property = "x2", getter = svg_line_animated_length_getter, data = callback_data_index_value(scope, 2))]+ x2: (),++ #[webapi(accessor_property = "y2", getter = svg_line_animated_length_getter, data = callback_data_index_value(scope, 3))]+ y2: (),+}++#[derive(WebApiFunctionTemplate)]+#[webapi(name = "SVGGraphicsBoxElement", enumerable)]+struct SvgGraphicsBoxElementPrototypeAccessorsDeclaration {+ #[webapi(accessor_property = "x", getter = svg_box_animated_length_getter, data = callback_data_index_value(scope, 0))]+ x: (),++ #[webapi(accessor_property = "y", getter = svg_box_animated_length_getter, data = callback_data_index_value(scope, 1))]+ y: (),++ #[webapi(accessor_property = "width", getter = svg_box_animated_length_getter, data = callback_data_index_value(scope, 2))]+ width: (),++ #[webapi(accessor_property = "height", getter = svg_box_animated_length_getter, data = callback_data_index_value(scope, 3))]+ height: (),+}+pub(super) fn install_svg_length_bindings<'s>(scope: &mut v8::PinScope<'s, '_, ()>,template: v8::Local<'s, v8::FunctionTemplate>,@@ -1011,6 +1072,26 @@ pub(super) fn install_svg_element_accessor_bindings<'s>(scope, prototype,);}+ "SVGCircleElement" => {+ SvgCircleElementPrototypeAccessorsDeclaration::initialize_prototype_template(+ scope, prototype,+ );+ }+ "SVGEllipseElement" => {+ SvgEllipseElementPrototypeAccessorsDeclaration::initialize_prototype_template(+ scope, prototype,+ );+ }+ "SVGLineElement" => {+ SvgLineElementPrototypeAccessorsDeclaration::initialize_prototype_template(+ scope, prototype,+ );+ }+ "SVGImageElement" | "SVGUseElement" | "SVGForeignObjectElement" => {+ SvgGraphicsBoxElementPrototypeAccessorsDeclaration::initialize_prototype_template(+ scope, prototype,+ );+ }_ => {}}}diff --git a/moli-renderer-v8/src/context_bootstrap/svg_runtime/builders.rs b/moli-renderer-v8/src/context_bootstrap/svg_runtime/builders.rsindex 497b5480f..20158bce5 100644--- a/moli-renderer-v8/src/context_bootstrap/svg_runtime/builders.rs+++ b/moli-renderer-v8/src/context_bootstrap/svg_runtime/builders.rs@@ -1288,15 +1288,22 @@ pub(super) fn svg_matrix_default(slot: &str) -> f64 {}}-pub(super) fn svg_rect_animated_length_slot(name: &str) -> &'static str {+pub(super) fn svg_animated_length_attribute_slot(name: &str) -> &'static str {match name {- "x" => "__moliSvgRectX",- "y" => "__moliSvgRectY",- "width" => "__moliSvgRectWidth",- "height" => "__moliSvgRectHeight",- "rx" => "__moliSvgRectRx",- "ry" => "__moliSvgRectRy",- _ => "__moliSvgRectUnknown",+ "x" => "__moliSvgAnimatedX",+ "y" => "__moliSvgAnimatedY",+ "width" => "__moliSvgAnimatedWidth",+ "height" => "__moliSvgAnimatedHeight",+ "cx" => "__moliSvgAnimatedCx",+ "cy" => "__moliSvgAnimatedCy",+ "r" => "__moliSvgAnimatedR",+ "rx" => "__moliSvgAnimatedRx",+ "ry" => "__moliSvgAnimatedRy",+ "x1" => "__moliSvgAnimatedX1",+ "y1" => "__moliSvgAnimatedY1",+ "x2" => "__moliSvgAnimatedX2",+ "y2" => "__moliSvgAnimatedY2",+ _ => "__moliSvgAnimatedUnknown",}}diff --git a/moli-renderer-v8/src/context_bootstrap/svg_runtime/callbacks.rs b/moli-renderer-v8/src/context_bootstrap/svg_runtime/callbacks.rsindex cf9084d9d..433ccfce1 100644--- a/moli-renderer-v8/src/context_bootstrap/svg_runtime/callbacks.rs+++ b/moli-renderer-v8/src/context_bootstrap/svg_runtime/callbacks.rs@@ -3,6 +3,10 @@ use super::*;use crate::util::serialize_v8_array;const SVG_RECT_ANIMATED_LENGTH_ATTRIBUTES: &[&str] = &["x", "y", "width", "height", "rx", "ry"];+const SVG_CIRCLE_ANIMATED_LENGTH_ATTRIBUTES: &[&str] = &["cx", "cy", "r"];+const SVG_ELLIPSE_ANIMATED_LENGTH_ATTRIBUTES: &[&str] = &["cx", "cy", "rx", "ry"];+const SVG_LINE_ANIMATED_LENGTH_ATTRIBUTES: &[&str] = &["x1", "y1", "x2", "y2"];+const SVG_BOX_ANIMATED_LENGTH_ATTRIBUTES: &[&str] = &["x", "y", "width", "height"];const SVG_LENGTH_ACCESSOR_NAMES: &[&str] = &["unitType","value",@@ -45,18 +49,85 @@ fn require_svg_receiver<'s>(pub(super) fn svg_rect_animated_length_getter<'s>(scope: &mut v8::PinScope<'s, '_>,args: v8::FunctionCallbackArguments<'s>,- mut rv: v8::ReturnValue<'_, v8::Value>,+ rv: v8::ReturnValue<'_, v8::Value>,) {- let Some(name) = callback_data_item(+ svg_element_animated_length_getter(scope,&args,+ rv,SVG_RECT_ANIMATED_LENGTH_ATTRIBUTES,"SVGRectElement animated length attributes",- ) else {+ );+}++pub(super) fn svg_circle_animated_length_getter<'s>(+ scope: &mut v8::PinScope<'s, '_>,+ args: v8::FunctionCallbackArguments<'s>,+ rv: v8::ReturnValue<'_, v8::Value>,+) {+ svg_element_animated_length_getter(+ scope,+ &args,+ rv,+ SVG_CIRCLE_ANIMATED_LENGTH_ATTRIBUTES,+ "SVGCircleElement animated length attributes",+ );+}++pub(super) fn svg_ellipse_animated_length_getter<'s>(+ scope: &mut v8::PinScope<'s, '_>,+ args: v8::FunctionCallbackArguments<'s>,+ rv: v8::ReturnValue<'_, v8::Value>,+) {+ svg_element_animated_length_getter(+ scope,+ &args,+ rv,+ SVG_ELLIPSE_ANIMATED_LENGTH_ATTRIBUTES,+ "SVGEllipseElement animated length attributes",+ );+}++pub(super) fn svg_line_animated_length_getter<'s>(+ scope: &mut v8::PinScope<'s, '_>,+ args: v8::FunctionCallbackArguments<'s>,+ rv: v8::ReturnValue<'_, v8::Value>,+) {+ svg_element_animated_length_getter(+ scope,+ &args,+ rv,+ SVG_LINE_ANIMATED_LENGTH_ATTRIBUTES,+ "SVGLineElement animated length attributes",+ );+}++pub(super) fn svg_box_animated_length_getter<'s>(+ scope: &mut v8::PinScope<'s, '_>,+ args: v8::FunctionCallbackArguments<'s>,+ rv: v8::ReturnValue<'_, v8::Value>,+) {+ svg_element_animated_length_getter(+ scope,+ &args,+ rv,+ SVG_BOX_ANIMATED_LENGTH_ATTRIBUTES,+ "SVG graphics box animated length attributes",+ );+}++fn svg_element_animated_length_getter<'s>(+ scope: &mut v8::PinScope<'s, '_>,+ args: &v8::FunctionCallbackArguments<'s>,+ mut rv: v8::ReturnValue<'_, v8::Value>,+ attributes: &'static [&'static str],+ label: &'static str,+) {+ let Some(name) = callback_data_item(scope, args, attributes, label) else {rv.set_undefined();return;};- let slot = svg_rect_animated_length_slot(name);+ let slot = svg_animated_length_attribute_slot(name);let owner = args.this();if let Some(value) = get_private_value(scope, owner, slot) {if let Ok(object) = v8::Local::<v8::Object>::try_from(value) {