diff --git a/layout/html/table/src/nsTableFrame.cpp b/layout/html/table/src/nsTableFrame.cpp
index b284f772235a..0dc86c4d1177 100644
--- a/layout/html/table/src/nsTableFrame.cpp
+++ b/layout/html/table/src/nsTableFrame.cpp
@@ -2992,7 +2992,7 @@ NS_METHOD nsTableFrame::AdjustForCollapsingCols(nsIPresContext& aPresContext,
// collapse the cols and/or col groups
PRInt32 numRows = mCellMap->GetRowCount();
- nsTableIterator groupIter(mColGroups, PR_TRUE);
+ nsTableIterator groupIter(mColGroups, eTableDIR);
nsIFrame* groupFrame = groupIter.First();
nscoord cellSpacingX = GetCellSpacingX();
nscoord xOffset = 0;
@@ -3002,7 +3002,7 @@ NS_METHOD nsTableFrame::AdjustForCollapsingCols(nsIPresContext& aPresContext,
const nsStyleDisplay* groupDisplay;
groupFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)groupDisplay));
PRBool collapseGroup = (NS_STYLE_VISIBILITY_COLLAPSE == groupDisplay->mVisible);
- nsTableIterator colIter(*groupFrame, PR_TRUE);
+ nsTableIterator colIter(*groupFrame, eTableDIR);
nsIFrame* colFrame = colIter.First();
while (nsnull != colFrame) {
const nsStyleDisplay* colDisplay;
@@ -4136,7 +4136,8 @@ nscoord nsTableFrame::ComputeDesiredHeight(nsIPresContext& aPresContext,
// and the rowgroup itself needs to be expanded by SUM(row height deltas)
nscoord excessForRowGroup=0;
nsIFrame * rowFrame=nsnull;
- rv = rowGroupFrame->FirstChild(nsnull, &rowFrame);
+ nsTableIterator iter(*rowGroupFrame, eTableLTR);
+ rowFrame = iter.First();
while ((NS_SUCCEEDED(rv)) && (nsnull!=rowFrame))
{
const nsStyleDisplay *rowDisplay;
@@ -4158,18 +4159,29 @@ nscoord nsTableFrame::ComputeDesiredHeight(nsIPresContext& aPresContext,
(mBorderEdges.mEdges[NS_SIDE_RIGHT].ElementAt(((nsTableRowFrame*)rowFrame)->GetRowIndex()));
border->mLength=newRowRect.height;
}
- // resize cells, too
- ((nsTableRowFrame *)rowFrame)->DidResize(aPresContext, aReflowState);
// better if this were part of an overloaded row::SetRect
y += excessForRow+rowRect.height;
excessForRowGroup += excessForRow;
}
- rowFrame->GetNextSibling(&rowFrame);
+ //rowFrame->GetNextSibling(&rowFrame);
+ rowFrame = iter.Next();
}
nsRect rowGroupRect;
rowGroupFrame->GetRect(rowGroupRect);
nsRect newRowGroupRect(rowGroupRect.x, rowGroupRect.y, rowGroupRect.width, excessForRowGroup+rowGroupRect.height);
rowGroupFrame->SetRect(newRowGroupRect);
+
+ // now that all of the rows have been resized, resize the cells
+ nsTableIterator iter2(*rowGroupFrame, eTableLTR);
+ rowFrame = iter2.First();
+ while ((NS_SUCCEEDED(rv)) && (nsnull!=rowFrame)) {
+ const nsStyleDisplay *rowDisplay;
+ rowFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)rowDisplay));
+ if (NS_STYLE_DISPLAY_TABLE_ROW == rowDisplay->mDisplay) {
+ ((nsTableRowFrame *)rowFrame)->DidResize(aPresContext, aReflowState);
+ }
+ rowFrame = iter2.Next();
+ }
}
rowGroupFrame->GetNextSibling(&rowGroupFrame);
}
@@ -5302,34 +5314,34 @@ nsTableFrame::IsFinalPass(const nsReflowState& aState)
}
// nsTableIterator
-nsTableIterator::nsTableIterator(nsIFrame& aSource,
- PRBool aUseDirection)
+nsTableIterator::nsTableIterator(nsIFrame& aSource,
+ nsTableIteration aType)
{
nsIFrame* firstChild;
aSource.FirstChild(nsnull, &firstChild);
- Init(firstChild, aUseDirection);
+ Init(firstChild, aType);
}
-nsTableIterator::nsTableIterator(nsFrameList& aSource,
- PRBool aUseDirection)
+nsTableIterator::nsTableIterator(nsFrameList& aSource,
+ nsTableIteration aType)
{
nsIFrame* firstChild = aSource.FirstChild();
- Init(firstChild, aUseDirection);
+ Init(firstChild, aType);
}
-void nsTableIterator::Init(nsIFrame* aFirstChild,
- PRBool aUseDirection)
+void nsTableIterator::Init(nsIFrame* aFirstChild,
+ nsTableIteration aType)
{
mFirstListChild = aFirstChild;
mFirstChild = aFirstChild;
mCurrentChild = nsnull;
- mLeftToRight = PR_TRUE;
+ mLeftToRight = (eTableRTL == aType) ? PR_FALSE : PR_TRUE;
mCount = -1;
if (!mFirstChild) {
return;
}
- if (aUseDirection) {
+ if (eTableDIR == aType) {
nsTableFrame* table = nsnull;
nsresult rv = nsTableFrame::GetTableFrame(mFirstChild, table);
if (NS_SUCCEEDED(rv) && (table != nsnull)) {
diff --git a/layout/html/table/src/nsTableFrame.h b/layout/html/table/src/nsTableFrame.h
index 57dc3651cb2c..5a9d11e6df96 100644
--- a/layout/html/table/src/nsTableFrame.h
+++ b/layout/html/table/src/nsTableFrame.h
@@ -844,21 +844,27 @@ inline PRBool nsTableFrame::IsRowGroup(PRInt32 aDisplayType) const
(NS_STYLE_DISPLAY_TABLE_ROW_GROUP == aDisplayType));
}
+enum nsTableIteration {
+ eTableLTR = 0,
+ eTableRTL = 1,
+ eTableDIR = 2
+};
+
class nsTableIterator
{
public:
- nsTableIterator(nsIFrame& aSource,
- PRBool aUseDirection);
- nsTableIterator(nsFrameList& aSource,
- PRBool aUseDirection);
+ nsTableIterator(nsIFrame& aSource,
+ nsTableIteration aType);
+ nsTableIterator(nsFrameList& aSource,
+ nsTableIteration aType);
nsIFrame* First();
nsIFrame* Next();
PRBool IsLeftToRight();
PRInt32 Count();
protected:
- void Init(nsIFrame* aFirstChild,
- PRBool aUseDirection);
+ void Init(nsIFrame* aFirstChild,
+ nsTableIteration aType);
PRBool mLeftToRight;
nsIFrame* mFirstListChild;
nsIFrame* mFirstChild;
diff --git a/layout/html/table/src/nsTableRowFrame.cpp b/layout/html/table/src/nsTableRowFrame.cpp
index c2526ccd814b..af8035db56b9 100644
--- a/layout/html/table/src/nsTableRowFrame.cpp
+++ b/layout/html/table/src/nsTableRowFrame.cpp
@@ -191,62 +191,65 @@ nsTableRowFrame::DidResize(nsIPresContext& aPresContext,
if (gsDebug) printf("Row %p DidResize: begin mRect.h=%d, mCellMTM=%d, mCellMBM=%d\n",
this, mRect.height, mCellMaxTopMargin, mCellMaxBottomMargin);
// Resize and re-align the cell frames based on our row height
- nscoord cellHeight = mRect.height - mCellMaxTopMargin - mCellMaxBottomMargin;
- if (gsDebug) printf("Row DidReflow: cellHeight=%d\n", cellHeight);
- nsTableIterator iter(*this, PR_TRUE);
- nsIFrame* cellFrame = iter.First();
+ nscoord rowCellHeight = mRect.height - mCellMaxTopMargin - mCellMaxBottomMargin;
+ if (gsDebug) printf("Row DidReflow: cellHeight=%d\n", rowCellHeight);
nsTableFrame* tableFrame;
nsTableFrame::GetTableFrame(this, tableFrame);
const nsStyleTable* tableStyle;
tableFrame->GetStyleData(eStyleStruct_Table, (const nsStyleStruct *&)tableStyle);
- while (nsnull != cellFrame)
- {
+
+ nsTableIterator iter(*this, eTableDIR);
+ nsIFrame* cellFrame = iter.First();
+
+ while (nsnull != cellFrame) {
const nsStyleDisplay *kidDisplay;
cellFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)kidDisplay));
- if (NS_STYLE_DISPLAY_TABLE_CELL == kidDisplay->mDisplay)
- {
+ if (NS_STYLE_DISPLAY_TABLE_CELL == kidDisplay->mDisplay) {
PRInt32 rowSpan = tableFrame->GetEffectiveRowSpan(mRowIndex, (nsTableCellFrame *)cellFrame);
if (gsDebug) printf("Row DidReflow: cellFrame %p ", cellFrame);
- if (1==rowSpan)
- {
- // resize the cell's height
- nsSize cellFrameSize;
- cellFrame->GetSize(cellFrameSize);
- //if (cellFrameSize.height!=cellHeight)
- {
- cellFrame->SizeTo(cellFrameSize.width, cellHeight);
- if (gsDebug) printf("given height %d\n", cellHeight);
- // realign cell content based on the new height
- /*nsHTMLReflowMetrics desiredSize(nsnull);
- nsHTMLReflowState kidReflowState(aPresContext, aReflowState,
- cellFrame,
- nsSize(cellFrameSize.width, cellHeight),
- eReflowReason_Resize);*/
- //XXX: the following reflow is necessary for any content of the cell
- // whose height is a percent of the cell's height (maybe indirectly.)
- // But some content crashes when this reflow is issued, to be investigated
- //XXX nsReflowStatus status;
- //ReflowChild(cellFrame, aPresContext, desiredSize, kidReflowState, status);
- ((nsTableCellFrame *)cellFrame)->VerticallyAlignChild();
- /* if we're collapsing borders, notify the cell that the border edge length has changed */
- if (NS_STYLE_BORDER_COLLAPSE==tableStyle->mBorderCollapse)
- {
- ((nsTableCellFrame *)(cellFrame))->SetBorderEdgeLength(NS_SIDE_LEFT,
- GetRowIndex(),
- cellHeight);
- ((nsTableCellFrame *)(cellFrame))->SetBorderEdgeLength(NS_SIDE_RIGHT,
- GetRowIndex(),
- cellHeight);
- }
+ nscoord cellHeight = rowCellHeight;
+ // add in height of rows spanned beyond the 1st one
+ nsIFrame* nextRow = nsnull;
+ GetNextSibling(&nextRow);
+ for (int i = 1; ((i < rowSpan) && nextRow);) {
+ const nsStyleDisplay *nextDisplay;
+ nextRow->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)nextDisplay));
+ if (NS_STYLE_DISPLAY_TABLE_ROW == nextDisplay->mDisplay) {
+ nsRect rect;
+ nextRow->GetRect(rect);
+ cellHeight += rect.height;
+ i++;
}
+ nextRow->GetNextSibling(&nextRow);
}
- else
+
+ // resize the cell's height
+ nsSize cellFrameSize;
+ cellFrame->GetSize(cellFrameSize);
+ //if (cellFrameSize.height!=cellHeight)
{
- if (gsDebug)
- {
- nsSize cellFrameSize;
- cellFrame->GetSize(cellFrameSize);
- printf("has rowspan %d and height %d, unchanged.\n", rowSpan, cellFrameSize.height);
+ cellFrame->SizeTo(cellFrameSize.width, cellHeight);
+ if (gsDebug) printf("given height %d\n", cellHeight);
+ // realign cell content based on the new height
+ /*nsHTMLReflowMetrics desiredSize(nsnull);
+ nsHTMLReflowState kidReflowState(aPresContext, aReflowState,
+ cellFrame,
+ nsSize(cellFrameSize.width, cellHeight),
+ eReflowReason_Resize);*/
+ //XXX: the following reflow is necessary for any content of the cell
+ // whose height is a percent of the cell's height (maybe indirectly.)
+ // But some content crashes when this reflow is issued, to be investigated
+ //XXX nsReflowStatus status;
+ //ReflowChild(cellFrame, aPresContext, desiredSize, kidReflowState, status);
+ ((nsTableCellFrame *)cellFrame)->VerticallyAlignChild();
+ /* if we're collapsing borders, notify the cell that the border edge length has changed */
+ if (NS_STYLE_BORDER_COLLAPSE==tableStyle->mBorderCollapse) {
+ ((nsTableCellFrame *)(cellFrame))->SetBorderEdgeLength(NS_SIDE_LEFT,
+ GetRowIndex(),
+ cellHeight);
+ ((nsTableCellFrame *)(cellFrame))->SetBorderEdgeLength(NS_SIDE_RIGHT,
+ GetRowIndex(),
+ cellHeight);
}
}
}
@@ -500,9 +503,6 @@ NS_METHOD nsTableRowFrame::ResizeReflow(nsIPresContext& aPresContext,
return NS_OK;
}
- PRBool isPass2Reflow = (aReflowState.reflowState.availableWidth == NS_UNCONSTRAINEDSIZE)
- ? PR_FALSE : PR_TRUE;
-
nsresult rv=NS_OK;
nsSize kidMaxElementSize;
nsSize* pKidMaxElementSize = (nsnull != aDesiredSize.maxElementSize) ?
@@ -515,7 +515,9 @@ NS_METHOD nsTableRowFrame::ResizeReflow(nsIPresContext& aPresContext,
PRInt32 prevColIndex; // remember the col index of the previous cell to handle rowspans into this row
- nsTableIterator iter(*this, isPass2Reflow);
+ nsTableIteration dir = (aReflowState.reflowState.availableWidth == NS_UNCONSTRAINEDSIZE)
+ ? eTableLTR : eTableDIR;
+ nsTableIterator iter(*this, dir);
if (iter.IsLeftToRight()) {
prevColIndex = -1;
}
@@ -527,6 +529,7 @@ NS_METHOD nsTableRowFrame::ResizeReflow(nsIPresContext& aPresContext,
}
prevColIndex = tableFrame->GetColCount();
}
+
// Reflow each of our existing cell frames
nsIFrame* kidFrame = iter.First();
while (nsnull != kidFrame) {
diff --git a/layout/tables/nsTableFrame.cpp b/layout/tables/nsTableFrame.cpp
index b284f772235a..0dc86c4d1177 100644
--- a/layout/tables/nsTableFrame.cpp
+++ b/layout/tables/nsTableFrame.cpp
@@ -2992,7 +2992,7 @@ NS_METHOD nsTableFrame::AdjustForCollapsingCols(nsIPresContext& aPresContext,
// collapse the cols and/or col groups
PRInt32 numRows = mCellMap->GetRowCount();
- nsTableIterator groupIter(mColGroups, PR_TRUE);
+ nsTableIterator groupIter(mColGroups, eTableDIR);
nsIFrame* groupFrame = groupIter.First();
nscoord cellSpacingX = GetCellSpacingX();
nscoord xOffset = 0;
@@ -3002,7 +3002,7 @@ NS_METHOD nsTableFrame::AdjustForCollapsingCols(nsIPresContext& aPresContext,
const nsStyleDisplay* groupDisplay;
groupFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)groupDisplay));
PRBool collapseGroup = (NS_STYLE_VISIBILITY_COLLAPSE == groupDisplay->mVisible);
- nsTableIterator colIter(*groupFrame, PR_TRUE);
+ nsTableIterator colIter(*groupFrame, eTableDIR);
nsIFrame* colFrame = colIter.First();
while (nsnull != colFrame) {
const nsStyleDisplay* colDisplay;
@@ -4136,7 +4136,8 @@ nscoord nsTableFrame::ComputeDesiredHeight(nsIPresContext& aPresContext,
// and the rowgroup itself needs to be expanded by SUM(row height deltas)
nscoord excessForRowGroup=0;
nsIFrame * rowFrame=nsnull;
- rv = rowGroupFrame->FirstChild(nsnull, &rowFrame);
+ nsTableIterator iter(*rowGroupFrame, eTableLTR);
+ rowFrame = iter.First();
while ((NS_SUCCEEDED(rv)) && (nsnull!=rowFrame))
{
const nsStyleDisplay *rowDisplay;
@@ -4158,18 +4159,29 @@ nscoord nsTableFrame::ComputeDesiredHeight(nsIPresContext& aPresContext,
(mBorderEdges.mEdges[NS_SIDE_RIGHT].ElementAt(((nsTableRowFrame*)rowFrame)->GetRowIndex()));
border->mLength=newRowRect.height;
}
- // resize cells, too
- ((nsTableRowFrame *)rowFrame)->DidResize(aPresContext, aReflowState);
// better if this were part of an overloaded row::SetRect
y += excessForRow+rowRect.height;
excessForRowGroup += excessForRow;
}
- rowFrame->GetNextSibling(&rowFrame);
+ //rowFrame->GetNextSibling(&rowFrame);
+ rowFrame = iter.Next();
}
nsRect rowGroupRect;
rowGroupFrame->GetRect(rowGroupRect);
nsRect newRowGroupRect(rowGroupRect.x, rowGroupRect.y, rowGroupRect.width, excessForRowGroup+rowGroupRect.height);
rowGroupFrame->SetRect(newRowGroupRect);
+
+ // now that all of the rows have been resized, resize the cells
+ nsTableIterator iter2(*rowGroupFrame, eTableLTR);
+ rowFrame = iter2.First();
+ while ((NS_SUCCEEDED(rv)) && (nsnull!=rowFrame)) {
+ const nsStyleDisplay *rowDisplay;
+ rowFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)rowDisplay));
+ if (NS_STYLE_DISPLAY_TABLE_ROW == rowDisplay->mDisplay) {
+ ((nsTableRowFrame *)rowFrame)->DidResize(aPresContext, aReflowState);
+ }
+ rowFrame = iter2.Next();
+ }
}
rowGroupFrame->GetNextSibling(&rowGroupFrame);
}
@@ -5302,34 +5314,34 @@ nsTableFrame::IsFinalPass(const nsReflowState& aState)
}
// nsTableIterator
-nsTableIterator::nsTableIterator(nsIFrame& aSource,
- PRBool aUseDirection)
+nsTableIterator::nsTableIterator(nsIFrame& aSource,
+ nsTableIteration aType)
{
nsIFrame* firstChild;
aSource.FirstChild(nsnull, &firstChild);
- Init(firstChild, aUseDirection);
+ Init(firstChild, aType);
}
-nsTableIterator::nsTableIterator(nsFrameList& aSource,
- PRBool aUseDirection)
+nsTableIterator::nsTableIterator(nsFrameList& aSource,
+ nsTableIteration aType)
{
nsIFrame* firstChild = aSource.FirstChild();
- Init(firstChild, aUseDirection);
+ Init(firstChild, aType);
}
-void nsTableIterator::Init(nsIFrame* aFirstChild,
- PRBool aUseDirection)
+void nsTableIterator::Init(nsIFrame* aFirstChild,
+ nsTableIteration aType)
{
mFirstListChild = aFirstChild;
mFirstChild = aFirstChild;
mCurrentChild = nsnull;
- mLeftToRight = PR_TRUE;
+ mLeftToRight = (eTableRTL == aType) ? PR_FALSE : PR_TRUE;
mCount = -1;
if (!mFirstChild) {
return;
}
- if (aUseDirection) {
+ if (eTableDIR == aType) {
nsTableFrame* table = nsnull;
nsresult rv = nsTableFrame::GetTableFrame(mFirstChild, table);
if (NS_SUCCEEDED(rv) && (table != nsnull)) {
diff --git a/layout/tables/nsTableFrame.h b/layout/tables/nsTableFrame.h
index 57dc3651cb2c..5a9d11e6df96 100644
--- a/layout/tables/nsTableFrame.h
+++ b/layout/tables/nsTableFrame.h
@@ -844,21 +844,27 @@ inline PRBool nsTableFrame::IsRowGroup(PRInt32 aDisplayType) const
(NS_STYLE_DISPLAY_TABLE_ROW_GROUP == aDisplayType));
}
+enum nsTableIteration {
+ eTableLTR = 0,
+ eTableRTL = 1,
+ eTableDIR = 2
+};
+
class nsTableIterator
{
public:
- nsTableIterator(nsIFrame& aSource,
- PRBool aUseDirection);
- nsTableIterator(nsFrameList& aSource,
- PRBool aUseDirection);
+ nsTableIterator(nsIFrame& aSource,
+ nsTableIteration aType);
+ nsTableIterator(nsFrameList& aSource,
+ nsTableIteration aType);
nsIFrame* First();
nsIFrame* Next();
PRBool IsLeftToRight();
PRInt32 Count();
protected:
- void Init(nsIFrame* aFirstChild,
- PRBool aUseDirection);
+ void Init(nsIFrame* aFirstChild,
+ nsTableIteration aType);
PRBool mLeftToRight;
nsIFrame* mFirstListChild;
nsIFrame* mFirstChild;
diff --git a/layout/tables/nsTableRowFrame.cpp b/layout/tables/nsTableRowFrame.cpp
index c2526ccd814b..af8035db56b9 100644
--- a/layout/tables/nsTableRowFrame.cpp
+++ b/layout/tables/nsTableRowFrame.cpp
@@ -191,62 +191,65 @@ nsTableRowFrame::DidResize(nsIPresContext& aPresContext,
if (gsDebug) printf("Row %p DidResize: begin mRect.h=%d, mCellMTM=%d, mCellMBM=%d\n",
this, mRect.height, mCellMaxTopMargin, mCellMaxBottomMargin);
// Resize and re-align the cell frames based on our row height
- nscoord cellHeight = mRect.height - mCellMaxTopMargin - mCellMaxBottomMargin;
- if (gsDebug) printf("Row DidReflow: cellHeight=%d\n", cellHeight);
- nsTableIterator iter(*this, PR_TRUE);
- nsIFrame* cellFrame = iter.First();
+ nscoord rowCellHeight = mRect.height - mCellMaxTopMargin - mCellMaxBottomMargin;
+ if (gsDebug) printf("Row DidReflow: cellHeight=%d\n", rowCellHeight);
nsTableFrame* tableFrame;
nsTableFrame::GetTableFrame(this, tableFrame);
const nsStyleTable* tableStyle;
tableFrame->GetStyleData(eStyleStruct_Table, (const nsStyleStruct *&)tableStyle);
- while (nsnull != cellFrame)
- {
+
+ nsTableIterator iter(*this, eTableDIR);
+ nsIFrame* cellFrame = iter.First();
+
+ while (nsnull != cellFrame) {
const nsStyleDisplay *kidDisplay;
cellFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)kidDisplay));
- if (NS_STYLE_DISPLAY_TABLE_CELL == kidDisplay->mDisplay)
- {
+ if (NS_STYLE_DISPLAY_TABLE_CELL == kidDisplay->mDisplay) {
PRInt32 rowSpan = tableFrame->GetEffectiveRowSpan(mRowIndex, (nsTableCellFrame *)cellFrame);
if (gsDebug) printf("Row DidReflow: cellFrame %p ", cellFrame);
- if (1==rowSpan)
- {
- // resize the cell's height
- nsSize cellFrameSize;
- cellFrame->GetSize(cellFrameSize);
- //if (cellFrameSize.height!=cellHeight)
- {
- cellFrame->SizeTo(cellFrameSize.width, cellHeight);
- if (gsDebug) printf("given height %d\n", cellHeight);
- // realign cell content based on the new height
- /*nsHTMLReflowMetrics desiredSize(nsnull);
- nsHTMLReflowState kidReflowState(aPresContext, aReflowState,
- cellFrame,
- nsSize(cellFrameSize.width, cellHeight),
- eReflowReason_Resize);*/
- //XXX: the following reflow is necessary for any content of the cell
- // whose height is a percent of the cell's height (maybe indirectly.)
- // But some content crashes when this reflow is issued, to be investigated
- //XXX nsReflowStatus status;
- //ReflowChild(cellFrame, aPresContext, desiredSize, kidReflowState, status);
- ((nsTableCellFrame *)cellFrame)->VerticallyAlignChild();
- /* if we're collapsing borders, notify the cell that the border edge length has changed */
- if (NS_STYLE_BORDER_COLLAPSE==tableStyle->mBorderCollapse)
- {
- ((nsTableCellFrame *)(cellFrame))->SetBorderEdgeLength(NS_SIDE_LEFT,
- GetRowIndex(),
- cellHeight);
- ((nsTableCellFrame *)(cellFrame))->SetBorderEdgeLength(NS_SIDE_RIGHT,
- GetRowIndex(),
- cellHeight);
- }
+ nscoord cellHeight = rowCellHeight;
+ // add in height of rows spanned beyond the 1st one
+ nsIFrame* nextRow = nsnull;
+ GetNextSibling(&nextRow);
+ for (int i = 1; ((i < rowSpan) && nextRow);) {
+ const nsStyleDisplay *nextDisplay;
+ nextRow->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)nextDisplay));
+ if (NS_STYLE_DISPLAY_TABLE_ROW == nextDisplay->mDisplay) {
+ nsRect rect;
+ nextRow->GetRect(rect);
+ cellHeight += rect.height;
+ i++;
}
+ nextRow->GetNextSibling(&nextRow);
}
- else
+
+ // resize the cell's height
+ nsSize cellFrameSize;
+ cellFrame->GetSize(cellFrameSize);
+ //if (cellFrameSize.height!=cellHeight)
{
- if (gsDebug)
- {
- nsSize cellFrameSize;
- cellFrame->GetSize(cellFrameSize);
- printf("has rowspan %d and height %d, unchanged.\n", rowSpan, cellFrameSize.height);
+ cellFrame->SizeTo(cellFrameSize.width, cellHeight);
+ if (gsDebug) printf("given height %d\n", cellHeight);
+ // realign cell content based on the new height
+ /*nsHTMLReflowMetrics desiredSize(nsnull);
+ nsHTMLReflowState kidReflowState(aPresContext, aReflowState,
+ cellFrame,
+ nsSize(cellFrameSize.width, cellHeight),
+ eReflowReason_Resize);*/
+ //XXX: the following reflow is necessary for any content of the cell
+ // whose height is a percent of the cell's height (maybe indirectly.)
+ // But some content crashes when this reflow is issued, to be investigated
+ //XXX nsReflowStatus status;
+ //ReflowChild(cellFrame, aPresContext, desiredSize, kidReflowState, status);
+ ((nsTableCellFrame *)cellFrame)->VerticallyAlignChild();
+ /* if we're collapsing borders, notify the cell that the border edge length has changed */
+ if (NS_STYLE_BORDER_COLLAPSE==tableStyle->mBorderCollapse) {
+ ((nsTableCellFrame *)(cellFrame))->SetBorderEdgeLength(NS_SIDE_LEFT,
+ GetRowIndex(),
+ cellHeight);
+ ((nsTableCellFrame *)(cellFrame))->SetBorderEdgeLength(NS_SIDE_RIGHT,
+ GetRowIndex(),
+ cellHeight);
}
}
}
@@ -500,9 +503,6 @@ NS_METHOD nsTableRowFrame::ResizeReflow(nsIPresContext& aPresContext,
return NS_OK;
}
- PRBool isPass2Reflow = (aReflowState.reflowState.availableWidth == NS_UNCONSTRAINEDSIZE)
- ? PR_FALSE : PR_TRUE;
-
nsresult rv=NS_OK;
nsSize kidMaxElementSize;
nsSize* pKidMaxElementSize = (nsnull != aDesiredSize.maxElementSize) ?
@@ -515,7 +515,9 @@ NS_METHOD nsTableRowFrame::ResizeReflow(nsIPresContext& aPresContext,
PRInt32 prevColIndex; // remember the col index of the previous cell to handle rowspans into this row
- nsTableIterator iter(*this, isPass2Reflow);
+ nsTableIteration dir = (aReflowState.reflowState.availableWidth == NS_UNCONSTRAINEDSIZE)
+ ? eTableLTR : eTableDIR;
+ nsTableIterator iter(*this, dir);
if (iter.IsLeftToRight()) {
prevColIndex = -1;
}
@@ -527,6 +529,7 @@ NS_METHOD nsTableRowFrame::ResizeReflow(nsIPresContext& aPresContext,
}
prevColIndex = tableFrame->GetColCount();
}
+
// Reflow each of our existing cell frames
nsIFrame* kidFrame = iter.First();
while (nsnull != kidFrame) {