about summary refs log tree commit diff stats
path: root/test
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2025-04-03 18:37:29 +0200
committerbptato <nincsnevem662@gmail.com>2025-04-03 18:37:29 +0200
commit19c573e794fc74cb57833f4d2cbe53e002958685 (patch)
tree4c1787f9467df009991aa41e05c6681999375971 /test
parent4703192bcd6bd444964116fc64a9d0cb2aef2a1f (diff)
downloadchawan-19c573e794fc74cb57833f4d2cbe53e002958685.tar.gz
layout: correct table-caption width calculation
It's surprisingly tricky.
Diffstat (limited to 'test')
-rw-r--r--test/layout/float-next-to-caption.expected2
-rw-r--r--test/layout/table-caption-intrinsic-size-affects-inner-table-and-vice-versa.color.expected13
-rw-r--r--test/layout/table-caption-intrinsic-size-affects-inner-table-and-vice-versa.html51
-rw-r--r--test/layout/table-caption-margins.expected2
-rw-r--r--test/layout/table-caption-margins.html2
5 files changed, 67 insertions, 3 deletions
diff --git a/test/layout/float-next-to-caption.expected b/test/layout/float-next-to-caption.expected
index 3021c733..31bd0d05 100644
--- a/test/layout/float-next-to-caption.expected
+++ b/test/layout/float-next-to-caption.expected
@@ -1,2 +1,2 @@
 test                                                                      test 1
-2
+ 2
diff --git a/test/layout/table-caption-intrinsic-size-affects-inner-table-and-vice-versa.color.expected b/test/layout/table-caption-intrinsic-size-affects-inner-table-and-vice-versa.color.expected
new file mode 100644
index 00000000..e9f490c1
--- /dev/null
+++ b/test/layout/table-caption-intrinsic-size-affects-inner-table-and-vice-versa.color.expected
@@ -0,0 +1,13 @@
+                
+testtesttesttest
+test
+testtesttesttest
+test test
+test 
+test 
+test 
+test 
+testtesttesttest
+test test
+          
+atest test
diff --git a/test/layout/table-caption-intrinsic-size-affects-inner-table-and-vice-versa.html b/test/layout/table-caption-intrinsic-size-affects-inner-table-and-vice-versa.html
new file mode 100644
index 00000000..a1862ec9
--- /dev/null
+++ b/test/layout/table-caption-intrinsic-size-affects-inner-table-and-vice-versa.html
@@ -0,0 +1,51 @@
+<!DOCTYPE html>
+<style>
+xtable { display: table; background: green }
+xcaption { display: table-caption; background: pink }
+xtr { display: table-row; background: blue }
+xtd { display: table-cell; background: red }
+</style>
+
+<!-- caption grows to its intrinsic min width -->
+<div style="width: 1ch">
+<xtable>
+<xcaption><div style="width: 20%; background: blue; height: 1em"></div>testtesttesttest</xcaption>
+<xtr><xtd>test</xtd></xtr>
+</xtable>
+</div>
+
+<!-- available space constrains table, caption is larger than space
+     -> table grows to caption's intrinsic min width -->
+<div style="width: 5ch">
+<xtable>
+<xcaption>testtesttesttest</xcaption>
+<xtr><xtd>test test</xtd></xtr>
+</xtable>
+</div>
+
+<!-- caption & table both fit in available space
+     -> break lines -->
+<div style="width: 5ch">
+<xtable>
+<xcaption>test test</xcaption>
+<xtr><xtd>test test</xtd></xtr>
+</xtable>
+</div>
+
+<!-- caption & table are not constrained in size, table is smaller
+     -> table remains smaller -->
+<xtable>
+<xcaption>testtesttesttest</xcaption>
+<xtr><xtd>test test</xtd></xtr>
+</xtable>
+
+<!-- caption & table are not constrained in size, table is larger
+     -> caption stretched to table size -->
+<xtable>
+<xcaption><div style="width: 50%; height: 1em; background: blue"></div></xcaption>
+<xtr>
+<xtd>
+atest test
+</xtd>
+</xtr>
+</xtable>
diff --git a/test/layout/table-caption-margins.expected b/test/layout/table-caption-margins.expected
index 7fe2215d..330acfa6 100644
--- a/test/layout/table-caption-margins.expected
+++ b/test/layout/table-caption-margins.expected
@@ -4,4 +4,4 @@
 
 
 
-        testing
+ testing
diff --git a/test/layout/table-caption-margins.html b/test/layout/table-caption-margins.html
index a3e3759e..aaf89d8a 100644
--- a/test/layout/table-caption-margins.html
+++ b/test/layout/table-caption-margins.html
@@ -6,7 +6,7 @@ something something
 <td>
 row 2
 <caption style="caption-side: bottom; margin-top: 2em; margin-left: 1ch">
-<div style="margin-top: 2em">
+<div style="margin-top: 2em; text-align: left">
 testing
 </div>
 </caption>