From 97d50de7d04334deffa7c605e327360b21bd2965 Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Tue, 11 Aug 2026 20:58:16 +0200 Subject: [PATCH] refactor(html): aim the sheet's cell styling at the sheet's own cells `table`, `td` and `td x-p` in the spreadsheet sheet named every element of their kind on the page, not the sheet's, so a table the document itself drew inside a cell would have taken the ruler's collapsed borders, fixed layout and cell padding. The font default stays sheet-wide on purpose: a shape anchored in a cell carries its text in spans of its own, and one that names no size would fall to the `font-size:0` a page gives every paragraph. Rendering is unchanged - htmlcmp compares 332 public and 1062 private outputs against main with no mismatch. Neither corpus has a table nested in a sheet, so this is what keeps one right when it turns up. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01QVkpzsGS6YASMqm3NwmWib --- src/odr/internal/html/frontend.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/odr/internal/html/frontend.cpp b/src/odr/internal/html/frontend.cpp index 808139e2..3d518bdf 100644 --- a/src/odr/internal/html/frontend.cpp +++ b/src/odr/internal/html/frontend.cpp @@ -55,11 +55,13 @@ constexpr std::string_view spreadsheet_css = R"css( } /* A sheet is not a page: past the last row and column is canvas. */ body{margin:0;background:var(--odr-sheet-canvas)} -.odr-sheet{background:#fff} -table{border-collapse:collapse;table-layout:fixed} -td{vertical-align:bottom;height:inherit;padding:1px 6px} -x-p{font-family:var(--odr-sheet-font);font-size:10pt} -td x-p{height:inherit} +.odr-sheet{background:#fff;border-collapse:collapse;table-layout:fixed} +/* The sheet's own cells, not a table the document itself drew inside one. */ +.odr-sheet>tbody>tr>td{vertical-align:bottom;height:inherit;padding:1px 6px} +.odr-sheet>tbody>tr>td>x-p{height:inherit} +/* Sheet-wide, not cell-only: a shape's text would otherwise fall to the + `font-size:0` a page carries. */ +.odr-sheet x-p{font-family:var(--odr-sheet-font);font-size:10pt} /* Sticky cells in a collapsed border model do not repaint their borders in Chrome or WebKit, so the ruler uses inset shadows. */ .odr-sheet th{position:sticky;background:var(--odr-sheet-ruler);color:var(--odr-sheet-ruler-text);font:500 12px/1.6 var(--odr-sheet-font);text-align:center;vertical-align:middle;padding:0 4px;white-space:nowrap;user-select:none}