From a0271d6699ae660df93361c49d6d2bd3b35a9b53 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Tue, 1 Sep 2026 06:49:09 -1000 Subject: Size the diffstat bars with colspan, not style --- source/ui-diff.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'source/ui-diff.c') diff --git a/source/ui-diff.c b/source/ui-diff.c index d783cb4..63c0148 100644 --- a/source/ui-diff.c +++ b/source/ui-diff.c @@ -80,21 +80,21 @@ static void release_bodies(void) } /* - * One bar segment of the per-file diffstat graph. The width is printed from - * integers so that a locale with a comma decimal separator, which a Lua - * filter can install mid-process, cannot render the declaration invalid. + * One bar segment of the per-file diffstat graph. The bar is a fixed-layout + * table whose row always spans 1000 columns, so a segment takes its share + * of the width through colspan rather than through an inline style, which + * a Content-Security-Policy would have to allow. */ -static void print_graph_cell(const char *class, int count, int scale) +static void print_graph_cell(const char *class, int span) { - int tenths = (int)(count * 1000.0 / scale + 0.5); - - htmlf("", - class, tenths / 10, tenths % 10); + if (span > 0) + htmlf("", class, span); } static void print_fileinfo(struct fileinfo *info) { int scale = max_changes ? max_changes : 1; + int add_span, rem_span; const char *class; switch (info->status) { @@ -159,10 +159,11 @@ static void print_fileinfo(struct fileinfo *info) htmlf("%d", info->added + info->removed); html(""); html(""); - print_graph_cell("add", info->added, scale); - print_graph_cell("rem", info->removed, scale); - print_graph_cell("none", max_changes - info->removed - info->added, - scale); + add_span = (int)(info->added * 1000.0 / scale + 0.5); + rem_span = (int)(info->removed * 1000.0 / scale + 0.5); + print_graph_cell("add", add_span); + print_graph_cell("rem", rem_span); + print_graph_cell("none", 1000 - add_span - rem_span); html("
\n"); } -- cgit v2.8.0