From 6ef6df34072e09bbd15e8ce7c2b889637695f75c Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 06:45:32 -0800 Subject: [PATCH] Scripts: round artboard rows as main's New Document test expects, and drop pathItems= from the host table Cause of the CI failures on 212090fd7a2: - main's dialogs::new_document test a_presets_rows_reach_the_document_create_makes sets artboardLayout.rows to 3.6 and expects 4, but this branch refused a rows value that was not a whole number. rows now rounds like columns and is still refused outside 1 to 1000. - script_host_vs_scriptcheck listed Document.prototype.pathItems=, the setter of main's placeholder. This branch makes pathItems a read-only collection, like pageItems, so the row goes. --- crates/engine/src/cmd/newdoc.rs | 5 +++-- crates/engine/src/tests/newdoc.rs | 2 +- crates/engine/src/tests/script_dom.rs | 2 +- crates/engine/tests/it/script_host_vs_scriptcheck.rs | 2 +- docs/mcp.md | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/crates/engine/src/cmd/newdoc.rs b/crates/engine/src/cmd/newdoc.rs index e4355bf934..21f3661c89 100644 --- a/crates/engine/src/cmd/newdoc.rs +++ b/crates/engine/src/cmd/newdoc.rs @@ -395,9 +395,10 @@ impl DocSettings { "rows" => { self.rows = v .as_f64() - .filter(|r| r.fract() == 0.0 && (1.0..=MAX_ARTBOARDS as f64).contains(r)) + .map(f64::round) + .filter(|r| (1.0..=MAX_ARTBOARDS as f64).contains(r)) .map(|r| r as u32) - .ok_or_else(|| bad(cmd, format!("artboardLayout.rows must be a whole number from 1 to {MAX_ARTBOARDS}")))? + .ok_or_else(|| bad(cmd, format!("artboardLayout.rows must be from 1 to {MAX_ARTBOARDS}")))? } "spacing" => { self.spacing = v diff --git a/crates/engine/src/tests/newdoc.rs b/crates/engine/src/tests/newdoc.rs index cd8feca36d..ad2711558e 100644 --- a/crates/engine/src/tests/newdoc.rs +++ b/crates/engine/src/tests/newdoc.rs @@ -161,7 +161,7 @@ fn ppi_overprint_preview_and_bad_params() { json!({"artboardLayout": {"layout": "spiral"}}), json!({"artboardLayout": {"columns": 0}}), json!({"artboardLayout": {"rows": 0}}), - json!({"artboardLayout": {"layout": "gridByColumn", "rows": 1.5}}), + json!({"artboardLayout": {"layout": "gridByColumn", "rows": 0.4}}), json!({"artboardLayout": {"layout": "gridByColumn", "rows": 1001}}), json!({"artboardLayout": {"tiles": 2}}), json!({"units": "furlongs"}), diff --git a/crates/engine/src/tests/script_dom.rs b/crates/engine/src/tests/script_dom.rs index 5d6b14da3b..03cab27e93 100644 --- a/crates/engine/src/tests/script_dom.rs +++ b/crates/engine/src/tests/script_dom.rs @@ -1017,7 +1017,7 @@ fn file_new_takes_the_rows_of_a_grid_by_column() { let (plain, spaced) = (plain.with_params(&to_row, "file.new").unwrap(), spaced.with_params(&to_row, "file.new").unwrap()); assert_eq!(plain.grid_columns(), spaced.grid_columns()); let e = s.execute("file.new", &json!({"artboardLayout": {"layout": "gridByColumn", "rows": 0}})).unwrap_err().to_string(); - assert!(e.contains("rows must be a whole number from 1 to 1000"), "{e}"); + assert!(e.contains("rows must be from 1 to 1000"), "{e}"); for layout in ["gridByRow", "row", "column"] { let e = s.execute("file.new", &json!({"artboardLayout": {"layout": layout, "rows": 2}})).unwrap_err().to_string(); assert!(e.contains("rows needs the gridByColumn layout"), "{layout}: {e}"); diff --git a/crates/engine/tests/it/script_host_vs_scriptcheck.rs b/crates/engine/tests/it/script_host_vs_scriptcheck.rs index 513f27ccf9..d8b6c989d5 100644 --- a/crates/engine/tests/it/script_host_vs_scriptcheck.rs +++ b/crates/engine/tests/it/script_host_vs_scriptcheck.rs @@ -113,7 +113,7 @@ const INSIDE: &[(&str, &str)] = &[ defaultStrokeDashOffset= defaultStrokeDashes defaultStrokeDashes= defaultStrokeJoin defaultStrokeJoin= \ defaultStrokeMiterLimit defaultStrokeMiterLimit= defaultStrokeOverprint defaultStrokeOverprint= \ defaultStrokeWidth defaultStrokeWidth= defaultStroked defaultStroked= documentColorSpace groupItems \ - groupItems= height layers layers= name pageItems paragraphStyles parent pathItems pathItems= rulerOrigin \ + groupItems= height layers layers= name pageItems paragraphStyles parent pathItems rulerOrigin \ rulerOrigin= rulerUnits saveAs saveAs= scaleFactor selection selection= stories swatches swatches= \ symbols symbols= tags textFrames toString typename views width", ), diff --git a/docs/mcp.md b/docs/mcp.md index 823adc251f..7ed0eebae6 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -10497,7 +10497,7 @@ and goes back to Document Setup, whose OK runs `document.setup`; its Cancel goes `file.new` takes everything New Document sets: `preset` (a name from `file.newPresets`), `name`, `width`/`height` (points, or lengths such as `"210 mm"`), `units`, `orientation`, `artboards` with `artboardLayout {layout, columns, -rows, spacing, rightToLeft}` (`rows`, a whole number from 1 to 1000, gives a `gridByColumn` layout that many rows, at most one for each artboard, in place of `columns`, and is +rows, spacing, rightToLeft}` (`rows`, 1 to 1000 and rounded to a whole number, gives a `gridByColumn` layout that many rows, at most one for each artboard, in place of `columns`, and is an error with another layout; a preset keeps the rows, and `file.newPresets` lists them as set even when there are fewer artboards, until `columns` without `rows`, or another layout, is given; New Document's Columns shows the columns the rows give the current number of artboards, and New Document drops the rows when Columns or the layout changes),