about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-05-08 22:26:23 +0200
committerbptato <nincsnevem662@gmail.com>2024-05-08 22:28:19 +0200
commit264419bde7a73ba34095af65fd0f34ab88e7070a (patch)
treeb61ba8d412d826bc58ebfeabc63ec1017157ebb4 /src
parentc90c11ea3840c9d25edb16aa5e6a2c366406cb89 (diff)
downloadchawan-264419bde7a73ba34095af65fd0f34ab88e7070a.tar.gz
layout: another table colwidth fix
Turns out we also have to *expand* column width, if the specified column
width is too small *and* no unspecified column exists to take the rest
of the place.
Diffstat (limited to 'src')
-rw-r--r--src/layout/engine.nim10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/layout/engine.nim b/src/layout/engine.nim
index 4fe4d5ce..28235c82 100644
--- a/src/layout/engine.nim
+++ b/src/layout/engine.nim
@@ -1951,7 +1951,7 @@ proc calcUnspecifiedColIndices(ctx: var TableContext; W: var LayoutUnit;
       weight += w
       inc j
     else:
-      if specifiedRatio < 1:
+      if specifiedRatio != 1:
         col.width *= specifiedRatio
         col.reflow = true
       W -= col.width
@@ -1976,14 +1976,20 @@ proc redistributeWidth(ctx: var TableContext) =
   W -= ctx.cols.len * ctx.inlineSpacing * 2
   var weight = 0f64
   var totalSpecified: LayoutUnit = 0
+  var hasUnspecified = false
   for col in ctx.cols:
     if col.wspecified:
       totalSpecified += col.width
     else:
+      hasUnspecified = true
       # Hack: reserve the minimum space needed for unspecified columns,
       # like other browsers do.
       totalSpecified += col.minwidth
-  let specifiedRatio = if totalSpecified != 0: W / totalSpecified else: 1
+  var specifiedRatio = if totalSpecified != 0: W / totalSpecified else: 1
+  if specifiedRatio > 1 and hasUnspecified:
+    # Only grow specified columns if no unspecified column exists to take the
+    # rest of the space.
+    specifiedRatio = 1
   var avail = ctx.calcUnspecifiedColIndices(W, weight, specifiedRatio)
   var redo = true
   while redo and avail.len > 0 and weight != 0: