fix(svg): prevent extreme arcs from stalling layout

Pin the shared SVG parser fix from lexmount/svgtypes#1 and guard
the CLI layout demand with an external process deadline.
This commit is contained in:
ldm0
2026-11-15 17:12:37 +08:00
committed by Donough Liu
parent 342b83fd6e
commit 080c3fc2cb
3 changed files with 26 additions and 2 deletions
Generated
+1 -1
View File
@@ -5763,7 +5763,7 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
[[package]]
name = "svgtypes"
version = "0.16.1"
source = "git+https://github.com/lexmount/svgtypes?branch=moli#e96c74ca675d56b65de71b4ce2b2d87f927bf79c"
source = "git+https://github.com/lexmount/svgtypes?rev=520374d714d69f8e2dc93c81a9d6be559ecde3ff#520374d714d69f8e2dc93c81a9d6be559ecde3ff"
dependencies = [
"color",
"kurbo",
+1 -1
View File
@@ -128,7 +128,7 @@ stylo_atoms = { git = "https://github.com/lexmount/stylo", rev = "5e853c2255715a
stylo_dom = { git = "https://github.com/lexmount/stylo", rev = "5e853c2255715a825e3f9ea043d3998a55377e77" }
stylo_static_prefs = { git = "https://github.com/lexmount/stylo", rev = "5e853c2255715a825e3f9ea043d3998a55377e77" }
stylo_traits = { git = "https://github.com/lexmount/stylo", rev = "5e853c2255715a825e3f9ea043d3998a55377e77" }
svgtypes = { git = "https://github.com/lexmount/svgtypes", branch = "moli" }
svgtypes = { git = "https://github.com/lexmount/svgtypes", rev = "520374d714d69f8e2dc93c81a9d6be559ecde3ff" }
# Preserve original SVG selector inputs and collect unclipped source geometry.
usvg = { git = "https://github.com/lexmount/resvg", rev = "614aaf4d21ca03a4773f1e4d07c6a404407589a2" }
taffy = { git = "https://github.com/ldm0/taffy", rev = "0a337871fa44db7d48571b06668f92737eefa8c2" }
@@ -35,6 +35,30 @@ fn run_layout(html: &str, expression: &str, fonts: bool) -> Result<Value> {
serde_json::from_slice(&output.stdout).context("layout probe must return JSON")
}
#[test]
fn extreme_svg_arc_layout_terminates_without_a_screenshot() -> Result<()> {
// Publishing layout used to expand this one arc into millions of cubics,
// then drain them with quadratic buffer shifts. The external process limit
// also bounds the test if the CLI's readiness timeout cannot interrupt it.
for doctype in ["<!doctype html>", ""] {
let control = run_layout(
&format!("{doctype}<svg width=300 height=300></svg>"),
"document.body.offsetHeight",
false,
)?;
let value = run_layout(
&format!(
"{doctype}<svg width=300 height=300><path d=\"M0 0 A 743 -417 0 1 1 7 1e38\"/></svg>"
),
"({bodyHeight:document.body.offsetHeight,svgHeight:document.querySelector('svg').getBoundingClientRect().height})",
false,
)?;
assert_eq!(value["bodyHeight"], control, "{doctype}");
assert_eq!(value["svgHeight"], 300);
}
Ok(())
}
#[test]
fn fractional_grid_track_limits_terminate_with_a_finite_item_width() -> Result<()> {
// This formerly loops in track growth even after the CLI's own timeout.