Truly independent web browser
LibWeb+LibCompositing: Use the native Path in Rust
Aliaksandr Kalenik4beaaef3444a
diff --git a/Libraries/LibCompositing/Rust/src/display_list/builder.rs b/Libraries/LibCompositing/Rust/src/display_list/builder.rsindex 083556547b7..d38421bf415 100644--- a/Libraries/LibCompositing/Rust/src/display_list/builder.rs+++ b/Libraries/LibCompositing/Rust/src/display_list/builder.rs@@ -6,7 +6,7 @@use super::commands::*;use crate::display_list::ffi_bytes::FfiBytes;-use libgfx_rust::path::OwnedPath;+use libgfx_rust::path::Path;use libgfx_rust::{AffineTransform, CornerRadii, FloatRect, IntRect, WindingRule, enclosing_int_rect};use std::rc::Rc;@@ -67,7 +67,7 @@ impl PendingInlineClip {}}- pub fn intersecting_path(path: &OwnedPath, path_winding_rule: WindingRule) -> Self {+ pub fn intersecting_path(path: &Path, path_winding_rule: WindingRule) -> Self {Self {kind: InlineClipKind::Path,path_winding_rule,diff --git a/Libraries/LibCompositing/Rust/src/display_list/damage.rs b/Libraries/LibCompositing/Rust/src/display_list/damage.rsindex e623dfb841a..621c1fd668f 100644--- a/Libraries/LibCompositing/Rust/src/display_list/damage.rs+++ b/Libraries/LibCompositing/Rust/src/display_list/damage.rs@@ -1581,10 +1581,10 @@ mod tests {TransformDataRole,};use libgfx_rust::filter::Filter;- use libgfx_rust::path::OwnedPath;+ use libgfx_rust::path::Path;use libgfx_rust::{- Color, ColorFilterType, CompositingAndBlendingOperator, CornerRadii, FloatMatrix4x4, IntPoint, MaskKind,- Orientation, ScalingMode, WindingRule, translation_matrix,+ Color, ColorFilterType, CompositingAndBlendingOperator, CornerRadii, FloatMatrix4x4, FloatPoint, IntPoint,+ MaskKind, Orientation, ScalingMode, WindingRule, translation_matrix,};const RED: Color = Color(0xffff0000);@@ -3151,12 +3151,17 @@ mod tests {#[test]fn clip_paths_are_compared_by_content_across_allocations() {let rect = IntRect::new(10, 10, 20, 20);- let scene = |path_bytes: &[u8]| {+ let scene = |apex_x: f32| {+ let mut path = Path::new();+ path.move_to(FloatPoint { x: 10.0, y: 30.0 });+ path.line_to(FloatPoint { x: apex_x, y: 10.0 });+ path.line_to(FloatPoint { x: 30.0, y: 30.0 });+ path.close();let mut tree = identity_tree();let context = clip_context(&mut tree,ClipNodeData::Path(ClipPathData {- path: std::sync::Arc::new(OwnedPath::from_serialized_bytes(path_bytes)),+ path: std::sync::Arc::new(path),bounding_rect: rect,fill_rule: WindingRule::Nonzero,}),@@ -3172,13 +3177,13 @@ mod tests {tree,)};- let (old_display_list, old_tree) = scene(&[1]);- let (same_display_list, same_tree) = scene(&[1]);+ let (old_display_list, old_tree) = scene(20.0);+ let (same_display_list, same_tree) = scene(20.0);assert_eq!(damage(&old_display_list, &old_tree, &same_display_list, &same_tree),Some(IntRect::default()));- let (changed_display_list, changed_tree) = scene(&[2]);+ let (changed_display_list, changed_tree) = scene(25.0);assert_eq!(damage(&old_display_list, &old_tree, &changed_display_list, &changed_tree),Some(IntRect::new(9, 9, 22, 22))diff --git a/Libraries/LibCompositing/Rust/src/display_list/replay.rs b/Libraries/LibCompositing/Rust/src/display_list/replay.rsindex d929fbc2c11..419e8ead04b 100644--- a/Libraries/LibCompositing/Rust/src/display_list/replay.rs+++ b/Libraries/LibCompositing/Rust/src/display_list/replay.rs@@ -19,7 +19,7 @@ use crate::visual_context::{ClipNodeData, ContextRef, EffectNodeData, SpatialData, VisualContextTree, device_offset_for_index,resolve_leaf_to_context_matrices, should_cull_back_face,};-use libgfx_rust::path::OwnedPath;+use libgfx_rust::path::Path;use libgfx_rust::{AffineTransform, CornerRadii, FloatMatrix4x4, FloatPoint, FloatRect, FloatVector3, IntRect, WindingRule,enclosing_int_rect, translation_matrix,@@ -31,7 +31,7 @@ pub trait ReplayPainter {fn set_matrix(&mut self, matrix: &FloatMatrix4x4);fn would_be_fully_clipped_by_painter(&mut self, rect: IntRect) -> bool;fn push_clip(&mut self, clip: &ReplayClip);- fn push_clip_path(&mut self, path: &OwnedPath, winding_rule: WindingRule);+ fn push_clip_path(&mut self, path: &Path, winding_rule: WindingRule);fn push_layer(&mut self, layer: &ReplayLayer);// `backdrop`, when given, carries the backdrop filter the mask's layer starts with.fn push_mask(&mut self, mask: &ReplayMask, backdrop: Option<&ReplayLayer>);@@ -954,7 +954,7 @@ mod tests {fn push_clip(&mut self, clip: &ReplayClip) {self.events.push(PainterEvent::PushClip(clip.rect));}- fn push_clip_path(&mut self, _path: &OwnedPath, _winding_rule: WindingRule) {+ fn push_clip_path(&mut self, _path: &Path, _winding_rule: WindingRule) {unreachable!("these tests build no clip paths");}fn push_layer(&mut self, layer: &ReplayLayer) {diff --git a/Libraries/LibCompositing/Rust/src/ffi.rs b/Libraries/LibCompositing/Rust/src/ffi.rsindex 0a0c50ee223..918204c922f 100644--- a/Libraries/LibCompositing/Rust/src/ffi.rs+++ b/Libraries/LibCompositing/Rust/src/ffi.rs@@ -806,7 +806,7 @@ pub unsafe extern "C" fn visual_context_tree_test_builder_append_clip_path(let tree = unsafe { test_builder_tree(builder) };// SAFETY: The caller guarantees `path_bytes` addresses `path_bytes_length` readable bytes.let path_bytes = unsafe { ak::slice_from_raw_parts(path_bytes, path_bytes_length) };- let path = libgfx_rust::path::OwnedPath::from_serialized_bytes(path_bytes);+ let path = libgfx_rust::path::Path::from_serialized_bytes(path_bytes);tree.append_clip(crate::visual_context::ClipNodeData::Path(crate::visual_context::ClipPathData {path: std::sync::Arc::new(path),diff --git a/Libraries/LibCompositing/Rust/src/host/replay.rs b/Libraries/LibCompositing/Rust/src/host/replay.rsindex 402b4ac24c0..2cc2c5de538 100644--- a/Libraries/LibCompositing/Rust/src/host/replay.rs+++ b/Libraries/LibCompositing/Rust/src/host/replay.rs@@ -6,7 +6,7 @@use crate::display_list::commands::{DisplayListCommandType, EffectNodeIndex, ReplayClip, ReplayLayer, ReplayMask};use crate::display_list::replay::ReplayPainter;-use libgfx_rust::path::OwnedPath;+use libgfx_rust::path::Path;use libgfx_rust::path::ffi::PathGeometryData;use libgfx_rust::{AffineTransform, FloatMatrix4x4, FloatVector3, IntRect, WindingRule};use std::ffi::c_void;@@ -54,7 +54,7 @@ impl ReplayPainter for FfiDisplayListReplayCallbacks {unsafe { (self.push_clip)(self.context, clip) };}- fn push_clip_path(&mut self, path: &OwnedPath, winding_rule: WindingRule) {+ fn push_clip_path(&mut self, path: &Path, winding_rule: WindingRule) {let data = path.geometry_data();// SAFETY: The C++ painter reads the contours synchronously; the tree keeps the path alive.unsafe { (self.push_clip_path)(self.context, &raw const data, path.identity(), winding_rule) };diff --git a/Libraries/LibCompositing/Rust/src/visual_context/mod.rs b/Libraries/LibCompositing/Rust/src/visual_context/mod.rsindex edb8b8946eb..9b0a72dfc98 100644--- a/Libraries/LibCompositing/Rust/src/visual_context/mod.rs+++ b/Libraries/LibCompositing/Rust/src/visual_context/mod.rs@@ -72,7 +72,7 @@ pub struct ClipData {#[derive(Clone)]pub struct ClipPathData {- pub path: std::sync::Arc<libgfx_rust::path::OwnedPath>,+ pub path: std::sync::Arc<libgfx_rust::path::Path>,pub bounding_rect: IntRect,pub fill_rule: WindingRule,}diff --git a/Libraries/LibCompositing/Rust/src/visual_context/queries.rs b/Libraries/LibCompositing/Rust/src/visual_context/queries.rsindex baa588d1dc3..b102689b92a 100644--- a/Libraries/LibCompositing/Rust/src/visual_context/queries.rs+++ b/Libraries/LibCompositing/Rust/src/visual_context/queries.rs@@ -339,7 +339,7 @@ impl VisualContextTree {}) {return false;}- clip_path.path.contains(point.x, point.y, clip_path.fill_rule as i32)+ clip_path.path.contains(point.x, point.y, clip_path.fill_rule)}ClipNodeData::Dead => true,}diff --git a/Libraries/LibCompositing/Rust/src/visual_context/serialize.rs b/Libraries/LibCompositing/Rust/src/visual_context/serialize.rsindex 8e6e3ba393b..709b884b837 100644--- a/Libraries/LibCompositing/Rust/src/visual_context/serialize.rs+++ b/Libraries/LibCompositing/Rust/src/visual_context/serialize.rs@@ -21,7 +21,7 @@ use crate::visual_animation::{MAXIMUM_TRANSFORM_OPERATION_VALUE_COUNT, VisualAnimation, VisualAnimationKeyframe,VisualAnimationTransformOperation, VisualAnimationValue,};-use libgfx_rust::path::OwnedPath;+use libgfx_rust::path::Path;use libgfx_rust::{Color, ColorFilterType, CompositingAndBlendingOperator, CornerRadii, CornerRadius, FloatMatrix4x4, FloatPoint,FloatRect, FloatSize, IntRect, MaskKind, WindingRule,@@ -441,7 +441,7 @@ fn read_clip_data(reader: &mut TreeByteReader<'_>) -> Option<ClipNodeData> {CLIP_KIND_PATH => {let bounding_rect = reader.int_rect()?;let fill_rule = reader.winding_rule()?;- let path = OwnedPath::from_serialized_bytes(reader.length_prefixed_bytes()?);+ let path = Path::from_serialized_bytes(reader.length_prefixed_bytes()?);ClipNodeData::Path(ClipPathData {path: std::sync::Arc::new(path),bounding_rect,@@ -1082,7 +1082,7 @@ mod tests {);let clip_path = tree.append_clip(ClipNodeData::Path(ClipPathData {- path: std::sync::Arc::new(OwnedPath::from_serialized_bytes(&[])),+ path: std::sync::Arc::new(Path::from_serialized_bytes(&[])),bounding_rect: IntRect::new(5, 6, 7, 8),fill_rule: WindingRule::EvenOdd,}),diff --git a/Libraries/LibWeb/Bindings/Rust/src/canvas_2d/context.rs b/Libraries/LibWeb/Bindings/Rust/src/canvas_2d/context.rsindex 15c6b1fcee3..debd4f2b3d9 100644--- a/Libraries/LibWeb/Bindings/Rust/src/canvas_2d/context.rs+++ b/Libraries/LibWeb/Bindings/Rust/src/canvas_2d/context.rs@@ -16,7 +16,7 @@ use ak::Utf16String;use libcompositing_rust::display_list::canvas_2d::{Compositing, Paint, Stroke};use libcompositing_rust::display_list::canvas_2d_recorder::{AlphaType, Recorder};use libcompositing_rust::display_list::commands::CanvasId;-use libgfx_rust::path::{OwnedPath, PathBuilder};+use libgfx_rust::path::Path;use libgfx_rust::{AffineTransform, Color, CompositingAndBlendingOperator, FloatRect, IntRect, IntSize, WindingRule};use libjs_rust::api::{ForeignCellSlot, Gc, Realm, Trace, Visitor, Vm};@@ -145,7 +145,7 @@ pub(crate) struct ContextState {states: RefCell<Vec<DrawingState>>,/// The current default path, in the coordinates of the current transformation matrix.#[gc(untraced)]- path: RefCell<OwnedPath>,+ path: RefCell<Path>,/// The matrix in whose coordinates the current default path is.////// NB: This is the current transformation matrix while that matrix is invertible. A path cannot be kept in the@@ -162,8 +162,8 @@ pub(crate) struct ContextState {color_cache: RefCell<Vec<ColorCacheEntry>>,}-fn empty_path() -> OwnedPath {- PathBuilder::new().build()+fn empty_path() -> Path {+ Path::new()}/// The paint of a draw with the style, with the image of a pattern added to the stream of the recorder.@@ -262,11 +262,11 @@ impl ContextState {}/// The current default path, which nothing may change while the borrow lasts.- pub(crate) fn path(&self) -> CellRef<'_, OwnedPath> {+ pub(crate) fn path(&self) -> CellRef<'_, Path> {self.path.borrow()}- pub(crate) fn path_mut(&self) -> RefMut<'_, OwnedPath> {+ pub(crate) fn path_mut(&self) -> RefMut<'_, Path> {self.path.borrow_mut()}@@ -702,7 +702,7 @@ impl ContextState {state.current_compositing_and_blending_operator == CompositingAndBlendingOperator::SourceOver}- pub(crate) fn fill_internal(&self, path: &OwnedPath, winding_rule: WindingRule) {+ pub(crate) fn fill_internal(&self, path: &Path, winding_rule: WindingRule) {if !self.recorder_is_ready() {return;}@@ -749,7 +749,7 @@ impl ContextState {self.did_draw();}- pub(crate) fn stroke_internal(&self, path: &OwnedPath) {+ pub(crate) fn stroke_internal(&self, path: &Path) {if !self.recorder_is_ready() {return;}@@ -813,7 +813,7 @@ impl ContextState {self.did_draw();}- pub(crate) fn clip_internal(&self, path: &OwnedPath, winding_rule: WindingRule) {+ pub(crate) fn clip_internal(&self, path: &Path, winding_rule: WindingRule) {if !self.recorder_is_ready() {return;}diff --git a/Libraries/LibWeb/Bindings/Rust/src/canvas_2d/path.rs b/Libraries/LibWeb/Bindings/Rust/src/canvas_2d/path.rsindex 6e7eed6cde5..228071df896 100644--- a/Libraries/LibWeb/Bindings/Rust/src/canvas_2d/path.rs+++ b/Libraries/LibWeb/Bindings/Rust/src/canvas_2d/path.rs@@ -7,7 +7,7 @@//! The operations of the CanvasPath mixin on the current default path of a 2D context, whose steps are in//! html/canvas_path.rs.-use libgfx_rust::path::PathMut;+use libgfx_rust::path::Path;use super::context::{CanvasKind, RenderingContext2D};use super::float;@@ -17,14 +17,13 @@ use crate::html::canvas_path::{};impl<K: CanvasKind> RenderingContext2D<K> {- fn build_path<R>(&self, function: impl FnOnce(&mut PathMut<'_>) -> R) -> R {- let mut path = self.path_mut();- function(&mut path.as_path_mut())+ fn build_path<R>(&self, function: impl FnOnce(&mut Path) -> R) -> R {+ function(&mut self.path_mut())}/// https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-closepathpub(crate) fn close_path(&self, _: &mut CallContext) -> WebIdlResult<()> {- self.build_path(|path| canvas_path::close_path(path));+ self.build_path(canvas_path::close_path);Ok(())}diff --git a/Libraries/LibWeb/Bindings/Rust/src/canvas_2d/text.rs b/Libraries/LibWeb/Bindings/Rust/src/canvas_2d/text.rsindex 701f7976891..0b2210a87bf 100644--- a/Libraries/LibWeb/Bindings/Rust/src/canvas_2d/text.rs+++ b/Libraries/LibWeb/Bindings/Rust/src/canvas_2d/text.rs@@ -8,7 +8,7 @@//! as the text preparation algorithm does, and its outlines.use libgfx_rust::font::{EmojiPresentation, FontCascadeListHandle, FontHandle};-use libgfx_rust::path::{GlyphRun, OwnedPath};+use libgfx_rust::path::{GlyphRun, Path};use libgfx_rust::text_layout::{DrawGlyph, TextType, shape_text as shape_text_in_font};use libgfx_rust::{AffineTransform, FloatPoint};@@ -94,7 +94,7 @@ pub(crate) fn shape_text(}/// The outlines of the glyphs of the runs, as one path.-pub(crate) fn path_of_runs(runs: &[ShapedRun]) -> OwnedPath {+pub(crate) fn path_of_runs(runs: &[ShapedRun]) -> Path {let glyph_runs: Vec<GlyphRun> = runs.iter().map(|run| GlyphRun {@@ -102,7 +102,7 @@ pub(crate) fn path_of_runs(runs: &[ShapedRun]) -> OwnedPath {glyphs: run.glyphs.clone(),}).collect();- OwnedPath::from_glyph_runs(&glyph_runs)+ Path::from_glyph_runs(&glyph_runs)}/// The distance from the alphabetic baseline down to the baseline that textBaseline names, in the metrics of thediff --git a/Libraries/LibWeb/Bindings/Rust/src/html/canvas_draw_path.rs b/Libraries/LibWeb/Bindings/Rust/src/html/canvas_draw_path.rsindex 53819484ff3..f5937595e6c 100644--- a/Libraries/LibWeb/Bindings/Rust/src/html/canvas_draw_path.rs+++ b/Libraries/LibWeb/Bindings/Rust/src/html/canvas_draw_path.rs@@ -6,7 +6,7 @@//! https://html.spec.whatwg.org/multipage/canvas.html#canvasdrawpath-use libgfx_rust::path::OwnedPath;+use libgfx_rust::path::Path;use libgfx_rust::{AffineTransform, FloatPoint, WindingRule};use super::path2d::Path2D;@@ -32,14 +32,14 @@ impl From<CanvasFillRule> for WindingRule {}/// The path of a Path2D, which nothing changes while a context draws with it, as no script runs meanwhile.-fn path_of(path: &Ref<Path2D>) -> &OwnedPath {+fn path_of(path: &Ref<Path2D>) -> &Path {// SAFETY: No script runs while the context uses the path.unsafe { path.path_unguarded() }}/// Whether the point, in the coordinates that the transform maps from, is inside the path.fn is_point_in_path_internal(- path: &OwnedPath,+ path: &Path,transform: AffineTransform,x: f64,y: f64,@@ -53,7 +53,7 @@ fn is_point_in_path_internal(x: float(x),y: float(y),});- path.contains(point.x, point.y, WindingRule::from(fill_rule) as i32)+ path.contains(point.x, point.y, WindingRule::from(fill_rule))}impl<K: CanvasKind> RenderingContext2D<K> {diff --git a/Libraries/LibWeb/Bindings/Rust/src/html/canvas_path.rs b/Libraries/LibWeb/Bindings/Rust/src/html/canvas_path.rsindex 8c6468329ee..ed26cd01ed2 100644--- a/Libraries/LibWeb/Bindings/Rust/src/html/canvas_path.rs+++ b/Libraries/LibWeb/Bindings/Rust/src/html/canvas_path.rs@@ -5,7 +5,7 @@*///! The operations of the CanvasPath mixin, https://html.spec.whatwg.org/multipage/canvas.html#canvaspath, which-//! Path2D and the 2D contexts share. They build on a Gfx::Path, with its rules for a path without a current point.+//! Path2D and the 2D contexts share. They build on a Path, with its rules for a path without a current point.//!//! The arithmetic is that of the C++ it replaces, in the same precision: the arguments of moveTo(), lineTo(),//! quadraticCurveTo(), arc() and ellipse() are floats, and those of the rest are doubles that become floats where@@ -53,7 +53,7 @@ pub(crate) fn round_rect_radii(}}-/// What the operations build on, which is a Gfx::Path, or what the crate tests record.+/// What the operations build on, which is a Path, or what the crate tests record.pub(crate) trait PathSink {/// Whether the path has no current point.fn is_empty(&self) -> bool;@@ -74,8 +74,7 @@ pub(crate) trait PathSink {fn close(&mut self);}-#[cfg(not(test))]-impl PathSink for libgfx_rust::path::PathMut<'_> {+impl PathSink for libgfx_rust::path::Path {fn is_empty(&self) -> bool {self.is_empty()}diff --git a/Libraries/LibWeb/Bindings/Rust/src/html/canvas_rect.rs b/Libraries/LibWeb/Bindings/Rust/src/html/canvas_rect.rsindex be13428ac1d..c28405695b0 100644--- a/Libraries/LibWeb/Bindings/Rust/src/html/canvas_rect.rs+++ b/Libraries/LibWeb/Bindings/Rust/src/html/canvas_rect.rs@@ -6,22 +6,25 @@//! https://html.spec.whatwg.org/multipage/canvas.html#canvasrect-use libgfx_rust::path::{OwnedPath, PathBuilder};-use libgfx_rust::{FloatRect, WindingRule};+use libgfx_rust::path::Path;+use libgfx_rust::{FloatPoint, FloatRect, WindingRule};use crate::bindings::{CallContext, WebIdlResult};use crate::canvas_2d::context::{CanvasKind, RenderingContext2D};use crate::canvas_2d::float;/// The outline of a rectangle, as a closed subpath that goes around it clockwise from its top left corner.-fn rect_path(x: f32, y: f32, width: f32, height: f32) -> OwnedPath {- let mut path = PathBuilder::new();- path.move_to(x, y);- path.line_to(x + width, y);- path.line_to(x + width, y + height);- path.line_to(x, y + height);- path.line_to(x, y);- path.build()+fn rect_path(x: f32, y: f32, width: f32, height: f32) -> Path {+ let mut path = Path::new();+ path.move_to(FloatPoint { x, y });+ path.line_to(FloatPoint { x: x + width, y });+ path.line_to(FloatPoint {+ x: x + width,+ y: y + height,+ });+ path.line_to(FloatPoint { x, y: y + height });+ path.line_to(FloatPoint { x, y });+ path}impl<K: CanvasKind> RenderingContext2D<K> {diff --git a/Libraries/LibWeb/Bindings/Rust/src/html/canvas_text.rs b/Libraries/LibWeb/Bindings/Rust/src/html/canvas_text.rsindex 7017d9f2924..9a7e643be87 100644--- a/Libraries/LibWeb/Bindings/Rust/src/html/canvas_text.rs+++ b/Libraries/LibWeb/Bindings/Rust/src/html/canvas_text.rs@@ -10,7 +10,7 @@ use core::ptr::NonNull;use ak::Utf16String;use libcompositing_rust::display_list::commands::DisplayListGlyph;-use libgfx_rust::path::{OwnedPath, PathBuilder};+use libgfx_rust::path::Path;use libgfx_rust::{CompositingAndBlendingOperator, FloatPoint, WindingRule};use super::text_metrics::{TextMeasurements, TextMetrics};@@ -24,9 +24,9 @@ use crate::html::canvas_rendering_context2d::CanvasTextBaseline;impl ContextState {/// The outlines of the glyphs of the text, drawn at the point.- fn text_path(&self, text: &[u16], x: f32, y: f32, max_width: Option<f64>) -> OwnedPath {+ fn text_path(&self, text: &[u16], x: f32, y: f32, max_width: Option<f64>) -> Path {if max_width.is_some_and(|max_width| max_width <= 0.0) {- return PathBuilder::new().build();+ return Path::new();}let font = self.current_font();diff --git a/Libraries/LibWeb/Bindings/Rust/src/html/path2d.rs b/Libraries/LibWeb/Bindings/Rust/src/html/path2d.rsindex 0cec65d9568..9eb63676be6 100644--- a/Libraries/LibWeb/Bindings/Rust/src/html/path2d.rs+++ b/Libraries/LibWeb/Bindings/Rust/src/html/path2d.rs@@ -9,7 +9,7 @@use core::cell::RefCell;use ak::Utf16String;-use libgfx_rust::path::{OwnedPath, PathBuilder, PathMut};+use libgfx_rust::path::Path;use libjs_rust::api::Trace;use super::canvas_path::{@@ -29,7 +29,7 @@ pub(crate) enum Path2DOrDOMString {#[gc(crate = libjs_rust)]pub(crate) struct Path2D {#[gc(untraced)]- path: RefCell<OwnedPath>,+ path: RefCell<Path>,}impl Wrappable for Path2D {}@@ -48,21 +48,20 @@ impl Path2D {/// # Safety////// Nothing may change the path while the reference is in use.- pub(crate) unsafe fn path_unguarded(&self) -> &OwnedPath {+ pub(crate) unsafe fn path_unguarded(&self) -> &Path {// SAFETY: The caller keeps the path from changing while it reads it.unsafe { self.path.try_borrow_unguarded() }.expect("nothing changes the path meanwhile")}- fn build<R>(&self, function: impl FnOnce(&mut PathMut<'_>) -> R) -> R {- let mut path = self.path.borrow_mut();- function(&mut path.as_path_mut())+ fn build<R>(&self, function: impl FnOnce(&mut Path) -> R) -> R {+ function(&mut self.path.borrow_mut())}/// https://html.spec.whatwg.org/multipage/canvas.html#dom-path2dpub(crate) fn construct(_: &mut CallContext, path: Option<Path2DOrDOMString>) -> WebIdlResult<Self> {// 1. Let output be a new Path2D object.let output = Self {- path: RefCell::new(PathBuilder::new().build()),+ path: RefCell::new(Path::new()),};// 2. If path is not given, then return output.@@ -142,7 +141,7 @@ impl Path2D {// The operations of the CanvasPath mixin, whose steps are in canvas_path.rs.pub(crate) fn close_path(&self, _: &mut CallContext) -> WebIdlResult<()> {- self.build(|path| canvas_path::close_path(path));+ self.build(canvas_path::close_path);Ok(())}diff --git a/Libraries/LibWeb/Rust/src/css/css_path.rs b/Libraries/LibWeb/Rust/src/css/css_path.rsindex 73c204207b8..4e4755e3b43 100644--- a/Libraries/LibWeb/Rust/src/css/css_path.rs+++ b/Libraries/LibWeb/Rust/src/css/css_path.rs@@ -62,7 +62,7 @@ impl CssPath {self.data().parsed.write_content_hash(hasher);}- pub(crate) fn to_gfx_path(&self) -> libgfx_rust::path::OwnedPath {+ pub(crate) fn to_gfx_path(&self) -> libgfx_rust::path::Path {self.data().parsed.to_gfx_path()}}diff --git a/Libraries/LibWeb/Rust/src/gfx_test_stubs.rs b/Libraries/LibWeb/Rust/src/gfx_test_stubs.rsindex a98eab840aa..88f782b17d0 100644--- a/Libraries/LibWeb/Rust/src/gfx_test_stubs.rs+++ b/Libraries/LibWeb/Rust/src/gfx_test_stubs.rs@@ -106,6 +106,17 @@ extern "C" fn ladybird_gfx_glyph_run_glyph_intercepts(unreachable!("no unit test shapes text");}+#[unsafe(no_mangle)]+extern "C" fn ladybird_gfx_font_glyph_outlines(+ _font: *const c_void,+ _glyphs: *const DrawGlyph,+ _glyph_count: usize,+ _visit: unsafe extern "C" fn(*mut c_void, usize, *const c_void),+ _context: *mut c_void,+) {+ unreachable!("no unit test reads a font");+}+#[unsafe(no_mangle)]extern "C" fn ladybird_gfx_path_create_from_ops(_kinds: *const u8, _values: *const f32, _count: usize) -> *mut c_void {unreachable!("no unit test builds a path");diff --git a/Libraries/LibWeb/Rust/src/layout/fragment_tree.rs b/Libraries/LibWeb/Rust/src/layout/fragment_tree.rsindex 337a6e108d8..f37f0bcf432 100644--- a/Libraries/LibWeb/Rust/src/layout/fragment_tree.rs+++ b/Libraries/LibWeb/Rust/src/layout/fragment_tree.rs@@ -38,7 +38,7 @@ pub(crate) struct Fragment {pub(crate) used_grid_tracks: Option<std::sync::Arc<grid_formatting_context::OwnedUsedGridTracks>>,/// Boxed, as only SVG boxes have any and the facts are larger than the rest of the fragment's box.pub(crate) svg: Option<Box<CommittedSvgFacts>>,- pub(crate) computed_svg_path: Option<std::sync::Arc<libgfx_rust::path::OwnedPath>>,+ pub(crate) computed_svg_path: Option<std::sync::Arc<libgfx_rust::path::Path>>,pub(crate) svg_text_character_cells: Option<std::sync::Arc<Vec<svg_formatting_context::FfiSvgTextCharacterCell>>>,pub(crate) has_line_clamp_point: bool,pub(crate) is_invisible_for_line_clamp: bool,@@ -412,7 +412,7 @@ struct CommittedRarePayloads {multicol_layout_data: Option<std::sync::Arc<fragmentation::MulticolLayoutData>>,used_grid_tracks: Option<std::sync::Arc<grid_formatting_context::OwnedUsedGridTracks>>,svg: CommittedSvgFacts,- computed_svg_path: Option<std::sync::Arc<libgfx_rust::path::OwnedPath>>,+ computed_svg_path: Option<std::sync::Arc<libgfx_rust::path::Path>>,svg_text_character_cells: Option<std::sync::Arc<Vec<svg_formatting_context::FfiSvgTextCharacterCell>>>,}diff --git a/Libraries/LibWeb/Rust/src/layout/svg_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/svg_formatting_context.rsindex e7d8f269c69..ef975550982 100644--- a/Libraries/LibWeb/Rust/src/layout/svg_formatting_context.rs+++ b/Libraries/LibWeb/Rust/src/layout/svg_formatting_context.rs@@ -6,6 +6,7 @@use super::*;use crate::css::style::tree::StyleNodeID;+use libgfx_rust::{FloatPoint, FloatSize};#[derive(Clone, Copy, Debug, Default, PartialEq)]#[repr(C)]@@ -737,8 +738,8 @@ impl SvgShapeGeometry {(used_rx, used_ry)}- fn svg_rect_path(&self, style: StyleValues<'_>) -> libgfx_rust::path::PathBuilder {- let mut path = libgfx_rust::path::PathBuilder::new();+ fn svg_rect_path(&self, style: StyleValues<'_>) -> libgfx_rust::path::Path {+ let mut path = libgfx_rust::path::Path::new();let computed_width = style.width();let computed_height = style.height();// FIXME: to_px rounds prematurely here - we shouldn't round to fixed point CSSPixels until@@ -770,71 +771,91 @@ impl SvgShapeGeometry {}let (rx, ry) = Self::svg_rect_corner_radii(style, width as f32, height as f32);+ let radii = FloatSize { width: rx, height: ry };let corner = (rx > 0.0) && (ry > 0.0);let x_axis_rotation = 0.0;let large_arc_flag = false;let sweep_flag = true;// 1. perform an absolute moveto operation to location (x+rx,y);- path.move_to((x + rx as f64) as f32, y as f32);+ path.move_to(FloatPoint {+ x: (x + rx as f64) as f32,+ y: y as f32,+ });// 2. perform an absolute horizontal lineto with parameter x+width-rx;- path.line_to((x + width - rx as f64) as f32, y as f32);+ path.line_to(FloatPoint {+ x: (x + width - rx as f64) as f32,+ y: y as f32,+ });// 3. if both rx and ry are greater than zero, perform an absolute elliptical arc operation// to coordinate (x+width,y+ry), where rx and ry are used as the equivalent parameters// to the elliptical arc command, the x-axis-rotation and large-arc-flag are set to// zero, the sweep-flag is set to one;if corner {path.elliptical_arc_to(- (x + width) as f32,- (y + ry as f64) as f32,- rx,- ry,+ FloatPoint {+ x: (x + width) as f32,+ y: (y + ry as f64) as f32,+ },+ radii,x_axis_rotation,large_arc_flag,sweep_flag,);}// 4. perform an absolute vertical lineto parameter y+height-ry;- path.line_to((x + width) as f32, (y + height - ry as f64) as f32);+ path.line_to(FloatPoint {+ x: (x + width) as f32,+ y: (y + height - ry as f64) as f32,+ });// 5. if both rx and ry are greater than zero, perform an absolute elliptical arc operation// to coordinate (x+width-rx,y+height), using the same parameters as previously;if corner {path.elliptical_arc_to(- (x + width - rx as f64) as f32,- (y + height) as f32,- rx,- ry,+ FloatPoint {+ x: (x + width - rx as f64) as f32,+ y: (y + height) as f32,+ },+ radii,x_axis_rotation,large_arc_flag,sweep_flag,);}// 6. perform an absolute horizontal lineto parameter x+rx;- path.line_to((x + rx as f64) as f32, (y + height) as f32);+ path.line_to(FloatPoint {+ x: (x + rx as f64) as f32,+ y: (y + height) as f32,+ });// 7. if both rx and ry are greater than zero, perform an absolute elliptical arc operation// to coordinate (x,y+height-ry), using the same parameters as previously;if corner {path.elliptical_arc_to(- x as f32,- (y + height - ry as f64) as f32,- rx,- ry,+ FloatPoint {+ x: x as f32,+ y: (y + height - ry as f64) as f32,+ },+ radii,x_axis_rotation,large_arc_flag,sweep_flag,);}// 8. perform an absolute vertical lineto parameter y+ry- path.line_to(x as f32, (y + ry as f64) as f32);+ path.line_to(FloatPoint {+ x: x as f32,+ y: (y + ry as f64) as f32,+ });// 9. if both rx and ry are greater than zero, perform an absolute elliptical arc operation// with a segment-completing close path operation, using the same parameters as// previously.if corner {path.elliptical_arc_to(- (x + rx as f64) as f32,- y as f32,- rx,- ry,+ FloatPoint {+ x: (x + rx as f64) as f32,+ y: y as f32,+ },+ radii,x_axis_rotation,large_arc_flag,sweep_flag,@@ -844,8 +865,8 @@ impl SvgShapeGeometry {path}- fn svg_circle_path(&self, style: StyleValues<'_>) -> libgfx_rust::path::PathBuilder {- let mut path = libgfx_rust::path::PathBuilder::new();+ fn svg_circle_path(&self, style: StyleValues<'_>) -> libgfx_rust::path::Path {+ let mut path = libgfx_rust::path::Path::new();let svg_reset = style.svg_reset();let to_px = |handle: &ComputedStyleValueHandle, basis: CssPixels| {handle@@ -865,15 +886,15 @@ impl SvgShapeGeometry {let large_arc = false;let sweep = true;// 1. A move-to command to the point cx+r,cy;- path.move_to(cx + r, cy);+ path.move_to(FloatPoint { x: cx + r, y: cy });// 2. arc to cx,cy+r;- path.arc_to(cx, cy + r, r, large_arc, sweep);+ path.arc_to(FloatPoint { x: cx, y: cy + r }, r, large_arc, sweep);// 3. arc to cx-r,cy;- path.arc_to(cx - r, cy, r, large_arc, sweep);+ path.arc_to(FloatPoint { x: cx - r, y: cy }, r, large_arc, sweep);// 4. arc to cx,cy-r;- path.arc_to(cx, cy - r, r, large_arc, sweep);+ path.arc_to(FloatPoint { x: cx, y: cy - r }, r, large_arc, sweep);// 5. arc with a segment-completing close path operation.- path.arc_to(cx + r, cy, r, large_arc, sweep);+ path.arc_to(FloatPoint { x: cx + r, y: cy }, r, large_arc, sweep);path}@@ -890,8 +911,8 @@ impl SvgShapeGeometry {)}- fn svg_ellipse_path(&self, style: StyleValues<'_>) -> libgfx_rust::path::PathBuilder {- let mut path = libgfx_rust::path::PathBuilder::new();+ fn svg_ellipse_path(&self, style: StyleValues<'_>) -> libgfx_rust::path::Path {+ let mut path = libgfx_rust::path::Path::new();let svg_reset = style.svg_reset();let computed_rx = &svg_reset.rx;let computed_ry = &svg_reset.ry;@@ -928,52 +949,80 @@ impl SvgShapeGeometry {if rx <= 0.0 || ry <= 0.0 {return path;}+ let radii = FloatSize { width: rx, height: ry };let x_axis_rotation = 0.0;let large_arc = false;// NB: Spec says sweep should be false, but it's wrong. https://github.com/w3c/svgwg/issues/765let sweep = true;// 1. A move-to command to the point cx+rx,cy;- path.move_to(cx + rx, cy);+ path.move_to(FloatPoint { x: cx + rx, y: cy });// 2. arc to cx,cy+ry;- path.elliptical_arc_to(cx, cy + ry, rx, ry, x_axis_rotation, large_arc, sweep);+ path.elliptical_arc_to(+ FloatPoint { x: cx, y: cy + ry },+ radii,+ x_axis_rotation,+ large_arc,+ sweep,+ );// 3. arc to cx-rx,cy;- path.elliptical_arc_to(cx - rx, cy, rx, ry, x_axis_rotation, large_arc, sweep);+ path.elliptical_arc_to(+ FloatPoint { x: cx - rx, y: cy },+ radii,+ x_axis_rotation,+ large_arc,+ sweep,+ );// 4. arc to cx,cy-ry;- path.elliptical_arc_to(cx, cy - ry, rx, ry, x_axis_rotation, large_arc, sweep);+ path.elliptical_arc_to(+ FloatPoint { x: cx, y: cy - ry },+ radii,+ x_axis_rotation,+ large_arc,+ sweep,+ );// 5. arc with a segment-completing close path operation.- path.elliptical_arc_to(cx + rx, cy, rx, ry, x_axis_rotation, large_arc, sweep);+ path.elliptical_arc_to(+ FloatPoint { x: cx + rx, y: cy },+ radii,+ x_axis_rotation,+ large_arc,+ sweep,+ );path}- fn svg_line_path(&self, attributes: FfiSvgAttributeFacts) -> libgfx_rust::path::PathBuilder {- let mut path = libgfx_rust::path::PathBuilder::new();+ fn svg_line_path(&self, attributes: FfiSvgAttributeFacts) -> libgfx_rust::path::Path {+ let mut path = libgfx_rust::path::Path::new();let viewport_width = self.viewport_width.to_float();let viewport_height = self.viewport_height.to_float();// 1. perform an absolute moveto operation to absolute location (x1,y1)- path.move_to(- attributes.line_x1.resolve_relative_to(viewport_width),- attributes.line_y1.resolve_relative_to(viewport_height),- );+ path.move_to(FloatPoint {+ x: attributes.line_x1.resolve_relative_to(viewport_width),+ y: attributes.line_y1.resolve_relative_to(viewport_height),+ });// 2. perform an absolute lineto operation to absolute location (x2,y2)- path.line_to(- attributes.line_x2.resolve_relative_to(viewport_width),- attributes.line_y2.resolve_relative_to(viewport_height),- );+ path.line_to(FloatPoint {+ x: attributes.line_x2.resolve_relative_to(viewport_width),+ y: attributes.line_y2.resolve_relative_to(viewport_height),+ });path}- fn svg_poly_path(points: Option<&[FfiFloatPoint]>, close: bool) -> libgfx_rust::path::PathBuilder {- let mut path = libgfx_rust::path::PathBuilder::new();+ fn svg_poly_path(points: Option<&[FfiFloatPoint]>, close: bool) -> libgfx_rust::path::Path {+ let mut path = libgfx_rust::path::Path::new();let Some(points) = points.filter(|points| !points.is_empty()) else {return path;};// 1. perform an absolute moveto operation to the first coordinate pair in the list of points- path.move_to(points[0].x, points[0].y);+ path.move_to(FloatPoint {+ x: points[0].x,+ y: points[0].y,+ });// 2. for each subsequent coordinate pair, perform an absolute lineto operation to that// coordinate pair.for point in &points[1..] {- path.line_to(point.x, point.y);+ path.line_to(FloatPoint { x: point.x, y: point.y });}// 3. a polygon performs a closepath command; a polyline does not.if close {@@ -989,36 +1038,35 @@ impl SvgShapeGeometry {attributes: FfiSvgAttributeFacts,style: StyleValues<'_>,points: Option<&[FfiFloatPoint]>,- ) -> libgfx_rust::path::OwnedPath {- let builder = match attributes.geometry_kind {- SVG_GEOMETRY_KIND_PATH => return self.svg_path_element_path(style),+ ) -> libgfx_rust::path::Path {+ match attributes.geometry_kind {+ SVG_GEOMETRY_KIND_PATH => self.svg_path_element_path(style),SVG_GEOMETRY_KIND_RECT => self.svg_rect_path(style),SVG_GEOMETRY_KIND_CIRCLE => self.svg_circle_path(style),SVG_GEOMETRY_KIND_ELLIPSE => self.svg_ellipse_path(style),SVG_GEOMETRY_KIND_LINE => self.svg_line_path(attributes),SVG_GEOMETRY_KIND_POLYLINE => Self::svg_poly_path(points, false),SVG_GEOMETRY_KIND_POLYGON => Self::svg_poly_path(points, true),- _ => libgfx_rust::path::PathBuilder::new(),- };- builder.build()+ _ => libgfx_rust::path::Path::new(),+ }}/// The `d` property's path. It is already a shared, immutable blob on the computed style, so/// the pass only has to realize it as geometry and stamp the shape's fill rule onto it.- fn svg_path_element_path(&self, style: StyleValues<'_>) -> libgfx_rust::path::OwnedPath {+ fn svg_path_element_path(&self, style: StyleValues<'_>) -> libgfx_rust::path::Path {let Some(shape) = style.svg_reset().d.style_value().and_then(crate::css::style_value::StyleValueData::basic_shape)else {- return libgfx_rust::path::PathBuilder::new().build();+ return libgfx_rust::path::Path::new();};// The C++ BasicShape variant `d` holds is a path().const BASIC_SHAPE_PATH: u8 = 6;debug_assert_eq!(shape.kind, BASIC_SHAPE_PATH, "the d property holds a path()");let mut path = shape.path.to_gfx_path();- path.set_fill_type(i32::from(shape.fill_rule));+ path.set_fill_rule(libgfx_rust::WindingRule::from_raw(i32::from(shape.fill_rule)));path}}@@ -1072,7 +1120,7 @@ impl<'pass> SvgFormattingContext<'pass> {}/// The geometry a shape element draws, in the user units of the viewport it sits in.- fn svg_geometry_path(&self, node: Node) -> libgfx_rust::path::OwnedPath {+ fn svg_geometry_path(&self, node: Node) -> libgfx_rust::path::Path {let points = self.run.callbacks.arena().svg_points(node);self.shape_geometry().path(self.svg_attributes(node), self.style(node), points.as_deref())@@ -1389,11 +1437,7 @@ impl<'pass> SvgFormattingContext<'pass> {fn svg_text_box_path(&mut self,text_box: Node,- ) -> (- libgfx_rust::path::OwnedPath,- SvgCssPixelRect,- Vec<FfiSvgTextCharacterCell>,- ) {+ ) -> (libgfx_rust::path::Path, SvgCssPixelRect, Vec<FfiSvgTextCharacterCell>) {let attributes = self.svg_attributes(text_box);// https://svgwg.org/svg2-draft/text.html#TextElementXAttribute// the starting X (Y) coordinate for rendering the glyphs corresponding to the given@@ -1447,7 +1491,7 @@ impl<'pass> SvgFormattingContext<'pass> {self.current_text_position.x += shaped.advance;(- libgfx_rust::path::OwnedPath::from_glyph_runs(&shaped.runs),+ libgfx_rust::path::Path::from_glyph_runs(&shaped.runs),shaped.glyph_cells,shaped.character_cells,)@@ -1459,11 +1503,8 @@ impl<'pass> SvgFormattingContext<'pass> {/// https://svgwg.org/svg2-draft/text.html#TextPathElement/// FIXME: The character cells are those of the text shaped from the origin; they aren't moved/// onto the path or rotated along it, so only their advances are meaningful.- fn svg_text_path_box_path(- &self,- text_path_box: Node,- ) -> (libgfx_rust::path::OwnedPath, Vec<FfiSvgTextCharacterCell>) {- let empty = || libgfx_rust::path::PathBuilder::new().build();+ fn svg_text_path_box_path(&self, text_path_box: Node) -> (libgfx_rust::path::Path, Vec<FfiSvgTextCharacterCell>) {+ let empty = || libgfx_rust::path::Path::new();let Some(shape_path) = self.svg_referenced_shape_path(text_path_box) else {return (empty(), Vec::new());};@@ -1494,7 +1535,7 @@ impl<'pass> SvgFormattingContext<'pass> {/// The geometry of the shape element an SVG reference names, read from what that element/// published rather than from a box: a `<textPath>`'s target is normally a `<path>` inside a/// `<defs>`, and a `<defs>` builds no box at all.- fn svg_referenced_shape_path(&self, referring_box: Node) -> Option<libgfx_rust::path::OwnedPath> {+ fn svg_referenced_shape_path(&self, referring_box: Node) -> Option<libgfx_rust::path::Path> {let arena = self.run.callbacks.arena();let referrer = arena.node_style_node(referring_box)?;let atom = self.svg_attributes(referring_box).reference_fragment_atom;@@ -2083,7 +2124,7 @@ impl<'pass> SvgFormattingContext<'pass> {let (path, character_cells) = self.svg_text_path_box_path(graphics_box);(path, None, Some(character_cells))}- _ => (libgfx_rust::path::PathBuilder::new().build(), None, None),+ _ => (libgfx_rust::path::Path::new(), None, None),};// https://svgwg.org/svg2-draft/coords.html#BoundingBoxesdiff --git a/Libraries/LibWeb/Rust/src/layout/used_values.rs b/Libraries/LibWeb/Rust/src/layout/used_values.rsindex 3174ab0c00f..81384037749 100644--- a/Libraries/LibWeb/Rust/src/layout/used_values.rs+++ b/Libraries/LibWeb/Rust/src/layout/used_values.rs@@ -239,7 +239,7 @@ impl CommittedSvgFacts {#[derive(Clone, Default)]pub(crate) struct UsedValuesRareData {- pub(crate) computed_svg_path: Option<std::sync::Arc<libgfx_rust::path::OwnedPath>>,+ pub(crate) computed_svg_path: Option<std::sync::Arc<libgfx_rust::path::Path>>,pub(crate) svg_text_character_cells: Option<std::sync::Arc<Vec<svg_formatting_context::FfiSvgTextCharacterCell>>>,pub(crate) svg: CommittedSvgFacts,pub(crate) grid_layout_data: Option<std::sync::Arc<grid_formatting_context::GridLayoutData>>,diff --git a/Libraries/LibWeb/Rust/src/painting/border_shape.rs b/Libraries/LibWeb/Rust/src/painting/border_shape.rsindex 929df1d0295..03de7e1412c 100644--- a/Libraries/LibWeb/Rust/src/painting/border_shape.rs+++ b/Libraries/LibWeb/Rust/src/painting/border_shape.rs@@ -18,26 +18,26 @@ use crate::painting::paintable_data::BorderEdge;use crate::painting::record::paint::border::{BordersDataDevicePixels, border_color};use crate::painting::visual_context::basic_shapes::basic_shape_device_path;use crate::painting::{paintable_geometry, style_queries};-use libgfx_rust::path::OwnedPath;+use libgfx_rust::path::Path;use libgfx_rust::{Color, WindingRule};/// A border drawn along a shape, in device space.pub(crate) enum BorderShape {/// A single shape: the border is a stroke along its path.Stroke {- path: OwnedPath,+ path: Path,fill_rule: WindingRule,/// The shape against its reference box shrunk by half the stroke width, along the inner edge of the stroke.- inner_edge: OwnedPath,+ inner_edge: Path,/// The shape against its reference box grown by half the stroke width, along the outer edge of the stroke.- outer_edge: OwnedPath,+ outer_edge: Path,width: f32,color: Option<Color>,},/// Two shapes: the border is the area between them.Fill {- outer: OwnedPath,- inner: OwnedPath,+ outer: Path,+ inner: Path,inner_fill_rule: WindingRule,color: Option<Color>,},@@ -50,7 +50,7 @@ pub(crate) fn has_border_shape(style: ComputedValuesView<'_>) -> bool {}/// One path holding the subpaths of both `paths`.-fn combined_path(paths: [&OwnedPath; 2]) -> Option<OwnedPath> {+fn combined_path(paths: [&Path; 2]) -> Option<Path> {let svg = paths.map(|path| path.to_svg_string()).join(" ");let parsed = crate::svg::parse_utf16_path(&svg.encode_utf16().collect::<Vec<_>>(), false)?;Some(crate::css::css_path::CssPath::new(parsed).to_gfx_path())@@ -58,7 +58,7 @@ fn combined_path(paths: [&OwnedPath; 2]) -> Option<OwnedPath> {impl BorderShape {/// The area the border covers, filled with the even-odd rule, when it is not a stroke.- pub(crate) fn fill_area(&self) -> Option<OwnedPath> {+ pub(crate) fn fill_area(&self) -> Option<Path> {match self {Self::Stroke { .. } => None,Self::Fill { outer, inner, .. } => combined_path([outer, inner]),@@ -69,7 +69,7 @@ impl BorderShape {/// An outer box-shadow is cast as if the shape defined by the outer path were opaque. An inner box-shadow is cast/// as if everything outside the shape defined by the inner path were opaque. A single shape's outer and inner/// paths are the edges of its stroke.- pub(crate) fn into_shadow_paths(self) -> (OwnedPath, OwnedPath) {+ pub(crate) fn into_shadow_paths(self) -> (Path, Path) {match self {Self::Stroke {outer_edge, inner_edge, ..@@ -79,7 +79,7 @@ impl BorderShape {}/// The inner border-shape clips the background. A single shape clips it along its path, under the stroke.- pub(crate) fn background_clip_path(&self) -> (&OwnedPath, WindingRule) {+ pub(crate) fn background_clip_path(&self) -> (&Path, WindingRule) {match self {Self::Stroke { path, fill_rule, .. } => (path, *fill_rule),Self::Fill {@@ -91,7 +91,7 @@ impl BorderShape {/// https://drafts.csswg.org/css-borders-4/#border-shape-overflow-interaction/// The inner border-shape clips the overflow content of the element. A single shape clips it along the inner edge/// of its stroke.- pub(crate) fn into_overflow_clip_path(self) -> (OwnedPath, WindingRule) {+ pub(crate) fn into_overflow_clip_path(self) -> (Path, WindingRule) {match self {Self::Stroke {inner_edge, fill_rule, ..diff --git a/Libraries/LibWeb/Rust/src/painting/corner_shape.rs b/Libraries/LibWeb/Rust/src/painting/corner_shape.rsindex 9007ddcc297..37fc952055a 100644--- a/Libraries/LibWeb/Rust/src/painting/corner_shape.rs+++ b/Libraries/LibWeb/Rust/src/painting/corner_shape.rs@@ -9,8 +9,8 @@//! https://drafts.csswg.org/css-borders-4/#corner-shape-renderinguse crate::css::computed_value_views::ComputedValuesView;-use libgfx_rust::path::{OwnedPath, PathBuilder};-use libgfx_rust::{CornerRadii, CornerRadius, FloatRect};+use libgfx_rust::path::Path;+use libgfx_rust::{CornerRadii, CornerRadius, FloatPoint, FloatRect};/// The superellipse parameter of each corner, in the order top-left, top-right, bottom-right,/// bottom-left.@@ -432,15 +432,15 @@ pub(crate) fn border_contour_path(radii: CornerRadii,shapes: CornerShapes,insets: Insets,-) -> OwnedPath {- let mut builder = PathBuilder::new();+) -> Path {+ let mut builder = Path::new();append_border_contour_path(&mut builder, border_rect, radii, shapes, insets);- builder.build()+ builder}/// Appends the border contour path to `builder` as a closed subpath of its own.pub(crate) fn append_border_contour_path(- builder: &mut PathBuilder,+ builder: &mut Path,border_rect: FloatRect,radii: CornerRadii,shapes: CornerShapes,@@ -520,10 +520,16 @@ pub(crate) fn append_border_contour_path(let mut first = true;let mut extend = |point: Point| {if first {- builder.move_to(point.x as f32, point.y as f32);+ builder.move_to(FloatPoint {+ x: point.x as f32,+ y: point.y as f32,+ });first = false;} else {- builder.line_to(point.x as f32, point.y as f32);+ builder.line_to(FloatPoint {+ x: point.x as f32,+ y: point.y as f32,+ });}};let target_rect = (left, top, right, bottom);diff --git a/Libraries/LibWeb/Rust/src/painting/display_list/dump.rs b/Libraries/LibWeb/Rust/src/painting/display_list/dump.rsindex d44686b1bb0..da529bc2a21 100644--- a/Libraries/LibWeb/Rust/src/painting/display_list/dump.rs+++ b/Libraries/LibWeb/Rust/src/painting/display_list/dump.rs@@ -20,7 +20,7 @@ use crate::painting::visual_context::VisualContextTree;use crate::painting::visual_context::VisualContextTreeDump;use crate::painting::visual_context::dump::SlotKind;use crate::stage::MainThread;-use libgfx_rust::path::OwnedPath;+use libgfx_rust::path::Path;use libgfx_rust::{Color, CompositingAndBlendingOperator, CornerRadii, FloatPoint, FloatRect, FloatSize, IntPoint, IntRect, IntSize,LineStyle, ScalingMode,@@ -709,7 +709,7 @@ fn dump_inline_clips(output: &mut String, header: &DisplayListCommandHeader, paylet start = clip.path_data.offset as usize;let size = clip.path_data.size as usize;assert!(start <= payload.len() && size <= payload.len() - start);- let path = OwnedPath::from_serialized_bytes(&payload[start..start + size]);+ let path = Path::from_serialized_bytes(&payload[start..start + size]);let svg_path = path.to_svg_string();let has_host_dependent_curves = svg_path.contains('Q') || svg_path.contains('C');output.push_str("clip_path=[bounds: ");diff --git a/Libraries/LibWeb/Rust/src/painting/display_list/recorder.rs b/Libraries/LibWeb/Rust/src/painting/display_list/recorder.rsindex 56f0dbec5f1..597fb0bef4e 100644--- a/Libraries/LibWeb/Rust/src/painting/display_list/recorder.rs+++ b/Libraries/LibWeb/Rust/src/painting/display_list/recorder.rs@@ -210,7 +210,7 @@ pub enum PaintStyleOrColor {pub struct FillPathParams<'a> {pub force_dark_role: ForceDarkRole,- pub path: &'a libgfx_rust::path::OwnedPath,+ pub path: &'a libgfx_rust::path::Path,pub opacity: f32,pub paint_style_or_color: PaintStyleOrColor,pub winding_rule: WindingRule,@@ -224,7 +224,7 @@ pub struct StrokePathParams<'a> {pub miter_limit: f32,pub dash_array: Vec<f32>,pub dash_offset: f32,- pub path: &'a libgfx_rust::path::OwnedPath,+ pub path: &'a libgfx_rust::path::Path,pub opacity: f32,pub paint_style_or_color: PaintStyleOrColor,pub thickness: f32,@@ -1087,7 +1087,7 @@ impl DisplayListRecorder {blur_radius: i32,spread_distance: f32,offset: FloatPoint,- shape_path: &libgfx_rust::path::OwnedPath,+ shape_path: &libgfx_rust::path::Path,inner: bool,force_dark_role: ForceDarkRole,) {diff --git a/Libraries/LibWeb/Rust/src/painting/hit_test/mod.rs b/Libraries/LibWeb/Rust/src/painting/hit_test/mod.rsindex 10f0839feef..4cc52cd5b86 100644--- a/Libraries/LibWeb/Rust/src/painting/hit_test/mod.rs+++ b/Libraries/LibWeb/Rust/src/painting/hit_test/mod.rs@@ -53,8 +53,8 @@ pub struct HitTestItem {pub block_container: NodeSlotId,pub context: ContextRef,pub border_radii: BorderRadii,- pub path: Option<Arc<libgfx_rust::path::OwnedPath>>,- pub winding_rule: i32,+ pub path: Option<Arc<libgfx_rust::path::Path>>,+ pub winding_rule: libgfx_rust::WindingRule,/// For an SVG path, the `svg_hit_area` flags naming which of its areas pointer events can target.pub svg_hit_areas: u8,/// For an SVG path whose stroke pointer events can target, the shape of that stroke.@@ -85,7 +85,7 @@ pub mod svg_hit_area {#[derive(Debug)]pub struct SvgStrokeHitRegion {style: libgfx_rust::path::StrokeStyle,- outline: std::sync::OnceLock<libgfx_rust::path::OwnedPath>,+ outline: std::sync::OnceLock<libgfx_rust::path::Path>,}impl SvgStrokeHitRegion {@@ -108,12 +108,10 @@ impl SvgStrokeHitRegion {self.style.thickness / 2.0 * factor}- pub fn contains(&self, path: &libgfx_rust::path::OwnedPath, x: f32, y: f32) -> bool {- self.outline.get_or_init(|| path.stroke_to_fill(&self.style)).contains(- x,- y,- libgfx_rust::WindingRule::Nonzero as i32,- )+ pub fn contains(&self, path: &libgfx_rust::path::Path, x: f32, y: f32) -> bool {+ self.outline+ .get_or_init(|| path.stroke_to_fill(&self.style))+ .contains(x, y, libgfx_rust::WindingRule::Nonzero)}}diff --git a/Libraries/LibWeb/Rust/src/painting/image_map_areas.rs b/Libraries/LibWeb/Rust/src/painting/image_map_areas.rsindex 5fccc2e80c2..d08144e21d5 100644--- a/Libraries/LibWeb/Rust/src/painting/image_map_areas.rs+++ b/Libraries/LibWeb/Rust/src/painting/image_map_areas.rs@@ -6,8 +6,8 @@use crate::css::style::fast_hash::FastMap;use crate::layout::node_data::NodeSlotId;-use libgfx_rust::WindingRule;-use libgfx_rust::path::{OwnedPath, PathBuilder};+use libgfx_rust::path::Path;+use libgfx_rust::{FloatPoint, WindingRule};use std::cell::RefCell;use std::sync::Arc;@@ -39,7 +39,7 @@ impl AreaShape {pub enum AreaCoverage {/// The default state, which covers the whole image.WholeImage,- Shape(OwnedPath),+ Shape(Path),/// A shape that is empty, such as one with too few coordinates.Nothing,}@@ -58,7 +58,7 @@ impl AreaCoverage {// that exactly covers the entire image excludes the image's borders and padding. Treat the default// state as covering everything that hits the image instead.Self::WholeImage => true,- Self::Shape(path) => path.contains(x, y, WindingRule::EvenOdd as i32),+ Self::Shape(path) => path.contains(x, y, WindingRule::EvenOdd),Self::Nothing => false,}}@@ -74,7 +74,7 @@ pub struct PublishedImageMapArea {// https://html.spec.whatwg.org/multipage/image-maps.html#image-map-processing-model/// The shape to layer onto the image, built with the same operations the DOM side built it with,/// so that the containment test is the one `Gfx::Path` already answered.-fn shape_path(shape: AreaShape, coords: &[f64]) -> Option<OwnedPath> {+fn shape_path(shape: AreaShape, coords: &[f64]) -> Option<Path> {// Each area element in areas must be processed as follows to obtain a shape to layer onto the image:// 1. Find the state that the element's shape attribute represents.@@ -108,14 +108,14 @@ fn shape_path(shape: AreaShape, coords: &[f64]) -> Option<OwnedPath> {let x = coords[0] as f32;let y = coords[1] as f32;let radius = coords[2] as f32;- let mut builder = PathBuilder::new();- builder.move_to(x + radius, y);- builder.arc_to(x, y + radius, radius, false, true);- builder.arc_to(x - radius, y, radius, false, true);- builder.arc_to(x, y - radius, radius, false, true);- builder.arc_to(x + radius, y, radius, false, true);+ let mut builder = Path::new();+ builder.move_to(FloatPoint { x: x + radius, y });+ builder.arc_to(FloatPoint { x, y: y + radius }, radius, false, true);+ builder.arc_to(FloatPoint { x: x - radius, y }, radius, false, true);+ builder.arc_to(FloatPoint { x, y: y - radius }, radius, false, true);+ builder.arc_to(FloatPoint { x: x + radius, y }, radius, false, true);builder.close();- Some(builder.build())+ Some(builder)}// The shape is a rectangle that exactly covers the entire image.// NB: AreaCoverage answers for the default state without a shape.@@ -125,15 +125,15 @@ fn shape_path(shape: AreaShape, coords: &[f64]) -> Option<OwnedPath> {return None;}- let mut builder = PathBuilder::new();+ let mut builder = Path::new();let (x, y) = vertex(0);- builder.move_to(x, y);+ builder.move_to(FloatPoint { x, y });for index in 1..coords.len() / 2 {let (x, y) = vertex(index);- builder.line_to(x, y);+ builder.line_to(FloatPoint { x, y });}builder.close();- Some(builder.build())+ Some(builder)}AreaShape::Rectangle => {if coords.len() < 4 {@@ -158,13 +158,13 @@ fn shape_path(shape: AreaShape, coords: &[f64]) -> Option<OwnedPath> {// corner is given by the coordinate (x2, y2), those coordinates being interpreted as CSS pixels from the// top left corner of the image.let [left, top, right, bottom] = corners.map(|corner| corner as f32);- let mut builder = PathBuilder::new();- builder.move_to(left, top);- builder.line_to(right, top);- builder.line_to(right, bottom);- builder.line_to(left, bottom);+ let mut builder = Path::new();+ builder.move_to(FloatPoint { x: left, y: top });+ builder.line_to(FloatPoint { x: right, y: top });+ builder.line_to(FloatPoint { x: right, y: bottom });+ builder.line_to(FloatPoint { x: left, y: bottom });builder.close();- Some(builder.build())+ Some(builder)}}}diff --git a/Libraries/LibWeb/Rust/src/painting/paintable_geometry.rs b/Libraries/LibWeb/Rust/src/painting/paintable_geometry.rsindex cb57c9518fa..3ac6cbb174b 100644--- a/Libraries/LibWeb/Rust/src/painting/paintable_geometry.rs+++ b/Libraries/LibWeb/Rust/src/painting/paintable_geometry.rs@@ -163,7 +163,7 @@ pub(crate) fn committed_collapsed_table_borders(pub(crate) fn committed_svg_path(arena: &impl GeometryRead,slot: NodeSlotId,-) -> Option<std::sync::Arc<libgfx_rust::path::OwnedPath>> {+) -> Option<std::sync::Arc<libgfx_rust::path::Path>> {if !arena.node_kind_if_live(slot).is_some_and(node_painting::is_svg_path) {return None;}diff --git a/Libraries/LibWeb/Rust/src/painting/record/assemble.rs b/Libraries/LibWeb/Rust/src/painting/record/assemble.rsindex b350eefd765..c068b71c1e9 100644--- a/Libraries/LibWeb/Rust/src/painting/record/assemble.rs+++ b/Libraries/LibWeb/Rust/src/painting/record/assemble.rs@@ -674,7 +674,7 @@ mod tests {context: ContextRef::default(),border_radii: BorderRadii::default(),path: None,- winding_rule: 0,+ winding_rule: libgfx_rust::WindingRule::Nonzero,svg_hit_areas: 0,svg_stroke: None,writing_mode: 0,diff --git a/Libraries/LibWeb/Rust/src/painting/record/hit_test_items.rs b/Libraries/LibWeb/Rust/src/painting/record/hit_test_items.rsindex 8dd65fd2f3c..acea527cda8 100644--- a/Libraries/LibWeb/Rust/src/painting/record/hit_test_items.rs+++ b/Libraries/LibWeb/Rust/src/painting/record/hit_test_items.rs@@ -456,7 +456,7 @@ impl<'a, O: Observer> PaintRecorder<'a, O> {let item = HitTestItem {rect: bounding_box,path: Some(path),- winding_rule: facts.svg_path_winding_rule as i32,+ winding_rule: facts.svg_path_winding_rule,svg_hit_areas: facts.svg_hit_areas,svg_stroke: stroke,..self.base_hit_test_item(HitTestItemKind::SvgPath, paintable, context)@@ -678,7 +678,7 @@ impl<'a, O: Observer> PaintRecorder<'a, O> {context,border_radii: BorderRadii::default(),path: None,- winding_rule: 0,+ winding_rule: WindingRule::Nonzero,svg_hit_areas: 0,svg_stroke: None,writing_mode: self.writing_mode_of(target),diff --git a/Libraries/LibWeb/Rust/src/painting/record/paint/border.rs b/Libraries/LibWeb/Rust/src/painting/record/paint/border.rsindex 04737421240..145dea58d47 100644--- a/Libraries/LibWeb/Rust/src/painting/record/paint/border.rs+++ b/Libraries/LibWeb/Rust/src/painting/record/paint/border.rs@@ -22,7 +22,7 @@ use crate::painting::paintable_data::{FfiPixelBox, PIECE_EDGE_BOTTOM, PIECE_EDGE_LEFT, PIECE_EDGE_RIGHT, PIECE_EDGE_TOP,};use crate::painting::record::{BasePaintFacts, PaintRecorder};-use libgfx_rust::path::{OwnedPath, PathBuilder};+use libgfx_rust::path::Path;use libgfx_rust::{CapStyle, Color, CornerRadii, CornerRadius, FloatPoint, FloatSize, IntPoint, IntRect, JoinStyle, LineStyle,ShouldAntiAlias, WindingRule,@@ -249,7 +249,7 @@ fn is_long_enough_for_pattern(length: f32, width: f32, dotted: bool) -> bool {// path, and the seam of a closed one, in a gap.fn stroke_patterned_path(painter: &mut DisplayListRecorder,- path: &libgfx_rust::path::OwnedPath,+ path: &Path,style: LineStyle,width: f32,color: Color,@@ -299,7 +299,7 @@ struct Corner {// Dashes and dots run along the middle of the border, so instead of filling the exact region covered by the edge -// which is what the solid border painting below does - they are stroked along a centerline path: the half of the// corner arc leading into the edge, the straight run, and the half of the corner arc leading out of it.-fn patterned_border_centerline(geometry: EdgeGeometry, borders_data: &BordersDataDevicePixels) -> PathBuilder {+fn patterned_border_centerline(geometry: EdgeGeometry, borders_data: &BordersDataDevicePixels) -> Path {let EdgeGeometry {edge,rect,@@ -420,26 +420,18 @@ fn patterned_border_centerline(geometry: EdgeGeometry, borders_data: &BordersDat// A corner whose centerline radii have collapsed leaves the dashes meeting at a sharp angle instead of curving.let has_arc = |corner: &Corner| corner.radii.width > 0.0 && corner.radii.height > 0.0;- let mut centerline = PathBuilder::new();+ let mut centerline = Path::new();if has_arc(&start) {let split = split_point(&start, joined_border_width);- centerline.move_to(split.x, split.y);- centerline.elliptical_arc_to(- straight_start.x,- straight_start.y,- start.radii.width,- start.radii.height,- 0.0,- false,- true,- );+ centerline.move_to(split);+ centerline.elliptical_arc_to(straight_start, start.radii, 0.0, false, true);} else {- centerline.move_to(straight_start.x, straight_start.y);+ centerline.move_to(straight_start);}- centerline.line_to(straight_end.x, straight_end.y);+ centerline.line_to(straight_end);if has_arc(&end) {let split = split_point(&end, opposite_joined_border_width);- centerline.elliptical_arc_to(split.x, split.y, end.radii.width, end.radii.height, 0.0, false, true);+ centerline.elliptical_arc_to(split, end.radii, 0.0, false, true);}centerline}@@ -704,68 +696,72 @@ impl SolidEdgeRegion {}}- pub(crate) fn append_to(&self, target: &mut PathBuilder) {+ pub(crate) fn append_to(&self, target: &mut Path) {let points = &self.points;let radius = self.radius;let opposite_radius = self.opposite_radius;let mut current = 0;- target.move_to(points[current].x, points[current].y);+ target.move_to(points[current]);current += 1;target.elliptical_arc_to(- points[current].x,- points[current].y,- radius.horizontal_radius as f32,- radius.vertical_radius as f32,+ points[current],+ FloatSize {+ width: radius.horizontal_radius as f32,+ height: radius.vertical_radius as f32,+ },0.0,false,false,);current += 1;- target.line_to(points[current].x, points[current].y);+ target.line_to(points[current]);current += 1;if self.joined_corner_has_inner_corner {target.elliptical_arc_to(- points[current].x,- points[current].y,- radius.horizontal_radius as f32 - self.joined_inner_corner_offset.width,- radius.vertical_radius as f32 - self.joined_inner_corner_offset.height,+ points[current],+ FloatSize {+ width: radius.horizontal_radius as f32 - self.joined_inner_corner_offset.width,+ height: radius.vertical_radius as f32 - self.joined_inner_corner_offset.height,+ },0.0,false,true,);current += 1;}- target.line_to(points[current].x, points[current].y);+ target.line_to(points[current]);current += 1;if self.opposite_joined_corner_has_inner_corner {target.elliptical_arc_to(- points[current].x,- points[current].y,- opposite_radius.horizontal_radius as f32 - self.opposite_joined_inner_corner_offset.width,- opposite_radius.vertical_radius as f32 - self.opposite_joined_inner_corner_offset.height,+ points[current],+ FloatSize {+ width: opposite_radius.horizontal_radius as f32 - self.opposite_joined_inner_corner_offset.width,+ height: opposite_radius.vertical_radius as f32 - self.opposite_joined_inner_corner_offset.height,+ },0.0,false,true,);current += 1;}- target.line_to(points[current].x, points[current].y);+ target.line_to(points[current]);current += 1;target.elliptical_arc_to(- points[current].x,- points[current].y,- opposite_radius.horizontal_radius as f32,- opposite_radius.vertical_radius as f32,+ points[current],+ FloatSize {+ width: opposite_radius.horizontal_radius as f32,+ height: opposite_radius.vertical_radius as f32,+ },0.0,false,false,);}- pub(crate) fn path(&self) -> OwnedPath {- let mut builder = PathBuilder::new();+ pub(crate) fn path(&self) -> Path {+ let mut builder = Path::new();self.append_to(&mut builder);- builder.build()+ builder}}@@ -773,7 +769,7 @@ pub(crate) fn paint_border(painter: &mut DisplayListRecorder,geometry: EdgeGeometry,borders_data: &BordersDataDevicePixels,- path: &mut PathBuilder,+ path: &mut Path,last: bool,) {let EdgeGeometry {@@ -791,27 +787,26 @@ pub(crate) fn paint_border(// Edges sharing a color are collected into one path and only filled once the color changes or// the last edge is reached.- let flush_queued_edges = |painter: &mut DisplayListRecorder, path: &mut PathBuilder| {+ let flush_queued_edges = |painter: &mut DisplayListRecorder, path: &mut Path| {if path.is_empty() {return;}- let built = path.build();+ let queued_edges = std::mem::take(path);painter.fill_path(FillPathParams {force_dark_role: borders_data.force_dark_role,- path: &built,+ path: &queued_edges,opacity: 1.0,paint_style_or_color: PaintStyleOrColor::Color(color),winding_rule: WindingRule::EvenOdd,should_anti_alias: ShouldAntiAlias::Yes,});- *path = PathBuilder::new();};let is_horizontal_edge = matches!(edge, BorderEdge::Top | BorderEdge::Bottom);let frame = edge_frame(edge, rect);let paint_double_border = |painter: &mut DisplayListRecorder,- path: &mut PathBuilder,+ path: &mut Path,proportional_line_thickness: f32,outer_style: u8,inner_style: u8| {@@ -976,7 +971,7 @@ pub(crate) fn paint_border(// Fails for an edge too short to hold the pattern, which is painted solid instead.if gfx_line_style != LineStyle::Solid {- let centerline = patterned_border_centerline(geometry, borders_data).build();+ let centerline = patterned_border_centerline(geometry, borders_data);if is_long_enough_for_pattern(centerline.length(), width_into, gfx_line_style == LineStyle::Dotted) {flush_queued_edges(painter, path);// The stroke is as wide as the border, so at a shared corner it would spill across the@@ -1189,57 +1184,73 @@ fn paint_uniform_patterned_border(// Starting halfway along the top edge puts the seam on an axis of symmetry.let start_x = ((left + right) / 2.0).clamp(left + top_left.width, right - top_right.width);- let mut centerline = PathBuilder::new();- centerline.move_to(start_x, top);- centerline.line_to(right - top_right.width, top);+ let mut centerline = Path::new();+ centerline.move_to(FloatPoint { x: start_x, y: top });+ centerline.line_to(FloatPoint {+ x: right - top_right.width,+ y: top,+ });if !is_empty(top_right) {centerline.elliptical_arc_to(- right,- top + top_right.height,- top_right.width,- top_right.height,+ FloatPoint {+ x: right,+ y: top + top_right.height,+ },+ top_right,0.0,false,true,);}- centerline.line_to(right, bottom - bottom_right.height);+ centerline.line_to(FloatPoint {+ x: right,+ y: bottom - bottom_right.height,+ });if !is_empty(bottom_right) {centerline.elliptical_arc_to(- right - bottom_right.width,- bottom,- bottom_right.width,- bottom_right.height,+ FloatPoint {+ x: right - bottom_right.width,+ y: bottom,+ },+ bottom_right,0.0,false,true,);}- centerline.line_to(left + bottom_left.width, bottom);+ centerline.line_to(FloatPoint {+ x: left + bottom_left.width,+ y: bottom,+ });if !is_empty(bottom_left) {centerline.elliptical_arc_to(- left,- bottom - bottom_left.height,- bottom_left.width,- bottom_left.height,+ FloatPoint {+ x: left,+ y: bottom - bottom_left.height,+ },+ bottom_left,0.0,false,true,);}- centerline.line_to(left, top + top_left.height);+ centerline.line_to(FloatPoint {+ x: left,+ y: top + top_left.height,+ });if !is_empty(top_left) {centerline.elliptical_arc_to(- left + top_left.width,- top,- top_left.width,- top_left.height,+ FloatPoint {+ x: left + top_left.width,+ y: top,+ },+ top_left,0.0,false,true,);}- centerline.line_to(start_x, top);+ centerline.line_to(FloatPoint { x: start_x, y: top });centerline.close();let style = if borders_data.top.line_style == line_style::DOTTED {@@ -1249,7 +1260,7 @@ fn paint_uniform_patterned_border(};stroke_patterned_path(painter,- ¢erline.build(),+ ¢erline,style,width,borders_data.top.color,@@ -1320,7 +1331,7 @@ pub fn paint_all_borders(}}- let mut path = PathBuilder::new();+ let mut path = Path::new();for i in 0..edges.len() {let last = i == edges.len() - 1;let geometry = geometries[(start_index + i) % edges.len()];@@ -1573,10 +1584,9 @@ fn paint_shaped_borders(bottom: f64::from(borders_data.bottom.width.max(0)),left: f64::from(borders_data.left.width.max(0)),};- let mut ring = PathBuilder::new();+ let mut ring = Path::new();append_border_contour_path(&mut ring, border_rect, corner_radii, shapes, Insets::default());append_border_contour_path(&mut ring, border_rect, corner_radii, shapes, widths);- let ring = ring.build();let fill_ring = |painter: &mut DisplayListRecorder, color: Color| {painter.fill_path(FillPathParams {force_dark_role: borders_data.force_dark_role,@@ -1632,13 +1642,18 @@ fn paint_shaped_borders(let Some(color) = color else {continue;};- let mut wedge_path = PathBuilder::new();- wedge_path.move_to(wedge[0].0 as f32, wedge[0].1 as f32);+ let mut wedge_path = Path::new();+ wedge_path.move_to(FloatPoint {+ x: wedge[0].0 as f32,+ y: wedge[0].1 as f32,+ });for &(x, y) in &wedge[1..] {- wedge_path.line_to(x as f32, y as f32);+ wedge_path.line_to(FloatPoint {+ x: x as f32,+ y: y as f32,+ });}wedge_path.close();- let wedge_path = wedge_path.build();painter.record_with_inline_clips(&[PendingInlineClip::intersecting_path(&wedge_path, WindingRule::Nonzero)],|painter| fill_ring(painter, color),diff --git a/Libraries/LibWeb/Rust/src/painting/record/paint/form_controls.rs b/Libraries/LibWeb/Rust/src/painting/record/paint/form_controls.rsindex 74c905e0a4f..d12c23cc221 100644--- a/Libraries/LibWeb/Rust/src/painting/record/paint/form_controls.rs+++ b/Libraries/LibWeb/Rust/src/painting/record/paint/form_controls.rs@@ -8,7 +8,7 @@ use crate::painting::paint_read::PaintRead;use crate::painting::record::trace::Observer;use crate::painting::force_dark::ForceDarkRole;-use libgfx_rust::path::{OwnedPath, PathBuilder};+use libgfx_rust::path::Path;use crate::css::css_pixels::CssPixelRect;use crate::css::css_pixels::CssPixels;@@ -16,7 +16,7 @@ use crate::layout::node_data::NodeSlotId;use crate::painting::display_list::recorder::{FillPathParams, PaintStyleOrColor};use crate::painting::paintable_geometry::absolute_rect;use crate::painting::record::PaintRecorder;-use libgfx_rust::{Color, IntRect, ShouldAntiAlias, WindingRule};+use libgfx_rust::{Color, FloatPoint, IntRect, ShouldAntiAlias, WindingRule};// Note: the color names reflect what the colors would be for a light theme,// not necessary the actual colors.@@ -106,16 +106,15 @@ fn centered_square_device_rect<O: Observer>(recorder.converter.enclosing_device_rect(rect)}-fn check_mark_path(checkbox_rect: IntRect) -> OwnedPath {- let mut builder = PathBuilder::new();- builder.move_to(72.0, 14.0);- builder.line_to(37.0, 64.0);- builder.line_to(19.0, 47.0);- builder.line_to(8.0, 58.0);- builder.line_to(40.0, 89.0);- builder.line_to(85.0, 24.0);- builder.close();- let path = builder.build();+fn check_mark_path(checkbox_rect: IntRect) -> Path {+ let mut path = Path::new();+ path.move_to(FloatPoint { x: 72.0, y: 14.0 });+ path.line_to(FloatPoint { x: 37.0, y: 64.0 });+ path.line_to(FloatPoint { x: 19.0, y: 47.0 });+ path.line_to(FloatPoint { x: 8.0, y: 58.0 });+ path.line_to(FloatPoint { x: 40.0, y: 89.0 });+ path.line_to(FloatPoint { x: 85.0, y: 24.0 });+ path.close();let checkmark_width = 100.0f32;let checkmark_height = 100.0f32;diff --git a/Libraries/LibWeb/Rust/src/painting/record/paint/outline.rs b/Libraries/LibWeb/Rust/src/painting/record/paint/outline.rsindex a3ec2214c37..52bc50a250f 100644--- a/Libraries/LibWeb/Rust/src/painting/record/paint/outline.rs+++ b/Libraries/LibWeb/Rust/src/painting/record/paint/outline.rs@@ -151,7 +151,7 @@ fn paint_focused_area_outline<O: Observer>(recorder: &mut PaintRecorder<'_, O>,if outline.image != paintable {return;}- let path = libgfx_rust::path::OwnedPath::from_serialized_bytes(&outline.path_bytes);+ let path = libgfx_rust::path::Path::from_serialized_bytes(&outline.path_bytes);let converter = recorder.converter;let image_rect = paintable_geometry::absolute_rect(recorder.source, paintable);let scale = recorder.inputs.device_pixels_per_css_pixel as f32;diff --git a/Libraries/LibWeb/Rust/src/painting/record/paint/overlay.rs b/Libraries/LibWeb/Rust/src/painting/record/paint/overlay.rsindex 392bb6c7181..96a7baa1e91 100644--- a/Libraries/LibWeb/Rust/src/painting/record/paint/overlay.rs+++ b/Libraries/LibWeb/Rust/src/painting/record/paint/overlay.rs@@ -154,12 +154,11 @@ fn paint_middle_button_scroll_indicator<O: Observer>(recorder: &mut PaintRecordelet x = device_origin.x as f32;let y = device_origin.y as f32;let mut paint_arrow = |p1: FloatPoint, p2: FloatPoint, p3: FloatPoint| {- let mut builder = libgfx_rust::path::PathBuilder::new();- builder.move_to(p1.x, p1.y);- builder.line_to(p2.x, p2.y);- builder.line_to(p3.x, p3.y);- builder.close();- let path = builder.build();+ let mut path = libgfx_rust::path::Path::new();+ path.move_to(p1);+ path.line_to(p2);+ path.line_to(p3);+ path.close();recorder.recorder.fill_path(FillPathParams {force_dark_role: ForceDarkRole::None,path: &path,diff --git a/Libraries/LibWeb/Rust/src/painting/record/paint/shadow.rs b/Libraries/LibWeb/Rust/src/painting/record/paint/shadow.rsindex 9fd4532c3c6..82e433730f3 100644--- a/Libraries/LibWeb/Rust/src/painting/record/paint/shadow.rs+++ b/Libraries/LibWeb/Rust/src/painting/record/paint/shadow.rs@@ -15,7 +15,7 @@ use crate::painting::corner_shape::{CornerShapes, Insets, border_contour_path};use crate::painting::display_list::commands::{PaintInnerBoxShadow, PaintOuterBoxShadow};use crate::painting::force_dark::ForceDarkRole;use crate::painting::record::PaintRecorder;-use libgfx_rust::path::OwnedPath;+use libgfx_rust::path::Path;use libgfx_rust::{Color, CornerRadii, FloatPoint, IntRect};fn add_spread_distance_to_border_radius(border_radius: &mut i32, spread_distance: i32) {@@ -184,8 +184,8 @@ fn paint_box_shadow_layers<O: Observer>(/// The shapes a box's shadows are cast from when they are not its rounded border and padding boxes: the shape outer/// shadows are cast from, and the shape whose outside casts inner shadows.struct ShadowShapes {- outer: OwnedPath,- inner: OwnedPath,+ outer: Path,+ inner: Path,}impl ShadowShapes {diff --git a/Libraries/LibWeb/Rust/src/painting/record/paint/text_decoration.rs b/Libraries/LibWeb/Rust/src/painting/record/paint/text_decoration.rsindex 863cb1d27b4..168f2f9a95b 100644--- a/Libraries/LibWeb/Rust/src/painting/record/paint/text_decoration.rs+++ b/Libraries/LibWeb/Rust/src/painting/record/paint/text_decoration.rs@@ -16,8 +16,8 @@ use crate::layout::node_data::NodeSlotId;use crate::painting::display_list::recorder::{PaintStyleOrColor, StrokePathParams};use crate::painting::force_dark::ForceDarkRole;use crate::painting::record::PaintRecorder;-use libgfx_rust::path::PathBuilder;-use libgfx_rust::{CapStyle, Color, IntPoint, JoinStyle, LineStyle, ShouldAntiAlias};+use libgfx_rust::path::Path;+use libgfx_rust::{CapStyle, Color, FloatPoint, IntPoint, JoinStyle, LineStyle, ShouldAntiAlias};#[derive(Clone, Copy, Default)]pub(crate) struct TextDecorationSet {@@ -345,12 +345,15 @@ fn compute_skip_ink_segments<O: Observer>(segments}-fn build_triangle_wave_path(from: IntPoint, to: IntPoint, amplitude: f32) -> PathBuilder {- let mut path = PathBuilder::new();+fn build_triangle_wave_path(from: IntPoint, to: IntPoint, amplitude: f32) -> Path {+ let mut path = Path::new();if from.y != to.y {return path;}- path.move_to(from.x as f32, from.y as f32);+ path.move_to(FloatPoint {+ x: from.x as f32,+ y: from.y as f32,+ });let wavelength = amplitude * 2.0;let half_wavelength = amplitude;@@ -361,51 +364,63 @@ fn build_triangle_wave_path(from: IntPoint, to: IntPoint, amplitude: f32) -> Patlet mut remaining = (to.x as f32 - position_x).abs();while remaining > wavelength {// Draw a whole wave- path.line_to(position_x + quarter_wavelength, position_y - quarter_wavelength);- path.line_to(- position_x + quarter_wavelength + half_wavelength,- position_y + quarter_wavelength,- );- path.line_to(position_x + wavelength, position_y);+ path.line_to(FloatPoint {+ x: position_x + quarter_wavelength,+ y: position_y - quarter_wavelength,+ });+ path.line_to(FloatPoint {+ x: position_x + quarter_wavelength + half_wavelength,+ y: position_y + quarter_wavelength,+ });+ path.line_to(FloatPoint {+ x: position_x + wavelength,+ y: position_y,+ });position_x += wavelength;remaining = (to.x as f32 - position_x).abs();}// Upif remaining > quarter_wavelength {- path.line_to(position_x + quarter_wavelength, position_y - quarter_wavelength);+ path.line_to(FloatPoint {+ x: position_x + quarter_wavelength,+ y: position_y - quarter_wavelength,+ });position_x += quarter_wavelength;remaining = (to.x as f32 - position_x).abs();} else if remaining >= 1.0 {let fraction = remaining / quarter_wavelength;- path.line_to(- position_x + (fraction * quarter_wavelength),- position_y - (fraction * quarter_wavelength),- );+ path.line_to(FloatPoint {+ x: position_x + (fraction * quarter_wavelength),+ y: position_y - (fraction * quarter_wavelength),+ });remaining = 0.0;}// Downif remaining > half_wavelength {- path.line_to(position_x + half_wavelength, position_y + quarter_wavelength);+ path.line_to(FloatPoint {+ x: position_x + half_wavelength,+ y: position_y + quarter_wavelength,+ });position_x += half_wavelength;remaining = (to.x as f32 - position_x).abs();} else if remaining >= 1.0 {let fraction = remaining / half_wavelength;- path.line_to(- position_x + (fraction * half_wavelength),- position_y - quarter_wavelength + (fraction * half_wavelength),- );+ path.line_to(FloatPoint {+ x: position_x + (fraction * half_wavelength),+ y: position_y - quarter_wavelength + (fraction * half_wavelength),+ });remaining = 0.0;}// Back to middleif remaining >= 1.0 {let fraction = remaining / quarter_wavelength;- path.line_to(- position_x + (fraction * quarter_wavelength),- position_y + ((1.0 - fraction) * quarter_wavelength),- );+ path.line_to(FloatPoint {+ x: position_x + (fraction * quarter_wavelength),+ y: position_y + ((1.0 - fraction) * quarter_wavelength),+ });}path}@@ -598,7 +613,7 @@ pub(crate) fn paint_decoration_lines<O: Observer>(x: segment.end_x,y: wave_y,};- let path = build_triangle_wave_path(from, to, amplitude as f32).build();+ let path = build_triangle_wave_path(from, to, amplitude as f32);recorder.recorder.stroke_path(StrokePathParams {force_dark_role: ForceDarkRole::Foreground,cap_style: CapStyle::Round,diff --git a/Libraries/LibWeb/Rust/src/painting/record/svg_resources.rs b/Libraries/LibWeb/Rust/src/painting/record/svg_resources.rsindex 3aa05ea75ae..890b1c35d82 100644--- a/Libraries/LibWeb/Rust/src/painting/record/svg_resources.rs+++ b/Libraries/LibWeb/Rust/src/painting/record/svg_resources.rs@@ -19,7 +19,7 @@ use crate::painting::visual_context::build::{};use crate::painting::visual_context::node_values::{MaskLayerPresenceEntry, mask_layer_presence};use crate::painting::visual_context::{ClipData, EffectNodeData, EffectNodeIndex, MaskData, MaskLayerOrigin};-use libgfx_rust::path::PathBuilder;+use libgfx_rust::path::Path;use libgfx_rust::{AffineTransform, CompositingAndBlendingOperator, FloatPoint, FloatRect, MaskKind, multiply_affine};#[derive(Clone, Copy, PartialEq, Eq)]@@ -70,7 +70,7 @@ fn transformed_rect_clip(transform: AffineTransform, rect: FloatRect, clip: &Cli)}-fn transformed_rect_path(transform: AffineTransform, rect: FloatRect) -> libgfx_rust::path::OwnedPath {+fn transformed_rect_path(transform: AffineTransform, rect: FloatRect) -> Path {let corners = [FloatPoint { x: rect.x, y: rect.y },FloatPoint {@@ -87,13 +87,13 @@ fn transformed_rect_path(transform: AffineTransform, rect: FloatRect) -> libgfx_},].map(|corner| transform.map_point(corner));- let mut path = PathBuilder::new();- path.move_to(corners[0].x, corners[0].y);+ let mut path = Path::new();+ path.move_to(corners[0]);for corner in &corners[1..] {- path.line_to(corner.x, corner.y);+ path.line_to(*corner);}path.close();- path.build()+ path}fn transformed_int_rect_clip(transform: AffineTransform, rect: libgfx_rust::IntRect) -> PendingInlineClip {diff --git a/Libraries/LibWeb/Rust/src/painting/visual_context/basic_shapes.rs b/Libraries/LibWeb/Rust/src/painting/visual_context/basic_shapes.rsindex 4c5d09fb398..2a97790c24a 100644--- a/Libraries/LibWeb/Rust/src/painting/visual_context/basic_shapes.rs+++ b/Libraries/LibWeb/Rust/src/painting/visual_context/basic_shapes.rs@@ -14,8 +14,8 @@ use crate::painting::border_radii::{BorderRadii, normalize_border_radii_data};use crate::painting::display_list::device_pixels::DevicePixelConverter;use crate::painting::paint_read::PaintRead;use crate::painting::{paintable_geometry, style_queries};-use libgfx_rust::WindingRule;-use libgfx_rust::path::{OwnedPath, PathBuilder};+use libgfx_rust::path::Path;+use libgfx_rust::{FloatPoint, FloatSize, WindingRule};pub(super) mod basic_shape_kind {pub const INSET: u8 = 0;@@ -245,14 +245,14 @@ pub(crate) fn position_resolved(position: Option<&StyleValueData>, rect: CssPixe)}-fn path_from_resolved_rect(top: f32, right: f32, bottom: f32, left: f32) -> OwnedPath {- let mut builder = PathBuilder::new();- builder.move_to(left, top);- builder.line_to(right, top);- builder.line_to(right, bottom);- builder.line_to(left, bottom);+fn path_from_resolved_rect(top: f32, right: f32, bottom: f32, left: f32) -> Path {+ let mut builder = Path::new();+ builder.move_to(FloatPoint { x: left, y: top });+ builder.line_to(FloatPoint { x: right, y: top });+ builder.line_to(FloatPoint { x: right, y: bottom });+ builder.line_to(FloatPoint { x: left, y: bottom });builder.close();- builder.build()+ builder}fn inset_to_path(@@ -262,7 +262,7 @@ fn inset_to_path(left: &RetainedStyleValueData,border_radius: &RetainedStyleValueData,reference_box: CssPixelRect,-) -> OwnedPath {+) -> Path {let mut resolved_top = to_px_or_zero(top, reference_box.height).to_float();let mut resolved_right = to_px_or_zero(right, reference_box.width).to_float();let mut resolved_bottom = to_px_or_zero(bottom, reference_box.height).to_float();@@ -315,46 +315,103 @@ fn inset_to_path(rounded_rect_path(top_edge, right_edge, bottom_edge, left_edge, radii)}-fn rounded_rect_path(- top_edge: f32,- right_edge: f32,- bottom_edge: f32,- left_edge: f32,- radii: BorderRadii,-) -> OwnedPath {+fn rounded_rect_path(top_edge: f32, right_edge: f32, bottom_edge: f32, left_edge: f32, radii: BorderRadii) -> Path {if !radii.has_any_radius() {return path_from_resolved_rect(top_edge, right_edge, bottom_edge, left_edge);}let [tl_h, tl_v, tr_h, tr_v, br_h, br_v, bl_h, bl_v] = radii.values.map(CssPixels::to_float);- let mut path = PathBuilder::new();- path.move_to(left_edge + tl_h, top_edge);- path.line_to(right_edge - tr_h, top_edge);+ let mut path = Path::new();+ path.move_to(FloatPoint {+ x: left_edge + tl_h,+ y: top_edge,+ });+ path.line_to(FloatPoint {+ x: right_edge - tr_h,+ y: top_edge,+ });if tr_h > 0.0 && tr_v > 0.0 {- path.elliptical_arc_to(right_edge, top_edge + tr_v, tr_h, tr_v, 0.0, false, true);+ path.elliptical_arc_to(+ FloatPoint {+ x: right_edge,+ y: top_edge + tr_v,+ },+ FloatSize {+ width: tr_h,+ height: tr_v,+ },+ 0.0,+ false,+ true,+ );}- path.line_to(right_edge, bottom_edge - br_v);+ path.line_to(FloatPoint {+ x: right_edge,+ y: bottom_edge - br_v,+ });if br_h > 0.0 && br_v > 0.0 {- path.elliptical_arc_to(right_edge - br_h, bottom_edge, br_h, br_v, 0.0, false, true);+ path.elliptical_arc_to(+ FloatPoint {+ x: right_edge - br_h,+ y: bottom_edge,+ },+ FloatSize {+ width: br_h,+ height: br_v,+ },+ 0.0,+ false,+ true,+ );}- path.line_to(left_edge + bl_h, bottom_edge);+ path.line_to(FloatPoint {+ x: left_edge + bl_h,+ y: bottom_edge,+ });if bl_h > 0.0 && bl_v > 0.0 {- path.elliptical_arc_to(left_edge, bottom_edge - bl_v, bl_h, bl_v, 0.0, false, true);+ path.elliptical_arc_to(+ FloatPoint {+ x: left_edge,+ y: bottom_edge - bl_v,+ },+ FloatSize {+ width: bl_h,+ height: bl_v,+ },+ 0.0,+ false,+ true,+ );}- path.line_to(left_edge, top_edge + tl_v);+ path.line_to(FloatPoint {+ x: left_edge,+ y: top_edge + tl_v,+ });if tl_h > 0.0 && tl_v > 0.0 {- path.elliptical_arc_to(left_edge + tl_h, top_edge, tl_h, tl_v, 0.0, false, true);+ path.elliptical_arc_to(+ FloatPoint {+ x: left_edge + tl_h,+ y: top_edge,+ },+ FloatSize {+ width: tl_h,+ height: tl_v,+ },+ 0.0,+ false,+ true,+ );}path.close();- path.build()+ path}fn circle_to_path(radius: &RetainedStyleValueData,position: &RetainedStyleValueData,reference_box: CssPixelRect,-) -> OwnedPath {+) -> Path {let translated_reference_box = CssPixelRect::new(CssPixels::from_raw(0),CssPixels::from_raw(0),@@ -370,20 +427,55 @@ fn circle_to_path(let center_y = center.y.to_float();// NB: The circle is traced in quarter arcs from its rightmost point, as SVG traces a <circle>, so that both// rasterize alike.- let mut path = PathBuilder::new();- path.move_to(center_x + radius_px, center_y);- path.arc_to(center_x, center_y + radius_px, radius_px, false, true);- path.arc_to(center_x - radius_px, center_y, radius_px, false, true);- path.arc_to(center_x, center_y - radius_px, radius_px, false, true);- path.arc_to(center_x + radius_px, center_y, radius_px, false, true);- path.build()+ let mut path = Path::new();+ path.move_to(FloatPoint {+ x: center_x + radius_px,+ y: center_y,+ });+ path.arc_to(+ FloatPoint {+ x: center_x,+ y: center_y + radius_px,+ },+ radius_px,+ false,+ true,+ );+ path.arc_to(+ FloatPoint {+ x: center_x - radius_px,+ y: center_y,+ },+ radius_px,+ false,+ true,+ );+ path.arc_to(+ FloatPoint {+ x: center_x,+ y: center_y - radius_px,+ },+ radius_px,+ false,+ true,+ );+ path.arc_to(+ FloatPoint {+ x: center_x + radius_px,+ y: center_y,+ },+ radius_px,+ false,+ true,+ );+ path}fn ellipse_to_path(radius: &RetainedStyleValueData,position: &RetainedStyleValueData,reference_box: CssPixelRect,-) -> OwnedPath {+) -> Path {let translated_reference_box = CssPixelRect::new(CssPixels::from_raw(0),CssPixels::from_raw(0),@@ -399,19 +491,62 @@ fn ellipse_to_path(let center_y = center.y.to_float();let radius_x = size.width.to_float();let radius_y = size.height.to_float();+ let radii = FloatSize {+ width: radius_x,+ height: radius_y,+ };// NB: The ellipse is traced in quarter arcs from its rightmost point, as SVG traces an <ellipse>, so that both// rasterize alike.- let mut path = PathBuilder::new();- path.move_to(center_x + radius_x, center_y);- path.elliptical_arc_to(center_x, center_y + radius_y, radius_x, radius_y, 0.0, false, true);- path.elliptical_arc_to(center_x - radius_x, center_y, radius_x, radius_y, 0.0, false, true);- path.elliptical_arc_to(center_x, center_y - radius_y, radius_x, radius_y, 0.0, false, true);- path.elliptical_arc_to(center_x + radius_x, center_y, radius_x, radius_y, 0.0, false, true);- path.build()+ let mut path = Path::new();+ path.move_to(FloatPoint {+ x: center_x + radius_x,+ y: center_y,+ });+ path.elliptical_arc_to(+ FloatPoint {+ x: center_x,+ y: center_y + radius_y,+ },+ radii,+ 0.0,+ false,+ true,+ );+ path.elliptical_arc_to(+ FloatPoint {+ x: center_x - radius_x,+ y: center_y,+ },+ radii,+ 0.0,+ false,+ true,+ );+ path.elliptical_arc_to(+ FloatPoint {+ x: center_x,+ y: center_y - radius_y,+ },+ radii,+ 0.0,+ false,+ true,+ );+ path.elliptical_arc_to(+ FloatPoint {+ x: center_x + radius_x,+ y: center_y,+ },+ radii,+ 0.0,+ false,+ true,+ );+ path}-fn polygon_to_path(points: &crate::css::style_value::RetainedShapePointList, reference_box: CssPixelRect) -> OwnedPath {- let mut path = PathBuilder::new();+fn polygon_to_path(points: &crate::css::style_value::RetainedShapePointList, reference_box: CssPixelRect) -> Path {+ let mut path = Path::new();let mut first = true;for point in points.as_slice() {let [x, y] = point.values();@@ -422,14 +557,20 @@ fn polygon_to_path(points: &crate::css::style_value::RetainedShapePointList, ref.to_px(reference_box.height).to_float();if first {- path.move_to(resolved_x, resolved_y);+ path.move_to(FloatPoint {+ x: resolved_x,+ y: resolved_y,+ });} else {- path.line_to(resolved_x, resolved_y);+ path.line_to(FloatPoint {+ x: resolved_x,+ y: resolved_y,+ });}first = false;}path.close();- path.build()+ path}/// One coordinate of a shape() point: a length-percentage, or a position edge holding one.@@ -447,14 +588,14 @@ pub(crate) fn shape_to_path(points: &[crate::css::style_value::RetainedShapePoint],commands: &[crate::css::style_value::ShapeCommand],reference_box: CssPixelRect,-) -> OwnedPath {+) -> Path {use crate::css::style_value::{ShapeCommandKind, ShapeControlPointAnchor};let (width, height) = (reference_box.width, reference_box.height);let resolve = |point: &crate::css::style_value::RetainedShapePoint| {let [x, y] = point.values();(shape_coordinate(x, width), shape_coordinate(y, height))};- let mut path = PathBuilder::new();+ let mut path = Path::new();let mut points = points.iter();let mut current = (0.0f32, 0.0f32);let mut subpath_start = current;@@ -474,11 +615,17 @@ pub(crate) fn shape_to_path(ShapeCommandKind::From | ShapeCommandKind::Move => {current = end_point(resolve(points.next().unwrap()));subpath_start = current;- path.move_to(current.0, current.1);+ path.move_to(FloatPoint {+ x: current.0,+ y: current.1,+ });}ShapeCommandKind::Line => {current = end_point(resolve(points.next().unwrap()));- path.line_to(current.0, current.1);+ path.line_to(FloatPoint {+ x: current.0,+ y: current.1,+ });}ShapeCommandKind::HorizontalLine => {let (x, _) = resolve(points.next().unwrap());@@ -487,7 +634,10 @@ pub(crate) fn shape_to_path(} else {(x, start.1)};- path.line_to(current.0, current.1);+ path.line_to(FloatPoint {+ x: current.0,+ y: current.1,+ });}ShapeCommandKind::VerticalLine => {let (_, y) = resolve(points.next().unwrap());@@ -496,7 +646,10 @@ pub(crate) fn shape_to_path(} else {(start.0, y)};- path.line_to(current.0, current.1);+ path.line_to(FloatPoint {+ x: current.0,+ y: current.1,+ });}ShapeCommandKind::Curve | ShapeCommandKind::Smooth => {let end = end_point(resolve(points.next().unwrap()));@@ -518,8 +671,18 @@ pub(crate) fn shape_to_path(control_points.insert(0, reflected);}match control_points[..] {- [only] => path.quadratic_bezier_curve_to(only.0, only.1, end.0, end.1),- [first, second] => path.cubic_bezier_curve_to(first.0, first.1, second.0, second.1, end.0, end.1),+ [only] => path.quadratic_bezier_curve_to(+ FloatPoint { x: only.0, y: only.1 },+ FloatPoint { x: end.0, y: end.1 },+ ),+ [first, second] => path.cubic_bezier_curve_to(+ FloatPoint { x: first.0, y: first.1 },+ FloatPoint {+ x: second.0,+ y: second.1,+ },+ FloatPoint { x: end.0, y: end.1 },+ ),_ => unreachable!("a curve has one or two control points"),}control_point = control_points.last().copied();@@ -544,10 +707,11 @@ pub(crate) fn shape_to_path(crate::css::table_group_builder::angle_degrees(points.next().unwrap().values()[0].data()).unwrap_or(0.0);path.elliptical_arc_to(- end.0,- end.1,- radius_x.abs(),- radius_y.abs(),+ FloatPoint { x: end.0, y: end.1 },+ FloatSize {+ width: radius_x.abs(),+ height: radius_y.abs(),+ },rotation_degrees.to_radians() as f32,command.arc_large,command.arc_clockwise,@@ -561,7 +725,7 @@ pub(crate) fn shape_to_path(}previous_control_point = control_point;}- path.build()+ path}/// The device-space path of a computed basic shape whose reference box is `reference_box`, and its fill rule.@@ -569,7 +733,7 @@ pub(crate) fn basic_shape_device_path(shape: &BasicShapeData,reference_box: CssPixelRect,pixel_ratio: f64,-) -> (OwnedPath, WindingRule) {+) -> (Path, WindingRule) {let BasicShapeData {kind,v0,@@ -610,7 +774,7 @@ pub(crate) fn basic_shape_device_path(}/// The device-space path of a path whose coordinates are relative to the origin of `reference_box`.-fn device_path_from_local_path(path: OwnedPath, reference_box: CssPixelRect, pixel_ratio: f64) -> OwnedPath {+fn device_path_from_local_path(path: Path, reference_box: CssPixelRect, pixel_ratio: f64) -> Path {let translated_path = path.copy_transformed([1.0,0.0,@@ -703,7 +867,7 @@ fn geometry_box_path(style: crate::css::computed_value_views::ComputedValuesView<'_>,geometry_box: u16,reference_box: CssPixelRect,-) -> OwnedPath {+) -> Path {let border = [style.border_top_width(),style.border_right_width(),@@ -746,7 +910,7 @@ pub(crate) fn compute_basic_shape_clip_path_data(layout_arena: &impl PaintRead,slot: NodeSlotId,pixel_ratio: f64,-) -> Option<(OwnedPath, libgfx_rust::IntRect, WindingRule)> {+) -> Option<(Path, libgfx_rust::IntRect, WindingRule)> {let node = slot;let style = layout_arena.node_style_if_live(node)?;let clip_path = style_queries::handle_value(&style.mask().clip_path)?;diff --git a/Libraries/LibWeb/Rust/src/painting/visual_context/build.rs b/Libraries/LibWeb/Rust/src/painting/visual_context/build.rsindex 75b1bbf38b4..490655bd957 100644--- a/Libraries/LibWeb/Rust/src/painting/visual_context/build.rs+++ b/Libraries/LibWeb/Rust/src/painting/visual_context/build.rs@@ -65,7 +65,7 @@ pub(crate) struct BoxFacts {pub overflow_clip_contour: Option<ClipPathData>,pub css_clip: Option<ClipData>,pub line_clamp_float_clip: Option<ClipData>,- pub clip_path: Option<(std::sync::Arc<libgfx_rust::path::OwnedPath>, IntRect, WindingRule)>,+ pub clip_path: Option<(std::sync::Arc<libgfx_rust::path::Path>, IntRect, WindingRule)>,pub mask_layers: Vec<MaskData>,pub establishes_absolute_containing_block: bool,pub establishes_fixed_containing_block: bool,diff --git a/Libraries/LibWeb/Rust/src/painting/visual_context/offset_transform.rs b/Libraries/LibWeb/Rust/src/painting/visual_context/offset_transform.rsindex 27962a89715..184181732c3 100644--- a/Libraries/LibWeb/Rust/src/painting/visual_context/offset_transform.rs+++ b/Libraries/LibWeb/Rust/src/painting/visual_context/offset_transform.rs@@ -14,7 +14,7 @@ use crate::css::style_value::{BasicShapeData, OwnedBasicShapeData, RetainedStyleuse crate::layout::node_data::NodeSlotId;use crate::painting::paint_read::PaintRead;use crate::painting::{paintable_geometry, style_queries};-use libgfx_rust::{FloatMatrix4x4, rotation_matrix, translation_matrix};+use libgfx_rust::{FloatMatrix4x4, FloatPoint, rotation_matrix, translation_matrix};use super::basic_shapes::{basic_shape_kind, position_resolved};@@ -299,10 +299,10 @@ pub(crate) fn compute_offset_transform(// <url>: If the URL does not reference a shape element this behaves as path("m 0 0") instead.// FIXME: Use the equivalent path of a referenced SVG shape element.Some(_) => {- let mut builder = libgfx_rust::path::PathBuilder::new();- builder.move_to(0.0, 0.0);+ let mut builder = libgfx_rust::path::Path::new();+ builder.move_to(FloatPoint { x: 0.0, y: 0.0 });let start = starting_position.unwrap_or((border_box.x.to_double(), border_box.y.to_double()));- (builder.build(), false, start)+ (builder, false, start)}};is_closed_loop = closed;diff --git a/Libraries/LibWeb/Rust/src/svg/path_parser.rs b/Libraries/LibWeb/Rust/src/svg/path_parser.rsindex 9b916af46a5..9560d8cc472 100644--- a/Libraries/LibWeb/Rust/src/svg/path_parser.rs+++ b/Libraries/LibWeb/Rust/src/svg/path_parser.rs@@ -7,7 +7,8 @@use super::parser::{Input, Parser as Lexer};use crate::css::css_tokenizer::TokenizerInput;use crate::css::ffi_support::FfiUtf16View;-use libgfx_rust::path::{OwnedPath, PathBuilder};+use libgfx_rust::path::Path;+use libgfx_rust::{FloatPoint, FloatSize};use std::ffi::c_void;use std::fmt::Write;@@ -147,6 +148,10 @@ pub struct ParsedPath {instructions: Vec<PathInstruction>,}+fn float_point([x, y]: [f32; 2]) -> FloatPoint {+ FloatPoint { x, y }+}+impl ParsedPath {pub(crate) fn normalize_for_serialization(&mut self) {let normalize = |values: &mut [f32]| {@@ -283,8 +288,8 @@ impl ParsedPath {}}- pub(crate) fn to_gfx_path(&self) -> OwnedPath {- let mut path = PathBuilder::new();+ pub(crate) fn to_gfx_path(&self) -> Path {+ let mut path = Path::new();let mut current_point = [0.0, 0.0];let mut subpath_start = [0.0, 0.0];let mut previous_control_point = None;@@ -295,7 +300,7 @@ impl ParsedPath {let point = match *instruction {PathInstruction::MoveTo { absolute, point } => {let point = if absolute { point } else { relative_to_current(point) };- path.move_to(point[0], point[1]);+ path.move_to(float_point(point));subpath_start = point;point}@@ -305,17 +310,17 @@ impl ParsedPath {}PathInstruction::LineTo { absolute, point } => {let point = if absolute { point } else { relative_to_current(point) };- path.line_to(point[0], point[1]);+ path.line_to(float_point(point));point}PathInstruction::HorizontalLineTo { absolute, x } => {let point = [if absolute { x } else { current_point[0] + x }, current_point[1]];- path.line_to(point[0], point[1]);+ path.line_to(float_point(point));point}PathInstruction::VerticalLineTo { absolute, y } => {let point = [current_point[0], if absolute { y } else { current_point[1] + y }];- path.line_to(point[0], point[1]);+ path.line_to(float_point(point));point}PathInstruction::CurveTo {@@ -336,12 +341,9 @@ impl ParsedPath {};let point = if absolute { point } else { relative_to_current(point) };path.cubic_bezier_curve_to(- control_point_1[0],- control_point_1[1],- control_point_2[0],- control_point_2[1],- point[0],- point[1],+ float_point(control_point_1),+ float_point(control_point_2),+ float_point(point),);previous_control_point = Some(control_point_2);point@@ -370,12 +372,9 @@ impl ParsedPath {};let point = if absolute { point } else { relative_to_current(point) };path.cubic_bezier_curve_to(- control_point_1[0],- control_point_1[1],- control_point_2[0],- control_point_2[1],- point[0],- point[1],+ float_point(control_point_1),+ float_point(control_point_2),+ float_point(point),);previous_control_point = Some(control_point_2);point@@ -391,7 +390,7 @@ impl ParsedPath {relative_to_current(control_point)};let point = if absolute { point } else { relative_to_current(point) };- path.quadratic_bezier_curve_to(control_point[0], control_point[1], point[0], point[1]);+ path.quadratic_bezier_curve_to(float_point(control_point), float_point(point));previous_control_point = Some(control_point);point}@@ -412,7 +411,7 @@ impl ParsedPath {2.0 * current_point[1] - reflected_from[1],];let point = if absolute { point } else { relative_to_current(point) };- path.quadratic_bezier_curve_to(control_point[0], control_point[1], point[0], point[1]);+ path.quadratic_bezier_curve_to(float_point(control_point), float_point(point));previous_control_point = Some(control_point);point}@@ -426,10 +425,11 @@ impl ParsedPath {} => {let point = if absolute { point } else { relative_to_current(point) };path.elliptical_arc_to(- point[0],- point[1],- radius[0],- radius[1],+ float_point(point),+ FloatSize {+ width: radius[0],+ height: radius[1],+ },(f64::from(x_axis_rotation).to_radians()) as f32,large_arc,sweep,@@ -451,7 +451,7 @@ impl ParsedPath {last_instruction = Some(*instruction);}- path.build()+ path}/// The same path with each relative command replaced by its absolute equivalent, or `None` when the path has@@ -1322,7 +1322,7 @@ pub(super) fn svg_input(view: FfiUtf16View<'_>) -> Option<Input<'_>> {/// The path that the path data describes, as SVG parses it, with its error recovery: what parsing a string of path/// data gives Path2D's constructor, which is an empty path where the data describes none.-pub fn gfx_path_from_path_data(input: ak::Utf16StringUnits<'_>) -> OwnedPath {+pub fn gfx_path_from_path_data(input: ak::Utf16StringUnits<'_>) -> Path {let input = match input {ak::Utf16StringUnits::Ascii(units) => Input::Ascii(units),ak::Utf16StringUnits::Utf16(units) => Input::Utf16(units),