Closed Bug 2071258 Opened 2 months ago Closed 2 months ago

Mermaid diagrams are scaled to the column width instead of their own size

Categories

(Developer Infrastructure :: Source Documentation, defect)

defect

Tracking

(firefox158 fixed)

RESOLVED FIXED
158 Branch
Tracking Status
firefox158 --- fixed

People

(Reporter: dao, Assigned: dao)

References

(Blocks 1 open bug)

Details

Attachments

(1 external file)

sphinxcontrib-mermaid injects a stylesheet setting width: 100% and max-width: 100% !important on a diagram's SVG, inside a <pre> sized by mermaid_width. The !important overrides the max-width: <intrinsic>px mermaid sets on the SVG itself, so every diagram is scaled to the column: a narrow one is blown up, a wide one shrunk until its labels are unreadable. On the SessionStore events page of bug 2066123, at a 767px column, a 497x1362 flowchart renders at 720x1972 and a 341x663 one at 720x1400, so their 18px labels come out near 26px and 38px.

The fix needs both halves. useMaxWidth off in mermaid_init_config gives the SVG an intrinsic size; with it on the SVG carries a viewBox and no width, and a content-sized box collapses to the CSS default object size of 300px, which is why bug 2070769 concluded the box needed a definite width. docs/_static/custom_theme.css then overrides the injected rule so the SVG keeps that size, and the <pre> becomes a horizontal scroll container for a diagram wider than the column. ipc/docs/ipdl.md's four diagrams then render at 1289, 745, 585 and 850 pixels wide, the two over the column scrolling in place, where today all four are forced to 720.

A scrolled diagram is reachable by mouse and by the extension's fullscreen button, but a <pre> is not keyboard focusable and Firefox's overlay scrollbars leave the affordance invisible until it is scrolled. The theme's existing code blocks have the same gap, so that wants a follow-up rather than blocking this.

Assignee: nobody → dao+bmo
Status: NEW → ASSIGNED
Blocks: 2071266
Blocks: 2071267
Blocks: 2071268
No longer blocks: first-class-docs
Pushed by sledru@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/fc05d1ba3317 https://hg.mozilla.org/integration/autoland/rev/908f24d073cc Render each mermaid diagram at its own size instead of the column width. r=firefox-source-docs-reviewers,sylvestre
Status: ASSIGNED → RESOLVED
Closed: 2 months ago
Resolution: --- → FIXED
Target Milestone: --- → 158 Branch
Regressions: 2088498
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: