Fix bug 404666 by making spanned colframes be continuations of the col that spans them. r=bernd, sr=roc, a=schrep

This commit is contained in:
bzbarsky@mit.edu 2007-12-02 23:45:06 -08:00
parent 55cae0276c
commit 6c0d0c1564
9 changed files with 118 additions and 13 deletions

View File

@ -3984,8 +3984,10 @@ nsCSSFrameConstructor::ConstructTableColFrame(nsFrameConstructorState& aState,
return NS_ERROR_OUT_OF_MEMORY;
}
InitAndRestoreFrame(aState, aContent, parentFrame, nsnull, newCol, PR_FALSE);
newCol->SetColType(eColAnonymousCol);
lastCol->SetNextSibling(newCol);
lastCol->SetNextContinuation(newCol);
newCol->SetPrevContinuation(lastCol);
newCol->SetColType(eColAnonymousCol);
lastCol = newCol;
}

View File

@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<style>
table { background: white }
col { background: green }
td { color: white }
</style>
</head>
<body>
<table>
<col id="col" span="2">
<tr>
<td>One</td>
<td>Two</td>
<td>Three</td>
</tr>
</table>
</html>

View File

@ -0,0 +1,25 @@
<!DOCTYPE html>
<html>
<head>
<style>
table { background: white }
td { color: white }
</style>
<script>
function runTest()
{
document.body.offsetHeight;
document.getElementById("col").style.backgroundColor = "green";
}
</script>
</head>
<body onload="runTest()">
<table>
<col id="col" span="2">
<tr>
<td>One</td>
<td>Two</td>
<td>Three</td>
</tr>
</table>
</html>

View File

@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<style>
table {background-color:green}
col {background-color:red}
td { color: white }
</style>
</head>
<body>
<table>
<col id="col" span="2" style="visibility: collapse">
<tr>
<td>One</td>
<td>Two</td>
<td>Three</td>
</tr>
</table>
</html>

View File

@ -0,0 +1,26 @@
<!DOCTYPE html>
<html>
<head>
<style>
table {background-color:green}
col {background-color:red}
td { color: white }
</style>
<script>
function runTest()
{
document.body.offsetHeight;
document.getElementById("col").style.visibility = "collapse";
}
</script>
</head>
<body onload="runTest()">
<table>
<col id="col" span="2">
<tr>
<td>One</td>
<td>Two</td>
<td>Three</td>
</tr>
</table>
</html>

View File

@ -487,6 +487,8 @@ random == 403134-1.html 403134-1-ref.html # bug 405377
!= 404030-1-notref2.html 404030-1.html
== 404301-1.html 404301-1-ref.html
!= data:application/xml,<foo/> data:text/plain, # bug 404419
== 404666-1.html 404666-1-ref.html
== 404666-2.html 404666-2-ref.html
== 405186-1.xhtml about:blank
== 405305-1.html 405305-1-ref.html
== 405584-1.html 405584-1-ref.html

View File

@ -52,7 +52,8 @@
#define COL_CONSTRAINT_BITS 0x07000000 // uses bits 25-27
#define COL_CONSTRAINT_OFFSET 24
nsTableColFrame::nsTableColFrame(nsStyleContext* aContext) : nsFrame(aContext)
nsTableColFrame::nsTableColFrame(nsStyleContext* aContext) :
nsSplittableFrame(aContext)
{
SetColType(eColContent);
ResetIntrinsics();
@ -73,6 +74,11 @@ nsTableColFrame::GetColType() const
void
nsTableColFrame::SetColType(nsTableColType aType)
{
NS_ASSERTION(aType != eColAnonymousCol ||
(GetPrevContinuation() &&
GetPrevContinuation()->GetNextContinuation() == this &&
GetPrevContinuation()->GetNextSibling() == this),
"spanned content cols must be continuations");
PRUint32 type = aType - eColContent;
mState |= (type << COL_TYPE_OFFSET);
}
@ -172,7 +178,7 @@ nsTableColFrame::Init(nsIContent* aContent,
nsIFrame* aPrevInFlow)
{
// Let the base class do its initialization
nsresult rv = nsFrame::Init(aContent, aParent, aPrevInFlow);
nsresult rv = nsSplittableFrame::Init(aContent, aParent, aPrevInFlow);
// record that children that are ignorable whitespace should be excluded
mState |= NS_FRAME_EXCLUDE_IGNORABLE_WHITESPACE;
@ -206,3 +212,10 @@ nsTableColFrame::GetFrameName(nsAString& aResult) const
return MakeFrameName(NS_LITERAL_STRING("TableCol"), aResult);
}
#endif
nsSplittableType
nsTableColFrame::GetSplittableType() const
{
return NS_FRAME_NOT_SPLITTABLE;
}

View File

@ -51,7 +51,7 @@ enum nsTableColType {
eColAnonymousCell = 3 // the result of a cell alone
};
class nsTableColFrame : public nsFrame {
class nsTableColFrame : public nsSplittableFrame {
public:
enum {eWIDTH_SOURCE_NONE =0, // no cell has contributed to the width style
@ -103,6 +103,8 @@ public:
NS_IMETHOD GetFrameName(nsAString& aResult) const;
#endif
virtual nsSplittableType GetSplittableType() const;
/** return the number of the columns the col represents. always >= 1 */
PRInt32 GetSpan();

View File

@ -247,20 +247,17 @@ nsTableColGroupFrame::InsertFrames(nsIAtom* aListName,
// 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.
NS_ASSERTION(col != aPrevFrame, "Bad aPrevFrame");
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();
}
}
NS_ASSERTION(!aPrevFrame || aPrevFrame == aPrevFrame->GetLastContinuation(),
"Prev frame should be last in continuation chain");
NS_ASSERTION(!aPrevFrame || !GetNextColumn(aPrevFrame) ||
GetNextColumn(aPrevFrame)->GetColType() != eColAnonymousCol,
"Shouldn't be inserting before a spanned colframe");
mFrames.InsertFrames(this, aPrevFrame, aFrameList);
nsIFrame* prevFrame = nsTableFrame::GetFrameAtOrBefore(this, aPrevFrame,