make visibility collapse work during incr reflows bug 77019 r= bzbarsky sr=dbaron

git-svn-id: svn://10.0.0.236/trunk@155641 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
bmlk%gmx.de 2004-04-28 16:42:59 +00:00
parent 1ef606ae5f
commit 8cea43fadb
12 changed files with 174 additions and 28 deletions

View File

@ -36,6 +36,7 @@
* ***** END LICENSE BLOCK ***** */ * ***** END LICENSE BLOCK ***** */
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsTableColFrame.h" #include "nsTableColFrame.h"
#include "nsTableFrame.h"
#include "nsContainerFrame.h" #include "nsContainerFrame.h"
#include "nsStyleContext.h" #include "nsStyleContext.h"
#include "nsStyleConsts.h" #include "nsStyleConsts.h"
@ -176,6 +177,15 @@ NS_METHOD nsTableColFrame::Reflow(nsIPresContext* aPresContext,
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus); DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
aDesiredSize.width=0; aDesiredSize.width=0;
aDesiredSize.height=0; aDesiredSize.height=0;
const nsStyleVisibility* colVis = GetStyleVisibility();
PRBool collapseCol = (NS_STYLE_VISIBILITY_COLLAPSE == colVis->mVisible);
if (collapseCol) {
nsTableFrame* tableFrame = nsnull;
nsTableFrame::GetTableFrame(this, tableFrame);
if (tableFrame) {
tableFrame->SetNeedToCollapseColumns(PR_TRUE);
}
}
if (aDesiredSize.mComputeMEW) if (aDesiredSize.mComputeMEW)
{ {
aDesiredSize.mMaxElementWidth=0; aDesiredSize.mMaxElementWidth=0;

View File

@ -426,10 +426,21 @@ NS_METHOD nsTableColGroupFrame::Reflow(nsIPresContext* aPresContext,
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus); DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
NS_ASSERTION(nsnull!=mContent, "bad state -- null content for frame"); NS_ASSERTION(nsnull!=mContent, "bad state -- null content for frame");
nsresult rv=NS_OK; nsresult rv=NS_OK;
const nsStyleVisibility* groupVis = GetStyleVisibility();
PRBool collapseGroup = (NS_STYLE_VISIBILITY_COLLAPSE == groupVis->mVisible);
if (collapseGroup) {
nsTableFrame* tableFrame = nsnull;
nsTableFrame::GetTableFrame(this, tableFrame);
if (tableFrame) {
tableFrame->SetNeedToCollapseColumns(PR_TRUE);
}
}
// for every content child that (is a column thingy and does not already have a frame) // for every content child that (is a column thingy and does not already have a frame)
// create a frame and adjust it's style // create a frame and adjust it's style
nsIFrame* kidFrame = nsnull; nsIFrame* kidFrame = nsnull;
if (eReflowReason_Incremental == aReflowState.reason) { if (eReflowReason_Incremental == aReflowState.reason) {
rv = IncrementalReflow(aPresContext, aDesiredSize, aReflowState, aStatus); rv = IncrementalReflow(aPresContext, aDesiredSize, aReflowState, aStatus);
} }

View File

@ -1905,7 +1905,6 @@ NS_METHOD nsTableFrame::Reflow(nsIPresContext* aPresContext,
GET_TWIPS_TO_PIXELS(aPresContext, p2t); GET_TWIPS_TO_PIXELS(aPresContext, p2t);
CalcBCBorders(*aPresContext); CalcBCBorders(*aPresContext);
} }
PRBool doCollapse = PR_FALSE; // collapsing rows, cols, etc.
aDesiredSize.width = aReflowState.availableWidth; aDesiredSize.width = aReflowState.availableWidth;
@ -2004,7 +2003,7 @@ NS_METHOD nsTableFrame::Reflow(nsIPresContext* aPresContext,
? NS_UNCONSTRAINEDSIZE : aReflowState.availableHeight; ? NS_UNCONSTRAINEDSIZE : aReflowState.availableHeight;
ReflowTable(aPresContext, aDesiredSize, aReflowState, availHeight, nextReason, ReflowTable(aPresContext, aDesiredSize, aReflowState, availHeight, nextReason,
lastChildReflowed, doCollapse, balanced, aStatus); lastChildReflowed, balanced, aStatus);
reflowedChildren = PR_TRUE; reflowedChildren = PR_TRUE;
} }
if (willInitiateSpecialReflow && NS_FRAME_IS_COMPLETE(aStatus)) { if (willInitiateSpecialReflow && NS_FRAME_IS_COMPLETE(aStatus)) {
@ -2017,7 +2016,7 @@ NS_METHOD nsTableFrame::Reflow(nsIPresContext* aPresContext,
((nsHTMLReflowState::ReflowStateFlags&)aReflowState.mFlags).mSpecialHeightReflow = PR_TRUE; ((nsHTMLReflowState::ReflowStateFlags&)aReflowState.mFlags).mSpecialHeightReflow = PR_TRUE;
ReflowTable(aPresContext, aDesiredSize, aReflowState, aReflowState.availableHeight, ReflowTable(aPresContext, aDesiredSize, aReflowState, aReflowState.availableHeight,
nextReason, lastChildReflowed, doCollapse, balanced, aStatus); nextReason, lastChildReflowed, balanced, aStatus);
// restore the previous special height reflow initiator // restore the previous special height reflow initiator
((nsHTMLReflowState&)aReflowState).mPercentHeightReflowInitiator = specialReflowInitiator; ((nsHTMLReflowState&)aReflowState).mPercentHeightReflowInitiator = specialReflowInitiator;
// XXX We should call SetInitiatedSpecialReflow(PR_FALSE) at some point, but it is difficult to tell when // XXX We should call SetInitiatedSpecialReflow(PR_FALSE) at some point, but it is difficult to tell when
@ -2054,8 +2053,10 @@ NS_METHOD nsTableFrame::Reflow(nsIPresContext* aPresContext,
nsMargin borderPadding = GetChildAreaOffset(&aReflowState); nsMargin borderPadding = GetChildAreaOffset(&aReflowState);
SetColumnDimensions(aDesiredSize.height, borderPadding); SetColumnDimensions(aDesiredSize.height, borderPadding);
if (doCollapse) { if (NeedToCollapseRows()) {
AdjustForCollapsingRows(aPresContext, aDesiredSize.height); AdjustForCollapsingRows(aPresContext, aDesiredSize.height);
}
if (NeedToCollapseColumns()) {
AdjustForCollapsingCols(aPresContext, aDesiredSize.width); AdjustForCollapsingCols(aPresContext, aDesiredSize.width);
} }
@ -2133,12 +2134,10 @@ nsTableFrame::ReflowTable(nsIPresContext* aPresContext,
nscoord aAvailHeight, nscoord aAvailHeight,
nsReflowReason aReason, nsReflowReason aReason,
nsIFrame*& aLastChildReflowed, nsIFrame*& aLastChildReflowed,
PRBool& aDoCollapse,
PRBool& aDidBalance, PRBool& aDidBalance,
nsReflowStatus& aStatus) nsReflowStatus& aStatus)
{ {
nsresult rv = NS_OK; nsresult rv = NS_OK;
aDoCollapse = PR_FALSE;
aDidBalance = PR_FALSE; aDidBalance = PR_FALSE;
aLastChildReflowed = nsnull; aLastChildReflowed = nsnull;
@ -2165,8 +2164,6 @@ nsTableFrame::ReflowTable(nsIPresContext* aPresContext,
if (eReflowReason_Resize == aReflowState.reason) { if (eReflowReason_Resize == aReflowState.reason) {
if (!DidResizeReflow()) { if (!DidResizeReflow()) {
// XXX we need to do this in other cases as well, but it needs to be made more incremental
aDoCollapse = PR_TRUE;
SetResizeReflow(PR_TRUE); SetResizeReflow(PR_TRUE);
} }
} }
@ -2292,14 +2289,21 @@ nsTableFrame::CollapseRowGroupIfNecessary(nsIPresContext* aPresContext,
const nsStyleVisibility* groupVis = aRowGroupFrame->GetStyleVisibility(); const nsStyleVisibility* groupVis = aRowGroupFrame->GetStyleVisibility();
PRBool collapseGroup = (NS_STYLE_VISIBILITY_COLLAPSE == groupVis->mVisible); PRBool collapseGroup = (NS_STYLE_VISIBILITY_COLLAPSE == groupVis->mVisible);
if (collapseGroup) {
SetNeedToCollapseRows(PR_TRUE);
}
nsIFrame* rowFrame = aRowGroupFrame->GetFirstChild(nsnull); nsIFrame* rowFrame = aRowGroupFrame->GetFirstChild(nsnull);
while (nsnull != rowFrame) { while (nsnull != rowFrame) {
const nsStyleDisplay* rowDisplay = rowFrame->GetStyleDisplay(); const nsStyleDisplay* rowDisplay = rowFrame->GetStyleDisplay();
if (NS_STYLE_DISPLAY_TABLE_ROW == rowDisplay->mDisplay) { if (NS_STYLE_DISPLAY_TABLE_ROW == rowDisplay->mDisplay) {
const nsStyleVisibility* rowVis = rowFrame->GetStyleVisibility(); const nsStyleVisibility* rowVis = rowFrame->GetStyleVisibility();
PRBool collapseRow = (NS_STYLE_VISIBILITY_COLLAPSE == rowVis->mVisible);
if (collapseRow) {
SetNeedToCollapseRows(PR_TRUE);
}
nsRect rowRect = rowFrame->GetRect(); nsRect rowRect = rowFrame->GetRect();
if (collapseGroup || (NS_STYLE_VISIBILITY_COLLAPSE == rowVis->mVisible)) { if (collapseGroup || collapseRow) {
aYGroupOffset += rowRect.height; aYGroupOffset += rowRect.height;
rowRect.height = 0; rowRect.height = 0;
rowFrame->SetRect(rowRect); rowFrame->SetRect(rowRect);
@ -2362,7 +2366,9 @@ NS_METHOD nsTableFrame::AdjustForCollapsingRows(nsIPresContext* aPresContext,
nscoord yGroupOffset = 0; // total offset among rows within a single row group nscoord yGroupOffset = 0; // total offset among rows within a single row group
nscoord yTotalOffset = 0; // total offset among all rows in all row groups nscoord yTotalOffset = 0; // total offset among all rows in all row groups
PRInt32 rowIndex = 0; PRInt32 rowIndex = 0;
// reset the bit, it will be set again if row/rowgroup is collapsed
SetNeedToCollapseRows(PR_FALSE);
// collapse the rows and/or row groups as necessary // collapse the rows and/or row groups as necessary
while (nsnull != groupFrame) { while (nsnull != groupFrame) {
if (IsRowGroup(groupFrame->GetStyleDisplay()->mDisplay)) { if (IsRowGroup(groupFrame->GetStyleDisplay()->mDisplay)) {
@ -2383,7 +2389,9 @@ NS_METHOD nsTableFrame::AdjustForCollapsingCols(nsIPresContext* aPresContext,
{ {
nsTableCellMap* cellMap = GetCellMap(); nsTableCellMap* cellMap = GetCellMap();
if (!cellMap) return NS_OK; if (!cellMap) return NS_OK;
// reset the bit, it will be set again if col/colgroup is collapsed
SetNeedToCollapseColumns(PR_FALSE);
PRInt32 numRows = cellMap->GetRowCount(); PRInt32 numRows = cellMap->GetRowCount();
nsTableIterator groupIter(mColGroups, eTableDIR); nsTableIterator groupIter(mColGroups, eTableDIR);
nsIFrame* groupFrame = groupIter.First(); nsIFrame* groupFrame = groupIter.First();
@ -2396,6 +2404,9 @@ NS_METHOD nsTableFrame::AdjustForCollapsingCols(nsIPresContext* aPresContext,
const nsStyleVisibility* groupVis = groupFrame->GetStyleVisibility(); const nsStyleVisibility* groupVis = groupFrame->GetStyleVisibility();
PRBool collapseGroup = (NS_STYLE_VISIBILITY_COLLAPSE == groupVis->mVisible); PRBool collapseGroup = (NS_STYLE_VISIBILITY_COLLAPSE == groupVis->mVisible);
if (collapseGroup) {
SetNeedToCollapseColumns(PR_TRUE);
}
nsTableIterator colIter(*groupFrame, eTableDIR); nsTableIterator colIter(*groupFrame, eTableDIR);
nsIFrame* colFrame = colIter.First(); nsIFrame* colFrame = colIter.First();
// iterate over the cols in the col group // iterate over the cols in the col group
@ -2404,6 +2415,9 @@ NS_METHOD nsTableFrame::AdjustForCollapsingCols(nsIPresContext* aPresContext,
if (NS_STYLE_DISPLAY_TABLE_COLUMN == colDisplay->mDisplay) { if (NS_STYLE_DISPLAY_TABLE_COLUMN == colDisplay->mDisplay) {
const nsStyleVisibility* colVis = colFrame->GetStyleVisibility(); const nsStyleVisibility* colVis = colFrame->GetStyleVisibility();
PRBool collapseCol = (NS_STYLE_VISIBILITY_COLLAPSE == colVis->mVisible); PRBool collapseCol = (NS_STYLE_VISIBILITY_COLLAPSE == colVis->mVisible);
if (collapseCol) {
SetNeedToCollapseColumns(PR_TRUE);
}
PRInt32 colWidth = GetColumnWidth(colX); PRInt32 colWidth = GetColumnWidth(colX);
if (collapseGroup || collapseCol) { if (collapseGroup || collapseCol) {
xOffset += colWidth + cellSpacingX; xOffset += colWidth + cellSpacingX;

View File

@ -382,7 +382,6 @@ public:
nscoord aAvailHeight, nscoord aAvailHeight,
nsReflowReason aReason, nsReflowReason aReason,
nsIFrame*& aLastChildReflowed, nsIFrame*& aLastChildReflowed,
PRBool& aDoCollapse,
PRBool& aDidBalance, PRBool& aDidBalance,
nsReflowStatus& aStatus); nsReflowStatus& aStatus);
@ -788,6 +787,12 @@ public:
PRBool NeedToCalcBCBorders() const; PRBool NeedToCalcBCBorders() const;
void SetNeedToCalcBCBorders(PRBool aValue); void SetNeedToCalcBCBorders(PRBool aValue);
PRBool NeedToCollapseRows() const;
void SetNeedToCollapseRows(PRBool aValue);
PRBool NeedToCollapseColumns() const;
void SetNeedToCollapseColumns(PRBool aValue);
/** Get the cell map for this table frame. It is not always mCellMap. /** Get the cell map for this table frame. It is not always mCellMap.
* Only the firstInFlow has a legit cell map * Only the firstInFlow has a legit cell map
@ -930,7 +935,9 @@ protected:
PRUint32 mInitiatedSpecialReflow:1; PRUint32 mInitiatedSpecialReflow:1;
PRUint32 mNeedToCalcBCBorders:1; PRUint32 mNeedToCalcBCBorders:1;
PRUint32 mLeftContBCBorder:8; PRUint32 mLeftContBCBorder:8;
PRUint32 : 11; // unused PRUint32 mNeedToCollapseRows:1; // rows that have visibility need to be collapse
PRUint32 mNeedToCollapseColumns:1; // colums that have visibility need to be collapsed
PRUint32 :9; // unused
} mBits; } mBits;
nsTableCellMap* mCellMap; // maintains the relationships between rows, cols, and cells nsTableCellMap* mCellMap; // maintains the relationships between rows, cols, and cells
@ -1048,6 +1055,26 @@ inline void nsTableFrame::SetRowInserted(PRBool aValue)
mBits.mRowInserted = (unsigned)aValue; mBits.mRowInserted = (unsigned)aValue;
} }
inline void nsTableFrame::SetNeedToCollapseRows(PRBool aValue)
{
mBits.mNeedToCollapseRows = (unsigned)aValue;
}
inline PRBool nsTableFrame::NeedToCollapseRows() const
{
return (PRBool)mBits.mNeedToCollapseRows;
}
inline void nsTableFrame::SetNeedToCollapseColumns(PRBool aValue)
{
mBits.mNeedToCollapseColumns = (unsigned)aValue;
}
inline PRBool nsTableFrame::NeedToCollapseColumns() const
{
return (PRBool)mBits.mNeedToCollapseColumns;
}
inline nsFrameList& nsTableFrame::GetColGroups() inline nsFrameList& nsTableFrame::GetColGroups()
{ {
return NS_STATIC_CAST(nsTableFrame*, GetFirstInFlow())->mColGroups; return NS_STATIC_CAST(nsTableFrame*, GetFirstInFlow())->mColGroups;

View File

@ -1373,6 +1373,12 @@ nsTableRowFrame::Reflow(nsIPresContext* aPresContext,
rv = nsTableFrame::GetTableFrame(this, tableFrame); rv = nsTableFrame::GetTableFrame(this, tableFrame);
if (!tableFrame) return NS_ERROR_NULL_POINTER; if (!tableFrame) return NS_ERROR_NULL_POINTER;
const nsStyleVisibility* rowVis = GetStyleVisibility();
PRBool collapseRow = (NS_STYLE_VISIBILITY_COLLAPSE == rowVis->mVisible);
if (collapseRow) {
tableFrame->SetNeedToCollapseRows(PR_TRUE);
}
// see if a special height reflow needs to occur due to having a pct height // see if a special height reflow needs to occur due to having a pct height
if (!NeedSpecialReflow()) if (!NeedSpecialReflow())
nsTableFrame::CheckRequestSpecialHeightReflow(aReflowState); nsTableFrame::CheckRequestSpecialHeightReflow(aReflowState);

View File

@ -1201,6 +1201,11 @@ nsTableRowGroupFrame::Reflow(nsIPresContext* aPresContext,
nsRowGroupReflowState state(aReflowState, tableFrame); nsRowGroupReflowState state(aReflowState, tableFrame);
PRBool haveDesiredHeight = PR_FALSE; PRBool haveDesiredHeight = PR_FALSE;
const nsStyleVisibility* groupVis = GetStyleVisibility();
PRBool collapseGroup = (NS_STYLE_VISIBILITY_COLLAPSE == groupVis->mVisible);
if (collapseGroup) {
tableFrame->SetNeedToCollapseRows(PR_TRUE);
}
if (eReflowReason_Incremental == aReflowState.reason) { if (eReflowReason_Incremental == aReflowState.reason) {
rv = IncrementalReflow(aPresContext, aDesiredSize, state, aStatus); rv = IncrementalReflow(aPresContext, aDesiredSize, state, aStatus);

View File

@ -36,6 +36,7 @@
* ***** END LICENSE BLOCK ***** */ * ***** END LICENSE BLOCK ***** */
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsTableColFrame.h" #include "nsTableColFrame.h"
#include "nsTableFrame.h"
#include "nsContainerFrame.h" #include "nsContainerFrame.h"
#include "nsStyleContext.h" #include "nsStyleContext.h"
#include "nsStyleConsts.h" #include "nsStyleConsts.h"
@ -176,6 +177,15 @@ NS_METHOD nsTableColFrame::Reflow(nsIPresContext* aPresContext,
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus); DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
aDesiredSize.width=0; aDesiredSize.width=0;
aDesiredSize.height=0; aDesiredSize.height=0;
const nsStyleVisibility* colVis = GetStyleVisibility();
PRBool collapseCol = (NS_STYLE_VISIBILITY_COLLAPSE == colVis->mVisible);
if (collapseCol) {
nsTableFrame* tableFrame = nsnull;
nsTableFrame::GetTableFrame(this, tableFrame);
if (tableFrame) {
tableFrame->SetNeedToCollapseColumns(PR_TRUE);
}
}
if (aDesiredSize.mComputeMEW) if (aDesiredSize.mComputeMEW)
{ {
aDesiredSize.mMaxElementWidth=0; aDesiredSize.mMaxElementWidth=0;

View File

@ -426,10 +426,21 @@ NS_METHOD nsTableColGroupFrame::Reflow(nsIPresContext* aPresContext,
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus); DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
NS_ASSERTION(nsnull!=mContent, "bad state -- null content for frame"); NS_ASSERTION(nsnull!=mContent, "bad state -- null content for frame");
nsresult rv=NS_OK; nsresult rv=NS_OK;
const nsStyleVisibility* groupVis = GetStyleVisibility();
PRBool collapseGroup = (NS_STYLE_VISIBILITY_COLLAPSE == groupVis->mVisible);
if (collapseGroup) {
nsTableFrame* tableFrame = nsnull;
nsTableFrame::GetTableFrame(this, tableFrame);
if (tableFrame) {
tableFrame->SetNeedToCollapseColumns(PR_TRUE);
}
}
// for every content child that (is a column thingy and does not already have a frame) // for every content child that (is a column thingy and does not already have a frame)
// create a frame and adjust it's style // create a frame and adjust it's style
nsIFrame* kidFrame = nsnull; nsIFrame* kidFrame = nsnull;
if (eReflowReason_Incremental == aReflowState.reason) { if (eReflowReason_Incremental == aReflowState.reason) {
rv = IncrementalReflow(aPresContext, aDesiredSize, aReflowState, aStatus); rv = IncrementalReflow(aPresContext, aDesiredSize, aReflowState, aStatus);
} }

View File

@ -1905,7 +1905,6 @@ NS_METHOD nsTableFrame::Reflow(nsIPresContext* aPresContext,
GET_TWIPS_TO_PIXELS(aPresContext, p2t); GET_TWIPS_TO_PIXELS(aPresContext, p2t);
CalcBCBorders(*aPresContext); CalcBCBorders(*aPresContext);
} }
PRBool doCollapse = PR_FALSE; // collapsing rows, cols, etc.
aDesiredSize.width = aReflowState.availableWidth; aDesiredSize.width = aReflowState.availableWidth;
@ -2004,7 +2003,7 @@ NS_METHOD nsTableFrame::Reflow(nsIPresContext* aPresContext,
? NS_UNCONSTRAINEDSIZE : aReflowState.availableHeight; ? NS_UNCONSTRAINEDSIZE : aReflowState.availableHeight;
ReflowTable(aPresContext, aDesiredSize, aReflowState, availHeight, nextReason, ReflowTable(aPresContext, aDesiredSize, aReflowState, availHeight, nextReason,
lastChildReflowed, doCollapse, balanced, aStatus); lastChildReflowed, balanced, aStatus);
reflowedChildren = PR_TRUE; reflowedChildren = PR_TRUE;
} }
if (willInitiateSpecialReflow && NS_FRAME_IS_COMPLETE(aStatus)) { if (willInitiateSpecialReflow && NS_FRAME_IS_COMPLETE(aStatus)) {
@ -2017,7 +2016,7 @@ NS_METHOD nsTableFrame::Reflow(nsIPresContext* aPresContext,
((nsHTMLReflowState::ReflowStateFlags&)aReflowState.mFlags).mSpecialHeightReflow = PR_TRUE; ((nsHTMLReflowState::ReflowStateFlags&)aReflowState.mFlags).mSpecialHeightReflow = PR_TRUE;
ReflowTable(aPresContext, aDesiredSize, aReflowState, aReflowState.availableHeight, ReflowTable(aPresContext, aDesiredSize, aReflowState, aReflowState.availableHeight,
nextReason, lastChildReflowed, doCollapse, balanced, aStatus); nextReason, lastChildReflowed, balanced, aStatus);
// restore the previous special height reflow initiator // restore the previous special height reflow initiator
((nsHTMLReflowState&)aReflowState).mPercentHeightReflowInitiator = specialReflowInitiator; ((nsHTMLReflowState&)aReflowState).mPercentHeightReflowInitiator = specialReflowInitiator;
// XXX We should call SetInitiatedSpecialReflow(PR_FALSE) at some point, but it is difficult to tell when // XXX We should call SetInitiatedSpecialReflow(PR_FALSE) at some point, but it is difficult to tell when
@ -2054,8 +2053,10 @@ NS_METHOD nsTableFrame::Reflow(nsIPresContext* aPresContext,
nsMargin borderPadding = GetChildAreaOffset(&aReflowState); nsMargin borderPadding = GetChildAreaOffset(&aReflowState);
SetColumnDimensions(aDesiredSize.height, borderPadding); SetColumnDimensions(aDesiredSize.height, borderPadding);
if (doCollapse) { if (NeedToCollapseRows()) {
AdjustForCollapsingRows(aPresContext, aDesiredSize.height); AdjustForCollapsingRows(aPresContext, aDesiredSize.height);
}
if (NeedToCollapseColumns()) {
AdjustForCollapsingCols(aPresContext, aDesiredSize.width); AdjustForCollapsingCols(aPresContext, aDesiredSize.width);
} }
@ -2133,12 +2134,10 @@ nsTableFrame::ReflowTable(nsIPresContext* aPresContext,
nscoord aAvailHeight, nscoord aAvailHeight,
nsReflowReason aReason, nsReflowReason aReason,
nsIFrame*& aLastChildReflowed, nsIFrame*& aLastChildReflowed,
PRBool& aDoCollapse,
PRBool& aDidBalance, PRBool& aDidBalance,
nsReflowStatus& aStatus) nsReflowStatus& aStatus)
{ {
nsresult rv = NS_OK; nsresult rv = NS_OK;
aDoCollapse = PR_FALSE;
aDidBalance = PR_FALSE; aDidBalance = PR_FALSE;
aLastChildReflowed = nsnull; aLastChildReflowed = nsnull;
@ -2165,8 +2164,6 @@ nsTableFrame::ReflowTable(nsIPresContext* aPresContext,
if (eReflowReason_Resize == aReflowState.reason) { if (eReflowReason_Resize == aReflowState.reason) {
if (!DidResizeReflow()) { if (!DidResizeReflow()) {
// XXX we need to do this in other cases as well, but it needs to be made more incremental
aDoCollapse = PR_TRUE;
SetResizeReflow(PR_TRUE); SetResizeReflow(PR_TRUE);
} }
} }
@ -2292,14 +2289,21 @@ nsTableFrame::CollapseRowGroupIfNecessary(nsIPresContext* aPresContext,
const nsStyleVisibility* groupVis = aRowGroupFrame->GetStyleVisibility(); const nsStyleVisibility* groupVis = aRowGroupFrame->GetStyleVisibility();
PRBool collapseGroup = (NS_STYLE_VISIBILITY_COLLAPSE == groupVis->mVisible); PRBool collapseGroup = (NS_STYLE_VISIBILITY_COLLAPSE == groupVis->mVisible);
if (collapseGroup) {
SetNeedToCollapseRows(PR_TRUE);
}
nsIFrame* rowFrame = aRowGroupFrame->GetFirstChild(nsnull); nsIFrame* rowFrame = aRowGroupFrame->GetFirstChild(nsnull);
while (nsnull != rowFrame) { while (nsnull != rowFrame) {
const nsStyleDisplay* rowDisplay = rowFrame->GetStyleDisplay(); const nsStyleDisplay* rowDisplay = rowFrame->GetStyleDisplay();
if (NS_STYLE_DISPLAY_TABLE_ROW == rowDisplay->mDisplay) { if (NS_STYLE_DISPLAY_TABLE_ROW == rowDisplay->mDisplay) {
const nsStyleVisibility* rowVis = rowFrame->GetStyleVisibility(); const nsStyleVisibility* rowVis = rowFrame->GetStyleVisibility();
PRBool collapseRow = (NS_STYLE_VISIBILITY_COLLAPSE == rowVis->mVisible);
if (collapseRow) {
SetNeedToCollapseRows(PR_TRUE);
}
nsRect rowRect = rowFrame->GetRect(); nsRect rowRect = rowFrame->GetRect();
if (collapseGroup || (NS_STYLE_VISIBILITY_COLLAPSE == rowVis->mVisible)) { if (collapseGroup || collapseRow) {
aYGroupOffset += rowRect.height; aYGroupOffset += rowRect.height;
rowRect.height = 0; rowRect.height = 0;
rowFrame->SetRect(rowRect); rowFrame->SetRect(rowRect);
@ -2362,7 +2366,9 @@ NS_METHOD nsTableFrame::AdjustForCollapsingRows(nsIPresContext* aPresContext,
nscoord yGroupOffset = 0; // total offset among rows within a single row group nscoord yGroupOffset = 0; // total offset among rows within a single row group
nscoord yTotalOffset = 0; // total offset among all rows in all row groups nscoord yTotalOffset = 0; // total offset among all rows in all row groups
PRInt32 rowIndex = 0; PRInt32 rowIndex = 0;
// reset the bit, it will be set again if row/rowgroup is collapsed
SetNeedToCollapseRows(PR_FALSE);
// collapse the rows and/or row groups as necessary // collapse the rows and/or row groups as necessary
while (nsnull != groupFrame) { while (nsnull != groupFrame) {
if (IsRowGroup(groupFrame->GetStyleDisplay()->mDisplay)) { if (IsRowGroup(groupFrame->GetStyleDisplay()->mDisplay)) {
@ -2383,7 +2389,9 @@ NS_METHOD nsTableFrame::AdjustForCollapsingCols(nsIPresContext* aPresContext,
{ {
nsTableCellMap* cellMap = GetCellMap(); nsTableCellMap* cellMap = GetCellMap();
if (!cellMap) return NS_OK; if (!cellMap) return NS_OK;
// reset the bit, it will be set again if col/colgroup is collapsed
SetNeedToCollapseColumns(PR_FALSE);
PRInt32 numRows = cellMap->GetRowCount(); PRInt32 numRows = cellMap->GetRowCount();
nsTableIterator groupIter(mColGroups, eTableDIR); nsTableIterator groupIter(mColGroups, eTableDIR);
nsIFrame* groupFrame = groupIter.First(); nsIFrame* groupFrame = groupIter.First();
@ -2396,6 +2404,9 @@ NS_METHOD nsTableFrame::AdjustForCollapsingCols(nsIPresContext* aPresContext,
const nsStyleVisibility* groupVis = groupFrame->GetStyleVisibility(); const nsStyleVisibility* groupVis = groupFrame->GetStyleVisibility();
PRBool collapseGroup = (NS_STYLE_VISIBILITY_COLLAPSE == groupVis->mVisible); PRBool collapseGroup = (NS_STYLE_VISIBILITY_COLLAPSE == groupVis->mVisible);
if (collapseGroup) {
SetNeedToCollapseColumns(PR_TRUE);
}
nsTableIterator colIter(*groupFrame, eTableDIR); nsTableIterator colIter(*groupFrame, eTableDIR);
nsIFrame* colFrame = colIter.First(); nsIFrame* colFrame = colIter.First();
// iterate over the cols in the col group // iterate over the cols in the col group
@ -2404,6 +2415,9 @@ NS_METHOD nsTableFrame::AdjustForCollapsingCols(nsIPresContext* aPresContext,
if (NS_STYLE_DISPLAY_TABLE_COLUMN == colDisplay->mDisplay) { if (NS_STYLE_DISPLAY_TABLE_COLUMN == colDisplay->mDisplay) {
const nsStyleVisibility* colVis = colFrame->GetStyleVisibility(); const nsStyleVisibility* colVis = colFrame->GetStyleVisibility();
PRBool collapseCol = (NS_STYLE_VISIBILITY_COLLAPSE == colVis->mVisible); PRBool collapseCol = (NS_STYLE_VISIBILITY_COLLAPSE == colVis->mVisible);
if (collapseCol) {
SetNeedToCollapseColumns(PR_TRUE);
}
PRInt32 colWidth = GetColumnWidth(colX); PRInt32 colWidth = GetColumnWidth(colX);
if (collapseGroup || collapseCol) { if (collapseGroup || collapseCol) {
xOffset += colWidth + cellSpacingX; xOffset += colWidth + cellSpacingX;

View File

@ -382,7 +382,6 @@ public:
nscoord aAvailHeight, nscoord aAvailHeight,
nsReflowReason aReason, nsReflowReason aReason,
nsIFrame*& aLastChildReflowed, nsIFrame*& aLastChildReflowed,
PRBool& aDoCollapse,
PRBool& aDidBalance, PRBool& aDidBalance,
nsReflowStatus& aStatus); nsReflowStatus& aStatus);
@ -788,6 +787,12 @@ public:
PRBool NeedToCalcBCBorders() const; PRBool NeedToCalcBCBorders() const;
void SetNeedToCalcBCBorders(PRBool aValue); void SetNeedToCalcBCBorders(PRBool aValue);
PRBool NeedToCollapseRows() const;
void SetNeedToCollapseRows(PRBool aValue);
PRBool NeedToCollapseColumns() const;
void SetNeedToCollapseColumns(PRBool aValue);
/** Get the cell map for this table frame. It is not always mCellMap. /** Get the cell map for this table frame. It is not always mCellMap.
* Only the firstInFlow has a legit cell map * Only the firstInFlow has a legit cell map
@ -930,7 +935,9 @@ protected:
PRUint32 mInitiatedSpecialReflow:1; PRUint32 mInitiatedSpecialReflow:1;
PRUint32 mNeedToCalcBCBorders:1; PRUint32 mNeedToCalcBCBorders:1;
PRUint32 mLeftContBCBorder:8; PRUint32 mLeftContBCBorder:8;
PRUint32 : 11; // unused PRUint32 mNeedToCollapseRows:1; // rows that have visibility need to be collapse
PRUint32 mNeedToCollapseColumns:1; // colums that have visibility need to be collapsed
PRUint32 :9; // unused
} mBits; } mBits;
nsTableCellMap* mCellMap; // maintains the relationships between rows, cols, and cells nsTableCellMap* mCellMap; // maintains the relationships between rows, cols, and cells
@ -1048,6 +1055,26 @@ inline void nsTableFrame::SetRowInserted(PRBool aValue)
mBits.mRowInserted = (unsigned)aValue; mBits.mRowInserted = (unsigned)aValue;
} }
inline void nsTableFrame::SetNeedToCollapseRows(PRBool aValue)
{
mBits.mNeedToCollapseRows = (unsigned)aValue;
}
inline PRBool nsTableFrame::NeedToCollapseRows() const
{
return (PRBool)mBits.mNeedToCollapseRows;
}
inline void nsTableFrame::SetNeedToCollapseColumns(PRBool aValue)
{
mBits.mNeedToCollapseColumns = (unsigned)aValue;
}
inline PRBool nsTableFrame::NeedToCollapseColumns() const
{
return (PRBool)mBits.mNeedToCollapseColumns;
}
inline nsFrameList& nsTableFrame::GetColGroups() inline nsFrameList& nsTableFrame::GetColGroups()
{ {
return NS_STATIC_CAST(nsTableFrame*, GetFirstInFlow())->mColGroups; return NS_STATIC_CAST(nsTableFrame*, GetFirstInFlow())->mColGroups;

View File

@ -1373,6 +1373,12 @@ nsTableRowFrame::Reflow(nsIPresContext* aPresContext,
rv = nsTableFrame::GetTableFrame(this, tableFrame); rv = nsTableFrame::GetTableFrame(this, tableFrame);
if (!tableFrame) return NS_ERROR_NULL_POINTER; if (!tableFrame) return NS_ERROR_NULL_POINTER;
const nsStyleVisibility* rowVis = GetStyleVisibility();
PRBool collapseRow = (NS_STYLE_VISIBILITY_COLLAPSE == rowVis->mVisible);
if (collapseRow) {
tableFrame->SetNeedToCollapseRows(PR_TRUE);
}
// see if a special height reflow needs to occur due to having a pct height // see if a special height reflow needs to occur due to having a pct height
if (!NeedSpecialReflow()) if (!NeedSpecialReflow())
nsTableFrame::CheckRequestSpecialHeightReflow(aReflowState); nsTableFrame::CheckRequestSpecialHeightReflow(aReflowState);

View File

@ -1201,6 +1201,11 @@ nsTableRowGroupFrame::Reflow(nsIPresContext* aPresContext,
nsRowGroupReflowState state(aReflowState, tableFrame); nsRowGroupReflowState state(aReflowState, tableFrame);
PRBool haveDesiredHeight = PR_FALSE; PRBool haveDesiredHeight = PR_FALSE;
const nsStyleVisibility* groupVis = GetStyleVisibility();
PRBool collapseGroup = (NS_STYLE_VISIBILITY_COLLAPSE == groupVis->mVisible);
if (collapseGroup) {
tableFrame->SetNeedToCollapseRows(PR_TRUE);
}
if (eReflowReason_Incremental == aReflowState.reason) { if (eReflowReason_Incremental == aReflowState.reason) {
rv = IncrementalReflow(aPresContext, aDesiredSize, state, aStatus); rv = IncrementalReflow(aPresContext, aDesiredSize, state, aStatus);