When inserting a col into a colgroup after a col with span, insert it after the last columnframe spanned by the span.
Bug 404301, r=bernd, sr=roc, a=schrep
When inserting a col into a colgroup after a col with span, insert it after the last columnframe spanned by the span.
Bug 404301, r=bernd, sr=roc, a=schrep
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/404301-1-ref.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+table { background: white }
+col[span] { background: green }
+td { color: white }
+</style>
+</head>
+<body>
+ <table>
+ <colgroup id="x">
+ <col span="2"></col>
+ <col></col>
+ <col id="y"></col>
+ </colgroup>
+ <tr>
+ <td>One</td>
+ <td>Two</td>
+ <td>Three</td>
+ <td>Four</td>
+ </tr>
+ </table>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/404301-1.html
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+table { background: white }
+col[span] { background: green }
+td { color: white }
+</style>
+</head>
+<body onload="runTest()">
+ <table>
+ <colgroup id="x">
+ <col span="2"></col>
+ <col id="y"></col>
+ </colgroup>
+ <tr>
+ <td>One</td>
+ <td>Two</td>
+ <td>Three</td>
+ <td>Four</td>
+ </tr>
+ </table>
+
+ <script>
+ function runTest() {
+ document.body.offsetWidth;
+ document.getElementById("x").insertBefore(document.createElement("col"),
+ document.getElementById("y"));
+ }
+ </script>
+</body>
+</html>
--- a/layout/reftests/bugs/reftest.list
+++ b/layout/reftests/bugs/reftest.list
@@ -467,8 +467,9 @@ fails == 386310-1d.html 386310-1-ref.htm
== 403656-3.html 403656-3-ref.html
== 403656-4.html 403656-4-ref.html
== 403656-5.html 403656-5-ref.html
== 403733-1.html 403733-1-ref.html
== 403962-1.xhtml 403962-1-ref.xhtml
== 404030-1.html 404030-1-ref.html
!= 404030-1-notref.html 404030-1.html
!= 404030-1-notref2.html 404030-1.html
++== 404301-1.html 404301-1-ref.html
--- a/layout/tables/nsTableColGroupFrame.cpp
+++ b/layout/tables/nsTableColGroupFrame.cpp
@@ -210,17 +210,19 @@ nsTableColGroupFrame::AppendFrames(nsIAt
nsIFrame* aFrameList)
{
NS_ASSERTION(!aListName, "unexpected child list");
nsTableColFrame* col = GetFirstColumn();
nsTableColFrame* nextCol;
while (col && col->GetColType() == eColAnonymousColGroup) {
// this colgroup spans one or more columns but now that there is a
- // real column below, spanned anonymous columns should be removed
+ // real column below, spanned anonymous columns should be removed,
+ // since the HTML spec says to ignore the span of a colgroup if it
+ // has content columns in it.
nextCol = col->GetNextCol();
RemoveFrame(nsnull, col);
col = nextCol;
}
mFrames.AppendFrames(this, aFrameList);
InsertColsReflow(GetStartColumnIndex() + mColCount, aFrameList);
return NS_OK;
@@ -236,23 +238,35 @@ nsTableColGroupFrame::InsertFrames(nsIAt
"inserting after sibling frame with different parent");
nsFrameList frames(aFrameList); // convience for getting last frame
nsIFrame* lastFrame = frames.LastChild();
nsTableColFrame* col = GetFirstColumn();
nsTableColFrame* nextCol;
while (col && col->GetColType() == eColAnonymousColGroup) {
- // this colgroup spans one or more columns but now that there is
- // real column below, spanned anonymous columns should be removed
+ // this colgroup spans one or more columns but now that there is a
+ // real column below, spanned anonymous columns should be removed,
+ // since the HTML spec says to ignore the span of a colgroup if it
+ // has content columns in it.
nextCol = col->GetNextCol();
RemoveFrame(nsnull, col);
col = nextCol;
}
+ if (aPrevFrame) {
+ col = GetNextColumn(aPrevFrame);
+ while (col && col->GetColType() == eColAnonymousCol) {
+ // This is a column frame from a <col span="N">. We want to
+ // insert our new frame after the end of this span
+ aPrevFrame = col;
+ col = col->GetNextCol();
+ }
+ }
+
mFrames.InsertFrames(this, aPrevFrame, aFrameList);
nsIFrame* prevFrame = nsTableFrame::GetFrameAtOrBefore(this, aPrevFrame,
nsGkAtoms::tableColFrame);
PRInt32 colIndex = (prevFrame) ? ((nsTableColFrame*)prevFrame)->GetColIndex() + 1 : GetStartColumnIndex();
InsertColsReflow(colIndex, aFrameList, lastFrame);
return NS_OK;