Skip to content

refactor(html): aim the sheet's cell styling at the sheet's own cells - #686

Merged
andiwand merged 1 commit into
mainfrom
refactor/scope-sheet-css
Aug 11, 2026
Merged

refactor(html): aim the sheet's cell styling at the sheet's own cells#686
andiwand merged 1 commit into
mainfrom
refactor/scope-sheet-css

Conversation

@andiwand

@andiwand andiwand commented Aug 11, 2026

Copy link
Copy Markdown
Member

Found while auditing the stylesheets for the same pattern as #685.

Three rules in spreadsheet_css named every element of their kind on the page rather than the sheet's own, while every rule around them is .odr-sheet-scoped:

table{border-collapse:collapse;table-layout:fixed}
td{vertical-align:bottom;height:inherit;padding:1px 6px}
td x-p{height:inherit}

A table the document itself drew inside a cell would have taken the ruler's collapsed borders, fixed layout and cell padding. Now the cell-geometry rules use child combinators from .odr-sheet, and the table properties merge into the .odr-sheet rule that was already there.

The font default deliberately does not become cell-only:

.odr-sheet x-p{font-family:var(--odr-sheet-font);font-size:10pt}

A sheet holds 98 td > div > x-p — text in a shape anchored in a cell. Those spans size the text themselves, and one that names no size falls back to the x-p{font-size:0} every page carries (which is there so an empty paragraph is exactly as tall as the empty <x-s> written for it in document_element.cpp:331). Scoping the font to cells only would have rendered such text at zero. Descendant scoping is enough here anyway: all 713038 x-p on a spreadsheet page are inside .odr-sheet, none outside.

Verification

Rendered both sides of the whole public corpus in Chrome and compared pixels: all 228 pages identical, apart from xls/file_example_XLS_5000.xls/sheet0.html, which shows the same 140-pixel difference at the same bounding box when the tree is compared against itself — nondeterministic sticky-header rendering, not this change.

Correction to an earlier claim in this PR. I first verified with htmlcmp, which reported all 332 + 1062 files matching. That result was empty: compare-html short-circuits byte-identical files without rendering them, and this PR changes only CSS, so every html file was identical and nothing was ever rendered. CI's compare step has the same blind spot. See #685 for the same correction.

No reference-output update needed. Neither corpus contains a table nested inside a sheet — checked all 1144 pages — so this is preventive: it keeps one styled correctly when it does turn up.

Independent of #685; both touch frontend.cpp but different sheets.

🤖 Generated with Claude Code

`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) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QVkpzsGS6YASMqm3NwmWib
@andiwand
andiwand enabled auto-merge (squash) August 11, 2026 19:09
@andiwand
andiwand disabled auto-merge August 11, 2026 19:14
@andiwand
andiwand merged commit 3f0d0c9 into main Aug 11, 2026
36 checks passed
@andiwand
andiwand deleted the refactor/scope-sheet-css branch August 11, 2026 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant