Distribute extra space in fixed-layout tables where all columns have widths proportionally rather than equally, for compatibility. (Bug 445142) r=bernd sr=roc a=blocking1.9.1+
authorL. David Baron <dbaron@dbaron.org>
Tue, 25 Nov 2008 15:22:39 -0800
changeset 21931 9bea28954d72dcecacbdbe5688707ea53b555a88
parent 21930 483aaa57f2902b5593e6f63ef408babae19208e0
child 21932 86fcd531d8fab03707cb93870dd7e79d09bd0166
push id3746
push userdbaron@mozilla.com
push dateTue, 25 Nov 2008 23:23:59 +0000
treeherdermozilla-central@86fcd531d8fa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbernd, roc, blocking1.9.1
bugs445142
milestone1.9.1b3pre
Distribute extra space in fixed-layout tables where all columns have widths proportionally rather than equally, for compatibility. (Bug 445142) r=bernd sr=roc a=blocking1.9.1+
layout/reftests/bugs/445142-1-ref.html
layout/reftests/bugs/445142-1a.html
layout/reftests/bugs/445142-1b.html
layout/reftests/bugs/445142-1c.html
layout/reftests/bugs/445142-2-ref.html
layout/reftests/bugs/445142-2a.html
layout/reftests/bugs/445142-2b.html
layout/reftests/bugs/reftest.list
layout/tables/FixedTableLayoutStrategy.cpp
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/445142-1-ref.html
@@ -0,0 +1,147 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
+	"http://www.w3.org/TR/html4/strict.dtd">
+<html lang="en-US">
+<head>
+	<title>table-layout: fixed width distribution with unassigned space</title>
+	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+	<meta http-equiv="Content-Style-Type" content="text/css">
+	<style type="text/css">
+
+	table, td { margin: 0; padding: 0; }
+
+	table {
+		border-spacing: 0;
+		margin-bottom: 2px;
+	}
+
+	td { color: black; background: yellow; }
+	td + td { background: aqua; }
+	td + td + td { background: fuchsia; }
+
+	</style>
+</head>
+<body>
+
+<table>
+  <tr>
+    <td style="width: 600px">100px</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 700px">700px</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 600px">600px</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 200px">100px</td>
+    <td style="width: 400px">200px</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 200px">150px</td>
+    <td style="width: 400px">300px</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 600px">20%</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 600px">100%</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 600px">120%</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 200px">20%</td>
+    <td style="width: 400px">40%</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 200px">30%</td>
+    <td style="width: 400px">60%</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 120px">20%</td>
+    <td style="width: 480px">100px</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 120px">20%</td>
+    <td style="width: 100px">100px</td>
+    <td style="width: 380px">div</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 600px">20%</td>
+    <td style="width: 0"><div style="width: 0">0</div></td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 600px">20%</td>
+    <td style="width: 0"><div style="width: 0">0%</div></td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 600px">100px</td>
+    <td style="width: 0"><div style="width: 0">0</div></td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 600px">100px</td>
+    <td style="width: 0"><div style="width: 0">0%</div></td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 300px">0</td>
+    <td style="width: 300px">0</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 300px">0%</td>
+    <td style="width: 300px">0</td>
+  </tr>
+</table>
+
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/445142-1a.html
@@ -0,0 +1,149 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
+	"http://www.w3.org/TR/html4/strict.dtd">
+<html lang="en-US">
+<head>
+	<title>table-layout: fixed width distribution with unassigned space</title>
+	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+	<meta http-equiv="Content-Style-Type" content="text/css">
+	<style type="text/css">
+
+	table, td { margin: 0; padding: 0; }
+
+	table {
+		table-layout: fixed;
+		width: 600px;
+		border-spacing: 0;
+		margin-bottom: 2px;
+	}
+
+	td { color: black; background: yellow; }
+	td + td { background: aqua; }
+	td + td + td { background: fuchsia; }
+
+	</style>
+</head>
+<body>
+
+<table>
+  <tr>
+    <td style="width: 100px">100px</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 700px">700px</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 600px">600px</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 100px">100px</td>
+    <td style="width: 200px">200px</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 150px">150px</td>
+    <td style="width: 300px">300px</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 20%">20%</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 100%">100%</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 120%">120%</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 20%">20%</td>
+    <td style="width: 40%">40%</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 30%">30%</td>
+    <td style="width: 60%">60%</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 20%">20%</td>
+    <td style="width: 100px">100px</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 20%">20%</td>
+    <td style="width: 100px">100px</td>
+    <td><div style="width: 100px">div</div></td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 20%">20%</td>
+    <td style="width: 0">0</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 20%">20%</td>
+    <td style="width: 0%">0%</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 100px">100px</td>
+    <td style="width: 0">0</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 100px">100px</td>
+    <td style="width: 0%">0%</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 0">0</td>
+    <td style="width: 0">0</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 0%">0%</td>
+    <td style="width: 0">0</td>
+  </tr>
+</table>
+
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/445142-1b.html
@@ -0,0 +1,187 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
+	"http://www.w3.org/TR/html4/strict.dtd">
+<html lang="en-US">
+<head>
+	<title>table-layout: fixed width distribution with unassigned space</title>
+	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+	<meta http-equiv="Content-Style-Type" content="text/css">
+	<style type="text/css">
+
+	table, td { margin: 0; padding: 0; }
+
+	table {
+		table-layout: fixed;
+		width: 600px;
+		border-spacing: 0;
+		margin-bottom: 2px;
+	}
+
+	td { color: black; background: yellow; }
+	td + td { background: aqua; }
+	td + td + td { background: fuchsia; }
+
+	</style>
+</head>
+<body>
+
+<!--
+
+A copy of 445142-1a.html where one of the widths is specified on a col
+instead of a td.
+
+-->
+
+<table>
+  <col style="width: 100px">
+  <tr>
+    <td>100px</td>
+  </tr>
+</table>
+
+<table>
+  <col style="width: 700px">
+  <tr>
+    <td>700px</td>
+  </tr>
+</table>
+
+<table>
+  <col style="width: 600px">
+  <tr>
+    <td>600px</td>
+  </tr>
+</table>
+
+<table>
+  <col>
+  <col style="width: 200px">
+  <tr>
+    <td style="width: 100px">100px</td>
+    <td>200px</td>
+  </tr>
+</table>
+
+<table>
+  <col style="width: 150px">
+  <col>
+  <tr>
+    <td style="width: 9999px">150px</td>
+    <td style="width: 300px">300px</td>
+  </tr>
+</table>
+
+<table>
+  <col style="width: 20%">
+  <tr>
+    <td>20%</td>
+  </tr>
+</table>
+
+<table>
+  <col style="width: 100%">
+  <tr>
+    <td>100%</td>
+  </tr>
+</table>
+
+<table>
+  <col style="width: 120%">
+  <tr>
+    <td>120%</td>
+  </tr>
+</table>
+
+<table>
+  <col style="width: 20%">
+  <col>
+  <tr>
+    <td>20%</td>
+    <td style="width: 40%">40%</td>
+  </tr>
+</table>
+
+<table>
+  <col>
+  <col style="width: 60%">
+  <tr>
+    <td style="width: 30%">30%</td>
+    <td style="width: 9999px">60%</td>
+  </tr>
+</table>
+
+<table>
+  <col style="width: 20%">
+  <col>
+  <tr>
+    <td>20%</td>
+    <td style="width: 100px">100px</td>
+  </tr>
+</table>
+
+<table>
+  <col>
+  <col style="width: 100px">
+  <col>
+  <tr>
+    <td style="width: 20%">20%</td>
+    <td style="width: 5%">100px</td>
+    <td><div style="width: 100px">div</div></td>
+  </tr>
+</table>
+
+<table>
+  <col style="width: 20%">
+  <col>
+  <tr>
+    <td>20%</td>
+    <td style="width: 0">0</td>
+  </tr>
+</table>
+
+<table>
+  <col>
+  <col style="width: 0%">
+  <tr>
+    <td style="width: 20%">20%</td>
+    <td>0%</td>
+  </tr>
+</table>
+
+<table>
+  <col>
+  <col style="width: 0">
+  <tr>
+    <td style="width: 100px">100px</td>
+    <td>0</td>
+  </tr>
+</table>
+
+<table>
+  <col style="width: 100px">
+  <col>
+  <tr>
+    <td>100px</td>
+    <td style="width: 0%">0%</td>
+  </tr>
+</table>
+
+<table>
+  <col style="width: 0">
+  <col>
+  <tr>
+    <td>0</td>
+    <td style="width: 0">0</td>
+  </tr>
+</table>
+
+<table>
+  <col>
+  <col style="width: 0">
+  <tr>
+    <td style="width: 0%">0%</td>
+    <td>0</td>
+  </tr>
+</table>
+
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/445142-1c.html
@@ -0,0 +1,155 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
+	"http://www.w3.org/TR/html4/strict.dtd">
+<html lang="en-US">
+<head>
+	<title>table-layout: fixed width distribution with unassigned space</title>
+	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+	<meta http-equiv="Content-Style-Type" content="text/css">
+	<style type="text/css">
+
+	table, td { margin: 0; padding: 0; }
+
+	table {
+		table-layout: fixed;
+		width: 600px;
+		border-spacing: 0;
+		margin-bottom: 2px;
+	}
+
+	td { color: black; background: yellow; }
+	td + td { background: aqua; }
+	td + td + td { background: fuchsia; }
+
+	</style>
+</head>
+<body>
+
+<!--
+
+A copy of 445142-1a.html where some cells have colspans.
+
+-->
+
+<table>
+  <tr>
+    <td colspan="3" style="width: 100px">100px</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td colspan="2" style="width: 700px">700px</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td colspan="5" style="width: 600px">600px</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td colspan="3" style="width: 100px">100px</td>
+    <td style="width: 200px">200px</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 150px">150px</td>
+    <td colspan="2" style="width: 300px">300px</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td colspan="4" style="width: 20%">20%</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td colspan="2" style="width: 100%">100%</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td colspan="3" style="width: 120%">120%</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td colspan="2" style="width: 20%">20%</td>
+    <td style="width: 40%">40%</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 30%">30%</td>
+    <td colspan="3" style="width: 60%">60%</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 20%">20%</td>
+    <td colspan="4" style="width: 100px">100px</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td colspan="3" style="width: 20%">20%</td>
+    <td style="width: 100px">100px</td>
+    <td><div style="width: 100px">div</div></td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td colspan="2" style="width: 20%">20%</td>
+    <td style="width: 0">0</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 20%">20%</td>
+    <td colspan="2" style="width: 0%">0%</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td colspan="4" style="width: 100px">100px</td>
+    <td style="width: 0">0</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 100px">100px</td>
+    <td colspan="2" style="width: 0%">0%</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td colspan="4" style="width: 0">0</td>
+    <td colspan="4" style="width: 0">0</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td colspan="10" style="width: 0%">0%</td>
+    <td colspan="10" style="width: 0">0</td>
+  </tr>
+</table>
+
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/445142-2-ref.html
@@ -0,0 +1,148 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
+	"http://www.w3.org/TR/html4/strict.dtd">
+<html lang="en-US">
+<head>
+	<title>table-layout: fixed width distribution with unassigned space</title>
+	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+	<meta http-equiv="Content-Style-Type" content="text/css">
+	<style type="text/css">
+
+	table, td { margin: 0; padding: 0; }
+
+	table {
+		border-spacing: 10px 0;
+		margin-bottom: 2px;
+		padding: 0 10px;
+	}
+
+	td { color: black; background: yellow; }
+	td + td { background: aqua; }
+	td + td + td { background: fuchsia; }
+
+	</style>
+</head>
+<body>
+
+<table>
+  <tr>
+    <td style="width: 460px">100px</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 500px">500px</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 600px">600px</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 150px">100px</td>
+    <td style="width: 300px">200px</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 150px">150px</td>
+    <td style="width: 300px">300px</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 460px">20%</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 460px">100%</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 460px">120%</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 150px">20%</td>
+    <td style="width: 300px">40%</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 150px">30%</td>
+    <td style="width: 300px">60%</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 90px">20%</td>
+    <td style="width: 360px">100px</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 88px">20%</td>
+    <td style="width: 100px">100px</td>
+    <td style="width: 252px">div</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 450px">20%</td>
+    <td style="width: 0"><div style="width: 0">0</div></td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 450px">20%</td>
+    <td style="width: 0"><div style="width: 0">0%</div></td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 450px">100px</td>
+    <td style="width: 0"><div style="width: 0">0</div></td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 450px">100px</td>
+    <td style="width: 0"><div style="width: 0">0%</div></td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 225px">0</td>
+    <td style="width: 225px">0</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 225px">0%</td>
+    <td style="width: 225px">0</td>
+  </tr>
+</table>
+
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/445142-2a.html
@@ -0,0 +1,150 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
+	"http://www.w3.org/TR/html4/strict.dtd">
+<html lang="en-US">
+<head>
+	<title>table-layout: fixed width distribution with unassigned space</title>
+	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+	<meta http-equiv="Content-Style-Type" content="text/css">
+	<style type="text/css">
+
+	table, td { margin: 0; padding: 0; }
+
+	table {
+		table-layout: fixed;
+		width: 500px;
+		border-spacing: 10px 0;
+		margin-bottom: 2px;
+		padding: 0 10px;
+	}
+
+	td { color: black; background: yellow; }
+	td + td { background: aqua; }
+	td + td + td { background: fuchsia; }
+
+	</style>
+</head>
+<body>
+
+<table>
+  <tr>
+    <td style="width: 100px">100px</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 500px">500px</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 600px">600px</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 100px">100px</td>
+    <td style="width: 200px">200px</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 150px">150px</td>
+    <td style="width: 300px">300px</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 20%">20%</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 100%">100%</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 120%">120%</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 20%">20%</td>
+    <td style="width: 40%">40%</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 30%">30%</td>
+    <td style="width: 60%">60%</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 20%">20%</td>
+    <td style="width: 100px">100px</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 20%">20%</td>
+    <td style="width: 100px">100px</td>
+    <td><div style="width: 100px">div</div></td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 20%">20%</td>
+    <td style="width: 0">0</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 20%">20%</td>
+    <td style="width: 0%">0%</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 100px">100px</td>
+    <td style="width: 0">0</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 100px">100px</td>
+    <td style="width: 0%">0%</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 0">0</td>
+    <td style="width: 0">0</td>
+  </tr>
+</table>
+
+<table>
+  <tr>
+    <td style="width: 0%">0%</td>
+    <td style="width: 0">0</td>
+  </tr>
+</table>
+
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/445142-2b.html
@@ -0,0 +1,188 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
+	"http://www.w3.org/TR/html4/strict.dtd">
+<html lang="en-US">
+<head>
+	<title>table-layout: fixed width distribution with unassigned space</title>
+	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+	<meta http-equiv="Content-Style-Type" content="text/css">
+	<style type="text/css">
+
+	table, td { margin: 0; padding: 0; }
+
+	table {
+		table-layout: fixed;
+		width: 500px;
+		border-spacing: 10px 0;
+		margin-bottom: 2px;
+		padding: 0 10px;
+	}
+
+	td { color: black; background: yellow; }
+	td + td { background: aqua; }
+	td + td + td { background: fuchsia; }
+
+	</style>
+</head>
+<body>
+
+<!--
+
+A copy of 445142-1a.html where one of the widths is specified on a col
+instead of a td.
+
+-->
+
+<table>
+  <col style="width: 100px">
+  <tr>
+    <td>100px</td>
+  </tr>
+</table>
+
+<table>
+  <col style="width: 500px">
+  <tr>
+    <td>500px</td>
+  </tr>
+</table>
+
+<table>
+  <col style="width: 600px">
+  <tr>
+    <td>600px</td>
+  </tr>
+</table>
+
+<table>
+  <col>
+  <col style="width: 200px">
+  <tr>
+    <td style="width: 100px">100px</td>
+    <td>200px</td>
+  </tr>
+</table>
+
+<table>
+  <col style="width: 150px">
+  <col>
+  <tr>
+    <td style="width: 9999px">150px</td>
+    <td style="width: 300px">300px</td>
+  </tr>
+</table>
+
+<table>
+  <col style="width: 20%">
+  <tr>
+    <td>20%</td>
+  </tr>
+</table>
+
+<table>
+  <col style="width: 100%">
+  <tr>
+    <td>100%</td>
+  </tr>
+</table>
+
+<table>
+  <col style="width: 120%">
+  <tr>
+    <td>120%</td>
+  </tr>
+</table>
+
+<table>
+  <col style="width: 20%">
+  <col>
+  <tr>
+    <td>20%</td>
+    <td style="width: 40%">40%</td>
+  </tr>
+</table>
+
+<table>
+  <col>
+  <col style="width: 60%">
+  <tr>
+    <td style="width: 30%">30%</td>
+    <td style="width: 9999px">60%</td>
+  </tr>
+</table>
+
+<table>
+  <col style="width: 20%">
+  <col>
+  <tr>
+    <td>20%</td>
+    <td style="width: 100px">100px</td>
+  </tr>
+</table>
+
+<table>
+  <col>
+  <col style="width: 100px">
+  <col>
+  <tr>
+    <td style="width: 20%">20%</td>
+    <td style="width: 5%">100px</td>
+    <td><div style="width: 100px">div</div></td>
+  </tr>
+</table>
+
+<table>
+  <col style="width: 20%">
+  <col>
+  <tr>
+    <td>20%</td>
+    <td style="width: 0">0</td>
+  </tr>
+</table>
+
+<table>
+  <col>
+  <col style="width: 0%">
+  <tr>
+    <td style="width: 20%">20%</td>
+    <td>0%</td>
+  </tr>
+</table>
+
+<table>
+  <col>
+  <col style="width: 0">
+  <tr>
+    <td style="width: 100px">100px</td>
+    <td>0</td>
+  </tr>
+</table>
+
+<table>
+  <col style="width: 100px">
+  <col>
+  <tr>
+    <td>100px</td>
+    <td style="width: 0%">0%</td>
+  </tr>
+</table>
+
+<table>
+  <col style="width: 0">
+  <col>
+  <tr>
+    <td>0</td>
+    <td style="width: 0">0</td>
+  </tr>
+</table>
+
+<table>
+  <col>
+  <col style="width: 0">
+  <tr>
+    <td style="width: 0%">0%</td>
+    <td>0</td>
+  </tr>
+</table>
+
+</body>
+</html>
--- a/layout/reftests/bugs/reftest.list
+++ b/layout/reftests/bugs/reftest.list
@@ -914,16 +914,21 @@ random == 429849-1.html 429849-1-ref.htm
 == 441259-1.html 441259-1-ref.html
 fails == 441259-2.html 441259-2-ref.html # bug 441400
 == 442542-1.html 442542-1-ref.html
 == 444015-1.html 444015-1-ref.html
 == 444928-1.html 444928-1-ref.html
 == 444928-2.html 444928-2-ref.html
 != 444928-3.html 444928-3-notref.html
 == 445004-1.html 445004-1-ref.html
+== 445142-1a.html 445142-1-ref.html
+== 445142-1b.html 445142-1-ref.html
+== 445142-1c.html 445142-1-ref.html
+== 445142-2a.html 445142-2-ref.html
+== 445142-2b.html 445142-2-ref.html
 == 446100-1a.html about:blank
 == 446100-1b.html about:blank
 == 446100-1c.html about:blank
 == 446100-1d.html about:blank
 == 446100-1e.html about:blank
 == 446100-1f.html about:blank
 == 446100-1g.html about:blank
 == 446100-1h.html about:blank
--- a/layout/tables/FixedTableLayoutStrategy.cpp
+++ b/layout/tables/FixedTableLayoutStrategy.cpp
@@ -194,34 +194,39 @@ FixedTableLayoutStrategy::ComputeColumnW
 
     // XXX Should we really ignore widths on column groups?
 
     PRUint32 unassignedCount = 0;
     nscoord unassignedSpace = tableWidth;
     const nscoord unassignedMarker = nscoord_MIN;
 
     // We use the PrefPercent on the columns to store the percentages
-    // used to compute column widths in case we need to reduce their
-    // basis.
+    // used to compute column widths in case we need to shrink or expand
+    // the columns.
     float pctTotal = 0.0f;
 
+    // Accumulate the total specified (non-percent) on the columns for
+    // distributing excess width to the columns.
+    nscoord specTotal = 0;
+
     for (PRInt32 col = 0; col < colCount; ++col) {
         nsTableColFrame *colFrame = mTableFrame->GetColFrame(col);
         if (!colFrame) {
             NS_ERROR("column frames out of sync with cell map");
             continue;
         }
         colFrame->ResetPrefPercent();
         const nsStyleCoord *styleWidth =
             &colFrame->GetStylePosition()->mWidth;
         nscoord colWidth;
         if (styleWidth->GetUnit() == eStyleUnit_Coord) {
             colWidth = nsLayoutUtils::ComputeWidthValue(
                          aReflowState.rendContext,
                          colFrame, 0, 0, 0, *styleWidth);
+            specTotal += colWidth;
         } else if (styleWidth->GetUnit() == eStyleUnit_Percent) {
             float pct = styleWidth->GetPercentValue();
             colWidth = NSToCoordFloor(pct * float(tableWidth));
             colFrame->AddPrefPercent(pct);
             pctTotal += pct;
         } else {
             NS_ASSERTION(styleWidth->GetUnit() == eStyleUnit_Auto ||
                          styleWidth->GetUnit() == eStyleUnit_Enumerated,
@@ -267,16 +272,19 @@ FixedTableLayoutStrategy::ComputeColumnW
                         // If a column-spanning cell is in the first
                         // row, split up the space evenly.  (XXX This
                         // isn't quite right if some of the columns it's
                         // in have specified widths.  Should we care?)
                         colWidth = ((colWidth + spacing) / colSpan) - spacing;
                         if (colWidth < 0)
                             colWidth = 0;
                     }
+                    if (styleWidth->GetUnit() != eStyleUnit_Percent) {
+                        specTotal += colWidth;
+                    }
                 }
             } else {
                 colWidth = unassignedMarker;
             }
         }
 
         colFrame->SetFinalWidth(colWidth);
 
@@ -308,33 +316,92 @@ FixedTableLayoutStrategy::ComputeColumnW
                     colWidth = 0;
                 colFrame->SetFinalWidth(colWidth);
             }
         }
         unassignedSpace = 0;
     }
 
     if (unassignedCount > 0) {
+        // The spec says to distribute the remaining space evenly among
+        // the columns.
         nscoord toAssign = unassignedSpace / unassignedCount;
         for (PRInt32 col = 0; col < colCount; ++col) {
             nsTableColFrame *colFrame = mTableFrame->GetColFrame(col);
             if (!colFrame) {
                 NS_ERROR("column frames out of sync with cell map");
                 continue;
             }
             if (colFrame->GetFinalWidth() == unassignedMarker)
                 colFrame->SetFinalWidth(toAssign);
         }
     } else if (unassignedSpace > 0) {
-        // The spec says to distribute extra space evenly.  (That's not
-        // what WinIE6 does, though.  It treats percentages and
-        // nonpercentages differently.)
-        nscoord toAdd = unassignedSpace / colCount;
-        for (PRInt32 col = 0; col < colCount; ++col) {
-            nsTableColFrame *colFrame = mTableFrame->GetColFrame(col);
-            if (!colFrame) {
-                NS_ERROR("column frames out of sync with cell map");
-                continue;
+        // The spec doesn't say how to distribute the unassigned space.
+        if (specTotal > 0) {
+            // Distribute proportionally to non-percentage columns.
+            nscoord specUndist = specTotal;
+            for (PRInt32 col = 0; col < colCount; ++col) {
+                nsTableColFrame *colFrame = mTableFrame->GetColFrame(col);
+                if (!colFrame) {
+                    NS_ERROR("column frames out of sync with cell map");
+                    continue;
+                }
+                if (colFrame->GetPrefPercent() == 0.0f) {
+                    NS_ASSERTION(colFrame->GetFinalWidth() <= specUndist,
+                                 "widths don't add up");
+                    nscoord toAdd = NSToCoordRound(float(unassignedSpace) *
+                       (float(colFrame->GetFinalWidth()) / float(specUndist)));
+                    specUndist -= colFrame->GetFinalWidth();
+                    colFrame->SetFinalWidth(colFrame->GetFinalWidth() + toAdd);
+                    unassignedSpace -= toAdd;
+                    if (specUndist <= 0) {
+                        NS_ASSERTION(specUndist == 0,
+                                     "math should be exact");
+                        break;
+                    }
+                }
             }
-            colFrame->SetFinalWidth(colFrame->GetFinalWidth() + toAdd);
+            NS_ASSERTION(unassignedSpace == 0, "failed to redistribute");
+        } else if (pctTotal > 0) {
+            // Distribute proportionally to percentage columns.
+            float pctUndist = pctTotal;
+            for (PRInt32 col = 0; col < colCount; ++col) {
+                nsTableColFrame *colFrame = mTableFrame->GetColFrame(col);
+                if (!colFrame) {
+                    NS_ERROR("column frames out of sync with cell map");
+                    continue;
+                }
+                if (pctUndist < colFrame->GetPrefPercent()) {
+                    // This can happen with floating-point math.
+                    NS_ASSERTION(colFrame->GetPrefPercent() - pctUndist
+                                   < 0.0001,
+                                 "widths don't add up");
+                    pctUndist = colFrame->GetPrefPercent();
+                }
+                nscoord toAdd = NSToCoordRound(float(unassignedSpace) *
+                    (colFrame->GetPrefPercent() / pctUndist));
+                colFrame->SetFinalWidth(colFrame->GetFinalWidth() + toAdd);
+                unassignedSpace -= toAdd;
+                pctUndist -= colFrame->GetPrefPercent();
+                if (pctUndist <= 0.0f) {
+                    break;
+                }
+            }
+            NS_ASSERTION(unassignedSpace == 0, "failed to redistribute");
+        } else {
+            // Distribute equally to the zero-width columns.
+            PRInt32 colsLeft = colCount;
+            for (PRInt32 col = 0; col < colCount; ++col) {
+                nsTableColFrame *colFrame = mTableFrame->GetColFrame(col);
+                if (!colFrame) {
+                    NS_ERROR("column frames out of sync with cell map");
+                    continue;
+                }
+                NS_ASSERTION(colFrame->GetFinalWidth() == 0, "yikes");
+                nscoord toAdd = NSToCoordRound(float(unassignedSpace) /
+                                               float(colsLeft));
+                colFrame->SetFinalWidth(toAdd);
+                unassignedSpace -= toAdd;
+                --colsLeft;
+            }
         }
     }
 }