Bug 413286: Let empty auto-width columns be expanded. r+sr=dbaron a=blocking1.9+
authordholbert@cs.stanford.edu
Thu, 21 Feb 2008 19:25:56 -0800
changeset 12071 8573db85a750ef223c891c8d7bb89cc92f10d1b2
parent 12070 9cc217f15d8a49a147fe7abebf0bc8fcdc611032
child 12072 0ce9e64afbb5bd098d60acfeed2d71a2beb54c72
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersblocking1.9
bugs413286
milestone1.9b4pre
Bug 413286: Let empty auto-width columns be expanded. r+sr=dbaron a=blocking1.9+
layout/reftests/bugs/413286-1-ref.html
layout/reftests/bugs/413286-1a.html
layout/reftests/bugs/413286-1b.html
layout/reftests/bugs/413286-1c.html
layout/reftests/bugs/413286-2-ref.html
layout/reftests/bugs/413286-2a.html
layout/reftests/bugs/413286-2b.html
layout/reftests/bugs/413286-2c.html
layout/reftests/bugs/413286-3-ref.html
layout/reftests/bugs/413286-3.html
layout/reftests/bugs/413286-4-ref.html
layout/reftests/bugs/413286-4a.html
layout/reftests/bugs/413286-4b.html
layout/reftests/bugs/413286-5-ref.html
layout/reftests/bugs/413286-5.html
layout/reftests/bugs/413286-6-ref.html
layout/reftests/bugs/413286-6.html
layout/reftests/bugs/reftest.list
layout/reftests/table-width/balancing-2-ref.html
layout/reftests/table-width/balancing-2.html
layout/tables/BasicTableLayoutStrategy.cpp
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/413286-1-ref.html
@@ -0,0 +1,89 @@
+<html>
+  <head>
+    <style>
+      table     { width: 400px; height: 25px; }
+      td.blue   { background: lightblue;  }
+      td.green  { background: lightgreen; }
+      td.skinny { width: 100px }
+      td.medium { width: 200px }
+      td.wide   { width: 300px }
+    </style>
+  </head>
+  <body>
+    With colspan:
+    <table cellspacing=0 cellpadding=0>
+      <tbody><tr>
+        <td class="blue skinny"></td>
+        <td class="green wide"></td>
+      </tr></tbody>
+    </table>
+    <table cellspacing=0 cellpadding=0>
+      <tbody><tr>
+        <td class="blue skinny"></td>
+        <td class="green wide"></td>
+      </tr></tbody>
+    </table>
+    <table cellspacing=0 cellpadding=0>
+      <tbody><tr>
+        <td class="blue skinny"></td>
+        <td class="green wide"></td>
+      </tr></tbody>
+    </table>
+    <table cellspacing=0 cellpadding=0>
+      <tbody><tr>
+        <td class="blue skinny"></td>
+        <td class="green wide"></td>
+      </tr></tbody>
+    </table>
+
+    Without colspan:
+    <table cellspacing=0 cellpadding=0>
+      <tbody><tr>
+        <td class="blue skinny"></td>
+        <td class="green wide"></td>
+      </tr></tbody>
+    </table>
+    <table cellspacing=0 cellpadding=0>
+      <tbody><tr>
+        <td class="blue skinny"></td>
+        <td class="green wide"></td>
+      </tr></tbody>
+    </table>
+    <table cellspacing=0 cellpadding=0>
+      <tbody><tr>
+        <td class="blue skinny"></td>
+        <td class="green wide"></td>
+      </tr></tbody>
+    </table>
+    <table cellspacing=0 cellpadding=0>
+      <tbody><tr>
+        <td class="blue skinny"></td>
+        <td class="green wide"></td>
+      </tr></tbody>
+    </table>
+    <table cellspacing=0 cellpadding=0>
+      <tbody><tr>
+        <td class="blue skinny"></td>
+        <td class="green wide"></td>
+      </tr></tbody>
+    </table>
+    <table cellspacing=0 cellpadding=0>
+      <tbody><tr>
+        <td class="blue skinny"></td>
+        <td class="green wide"></td>
+      </tr></tbody>
+    </table>
+    <table cellspacing=0 cellpadding=0>
+      <tbody><tr>
+        <td class="blue skinny"></td>
+        <td class="green wide"></td>
+      </tr></tbody>
+    </table>
+    <table cellspacing=0 cellpadding=0>
+      <tbody><tr>
+        <td class="blue skinny"></td>
+        <td class="green wide"></td>
+      </tr></tbody>
+    </table>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/413286-1a.html
@@ -0,0 +1,108 @@
+<html>
+  <head>
+    <style>
+      table     { width: 400px; height: 25px; }
+      td.blue   { background: lightblue;  color: lightblue  }
+      td.green  { background: lightgreen; color: lightgreen }
+      col.a     { width: 100px; }
+      col.c     { width: 25%;   }
+    </style>
+  </head>
+  <body>
+    With colspan:
+    <table cellspacing=0 cellpadding=0>
+      <colgroup><col class="a"/><col/><col class="c"/></colgroup>
+      <tbody><tr>
+        <td class="blue"></td>
+        <td class="green" colspan="2"></td>
+      </tr></tbody>
+    </table>
+    <table cellspacing=0 cellpadding=0>
+      <colgroup><col class="a"/><col/><col class="c"/></colgroup>
+      <tbody><tr>
+        <td class="blue">xxx</td>
+        <td class="green" colspan="2"></td>
+      </tr></tbody>
+    </table>
+    <table cellspacing=0 cellpadding=0>
+      <colgroup><col class="a"/><col/><col class="c"/></colgroup>
+      <tbody><tr>
+        <td class="blue"></td>
+        <td class="green" colspan="2">xxx</td>
+      </tr></tbody>
+    </table>
+    <table cellspacing=0 cellpadding=0>
+      <colgroup><col class="a"/><col/><col class="c"/></colgroup>
+      <tbody><tr>
+        <td class="blue">xxx</td>
+        <td class="green" colspan="2">xxx</td>
+      </tr></tbody>
+    </table>
+
+    Without colspan:
+    <table cellspacing=0 cellpadding=0>
+      <colgroup><col class="a"/><col/><col class="c"/></colgroup>
+      <tbody><tr>
+        <td class="blue"></td>
+        <td class="green"></td>
+        <td class="green"></td>
+      </tr></tbody>
+    </table>
+    <table cellspacing=0 cellpadding=0>
+      <colgroup><col class="a"/><col/><col class="c"/></colgroup>
+      <tbody><tr>
+        <td class="blue">xxx</td>
+        <td class="green"></td>
+        <td class="green"></td>
+      </tr></tbody>
+    </table>
+    <table cellspacing=0 cellpadding=0>
+      <colgroup><col class="a"/><col/><col class="c"/></colgroup>
+      <tbody><tr>
+        <td class="blue"></td>
+        <td class="green">xxx</td>
+        <td class="green"></td>
+      </tr></tbody>
+    </table>
+    <table cellspacing=0 cellpadding=0>
+      <colgroup><col class="a"/><col/><col class="c"/></colgroup>
+      <tbody><tr>
+        <td class="blue"></td>
+        <td class="green"></td>
+        <td class="green">xxx</td>
+      </tr></tbody>
+    </table>
+    <table cellspacing=0 cellpadding=0>
+      <colgroup><col class="a"/><col/><col class="c"/></colgroup>
+      <tbody><tr>
+        <td class="blue">xxx</td>
+        <td class="green">xxx</td>
+        <td class="green"></td>
+      </tr></tbody>
+    </table>
+    <table cellspacing=0 cellpadding=0>
+      <colgroup><col class="a"/><col/><col class="c"/></colgroup>
+      <tbody><tr>
+        <td class="blue">xxx</td>
+        <td class="green"></td>
+        <td class="green">xxx</td>
+      </tr></tbody>
+    </table>
+    <table cellspacing=0 cellpadding=0>
+      <colgroup><col class="a"/><col/><col class="c"/></colgroup>
+      <tbody><tr>
+        <td class="blue"></td>
+        <td class="green">xxx</td>
+        <td class="green">xxx</td>
+      </tr></tbody>
+    </table>
+    <table cellspacing=0 cellpadding=0>
+      <colgroup><col class="a"/><col/><col class="c"/></colgroup>
+      <tbody><tr>
+        <td class="blue">xxx</td>
+        <td class="green">xxx</td>
+        <td class="green">xxx</td>
+      </tr></tbody>
+    </table>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/413286-1b.html
@@ -0,0 +1,108 @@
+<html>
+  <head>
+    <style>
+      table     { width: 400px; height: 25px; }
+      td.blue   { background: lightblue;  color: lightblue  }
+      td.green  { background: lightgreen; color: lightgreen }
+      col.a     { width: 25%;   }
+      col.c     { width: 25%;   }
+    </style>
+  </head>
+  <body>
+    With colspan:
+    <table cellspacing=0 cellpadding=0>
+      <colgroup><col class="a"/><col/><col class="c"/></colgroup>
+      <tbody><tr>
+        <td class="blue"></td>
+        <td class="green" colspan="2"></td>
+      </tr></tbody>
+    </table>
+    <table cellspacing=0 cellpadding=0>
+      <colgroup><col class="a"/><col/><col class="c"/></colgroup>
+      <tbody><tr>
+        <td class="blue">xxx</td>
+        <td class="green" colspan="2"></td>
+      </tr></tbody>
+    </table>
+    <table cellspacing=0 cellpadding=0>
+      <colgroup><col class="a"/><col/><col class="c"/></colgroup>
+      <tbody><tr>
+        <td class="blue"></td>
+        <td class="green" colspan="2">xxx</td>
+      </tr></tbody>
+    </table>
+    <table cellspacing=0 cellpadding=0>
+      <colgroup><col class="a"/><col/><col class="c"/></colgroup>
+      <tbody><tr>
+        <td class="blue">xxx</td>
+        <td class="green" colspan="2">xxx</td>
+      </tr></tbody>
+    </table>
+
+    Without colspan:
+    <table cellspacing=0 cellpadding=0>
+      <colgroup><col class="a"/><col/><col class="c"/></colgroup>
+      <tbody><tr>
+        <td class="blue"></td>
+        <td class="green"></td>
+        <td class="green"></td>
+      </tr></tbody>
+    </table>
+    <table cellspacing=0 cellpadding=0>
+      <colgroup><col class="a"/><col/><col class="c"/></colgroup>
+      <tbody><tr>
+        <td class="blue">xxx</td>
+        <td class="green"></td>
+        <td class="green"></td>
+      </tr></tbody>
+    </table>
+    <table cellspacing=0 cellpadding=0>
+      <colgroup><col class="a"/><col/><col class="c"/></colgroup>
+      <tbody><tr>
+        <td class="blue"></td>
+        <td class="green">xxx</td>
+        <td class="green"></td>
+      </tr></tbody>
+    </table>
+    <table cellspacing=0 cellpadding=0>
+      <colgroup><col class="a"/><col/><col class="c"/></colgroup>
+      <tbody><tr>
+        <td class="blue"></td>
+        <td class="green"></td>
+        <td class="green">xxx</td>
+      </tr></tbody>
+    </table>
+    <table cellspacing=0 cellpadding=0>
+      <colgroup><col class="a"/><col/><col class="c"/></colgroup>
+      <tbody><tr>
+        <td class="blue">xxx</td>
+        <td class="green">xxx</td>
+        <td class="green"></td>
+      </tr></tbody>
+    </table>
+    <table cellspacing=0 cellpadding=0>
+      <colgroup><col class="a"/><col/><col class="c"/></colgroup>
+      <tbody><tr>
+        <td class="blue">xxx</td>
+        <td class="green"></td>
+        <td class="green">xxx</td>
+      </tr></tbody>
+    </table>
+    <table cellspacing=0 cellpadding=0>
+      <colgroup><col class="a"/><col/><col class="c"/></colgroup>
+      <tbody><tr>
+        <td class="blue"></td>
+        <td class="green">xxx</td>
+        <td class="green">xxx</td>
+      </tr></tbody>
+    </table>
+    <table cellspacing=0 cellpadding=0>
+      <colgroup><col class="a"/><col/><col class="c"/></colgroup>
+      <tbody><tr>
+        <td class="blue">xxx</td>
+        <td class="green">xxx</td>
+        <td class="green">xxx</td>
+      </tr></tbody>
+    </table>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/413286-1c.html
@@ -0,0 +1,108 @@
+<html>
+  <head>
+    <style>
+      table     { width: 400px; height: 25px; }
+      td.blue   { background: lightblue;  color: lightblue  }
+      td.green  { background: lightgreen; color: lightgreen }
+      col.a     { width: 100px; }
+      col.c     { width: 100px; }
+    </style>
+  </head>
+  <body>
+    With colspan:
+    <table cellspacing=0 cellpadding=0>
+      <colgroup><col class="a"/><col/><col class="c"/></colgroup>
+      <tbody><tr>
+        <td class="blue"></td>
+        <td class="green" colspan="2"></td>
+      </tr></tbody>
+    </table>
+    <table cellspacing=0 cellpadding=0>
+      <colgroup><col class="a"/><col/><col class="c"/></colgroup>
+      <tbody><tr>
+        <td class="blue">xxx</td>
+        <td class="green" colspan="2"></td>
+      </tr></tbody>
+    </table>
+    <table cellspacing=0 cellpadding=0>
+      <colgroup><col class="a"/><col/><col class="c"/></colgroup>
+      <tbody><tr>
+        <td class="blue"></td>
+        <td class="green" colspan="2">xxx</td>
+      </tr></tbody>
+    </table>
+    <table cellspacing=0 cellpadding=0>
+      <colgroup><col class="a"/><col/><col class="c"/></colgroup>
+      <tbody><tr>
+        <td class="blue">xxx</td>
+        <td class="green" colspan="2">xxx</td>
+      </tr></tbody>
+    </table>
+
+    Without colspan:
+    <table cellspacing=0 cellpadding=0>
+      <colgroup><col class="a"/><col/><col class="c"/></colgroup>
+      <tbody><tr>
+        <td class="blue"></td>
+        <td class="green"></td>
+        <td class="green"></td>
+      </tr></tbody>
+    </table>
+    <table cellspacing=0 cellpadding=0>
+      <colgroup><col class="a"/><col/><col class="c"/></colgroup>
+      <tbody><tr>
+        <td class="blue">xxx</td>
+        <td class="green"></td>
+        <td class="green"></td>
+      </tr></tbody>
+    </table>
+    <table cellspacing=0 cellpadding=0>
+      <colgroup><col class="a"/><col/><col class="c"/></colgroup>
+      <tbody><tr>
+        <td class="blue"></td>
+        <td class="green">xxx</td>
+        <td class="green"></td>
+      </tr></tbody>
+    </table>
+    <table cellspacing=0 cellpadding=0>
+      <colgroup><col class="a"/><col/><col class="c"/></colgroup>
+      <tbody><tr>
+        <td class="blue"></td>
+        <td class="green"></td>
+        <td class="green">xxx</td>
+      </tr></tbody>
+    </table>
+    <table cellspacing=0 cellpadding=0>
+      <colgroup><col class="a"/><col/><col class="c"/></colgroup>
+      <tbody><tr>
+        <td class="blue">xxx</td>
+        <td class="green">xxx</td>
+        <td class="green"></td>
+      </tr></tbody>
+    </table>
+    <table cellspacing=0 cellpadding=0>
+      <colgroup><col class="a"/><col/><col class="c"/></colgroup>
+      <tbody><tr>
+        <td class="blue">xxx</td>
+        <td class="green"></td>
+        <td class="green">xxx</td>
+      </tr></tbody>
+    </table>
+    <table cellspacing=0 cellpadding=0>
+      <colgroup><col class="a"/><col/><col class="c"/></colgroup>
+      <tbody><tr>
+        <td class="blue"></td>
+        <td class="green">xxx</td>
+        <td class="green">xxx</td>
+      </tr></tbody>
+    </table>
+    <table cellspacing=0 cellpadding=0>
+      <colgroup><col class="a"/><col/><col class="c"/></colgroup>
+      <tbody><tr>
+        <td class="blue">xxx</td>
+        <td class="green">xxx</td>
+        <td class="green">xxx</td>
+      </tr></tbody>
+    </table>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/413286-2-ref.html
@@ -0,0 +1,66 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Reference Case</title>
+  <style>
+    table     { width: 500px;      }
+    td        { height: 2em;       }
+    td.aqua   { background: aqua   }
+    td.lime   { background: lime   }
+    td.blue   { background: blue   }
+    td.pink   { background: pink   }
+    td.yellow { background: yellow }
+  </style>
+</head>
+<body>
+  <h2>No third column</h2>
+  <table cellpadding="0" cellspacing="0">
+    <tr>
+      <td class="aqua"></td>
+      <td class="aqua"></td>
+    </tr><tr>
+      <td class="lime" style="width: 50px"></td>
+      <td class="blue" style="width: 450px"></td>
+    </tr>
+  </table>
+
+  <h2>Third column with low percent width</h2>
+  <table cellpadding="0" cellspacing="0">
+    <tr>
+      <td class="aqua"></td>
+      <td class="aqua"></td>
+      <td class="yellow"></td>
+    </tr><tr>
+      <td class="lime" style="width: 50px"></td>
+      <td class="blue" style="width: 400px"></td>
+      <td class="pink" style="width: 50px"></td>
+    </tr>
+  </table>
+
+  <h2>Third column with medium percent width</h2>
+  <table cellpadding="0" cellspacing="0">
+    <tr>
+      <td class="aqua"></td>
+      <td class="aqua"></td>
+      <td class="yellow"></td>
+    </tr><tr>
+      <td class="lime" style="width: 50px"></td>
+      <td class="blue" style="width: 250px"></td>
+      <td class="pink" style="width: 200px"></td>
+    </tr>
+  </table>
+
+  <h2>Third column with preferred width</h2>
+  <table cellpadding="0" cellspacing="0">
+    <tr>
+      <td class="aqua"></td>
+      <td class="aqua"></td>
+      <td class="yellow"></td>
+    </tr><tr>
+      <td class="lime" style="width: 50px"></td>
+      <td class="blue" style="width: 400px"></td>
+      <td class="pink" style="width: 50px"></td>
+    </tr>
+  </table>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/413286-2a.html
@@ -0,0 +1,67 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Spanning cell has no specified width</title>
+  <style>
+    table     { width: 500px;      }
+    td        { height: 2em;       }
+    td.aqua   { background: aqua   }
+    td.lime   { background: lime   }
+    td.blue   { background: blue   }
+    td.pink   { background: pink   }
+    td.yellow { background: yellow }
+
+    td.lowPct    { width: 10% }
+    td.medPct    { width: 40% }
+    td.hiPct     { width: 50% }
+    td.specWidth { width: 50px }
+  </style>
+</head>
+<body>
+  <h2>No third column</h2>
+  <table cellpadding="0" cellspacing="0">
+    <tr>
+      <td colspan="2" class="aqua"></td>
+    </tr><tr>
+      <td class="lime specWidth"></td>
+      <td class="blue"></td>
+    </tr>
+  </table>
+
+  <h2>Third column with low percent width</h2>
+  <table cellpadding="0" cellspacing="0">
+    <tr>
+      <td colspan="2" class="aqua"></td>
+      <td class="yellow lowPct"></td>
+    </tr><tr>
+      <td class="lime specWidth"></td>
+      <td class="blue"></td>
+      <td class="pink lowPct"></td>
+    </tr>
+  </table>
+
+  <h2>Third column with medium percent width</h2>
+  <table cellpadding="0" cellspacing="0">
+    <tr>
+      <td colspan="2" class="aqua"></td>
+      <td class="yellow medPct"></td>
+    </tr><tr>
+      <td class="lime specWidth"></td>
+      <td class="blue"></td>
+      <td class="pink medPct"></td>
+    </tr>
+  </table>
+
+  <h2>Third column with preferred width</h2>
+  <table cellpadding="0" cellspacing="0">
+    <tr>
+      <td colspan="2" class="aqua"></td>
+      <td class="yellow specWidth"></td>
+    </tr><tr>
+      <td class="lime specWidth"></td>
+      <td class="blue"></td>
+      <td class="pink specWidth"></td>
+    </tr>
+  </table>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/413286-2b.html
@@ -0,0 +1,68 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Spanning cell has nonzero pref & min width</title>
+  <style>
+    table     { width: 500px;      }
+    td        { height: 2em;       }
+    td.aqua   { background: aqua   }
+    td.lime   { background: lime   }
+    td.blue   { background: blue   }
+    td.pink   { background: pink   }
+    td.yellow { background: yellow }
+
+    td.aquaText  { color: aqua }
+    td.lowPct    { width: 10% }
+    td.medPct    { width: 40% }
+    td.hiPct     { width: 50% }
+    td.specWidth { width: 50px }
+  </style>
+</head>
+<body>
+  <h2>No third column</h2>
+  <table cellpadding="0" cellspacing="0">
+    <tr>
+      <td colspan="2" class="aqua aquaText">text</td>
+    </tr><tr>
+      <td class="lime specWidth"></td>
+      <td class="blue"></td>
+    </tr>
+  </table>
+
+  <h2>Third column with low percent width</h2>
+  <table cellpadding="0" cellspacing="0">
+    <tr>
+      <td colspan="2" class="aqua aquaText">text</td>
+      <td class="yellow lowPct"></td>
+    </tr><tr>
+      <td class="lime specWidth"></td>
+      <td class="blue"></td>
+      <td class="pink lowPct"></td>
+    </tr>
+  </table>
+
+  <h2>Third column with medium percent width</h2>
+  <table cellpadding="0" cellspacing="0">
+    <tr>
+      <td colspan="2" class="aqua aquaText">text</td>
+      <td class="yellow medPct"></td>
+    </tr><tr>
+      <td class="lime specWidth"></td>
+      <td class="blue"></td>
+      <td class="pink medPct"></td>
+    </tr>
+  </table>
+
+  <h2>Third column with preferred width</h2>
+  <table cellpadding="0" cellspacing="0">
+    <tr>
+      <td colspan="2" class="aqua aquaText">text</td>
+      <td class="yellow specWidth"></td>
+    </tr><tr>
+      <td class="lime specWidth"></td>
+      <td class="blue"></td>
+      <td class="pink specWidth"></td>
+    </tr>
+  </table>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/413286-2c.html
@@ -0,0 +1,67 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Spanning cell has low percent width</title>
+  <style>
+    table     { width: 500px;      }
+    td        { height: 2em;       }
+    td.aqua   { background: aqua   }
+    td.lime   { background: lime   }
+    td.blue   { background: blue   }
+    td.pink   { background: pink   }
+    td.yellow { background: yellow }
+
+    td.lowPct    { width: 10% }
+    td.medPct    { width: 40% }
+    td.hiPct     { width: 50% }
+    td.specWidth { width: 50px }
+  </style>
+</head>
+<body>
+  <h2>No third column</h2>
+  <table cellpadding="0" cellspacing="0">
+    <tr>
+      <td colspan="2" class="aqua lowPct"></td>
+    </tr><tr>
+      <td class="lime specWidth"></td>
+      <td class="blue"></td>
+    </tr>
+  </table>
+
+  <h2>Third column with low percent width</h2>
+  <table cellpadding="0" cellspacing="0">
+    <tr>
+      <td colspan="2" class="aqua lowPct"></td>
+      <td class="yellow lowPct"></td>
+    </tr><tr>
+      <td class="lime specWidth"></td>
+      <td class="blue"></td>
+      <td class="pink lowPct"></td>
+    </tr>
+  </table>
+
+  <h2>Third column with medium percent width</h2>
+  <table cellpadding="0" cellspacing="0">
+    <tr>
+      <td colspan="2" class="aqua lowPct"></td>
+      <td class="yellow medPct"></td>
+    </tr><tr>
+      <td class="lime specWidth"></td>
+      <td class="blue"></td>
+      <td class="pink medPct"></td>
+    </tr>
+  </table>
+
+  <h2>Third column with preferred width</h2>
+  <table cellpadding="0" cellspacing="0">
+    <tr>
+      <td colspan="2" class="aqua lowPct"></td>
+      <td class="yellow specWidth"></td>
+    </tr><tr>
+      <td class="lime specWidth"></td>
+      <td class="blue"></td>
+      <td class="pink specWidth"></td>
+    </tr>
+  </table>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/413286-3-ref.html
@@ -0,0 +1,66 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Reference Case</title>
+  <style>
+    table     { width: 500px;      }
+    td        { height: 2em;       }
+    td.aqua   { background: aqua   }
+    td.lime   { background: lime   }
+    td.blue   { background: blue   }
+    td.pink   { background: pink   }
+    td.yellow { background: yellow }
+  </style>
+</head>
+<body>
+  <h2>No third column</h2>
+  <table cellpadding="0" cellspacing="0">
+    <tr>
+      <td class="aqua"></td>
+      <td class="aqua"></td>
+    </tr><tr>
+      <td class="lime" style="width: 250px"></td>
+      <td class="blue" style="width: 250px"></td>
+    </tr>
+  </table>
+
+  <h2>Third column with low percent width</h2>
+  <table cellpadding="0" cellspacing="0">
+    <tr>
+      <td class="aqua"></td>
+      <td class="aqua"></td>
+      <td class="yellow"></td>
+    </tr><tr>
+      <td class="lime" style="width: 250px"></td>
+      <td class="blue" style="width: 200px"></td>
+      <td class="pink" style="width: 50px"></td>
+    </tr>
+  </table>
+
+  <h2>Third column with medium percent width</h2>
+  <table cellpadding="0" cellspacing="0">
+    <tr>
+      <td class="aqua"></td>
+      <td class="aqua"></td>
+      <td class="yellow"></td>
+    </tr><tr>
+      <td class="lime" style="width: 250px"></td>
+      <td class="blue" style="width: 50px"></td>
+      <td class="pink" style="width: 200px"></td>
+    </tr>
+  </table>
+
+  <h2>Third column with preferred width</h2>
+  <table cellpadding="0" cellspacing="0">
+    <tr>
+      <td class="aqua"></td>
+      <td class="aqua"></td>
+      <td class="yellow"></td>
+    </tr><tr>
+      <td class="lime" style="width: 250px"></td>
+      <td class="blue" style="width: 200px"></td>
+      <td class="pink" style="width: 50px"></td>
+    </tr>
+  </table>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/413286-3.html
@@ -0,0 +1,67 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Spanning cell has high percent width</title>
+  <style>
+    table     { width: 500px;      }
+    td        { height: 2em;       }
+    td.aqua   { background: aqua   }
+    td.lime   { background: lime   }
+    td.blue   { background: blue   }
+    td.pink   { background: pink   }
+    td.yellow { background: yellow }
+
+    td.lowPct    { width: 10% }
+    td.medPct    { width: 40% }
+    td.hiPct     { width: 50% }
+    td.specWidth { width: 50px }
+  </style>
+</head>
+<body>
+  <h2>No third column</h2>
+  <table cellpadding="0" cellspacing="0">
+    <tr>
+      <td colspan="2" class="aqua hiPct"></td>
+    </tr><tr>
+      <td class="lime specWidth"></td>
+      <td class="blue"></td>
+    </tr>
+  </table>
+
+  <h2>Third column with low percent width</h2>
+  <table cellpadding="0" cellspacing="0">
+    <tr>
+      <td colspan="2" class="aqua hiPct"></td>
+      <td class="yellow lowPct"></td>
+    </tr><tr>
+      <td class="lime specWidth"></td>
+      <td class="blue"></td>
+      <td class="pink lowPct"></td>
+    </tr>
+  </table>
+
+  <h2>Third column with medium percent width</h2>
+  <table cellpadding="0" cellspacing="0">
+    <tr>
+      <td colspan="2" class="aqua hiPct"></td>
+      <td class="yellow medPct"></td>
+    </tr><tr>
+      <td class="lime specWidth"></td>
+      <td class="blue"></td>
+      <td class="pink medPct"></td>
+    </tr>
+  </table>
+
+  <h2>Third column with preferred width</h2>
+  <table cellpadding="0" cellspacing="0">
+    <tr>
+      <td colspan="2" class="aqua hiPct"></td>
+      <td class="yellow specWidth"></td>
+    </tr><tr>
+      <td class="lime specWidth"></td>
+      <td class="blue"></td>
+      <td class="pink specWidth"></td>
+    </tr>
+  </table>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/413286-4-ref.html
@@ -0,0 +1,66 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>First two columns have no width</title>
+  <style>
+    table     { width: 500px;      }
+    td        { height: 2em;       }
+    td.aqua   { background: aqua   }
+    td.lime   { background: lime   }
+    td.blue   { background: blue   }
+    td.pink   { background: pink   }
+    td.yellow { background: yellow }
+  </style>
+</head>
+<body>
+  <h2>No third column</h2>
+  <table cellpadding="0" cellspacing="0">
+    <tr>
+      <td class="aqua"></td>
+      <td class="aqua"></td>
+    </tr><tr>
+      <td class="lime" style="width: 250px"></td>
+      <td class="blue" style="width: 250px"></td>
+    </tr>
+  </table>
+
+  <h2>Third column with low percent width</h2>
+  <table cellpadding="0" cellspacing="0">
+    <tr>
+      <td class="aqua"></td>
+      <td class="aqua"></td>
+      <td class="yellow"></td>
+    </tr><tr>
+      <td class="lime" style="width: 225px"></td>
+      <td class="blue" style="width: 225px"></td>
+      <td class="pink" style="width: 50px"></td>
+    </tr>
+  </table>
+
+  <h2>Third column with medium percent width</h2>
+  <table cellpadding="0" cellspacing="0">
+    <tr>
+      <td class="aqua"></td>
+      <td class="aqua"></td>
+      <td class="yellow"></td>
+    </tr><tr>
+      <td class="lime" style="width: 150px"></td>
+      <td class="blue" style="width: 150px"></td>
+      <td class="pink" style="width: 200px"></td>
+    </tr>
+  </table>
+
+  <h2>Third column with preferred width</h2>
+  <table cellpadding="0" cellspacing="0">
+    <tr>
+      <td class="aqua"></td>
+      <td class="aqua"></td>
+      <td class="yellow"></td>
+    </tr><tr>
+      <td class="lime" style="width: 225px"></td>
+      <td class="blue" style="width: 225px"></td>
+      <td class="pink" style="width: 50px"></td>
+    </tr>
+  </table>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/413286-4a.html
@@ -0,0 +1,66 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Span & its columns have no width</title>
+  <style>
+    table     { width: 500px;      }
+    td        { height: 2em;       }
+    td.aqua   { background: aqua   }
+    td.lime   { background: lime   }
+    td.blue   { background: blue   }
+    td.pink   { background: pink   }
+    td.yellow { background: yellow }
+
+    td.lowPct    { width: 10% }
+    td.medPct    { width: 40% }
+    td.specWidth { width: 50px }
+  </style>
+</head>
+<body>
+  <h2>No third column</h2>
+  <table cellpadding="0" cellspacing="0">
+    <tr>
+      <td colspan="2" class="aqua"></td>
+    </tr><tr>
+      <td class="lime"></td>
+      <td class="blue"></td>
+    </tr>
+  </table>
+
+  <h2>Third column with low percent width</h2>
+  <table cellpadding="0" cellspacing="0">
+    <tr>
+      <td colspan="2" class="aqua"></td>
+      <td class="yellow lowPct"></td>
+    </tr><tr>
+      <td class="lime"></td>
+      <td class="blue"></td>
+      <td class="pink lowPct"></td>
+    </tr>
+  </table>
+
+  <h2>Third column with medium percent width</h2>
+  <table cellpadding="0" cellspacing="0">
+    <tr>
+      <td colspan="2" class="aqua"></td>
+      <td class="yellow medPct"></td>
+    </tr><tr>
+      <td class="lime"></td>
+      <td class="blue"></td>
+      <td class="pink medPct"></td>
+    </tr>
+  </table>
+
+  <h2>Third column with preferred width</h2>
+  <table cellpadding="0" cellspacing="0">
+    <tr>
+      <td colspan="2" class="aqua"></td>
+      <td class="yellow specWidth"></td>
+    </tr><tr>
+      <td class="lime"></td>
+      <td class="blue"></td>
+      <td class="pink specWidth"></td>
+    </tr>
+  </table>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/413286-4b.html
@@ -0,0 +1,70 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>First two columns have no width</title>
+  <style>
+    table     { width: 500px;      }
+    td        { height: 2em;       }
+    td.aqua   { background: aqua   }
+    td.lime   { background: lime   }
+    td.blue   { background: blue   }
+    td.pink   { background: pink   }
+    td.yellow { background: yellow }
+
+    td.lowPct    { width: 10% }
+    td.medPct    { width: 40% }
+    td.specWidth { width: 50px }
+  </style>
+</head>
+<body>
+  <h2>No third column</h2>
+  <table cellpadding="0" cellspacing="0">
+    <tr>
+      <td class="aqua"></td>
+      <td class="aqua"></td>
+    </tr><tr>
+      <td class="lime"></td>
+      <td class="blue"></td>
+    </tr>
+  </table>
+
+  <h2>Third column with low percent width</h2>
+  <table cellpadding="0" cellspacing="0">
+    <tr>
+      <td class="aqua"></td>
+      <td class="aqua"></td>
+      <td class="yellow lowPct"></td>
+    </tr><tr>
+      <td class="lime"></td>
+      <td class="blue"></td>
+      <td class="pink lowPct"></td>
+    </tr>
+  </table>
+
+  <h2>Third column with medium percent width</h2>
+  <table cellpadding="0" cellspacing="0">
+    <tr>
+      <td class="aqua"></td>
+      <td class="aqua"></td>
+      <td class="yellow medPct"></td>
+    </tr><tr>
+      <td class="lime"></td>
+      <td class="blue"></td>
+      <td class="pink medPct"></td>
+    </tr>
+  </table>
+
+  <h2>Third column with preferred width</h2>
+  <table cellpadding="0" cellspacing="0">
+    <tr>
+      <td class="aqua"></td>
+      <td class="aqua"></td>
+      <td class="yellow specWidth"></td>
+    </tr><tr>
+      <td class="lime"></td>
+      <td class="blue"></td>
+      <td class="pink specWidth"></td>
+    </tr>
+  </table>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/413286-5-ref.html
@@ -0,0 +1,68 @@
+<html>
+<head><style>
+  table        { width: 600px  }
+  td.smallSpec { width: 100px; }
+  td.bigSpec   { width: 500px; }
+  td.smallPct  { width: 10%;   }
+  td.bigPct    { width: 90%;   }
+  td.pink      { background: pink }
+  td.teal      { background: teal }
+</style></head>
+<body>
+
+<h2>Other column fixed-width</h2>
+
+<table cellspacing="0" cellpadding="0">
+  <tr>
+    <td class="smallSpec pink">100</td>
+    <td class="bigSpec teal"/>
+  </tr>
+</table>
+
+<h2>Other column percent-width</h2>
+
+<table cellspacing="0" cellpadding="0">
+  <tr>
+    <td class="smallPct pink">10%</td>
+    <td class="bigPct teal"/>
+  </tr>
+</table>
+
+<h2>Other column fixed-width; zero column spanned by colspan (crossing other column)</h2>
+
+<table cellspacing="0" cellpadding="0">
+  <tr>
+    <td class="smallSpec pink">100</td>
+    <td class="bigSpec teal"/>
+  </tr>
+</table>
+
+<h2>Other column percent-width; zero column spanned by colspan (crossing other column)</h2>
+
+<table cellspacing="0" cellpadding="0">
+  <tr>
+    <td class="smallPct pink">10%</td>
+    <td class="bigPct teal"/>
+  </tr>
+</table>
+
+<h2>Other column fixed-width; two zero columns with colspan</h2>
+
+<table cellspacing="0" cellpadding="0">
+  <tr>
+    <td class="smallSpec pink">100</td>
+    <td class="bigSpec teal"/>
+  </tr>
+</table>
+
+<h2>Other column percent-width; two zero columns with colspan</h2>
+
+<table cellspacing="0" cellpadding="0">
+  <tr>
+    <td class="smallPct pink">10%</td>
+    <td class="bigPct teal"/>
+  </tr>
+</table>
+
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/413286-5.html
@@ -0,0 +1,68 @@
+<html>
+<head><style>
+  table        { width: 600px  }
+  td.smallSpec { width: 100px; }
+  td.smallPct  { width: 10%;   }
+  td.pink      { background: pink }
+  td.teal      { background: teal }
+</style></head>
+<body>
+
+<h2>Other column fixed-width</h2>
+
+<table cellspacing="0" cellpadding="0">
+  <tr>
+    <td class="smallSpec pink">100</td>
+    <td class="teal"/>
+  </tr>
+</table>
+
+<h2>Other column percent-width</h2>
+
+<table cellspacing="0" cellpadding="0">
+  <tr>
+    <td class="smallPct pink">10%</td>
+    <td class="teal"/>
+  </tr>
+</table>
+
+<h2>Other column fixed-width; zero column spanned by colspan (crossing other column)</h2>
+
+<table cellspacing="0" cellpadding="0">
+  <tr>
+    <td class="smallSpec pink">100</td>
+    <td class="teal"/>
+  </tr>
+  <tr><td colspan="2"/></tr>
+</table>
+
+<h2>Other column percent-width; zero column spanned by colspan (crossing other column)</h2>
+
+<table cellspacing="0" cellpadding="0">
+  <tr>
+    <td class="smallPct pink">10%</td>
+    <td class="teal"/>
+  </tr>
+  <tr><td colspan="2"/></tr>
+</table>
+
+<h2>Other column fixed-width; two zero columns with colspan</h2>
+
+<table cellspacing="0" cellpadding="0">
+  <tr>
+    <td class="smallSpec pink">100</td>
+    <td class="teal" colspan="2"/>
+  </tr>
+</table>
+
+<h2>Other column percent-width; two zero columns with colspan</h2>
+
+<table cellspacing="0" cellpadding="0">
+  <tr>
+    <td class="smallPct pink">10%</td>
+    <td class="teal" colspan="2"/>
+  </tr>
+</table>
+
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/413286-6-ref.html
@@ -0,0 +1,48 @@
+<html>
+<head><style>
+  table        { width: 600px; }
+  td.smallSpec { width: 100px; }
+  td.bigSpec   { width: 500px; }
+  td.smallPct  { width: 10%;   }
+  td.bigPct    { width: 90%;   }
+  td.pink      { background: pink; }
+  td.teal      { background: teal; }
+</style></head>
+<body>
+
+<h2>Other column fixed-width; two zero columns with colspan; explicit 0 width on span</h2>
+
+<table cellspacing="0" cellpadding="0">
+  <tr>
+    <td class="smallSpec pink">100</td>
+    <td class="bigSpec teal"/>
+  </tr>
+</table>
+
+<h2>Other column percent-width; two zero columns with colspan; explicit 0 width on span</h2>
+
+<table cellspacing="0" cellpadding="0">
+  <tr>
+    <td class="smallPct pink">10%</td>
+    <td class="bigPct teal"/>
+  </tr>
+</table>
+
+<h2>Other column fixed-width; zero-column explicitly zero-width; zero column spanned by colspan (crossing other column)</h2>
+
+<table cellspacing="0" cellpadding="0">
+  <tr>
+    <td class="pink">100</td>
+  </tr>
+</table>
+
+<h2>Other column percent-width; zero-column explicitly zero-width; zero column spanned by colspan (crossing other column)</h2>
+
+<table cellspacing="0" cellpadding="0">
+  <tr>
+    <td class="pink">10%</td>
+  </tr>
+</table>
+
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/413286-6.html
@@ -0,0 +1,51 @@
+<html>
+<head><style>
+  table        { width: 600px; }
+  td.smallSpec { width: 100px; }
+  td.zeroSpec  { width: 0px;   }
+  td.smallPct  { width: 10%;   }
+  td.pink      { background: pink; }
+  td.teal      { background: teal; }
+</style></head>
+<body>
+
+<h2>Other column fixed-width; two zero columns with colspan; explicit 0 width on span</h2>
+
+<table cellspacing="0" cellpadding="0">
+  <tr>
+    <td class="smallSpec pink">100</td>
+    <td class="zeroSpec teal" colspan="2"/>
+  </tr>
+</table>
+
+<h2>Other column percent-width; two zero columns with colspan; explicit 0 width on span</h2>
+
+<table cellspacing="0" cellpadding="0">
+  <tr>
+    <td class="smallPct pink">10%</td>
+    <td class="zeroSpec teal" colspan="2"/>
+  </tr>
+</table>
+
+<h2>Other column fixed-width; zero-column explicitly zero-width; zero column spanned by colspan (crossing other column)</h2>
+
+<table cellspacing="0" cellpadding="0">
+  <tr>
+    <td class="smallSpec pink">100</td>
+    <td class="zeroSpec teal"/>
+  </tr>
+  <tr><td colspan="2"/></tr>
+</table>
+
+<h2>Other column percent-width; zero-column explicitly zero-width; zero column spanned by colspan (crossing other column)</h2>
+
+<table cellspacing="0" cellpadding="0">
+  <tr>
+    <td class="smallPct pink">10%</td>
+    <td class="zeroSpec teal"/>
+  </tr>
+  <tr><td colspan="2"/></tr>
+</table>
+
+</body>
+</html>
--- a/layout/reftests/bugs/reftest.list
+++ b/layout/reftests/bugs/reftest.list
@@ -703,16 +703,27 @@ random == 403134-1.html 403134-1-ref.htm
 != 409659-1c.html 409659-1-ref.html
 == 409659-1d.html 409659-1-ref.html
 == 411334-1.xml 411334-1-ref.xml
 == 411792-1.html 411792-1-ref.html
 == 412607-1a.html 412607-1-ref.html
 == 412607-1b.html 412607-1-ref.html
 == 412679-1.html 412679-1-ref.html
 == 412679-2.html 412679-2-ref.html
+== 413286-1a.html 413286-1-ref.html
+== 413286-1b.html 413286-1-ref.html
+== 413286-1c.html 413286-1-ref.html
+== 413286-2a.html 413286-2-ref.html
+== 413286-2b.html 413286-2-ref.html
+== 413286-2c.html 413286-2-ref.html
+== 413286-3.html 413286-3-ref.html 
+== 413286-4a.html 413286-4-ref.html 
+== 413286-4b.html 413286-4-ref.html 
+== 413286-5.html 413286-5-ref.html 
+== 413286-6.html 413286-6-ref.html 
 == 413292-1.html 413292-1-ref.html
 == 413361-1.html 413361-1-ref.html
 == 413840-background-unchanged.html 413840-background-unchanged-ref.html
 == 413840-ltr-offsets.html 413840-ltr-offsets-ref.html
 == 413840-rtl-offsets.html 413840-rtl-offsets-ref.html
 == 413840-pushed-line-bullet.html 413840-pushed-line-bullet-ref.html
 == 413840-bullet-first-line.html 413840-bullet-first-line-ref.html
 == 413982.html 413982-ref.html
--- a/layout/reftests/table-width/balancing-2-ref.html
+++ b/layout/reftests/table-width/balancing-2-ref.html
@@ -46,16 +46,30 @@ td { background: black; background: curr
 <!-- width: 400px --><table><tr>
 <td style="color:aqua"    width="50">&nbsp;</td>
 <td style="color:yellow"  width="50">&nbsp;</td>
 <td style="color:red"     width="0"></td>
 <td style="color:fuchsia" width="50">&nbsp;</td>
 <td style="color:blue"    width="250">&nbsp;</td>
 </tr></table>
 
+<!-- width: 420px --><table><tr>
+<td style="color:aqua"    width="75">&nbsp;</td>
+<td style="color:yellow"  width="85">&nbsp;</td>
+<td style="color:fuchsia" width="50">&nbsp;</td>
+<td style="color:blue"    width="210">&nbsp;</td>
+</tr></table>
+
+<!-- width: 400px --><table><tr>
+<td style="color:aqua"    width="60">&nbsp;</td>
+<td style="color:yellow"  width="80">&nbsp;</td>
+<td style="color:fuchsia" width="60">&nbsp;</td>
+<td style="color:blue"    width="200">&nbsp;</td>
+</tr></table>
+
 <!-- width: 400px --><table><tr>
 <td style="color:aqua"    width="100">&nbsp;</td>
 <td style="color:yellow"  width="100">&nbsp;</td>
 <td style="color:fuchsia" width="100">&nbsp;</td>
 <td style="color:blue"    width="100">&nbsp;</td>
 </tr></table>
 
 </body>
--- a/layout/reftests/table-width/balancing-2.html
+++ b/layout/reftests/table-width/balancing-2.html
@@ -52,32 +52,47 @@ span {
 <table width="518"><tr>
 <td style="color:aqua"><span></span>&#x200b;<span></span>&#x200b;<span></span></td>
 <td style="color:yellow"><span></span></td>
 <td style="color:red"></td>
 <td style="color:fuchsia" width="50"><span></span></td>
 <td style="color:blue" width="50%"><span></span></td>
 </tr></table>
 
+<!-- XXXdholbert: Change "width: 0px" to width="0px" in next 2 cases -->
 <table width="438"><tr>
 <td style="color:aqua" width="75"><span></span>&#x200b;<span></span>&#x200b;<span></span></td>
 <td style="color:yellow" width="25"><span></span></td>
-<td style="color:red"></td>
+<td style="color:red; width: 0px"></td>
 <td style="color:fuchsia" width="50"><span></span></td>
 <td style="color:blue" width="50%"><span></span></td>
 </tr></table>
 
 <table width="418"><tr>
 <td style="color:aqua" width="10%"><span></span></td>
 <td style="color:yellow" width="10%"><span></span></td>
-<td style="color:red"></td>
+<td style="color:red; width: 0px"></td>
 <td style="color:fuchsia" width="10%"><span></span></td>
 <td style="color:blue" width="50%"><span></span></td>
 </tr></table>
 
+<table width="435"><tr>
+<td style="color:aqua" width="75"><span></span>&#x200b;<span></span>&#x200b;<span></span></td>
+<td style="color:yellow"></td>
+<td style="color:fuchsia" width="50"><span></span></td>
+<td style="color:blue" width="50%"><span></span></td>
+</tr></table>
+
+<table width="415"><tr>
+<td style="color:aqua" width="15%"><span></span></td>
+<td style="color:yellow"></td>
+<td style="color:fuchsia" width="15%"><span></span></td>
+<td style="color:blue" width="50%"><span></span></td>
+</tr></table>
+
 <table width="415"><tr>
 <td style="color:aqua"></td>
 <td style="color:yellow"></td>
 <td style="color:fuchsia"></td>
 <td style="color:blue"></td>
 </tr></table>
 
 </body>
--- a/layout/tables/BasicTableLayoutStrategy.cpp
+++ b/layout/tables/BasicTableLayoutStrategy.cpp
@@ -667,36 +667,41 @@ BasicTableLayoutStrategy::DistributeWidt
      *
      * If |aWidth| is *larger* than what we would assign in (4), then we
      * expand the columns:
      *
      *   a. if any columns without a specified coordinate width or
      *   percent width have nonzero pref width, in proportion to pref
      *   width [total_flex_pref]
      *
-     *   b. otherwise, if any columns without percent width have nonzero
+     *   b. (NOTE: this case is for BTLS_FINAL_WIDTH only) otherwise, if any
+     *   columns without a specified coordinate width or percent width have
+     *   zero pref width, equally between these [numNonSpecZeroWidthCols]
+     *
+     *   c. otherwise, if any columns without percent width have nonzero
      *   pref width, in proportion to pref width [total_fixed_pref]
      *
-     *   c. otherwise, if any columns have nonzero percentage widths, in
+     *   d. otherwise, if any columns have nonzero percentage widths, in
      *   proportion to the percentage widths [total_pct]
      *
-     *   d. otherwise, equally.
+     *   e. otherwise, equally.
      */
 
     // Loop #1 over the columns, to figure out the four values above so
     // we know which case we're dealing with.
 
     nscoord guess_min = 0,
             guess_min_pct = 0,
             guess_min_spec = 0,
             guess_pref = 0,
             total_flex_pref = 0,
             total_fixed_pref = 0;
     float total_pct = 0.0f; // 0.0f to 1.0f
     PRInt32 numInfiniteWidthCols = 0;
+    PRInt32 numNonSpecZeroWidthCols = 0;
 
     PRInt32 col;
     for (col = aFirstCol; col < aFirstCol + aColCount; ++col) {
         nsTableColFrame *colFrame = mTableFrame->GetColFrame(col);
         if (!colFrame) {
             NS_ERROR("column frames out of sync with cell map");
             continue;
         }
@@ -708,45 +713,50 @@ BasicTableLayoutStrategy::DistributeWidt
             nscoord val = nscoord(float(aWidth) * pct);
             if (val < min_width)
                 val = min_width;
             guess_min_pct += val;
             guess_pref = NSCoordSaturatingAdd(guess_pref, val);
         } else {
             nscoord pref_width = colFrame->GetPrefCoord();
             if (pref_width == nscoord_MAX) {
-                numInfiniteWidthCols++;
+                ++numInfiniteWidthCols;
             }
             guess_pref = NSCoordSaturatingAdd(guess_pref, pref_width);
             guess_min_pct += min_width;
             if (colFrame->GetHasSpecifiedCoord()) {
                 // we'll add on the rest of guess_min_spec outside the
                 // loop
                 nscoord delta = NSCoordSaturatingSubtract(pref_width, 
                                                           min_width, 0);
                 guess_min_spec = NSCoordSaturatingAdd(guess_min_spec, delta);
                 total_fixed_pref = NSCoordSaturatingAdd(total_fixed_pref, 
                                                         pref_width);
+            } else if (pref_width == 0) {
+                if (aWidthType == BTLS_FINAL_WIDTH) {
+                    ++numNonSpecZeroWidthCols;
+                }
             } else {
                 total_flex_pref = NSCoordSaturatingAdd(total_flex_pref,
                                                        pref_width);
             }
         }
     }
     guess_min_spec = NSCoordSaturatingAdd(guess_min_spec, guess_min_pct);
 
     // Determine what we're flexing:
     enum Loop2Type {
         FLEX_PCT_SMALL, // between (1) and (2) above
         FLEX_FIXED_SMALL, // between (2) and (3) above
         FLEX_FLEX_SMALL, // between (3) and (4) above
         FLEX_FLEX_LARGE, // greater than (4) above, case (a)
-        FLEX_FIXED_LARGE, // greater than (4) above, case (b)
-        FLEX_PCT_LARGE, // greater than (4) above, case (c)
-        FLEX_ALL_LARGE // greater than (4) above, case (d)
+        FLEX_FLEX_LARGE_ZERO, // greater than (4) above, case (b)
+        FLEX_FIXED_LARGE, // greater than (4) above, case (c)
+        FLEX_PCT_LARGE, // greater than (4) above, case (d)
+        FLEX_ALL_LARGE // greater than (4) above, case (e)
     };
 
     Loop2Type l2t;
     // These are constants (over columns) for each case's math.  We use
     // a pair of nscoords rather than a float so that we can subtract
     // each column's allocation so we avoid accumulating rounding error.
     nscoord space; // the amount of extra width to allocate
     union {
@@ -777,16 +787,22 @@ BasicTableLayoutStrategy::DistributeWidt
             basis.c = NSCoordSaturatingSubtract(guess_pref, guess_min_spec,
                                                 nscoord_MAX);
         }
     } else {
         space = NSCoordSaturatingSubtract(aWidth, guess_pref, nscoord_MAX);
         if (total_flex_pref > 0) {
             l2t = FLEX_FLEX_LARGE;
             basis.c = total_flex_pref;
+        } else if (numNonSpecZeroWidthCols > 0) {
+            NS_ASSERTION(aWidthType == BTLS_FINAL_WIDTH,
+                         "numNonSpecZeroWidthCols should only "
+                         "be set when we're setting final width.");
+            l2t = FLEX_FLEX_LARGE_ZERO;
+            basis.c = numNonSpecZeroWidthCols;
         } else if (total_fixed_pref > 0) {
             l2t = FLEX_FIXED_LARGE;
             basis.c = total_fixed_pref;
         } else if (total_pct > 0.0f) {
             l2t = FLEX_PCT_LARGE;
             basis.f = total_pct;
         } else {
             l2t = FLEX_ALL_LARGE;
@@ -873,17 +889,17 @@ BasicTableLayoutStrategy::DistributeWidt
                         // nscoord_MAX and will cancel each other out in the
                         // col_width adjustment (making us assign all the
                         // space to the first inf-width col).  To correct for
                         // this, we'll also divide by numInfiniteWidthCols to
                         // spread the space equally among the inf-width cols.
                         if (numInfiniteWidthCols) {
                             if (colFrame->GetPrefCoord() == nscoord_MAX) {
                                 c = c / float(numInfiniteWidthCols);
-                                numInfiniteWidthCols--;
+                                --numInfiniteWidthCols;
                             } else {
                                 c = 0.0f;
                             }
                         }
                         basis.c = NSCoordSaturatingSubtract(basis.c, 
                                                             pref_minus_min,
                                                             nscoord_MAX);
                         col_width += NSToCoordRound(
@@ -903,16 +919,33 @@ BasicTableLayoutStrategy::DistributeWidt
                         } else {
                             float c = float(space) / float(basis.c);
                             basis.c -= col_width;
                             col_width += NSToCoordRound(float(col_width) * c);
                         }
                     }
                 }
                 break;
+            case FLEX_FLEX_LARGE_ZERO:
+                NS_ASSERTION(aWidthType == BTLS_FINAL_WIDTH,
+                             "FLEX_FLEX_LARGE_ZERO only should be hit "
+                             "when we're setting final width.");
+                if (pct == 0.0f &&
+                    !colFrame->GetHasSpecifiedCoord()) {
+
+                    NS_ASSERTION(col_width == 0 &&
+                                 colFrame->GetPrefCoord() == 0,
+                                 "Since we're in FLEX_FLEX_LARGE_ZERO case, "
+                                 "all auto-width cols should have zero pref "
+                                 "width.");
+                    float c = float(space) / float(basis.c);
+                    col_width += NSToCoordRound(c);
+                    --basis.c;
+                }
+                break;
             case FLEX_FIXED_LARGE:
                 if (pct == 0.0f) {
                     NS_ASSERTION(col_width == colFrame->GetPrefCoord(),
                                  "wrong width assigned");
                     NS_ASSERTION(colFrame->GetHasSpecifiedCoord() ||
                                  colFrame->GetPrefCoord() == 0,
                                  "wrong case");
                     if (col_width != 0) {