From bbfacd8f624a751f11e8bc614ddf27dd675f7388 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A2n=20Minh=20Ngh=C4=A9a?= Date: Tue, 17 Nov 2026 17:54:39 +0700 Subject: [PATCH] #6438: a right-to-left table's move handle sits at its top-right corner, and dragging it moves the whole table (#6477) --- crates/engine/src/cmd/table_mouse.rs | 39 ++++++----- crates/engine/src/cmd/table_mouse/tests.rs | 73 +++++++++++++++++++++ crates/engine/src/cmd/table_resize.rs | 59 ++++++++++++++--- crates/engine/src/cmd/table_resize/tests.rs | 26 ++++++++ 4 files changed, 171 insertions(+), 26 deletions(-) diff --git a/crates/engine/src/cmd/table_mouse.rs b/crates/engine/src/cmd/table_mouse.rs index 50fff12882..98b083ea3f 100644 --- a/crates/engine/src/cmd/table_mouse.rs +++ b/crates/engine/src/cmd/table_mouse.rs @@ -2,10 +2,11 @@ //! column, left of a row and along a cell's left edge inside it select the column, row or cell, //! and a drag from one selects every one up to the pointer; insert buttons left of a row border //! and above a column border add a row or column there; the move handle just past the table's -//! top-left corner selects the table or, dragged, moves it (the table then floats where it's -//! dropped, the text wrapping around it, as in Word); a double-click on a column border fits the -//! column left of it to its contents. The app sends each click or finished drag here in page -//! points, so each is one command (one undo step when it changes the document). +//! top-left corner (top-right in a right-to-left table) selects the table or, dragged, moves it +//! (the table then floats where it's dropped, the text wrapping around it, as in Word); a +//! double-click on a column border fits the column left of it to its contents. The app sends +//! each click or finished drag here in page points, so each is one command (one undo step when +//! it changes the document). use std::collections::BTreeMap; @@ -34,7 +35,7 @@ const INSERT_REACH: f32 = 3.5; const INSERT_OUT: f32 = 14.0; /// An insert button's centre sits this far out from the table's edge (points). const BUTTON_OUT: f32 = 8.0; -/// The move handle's side and its gap from the table's top-left corner (points). +/// The move handle's side and its gap from the table's top corner (points). const HANDLE: f32 = 8.0; const HANDLE_GAP: f32 = 2.0; /// The farthest a drag moves a table (points; Word's 22 inches). @@ -44,14 +45,14 @@ pub fn specs() -> Vec { vec![ CommandSpec::new("table.selectAt", "Select Table Cells by Clicking", "Table Layout › Table › Select", select_at) .params( - r#"{"page": n, "x": pt, "y": pt, "toX"?: pt, "toY"?: pt, "reach"?: pt, "extend"?: bool, "anchorRow"?: n} (a click in page points, 0-based page, on a selection area of a table in the caret's story: just above a column selects the column, left of a row the row, along a cell's left edge inside it the cell, the move handle past the top-left corner the table; with toX/toY (a drag) every column, row or cell from there to that point; the page margin beside a table (its leading side: right for a right-to-left table) is a row area too, and `extend` (Shift+click) on one takes the rows from the selected ones' anchor, or from row `anchorRow` (0-based) when given, so a drag keeps its press's anchor. `reach` (default 3) is the column borders' resize reach, which the cell areas keep clear of.)"#, + r#"{"page": n, "x": pt, "y": pt, "toX"?: pt, "toY"?: pt, "reach"?: pt, "extend"?: bool, "anchorRow"?: n} (a click in page points, 0-based page, on a selection area of a table in the caret's story: just above a column selects the column, left of a row the row, along a cell's left edge inside it the cell, the move handle past the top-left corner (top-right in a right-to-left table) the table; with toX/toY (a drag) every column, row or cell from there to that point; the page margin beside a table (its leading side: right for a right-to-left table) is a row area too, and `extend` (Shift+click) on one takes the rows from the selected ones' anchor, or from row `anchorRow` (0-based) when given, so a drag keeps its press's anchor. `reach` (default 3) is the column borders' resize reach, which the cell areas keep clear of.)"#, ) .pure(), CommandSpec::new("table.insertAt", "Insert Row or Column by Clicking", "Table Layout › Rows & Columns", insert_at).params( r#"{"page": n, "x": pt, "y": pt, "reach"?: pt} (a click on a table's insert button: left of a row border adds a row there, above a column border a column; the new row or column is selected, as in Word)"#, ), CommandSpec::new("table.moveDrag", "Move Table by Dragging", "Table Layout › Table", move_drag).params( - r#"{"page": n, "x": pt, "y": pt, "toX": pt, "toY": pt, "reach"?: pt} (a drag from the move handle past a table's top-left corner: the table floats where it's dropped, the text wrapping around it; tables in the main text only)"#, + r#"{"page": n, "x": pt, "y": pt, "toX": pt, "toY": pt, "reach"?: pt} (a drag from the move handle past a table's top-left corner (top-right in a right-to-left table): the table floats where it's dropped, the text wrapping around it; tables in the main text only)"#, ), CommandSpec::new("table.fitColumn", "AutoFit Column by Double-Clicking", "Table Layout › Cell Size", fit_column).params( r#"{"page": n, "x": pt, "y": pt, "reach"?: pt} (a double-click on a column border: the column left of it fits its contents and the columns right of it keep their widths, moving with the border, so the table narrows or widens (up to the right margin), as in Word)"#, @@ -67,7 +68,8 @@ pub enum Spot { /// The insert button of horizontal border `n` (0 = the table's top, `n` = the bottom of row /// `n - 1`). InsertRow(usize), - /// The insert button of grid line `n` (0 = the table's left edge). + /// The insert button of grid line `n` (0 = the table's left edge, or a right-to-left table's + /// right edge). InsertColumn(usize), /// The selection area above grid column `n`. Column(usize), @@ -92,9 +94,11 @@ pub struct InsertMark { pub to: (f32, f32), } -/// The move handle's square (page points), just past the table's top-left corner. +/// The move handle's square (page points), just past the table's top-left corner, or its +/// top-right one when the table runs right to left (#6438). pub fn handle(geom: &ResizeTarget) -> Rect { - Rect::new(geom.left() - HANDLE_GAP - HANDLE, geom.top() - HANDLE_GAP - HANDLE, HANDLE, HANDLE) + let x = if geom.rtl { geom.right() + HANDLE_GAP } else { geom.left() - HANDLE_GAP - HANDLE }; + Rect::new(x, geom.top() - HANDLE_GAP - HANDLE, HANDLE, HANDLE) } /// Whether the table's first row is on this page (its move handle is there). @@ -116,10 +120,12 @@ fn nearest(lines: impl Iterator, at: f32, reach: f32) -> Op lines.map(|(i, v)| (i, (at - v).abs())).filter(|(_, d)| *d <= reach).min_by(|a, b| a.1.total_cmp(&b.1)).map(|(i, _)| i) } -/// The grid column at page x `x` (the first or the last beyond the table). +/// The grid column at page x `x` (the first or the last beyond the table); a right-to-left +/// table's count from the right. fn column_at(geom: &ResizeTarget, x: f32) -> usize { let n = geom.cols.len().saturating_sub(1); - geom.cols.iter().skip(1).take_while(|cx| **cx <= x).count().min(n.saturating_sub(1)) + let drawn = geom.cols.iter().skip(1).take_while(|cx| **cx <= x).count().min(n.saturating_sub(1)); + if geom.rtl { n.saturating_sub(1).saturating_sub(drawn) } else { drawn } } /// The drawn row at page y `y` (the first or the last beyond the table). @@ -140,7 +146,7 @@ fn spot_in(geom: &ResizeTarget, cells: &[&CellBox], x: f32, y: f32, reach: f32, if y < top && let Some(line) = nearest(lines, x, INSERT_REACH) { - return Some(Spot::InsertColumn(line)); + return Some(Spot::InsertColumn(geom.grid_line(line))); } if y >= top - COLUMN_ABOVE && x >= left && x <= right { return Some(Spot::Column(column_at(geom, x))); @@ -230,7 +236,8 @@ pub fn handle_table(l: &DocLayout, doc: &Document, story: StoryRef, page: usize, .into_iter() .filter(|g| { let h = handle(g); - g.story == story && starts_here(g) && x >= h.x - pad && x <= g.right() && y >= h.y - pad && y <= g.bottom() + let (x0, x1) = if g.rtl { (g.left(), h.right() + pad) } else { (h.x - pad, g.right()) }; + g.story == story && starts_here(g) && x >= x0 && x <= x1 && y >= h.y - pad && y <= g.bottom() }) .max_by_key(|g| g.table.0.len()) } @@ -256,7 +263,7 @@ pub fn caret_handles(l: &DocLayout, doc: &Document, story: StoryRef, table: &Pat let Some(g) = table_resize::tables_on(l, doc, page).into_iter().find(|g| g.story == story && g.table == *table) else { return (None, None); }; - (first.then(|| handle(&g)), last.then(|| g.handle())) + (first.then(|| handle(&g)), (last && g.resizable_columns()).then(|| g.handle())) } /// The insert button a target is, if it's one. @@ -269,7 +276,7 @@ pub fn insert_mark(t: &Target) -> Option { Some(InsertMark { center: (g.left() - BUTTON_OUT, y), from: (g.left(), y), to: (g.right(), y) }) } Spot::InsertColumn(line) => { - let x = g.cols.get(line).copied()?; + let x = g.cols.get(g.grid_line(line)).copied()?; Some(InsertMark { center: (x, g.top() - BUTTON_OUT), from: (x, g.top()), to: (x, g.bottom()) }) } _ => None, diff --git a/crates/engine/src/cmd/table_mouse/tests.rs b/crates/engine/src/cmd/table_mouse/tests.rs index bdbd7e66c3..488b0fd995 100644 --- a/crates/engine/src/cmd/table_mouse/tests.rs +++ b/crates/engine/src/cmd/table_mouse/tests.rs @@ -379,6 +379,79 @@ fn dragging_the_handle_moves_the_table() { assert!(!movable(&nested)); } +fn rtl_table_session(rows: usize, cols: usize) -> Session { + let mut s = table_session(rows, cols); + s.run("table.rtl", &json!({"value": true})).unwrap(); + s +} + +/// #6438: a right-to-left table's first column is drawn at the right, and its move handle sits +/// past its top-right corner, not by the first cell's left edge in the middle of the table. The +/// pointer finds the table's edges where they are drawn; the handle selects it. +#[test] +fn a_right_to_left_tables_move_handle_is_past_its_top_right_corner() { + let mut s = rtl_table_session(3, 4); + let (first, last) = (cell_rect(&mut s, 0, 0), cell_rect(&mut s, 0, 3)); + assert!(first.x > last.right(), "the first column is drawn at the right: {first:?} {last:?}"); + let g = table_resize::tables_on(&s.layout(), &s.doc, 0)[0].clone(); + assert_eq!((g.left(), g.right()), (last.x, first.right()), "the table's drawn edges"); + let h = handle(&g); + assert!(h.x > first.right() && h.bottom() < first.y, "past the top-right corner: {h:?}, {first:?}"); + assert_eq!(spot_at(&mut s, h.x + h.w / 2.0, h.y + h.h / 2.0), Some(Spot::Handle)); + assert_ne!(spot_at(&mut s, first.x - 6.0, first.y - 6.0), Some(Spot::Handle), "not by the first cell's left edge"); + // The caret's table shows it there, and the pointer finds it on its way there. + let l = s.layout(); + assert_eq!(caret_handles(&l, &s.doc, StoryRef::Body, &table_path(&s), 0).0, Some(h)); + assert_eq!(handle_table(&l, &s.doc, StoryRef::Body, 0, h.right(), h.bottom(), REACH).map(|g| g.table), Some(table_path(&s))); + s.run("table.selectAt", &json!({"page": 0, "x": h.x + 4.0, "y": h.y + 4.0})).unwrap(); + assert_eq!(s.cell_range().map(|r| (r.rows, r.cols)), Some(((0, 2), (0, 3)))); +} + +/// #6438: dragging a right-to-left table's move handle moves the whole table as far as the +/// pointer went, as with any table, instead of putting its left edge where its first cell's was +/// (past the right margin, all but one column off the page). Dragged far right, it stays on the +/// page. +#[test] +fn dragging_a_right_to_left_tables_handle_moves_the_whole_table() { + let mut s = rtl_table_session(3, 4); + let row = |s: &mut Session| (0..4).map(|c| cell_rect(s, 0, c)).collect::>(); + let before = row(&mut s); + let h = handle(&table_resize::tables_on(&s.layout(), &s.doc, 0)[0]); + let (hx, hy) = (h.x + h.w / 2.0, h.y + h.h / 2.0); + s.run("table.moveDrag", &json!({"page": 0, "x": hx, "y": hy, "toX": hx - 40.0, "toY": hy + 30.0})).unwrap(); + assert!(first_table(&s).props.float.is_some()); + for (a, b) in before.iter().zip(row(&mut s)) { + assert!((b.x - (a.x - 40.0)).abs() < 0.5 && (b.y - (a.y + 30.0)).abs() < 0.5 && (b.w - a.w).abs() < 0.5, "{a:?} → {b:?}"); + } + let h = handle(&table_resize::tables_on(&s.layout(), &s.doc, 0)[0]); + let (hx, hy) = (h.x + h.w / 2.0, h.y + h.h / 2.0); + s.run("table.moveDrag", &json!({"page": 0, "x": hx, "y": hy, "toX": hx + 1000.0, "toY": hy})).unwrap(); + let (moved, page_w) = (row(&mut s), s.layout().pages[0].w); + assert!(moved[0].right() <= page_w + 0.5 && moved[0].right() > page_w - 1.0, "at the page's right edge: {moved:?}"); + assert!((moved[0].right() - moved[3].x - (before[0].right() - before[3].x)).abs() < 0.5, "the whole table: {moved:?}"); +} + +/// A right-to-left table's columns are found where they are drawn: the area above its right +/// column selects the first, above its left one the last; the insert button on the border left +/// of the first cell adds the second column. +#[test] +fn a_right_to_left_tables_columns_are_found_where_they_are_drawn() { + let mut s = rtl_table_session(2, 3); + fill(&mut s); + let (c0, c1, c2) = (cell_rect(&mut s, 0, 0), cell_rect(&mut s, 0, 1), cell_rect(&mut s, 0, 2)); + assert_eq!(spot_at(&mut s, c0.x + c0.w / 2.0, c0.y - 3.0), Some(Spot::Column(0))); + assert_eq!(spot_at(&mut s, c2.x + c2.w / 2.0, c2.y - 3.0), Some(Spot::Column(2))); + s.run("table.selectAt", &json!({"page": 0, "x": c2.x + c2.w / 2.0, "y": c2.y - 3.0})).unwrap(); + assert_eq!(s.selected_text(), "r0c2\nr1c2"); + s.run("table.selectAt", &json!({"page": 0, "x": c0.x + 20.0, "y": c0.y - 3.0, "toX": c1.x + 20.0, "toY": c1.y - 3.0})).unwrap(); + assert_eq!(s.cell_range().map(|r| r.cols), Some((0, 1)), "a drag from the first column to the second"); + assert_eq!(spot_at(&mut s, c0.x, c0.y - 8.0), Some(Spot::InsertColumn(1))); + s.run("table.insertAt", &json!({"page": 0, "x": c0.x, "y": c0.y - 8.0})).unwrap(); + assert_eq!(first_table(&s).cols(), 4); + assert!(para(&s, 0, 0).plain_text() == "r0c0" && para(&s, 0, 1).is_empty() && para(&s, 0, 2).plain_text() == "r0c1"); + assert_eq!(s.cell_range().map(|r| r.cols), Some((1, 1)), "it's selected"); +} + /// A double-click on a column border fits the column left of it to its text; as in Word, the /// columns right of it keep their widths and move along, so the table narrows. The right /// edge's column fits the same way. diff --git a/crates/engine/src/cmd/table_resize.rs b/crates/engine/src/cmd/table_resize.rs index 709d4038f5..6395cf3f5b 100644 --- a/crates/engine/src/cmd/table_resize.rs +++ b/crates/engine/src/cmd/table_resize.rs @@ -4,7 +4,8 @@ //! only in their rows. The geometry comes from the layout (what is on the page, in //! page points), so the result is what the drag showed even when autofit or a percentage width //! made the drawn columns differ from the stored grid. The app sends each finished drag here, -//! so every drag is one undo step. +//! so every drag is one undo step. A right-to-left table's rows resize; its columns and corner +//! don't yet (`ResizeTarget::resizable_columns`). use serde_json::Value; use wordcraft_doc::props::{Align, HeightRule, VMerge}; @@ -72,7 +73,8 @@ pub struct DrawnRow { pub row: usize, pub top: f32, pub bottom: f32, - /// Grid lines that are cell borders in this row (a merged cell hides the ones it covers). + /// Drawn grid lines (`ResizeTarget::cols`' indices) that are cell borders in this row (a + /// merged cell hides the ones it covers). pub(crate) edges: Vec, } @@ -82,12 +84,16 @@ pub struct ResizeTarget { pub edge: Edge, pub story: StoryRef, pub table: Path, - /// Drawn grid lines, page x, left to right (columns + 1 of them). + /// Drawn grid lines, page x, left to right (columns + 1 of them); a right-to-left table's + /// grid runs the other way (`grid_line`). pub cols: Vec, /// Drawn rows on this page, top to bottom. pub rows: Vec, /// Whether the table's last row is on this page (the handle is shown only then). pub ends_here: bool, + /// Whether the table runs right to left (`w:bidiVisual`): its first column is drawn at the + /// right. + pub rtl: bool, /// When cells of the table are selected and the column border is one of theirs /// (`limit_to_selection`): their rows, each with the grid lines its cells' borders are on. /// The border moves only there; empty, it moves in the whole column. @@ -131,6 +137,18 @@ impl ResizeTarget { pub fn handle(&self) -> Rect { Rect::new(self.right() + 1.0, self.bottom() + 1.0, HANDLE, HANDLE) } + /// The grid line that drawn line `line` (`cols`' index) is, or the other way round: the same + /// in a left-to-right table, counted from the other edge in a right-to-left one. + pub fn grid_line(&self, line: usize) -> usize { + if self.rtl { self.cols.len().saturating_sub(1).saturating_sub(line) } else { line } + } + /// Whether the table's column borders and resize handle are grabbed. Not a right-to-left + /// table's: its grid runs from its right edge, and these drags, made for a grid running from + /// the left, would put the new widths on the wrong columns. Mirrored ones aren't built yet + /// (#6438). + pub fn resizable_columns(&self) -> bool { + !self.rtl + } /// The new widths and heights a drag that moved the pointer by (`dx`, `dy`) points gives; /// `share` says who makes up a column border's move (`true`: Shift is held). @@ -340,18 +358,23 @@ pub(crate) fn cell_boxes(l: &DocLayout, page: usize) -> Vec { .collect() } -/// The drawn geometry of one table on a page, from its cells' boxes. +/// The drawn geometry of one table on a page, from its cells' boxes: its grid lines as drawn, +/// left to right, and its rows. fn geometry(t: &Table, boxes: &[&CellBox]) -> Option<(Vec, Vec)> { let n = t.cols(); if n == 0 || n > wordcraft_doc::table::MAX_COLS || boxes.is_empty() { return None; } + // Lines are counted from the left as drawn. A right-to-left table's grid runs from its right + // edge (`layout::table`), so a cell's left edge is the grid line it ends at, from the right. + let rtl = t.props.bidi_visual; let mut lines: Vec> = vec![None; n + 1]; let mut rows: Vec = Vec::new(); for b in boxes { let g = t.grid_col(b.row, b.cell); let span = t.rows.get(b.row).and_then(|r| r.cells.get(b.cell)).map_or(1, wordcraft_doc::Cell::span); let end = g.saturating_add(span).min(n); + let (g, end) = if rtl { (n.saturating_sub(end), n.saturating_sub(g)) } else { (g, end) }; if let Some(x) = lines.get_mut(g) { x.get_or_insert(b.rect.x); } @@ -371,7 +394,10 @@ fn geometry(t: &Table, boxes: &[&CellBox]) -> Option<(Vec, Vec)> } // A line no cell on this page ends at: between its drawn neighbours, as the grid shares it. let (first, last) = (lines.first().copied().flatten()?, lines.last().copied().flatten()?); - let weight = |i: usize| t.grid.get(i).copied().filter(|w| t.grid.len() == n && w.is_finite() && *w > 0.0).unwrap_or(1.0); + let weight = |i: usize| { + let i = if rtl { n.saturating_sub(1).saturating_sub(i) } else { i }; + t.grid.get(i).copied().filter(|w| t.grid.len() == n && w.is_finite() && *w > 0.0).unwrap_or(1.0) + }; let mut cols = Vec::with_capacity(n + 1); let mut prev = (0usize, first); for i in 0..=n { @@ -418,14 +444,20 @@ pub(crate) fn tables_on(l: &DocLayout, doc: &Document, page: usize) -> Vec = boxes.iter().filter(|b| b.story == story && b.table == *path).collect(); let (cols, rows) = geometry(t, &mine)?; let ends_here = rows.last().is_some_and(|r| r.row + 1 == t.rows.len()); - Some(ResizeTarget { edge: Edge::Corner, story, table: path.clone(), cols, rows, ends_here, only: Vec::new() }) + let rtl = t.props.bidi_visual; + Some(ResizeTarget { edge: Edge::Corner, story, table: path.clone(), cols, rows, ends_here, rtl, only: Vec::new() }) }) .collect() } fn on_handle(t: &ResizeTarget, x: f32, y: f32, reach: f32) -> bool { let h = t.handle(); - t.ends_here && x >= h.x - reach / 2.0 && x <= h.right() + reach / 2.0 && y >= h.y - reach / 2.0 && y <= h.bottom() + reach / 2.0 + t.ends_here + && t.resizable_columns() + && x >= h.x - reach / 2.0 + && x <= h.right() + reach / 2.0 + && y >= h.y - reach / 2.0 + && y <= h.bottom() + reach / 2.0 } /// The innermost table under page point (`x`, `y`) whose resize handle is on this page, or whose @@ -437,7 +469,11 @@ pub fn table_under(l: &DocLayout, doc: &Document, page: usize, x: f32, y: f32, r let reach = if reach.is_finite() { reach.clamp(0.5, 24.0) } else { REACH }; tables_on(l, doc, page) .into_iter() - .filter(|t| t.ends_here && ((x >= t.left() && x <= t.right() && y >= t.top() && y <= t.bottom()) || on_handle(t, x, y, reach))) + .filter(|t| { + t.ends_here + && t.resizable_columns() + && ((x >= t.left() && x <= t.right() && y >= t.top() && y <= t.bottom()) || on_handle(t, x, y, reach)) + }) .max_by_key(|t| t.table.0.len()) } @@ -464,9 +500,12 @@ pub fn resize_target(l: &DocLayout, doc: &Document, page: usize, x: f32, y: f32, if x < left - reach || x > right + reach || y < top - reach || y > bottom + reach { continue; } - // Column borders: in the row under the pointer, only lines that are cell borders there. + // Column borders: in the row under the pointer, only lines that are cell borders there + // (none of a right-to-left table's yet, `resizable_columns`). let row_here = target.rows.iter().find(|r| y >= r.top && y <= r.bottom).cloned(); - if let Some(r) = &row_here { + if let Some(r) = &row_here + && target.resizable_columns() + { for line in 0..target.cols.len() { // The table's left edge is grabbed from outside it (a point in, for the border's // width): inside starts the first cell. diff --git a/crates/engine/src/cmd/table_resize/tests.rs b/crates/engine/src/cmd/table_resize/tests.rs index 5dfb58356f..aec106ce51 100644 --- a/crates/engine/src/cmd/table_resize/tests.rs +++ b/crates/engine/src/cmd/table_resize/tests.rs @@ -128,6 +128,32 @@ fn the_corner_handle_scales_the_table() { assert!(((d1.bottom() - a1.y) - h * 2.0).abs() < 0.5, "{h} → {}", d1.bottom() - a1.y); } +/// #6438: a right-to-left table's columns run from its right edge, and mirrored drags for its +/// column borders and corner aren't built yet: they aren't grabbed, so a drag leaves its columns +/// alone (one used to squeeze all but the first to nothing). Its rows' borders resize as in any +/// table. +#[test] +fn a_right_to_left_tables_columns_keep_their_widths() { + let mut s = table_session(2, 3); + s.run("table.rtl", &json!({"value": true})).unwrap(); + let start = first_table(&s); + let (a, c) = (cell_rect(&mut s, 0, 0), cell_rect(&mut s, 1, 2)); + let y = a.y + a.h / 2.0; + let l = s.layout(); + for x in [a.x, a.x + 1.0, a.x - 1.0, a.right(), c.x, c.right()] { + assert!(resize_target(&l, &s.doc, 0, x, y, REACH).is_none_or(|t| !matches!(t.edge, Edge::Column(_))), "x {x}"); + let _ = s.run("table.resizeDrag", &json!({"page": 0, "x": x, "y": y, "toX": x - 30.0, "toY": y})); + assert_eq!(first_table(&s), start, "x {x}"); + } + let below = c.bottom() + 1.0 + HANDLE / 2.0; + for (x, y) in [(a.right() + 1.0 + HANDLE / 2.0, below), (c.x - 1.0 - HANDLE / 2.0, below), (a.x + 10.0, y)] { + assert!(table_under(&l, &s.doc, 0, x, y, REACH).is_none(), "no corner handle at {x}, {y}"); + } + let x = a.x + a.w / 2.0; + s.run("table.resizeDrag", &json!({"page": 0, "x": x, "y": a.bottom() + 1.0, "toX": x, "toY": a.bottom() + 21.0})).unwrap(); + assert!((cell_rect(&mut s, 0, 0).h - (a.h + 20.0)).abs() < 0.1, "the row border moves"); +} + /// A merged cell hides the border it covers: no column border to grab in its middle. #[test] fn merged_cells_have_no_border_inside() {