Merge backout of 6ce5f62a59455c79b3e12414989d3727f283b7c3 due to mac startup failures.

This commit is contained in:
L. David Baron 2008-11-25 14:38:11 -08:00
Родитель bcce3fc718 114a60a7ec
Коммит 5ce4b1b1cf
9 изменённых файлов: 12 добавлений и 1208 удалений

Просмотреть файл

@ -1,147 +0,0 @@
<!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>

Просмотреть файл

@ -1,149 +0,0 @@
<!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>

Просмотреть файл

@ -1,187 +0,0 @@
<!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>

Просмотреть файл

@ -1,155 +0,0 @@
<!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>

Просмотреть файл

@ -1,148 +0,0 @@
<!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>

Просмотреть файл

@ -1,150 +0,0 @@
<!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>

Просмотреть файл

@ -1,188 +0,0 @@
<!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>

Просмотреть файл

@ -919,11 +919,6 @@ fails == 441259-2.html 441259-2-ref.html # bug 441400
== 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

Просмотреть файл

@ -199,14 +199,10 @@ FixedTableLayoutStrategy::ComputeColumnWidths(const nsHTMLReflowState& aReflowSt
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 shrink or expand
// the columns.
// used to compute column widths in case we need to reduce their
// basis.
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) {
@ -221,7 +217,6 @@ FixedTableLayoutStrategy::ComputeColumnWidths(const nsHTMLReflowState& aReflowSt
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));
@ -277,9 +272,6 @@ FixedTableLayoutStrategy::ComputeColumnWidths(const nsHTMLReflowState& aReflowSt
if (colWidth < 0)
colWidth = 0;
}
if (styleWidth->GetUnit() != eStyleUnit_Percent) {
specTotal += colWidth;
}
}
} else {
colWidth = unassignedMarker;
@ -321,8 +313,6 @@ FixedTableLayoutStrategy::ComputeColumnWidths(const nsHTMLReflowState& aReflowSt
}
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);
@ -334,74 +324,17 @@ FixedTableLayoutStrategy::ComputeColumnWidths(const nsHTMLReflowState& aReflowSt
colFrame->SetFinalWidth(toAssign);
}
} else if (unassignedSpace > 0) {
// 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;
}
}
}
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;
// 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;
}
colFrame->SetFinalWidth(colFrame->GetFinalWidth() + toAdd);
}
}
}