diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/ui-diff.c25
1 file changed, 13 insertions, 12 deletions
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("<td class='%s' style='width: %d.%d%%;'></td>",
- class, tenths / 10, tenths % 10);
+ if (span > 0)
+ htmlf("<td class='%s' colspan='%d'></td>", 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("</td><td class='graph'>");
html("<table><tr>");
- 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("</tr></table></td></tr>\n");
}