Bug 434733: Don't apply width on colgroups to columns that have their own width. r=dbaron

This commit is contained in:
Makoto Kato 2009-08-01 08:53:40 -07:00
parent 7fbb9db0a5
commit 63a9fda84f
6 changed files with 62 additions and 8 deletions

View File

@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<head>
<title>Testcase for width attribute of colgroup element (bug 434733)</title>
</head>
<body>
<table border="1">
<colgroup><col width="200"/><col width="400"/></colgroup>
<tr><td>width is 200</td><td>width is 400</td></tr>
</table>
</body>
</html>

View File

@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<head>
<title>Testcase for width attribute of colgroup element (bug 434733)</title>
</head>
<body>
<table border="1">
<colgroup width="400"><col width="200"/><col/></colgroup>
<tr><td>width is 200</td><td>width is 400</td></tr>
</table>
</body>
</html>

View File

@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<head>
<title>Testcase for width attribute of colgroup element (bug 434733)</title>
</head>
<body>
<table border="1" width="600">
<colgroup><col width="20%"/><col width="40%"/><col width="40%"/></colgroup>
<tr><td>width is 20%</td><td>width is 40%</td><td>width is 40%</td></tr>
</table>
</body>
</html>

View File

@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<head>
<title>Testcase for width attribute of colgroup element (bug 434733)</title>
</head>
<body>
<table border="1" width="600">
<colgroup width="40%"><col width="20%"/><col/><col/></colgroup>
<tr><td>width is 20%</td><td>width is 40%</td><td>width is 40%</td></tr>
</table>
</body>
</html>

View File

@ -54,3 +54,5 @@ fails == default-box-sizing-collapse-quirks.html default-box-sizing-collapse-qui
== spanning-cell-sort-2-large.html spanning-cell-sort-2-ref.html
== spanning-cell-sort-2-small-fixed.html spanning-cell-sort-2-fixed-ref.html
== spanning-cell-sort-2-large-fixed.html spanning-cell-sort-2-fixed-ref.html
== colgroup-vs-column-1.html colgroup-vs-column-1-ref.html
== colgroup-vs-column-2.html colgroup-vs-column-2-ref.html

View File

@ -273,14 +273,18 @@ BasicTableLayoutStrategy::ComputeColumnIntrinsicWidths(nsIRenderingContext* aRen
// Consider the widths on the column-group. Note that we follow
// what the HTML spec says here, and make the width apply to
// each column in the group, not the group as a whole.
// XXX Should we be doing this when we have widths on the column?
NS_ASSERTION(colFrame->GetParent()->GetType() ==
nsGkAtoms::tableColGroupFrame,
"expected a column-group");
colInfo = GetColWidthInfo(aRenderingContext, colFrame->GetParent());
colFrame->AddCoords(colInfo.minCoord, colInfo.prefCoord,
colInfo.hasSpecifiedWidth);
colFrame->AddPrefPercent(colInfo.prefPercent);
// If column has width, column-group doesn't override width.
if (colInfo.minCoord == 0 && colInfo.prefCoord == 0 &&
colInfo.prefPercent == 0.0f) {
NS_ASSERTION(colFrame->GetParent()->GetType() ==
nsGkAtoms::tableColGroupFrame,
"expected a column-group");
colInfo = GetColWidthInfo(aRenderingContext, colFrame->GetParent());
colFrame->AddCoords(colInfo.minCoord, colInfo.prefCoord,
colInfo.hasSpecifiedWidth);
colFrame->AddPrefPercent(colInfo.prefPercent);
}
// Consider the contents of and the widths on the cells without
// colspans.