diff --git a/layout/html/table/src/nsTableFrame.cpp b/layout/html/table/src/nsTableFrame.cpp
index 4640d2e517d3..04dc3ebd0bbe 100644
--- a/layout/html/table/src/nsTableFrame.cpp
+++ b/layout/html/table/src/nsTableFrame.cpp
@@ -359,7 +359,11 @@ PRInt32 nsTableFrame::GetRowCount ()
if (NS_STYLE_DISPLAY_TABLE_ROW_GROUP == childDisplay->mDisplay ||
NS_STYLE_DISPLAY_TABLE_HEADER_GROUP == childDisplay->mDisplay ||
NS_STYLE_DISPLAY_TABLE_FOOTER_GROUP == childDisplay->mDisplay )
- rowCount += ((nsTableRowGroupFrame *)child)->GetRowCount ();
+ {
+ PRInt32 thisRowCount=0;
+ ((nsTableRowGroupFrame *)child)->GetRowCount(thisRowCount);
+ rowCount += thisRowCount;
+ }
child->GetNextSibling(child);
}
return rowCount;
@@ -449,6 +453,9 @@ PRInt32 nsTableFrame::GetEffectiveRowSpan (PRInt32 aRowIndex, nsTableCellFrame *
NS_PRECONDITION (nsnull!=aCell, "bad cell arg");
NS_PRECONDITION (0<=aRowIndex && aRowIndexGetRowSpan();
PRInt32 rowCount = GetRowCount();
if (rowCount < (aRowIndex + rowSpan))
diff --git a/layout/html/table/src/nsTableRowGroupFrame.cpp b/layout/html/table/src/nsTableRowGroupFrame.cpp
index 11615126d4d9..eff4da2972ba 100644
--- a/layout/html/table/src/nsTableRowGroupFrame.cpp
+++ b/layout/html/table/src/nsTableRowGroupFrame.cpp
@@ -107,6 +107,25 @@ NS_METHOD nsTableRowGroupFrame::GetRowGroupType(nsIAtom *& aType)
return NS_OK;
}
+NS_METHOD nsTableRowGroupFrame::GetRowCount(PRInt32 &aCount)
+{
+ // init out-param
+ aCount=0;
+
+ // loop through children, adding one to aCount for every legit row
+ nsIFrame *childFrame = mFirstChild;
+ while (PR_TRUE)
+ {
+ if (nsnull==childFrame)
+ break;
+ const nsStyleDisplay *childDisplay;
+ childFrame->GetStyleData(eStyleStruct_Display, ((nsStyleStruct *&)childDisplay));
+ if (NS_STYLE_DISPLAY_TABLE_ROW == childDisplay->mDisplay)
+ aCount++;
+ childFrame->GetNextSibling(childFrame);
+ }
+ return NS_OK;
+}
NS_METHOD nsTableRowGroupFrame::Paint(nsIPresContext& aPresContext,
nsIRenderingContext& aRenderingContext,
@@ -844,6 +863,7 @@ nsTableRowGroupFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext,
return result;
}
+#include "nsIPresShell.h"
/**
*/
void nsTableRowGroupFrame::ShrinkWrapChildren(nsIPresContext* aPresContext,
@@ -854,39 +874,41 @@ void nsTableRowGroupFrame::ShrinkWrapChildren(nsIPresContext* aPresContext,
nscoord topInnerMargin = 0;
nscoord bottomInnerMargin = 0;
PRInt32 numRows;
- ChildCount(numRows); //XXX: this doesn't work if we allow non-table row content.
- // we actually need to go through our content and count the
- // children that are display type == table row
+ GetRowCount(numRows);
PRInt32 *rowHeights = new PRInt32[numRows];
nsCRT::memset (rowHeights, 0, numRows*sizeof(PRInt32));
/* Step 1: get the height of the tallest cell in the row and save it for
* pass 2
*/
- nsTableRowFrame* rowFrame = (nsTableRowFrame*)mFirstChild;
- PRInt32 rowIndex = 0;
+ nsIFrame* rowFrame = mFirstChild;
+ PRInt32 rowIndex = 0;
while (nsnull != rowFrame)
{
- // get the height of the tallest cell in the row (excluding cells that span rows)
- nscoord maxCellHeight = rowFrame->GetTallestChild();
- nscoord maxCellTopMargin = rowFrame->GetChildMaxTopMargin();
- nscoord maxCellBottomMargin = rowFrame->GetChildMaxBottomMargin();
- nscoord maxRowHeight = maxCellHeight + maxCellTopMargin + maxCellBottomMargin;
+ const nsStyleDisplay *childDisplay;
+ rowFrame->GetStyleData(eStyleStruct_Display, ((nsStyleStruct *&)childDisplay));
+ if (NS_STYLE_DISPLAY_TABLE_ROW == childDisplay->mDisplay)
+ {
+ // get the height of the tallest cell in the row (excluding cells that span rows)
+ nscoord maxCellHeight = ((nsTableRowFrame*)rowFrame)->GetTallestChild();
+ nscoord maxCellTopMargin = ((nsTableRowFrame*)rowFrame)->GetChildMaxTopMargin();
+ nscoord maxCellBottomMargin = ((nsTableRowFrame*)rowFrame)->GetChildMaxBottomMargin();
+ nscoord maxRowHeight = maxCellHeight + maxCellTopMargin + maxCellBottomMargin;
- // save the row height for pass 2 below
- rowHeights[rowIndex] = maxRowHeight;
+ // save the row height for pass 2 below
+ rowHeights[rowIndex] = maxRowHeight;
- // Update top and bottom inner margin if applicable
- if (0 == rowIndex) {
- topInnerMargin = maxCellTopMargin;
+ // Update top and bottom inner margin if applicable
+ if (0 == rowIndex) {
+ topInnerMargin = maxCellTopMargin;
+ }
+ if ((rowIndex + 1) == numRows) {
+ bottomInnerMargin = maxCellBottomMargin;
+ }
+ rowIndex++;
}
- if ((rowIndex + 1) == numRows) {
- bottomInnerMargin = maxCellBottomMargin;
- }
-
// Get the next row
- rowFrame->GetNextSibling((nsIFrame*&)rowFrame);
- rowIndex++;
+ rowFrame->GetNextSibling(rowFrame);
}
/* Step 2: now account for cells that span rows.
@@ -902,88 +924,95 @@ void nsTableRowGroupFrame::ShrinkWrapChildren(nsIPresContext* aPresContext,
* There should be a "rational" check to terminate that kind of loop after n passes, probably 3 or 4.
*/
PRInt32 rowGroupHeight = 0;
- rowFrame = (nsTableRowFrame*)mFirstChild;
+ rowFrame = mFirstChild;
rowIndex = 0;
while (nsnull != rowFrame)
{
- // check this row for a cell with rowspans
- nsTableCellFrame* cellFrame;
- rowFrame->FirstChild((nsIFrame*&)cellFrame);
- while (nsnull != cellFrame)
+ const nsStyleDisplay *childDisplay;
+ rowFrame->GetStyleData(eStyleStruct_Display, ((nsStyleStruct *&)childDisplay));
+ if (NS_STYLE_DISPLAY_TABLE_ROW == childDisplay->mDisplay)
{
- PRInt32 rowSpan = ((nsTableFrame*)mGeometricParent)->GetEffectiveRowSpan(rowIndex,
- cellFrame);
- if (rowSpan > 1)
- { // found a cell with rowspan > 1, determine its height
- nscoord heightOfRowsSpanned = 0;
- PRInt32 i;
- for ( i = 0; i < rowSpan; i++)
- heightOfRowsSpanned += rowHeights[rowIndex + i];
+ // check this row for a cell with rowspans
+ nsIFrame *cellFrame;
+ rowFrame->FirstChild(cellFrame);
+ while (nsnull != cellFrame)
+ {
+ const nsStyleDisplay *childDisplay;
+ cellFrame->GetStyleData(eStyleStruct_Display, ((nsStyleStruct *&)childDisplay));
+ if (NS_STYLE_DISPLAY_TABLE_CELL == childDisplay->mDisplay)
+ {
+ PRInt32 rowSpan = ((nsTableFrame*)mGeometricParent)->
+ GetEffectiveRowSpan(rowIndex,(nsTableCellFrame*)cellFrame);
+ if (rowSpan > 1)
+ { // found a cell with rowspan > 1, determine its height
+ nscoord heightOfRowsSpanned = 0;
+ PRInt32 i;
+ for ( i = 0; i < rowSpan; i++)
+ heightOfRowsSpanned += rowHeights[rowIndex + i];
- heightOfRowsSpanned -= topInnerMargin + bottomInnerMargin;
+ heightOfRowsSpanned -= topInnerMargin + bottomInnerMargin;
- /* if the cell height fits in the rows, expand the spanning cell's height and slap it in */
- nsSize cellFrameSize;
- cellFrame->GetSize(cellFrameSize);
- if (heightOfRowsSpanned > cellFrameSize.height)
- {
- cellFrame->SizeTo(cellFrameSize.width, heightOfRowsSpanned);
- // Realign cell content based on new height
- cellFrame->VerticallyAlignChild(aPresContext);
- }
- /* otherwise, distribute the excess height to the rows effected.
- * push all subsequent rows down by the total change in height of all the rows above it
- */
- else
- {
- PRInt32 excessHeight = cellFrameSize.height - heightOfRowsSpanned;
- PRInt32 excessHeightPerRow = excessHeight/rowSpan;
-
- // for every row starting at the row with the spanning cell...
- nsTableRowFrame *rowFrameToBeResized = rowFrame;
- for (i = rowIndex; i < numRows; i++)
- {
- // if the row is within the spanned range, resize the row
- if (i < (rowIndex + rowSpan))
+ /* if the cell height fits in the rows, expand the spanning cell's height and slap it in */
+ nsSize cellFrameSize;
+ cellFrame->GetSize(cellFrameSize);
+ if (heightOfRowsSpanned > cellFrameSize.height)
{
- // update the row height
- rowHeights[i] += excessHeightPerRow;
-
- // adjust the height of the row
- nsSize rowFrameSize;
- rowFrameToBeResized->GetSize(rowFrameSize);
- rowFrameToBeResized->SizeTo(rowFrameSize.width, rowHeights[i]);
+ cellFrame->SizeTo(cellFrameSize.width, heightOfRowsSpanned);
+ // Realign cell content based on new height
+ ((nsTableCellFrame*)cellFrame)->VerticallyAlignChild(aPresContext);
}
-
- // if we're dealing with a row below the row containing the spanning cell,
- // push that row down by the amount we've expanded the cell heights by
- if ((i >= rowIndex) && (i != 0))
+ /* otherwise, distribute the excess height to the rows effected.
+ * push all subsequent rows down by the total change in height of all the rows above it
+ */
+ else
{
- nsRect rowRect;
+ PRInt32 excessHeight = cellFrameSize.height - heightOfRowsSpanned;
+ PRInt32 excessHeightPerRow = excessHeight/rowSpan;
+
+ // for every row starting at the row with the spanning cell...
+ nsTableRowFrame *rowFrameToBeResized = (nsTableRowFrame *)rowFrame;
+ for (i = rowIndex; i < numRows; i++)
+ {
+ // if the row is within the spanned range, resize the row
+ if (i < (rowIndex + rowSpan))
+ {
+ // update the row height
+ rowHeights[i] += excessHeightPerRow;
+
+ // adjust the height of the row
+ nsSize rowFrameSize;
+ rowFrameToBeResized->GetSize(rowFrameSize);
+ rowFrameToBeResized->SizeTo(rowFrameSize.width, rowHeights[i]);
+ }
+
+ // if we're dealing with a row below the row containing the spanning cell,
+ // push that row down by the amount we've expanded the cell heights by
+ if ((i >= rowIndex) && (i != 0))
+ {
+ nsRect rowRect;
- rowFrameToBeResized->GetRect(rowRect);
- nscoord delta = excessHeightPerRow * (i - rowIndex);
- if (delta > excessHeight)
- delta = excessHeight;
- rowFrameToBeResized->MoveTo(rowRect.x, rowRect.y + delta);
- }
+ rowFrameToBeResized->GetRect(rowRect);
+ nscoord delta = excessHeightPerRow * (i - rowIndex);
+ if (delta > excessHeight)
+ delta = excessHeight;
+ rowFrameToBeResized->MoveTo(rowRect.x, rowRect.y + delta);
+ }
- // Get the next row frame
- rowFrameToBeResized->GetNextSibling((nsIFrame*&)rowFrameToBeResized);
+ // Get the next row frame
+ rowFrameToBeResized->GetNextSibling((nsIFrame*&)rowFrameToBeResized);
+ }
+ }
}
}
+ // Get the next row child (cell frame)
+ cellFrame->GetNextSibling(cellFrame);
}
-
- // Get the next cell frame
- cellFrame->GetNextSibling((nsIFrame*&)cellFrame);
+ // Update the running row group height
+ rowGroupHeight += rowHeights[rowIndex];
+ rowIndex++;
}
-
- // Update the running row group height
- rowGroupHeight += rowHeights[rowIndex];
-
- // Get the next row
- rowFrame->GetNextSibling((nsIFrame*&)rowFrame);
- rowIndex++;
+ // Get the next rowgroup child (row frame)
+ rowFrame->GetNextSibling(rowFrame);
}
// Adjust our desired size
diff --git a/layout/html/table/src/nsTableRowGroupFrame.h b/layout/html/table/src/nsTableRowGroupFrame.h
index 5c3dc08f2932..7d20c18d5eab 100644
--- a/layout/html/table/src/nsTableRowGroupFrame.h
+++ b/layout/html/table/src/nsTableRowGroupFrame.h
@@ -92,8 +92,8 @@ public:
*/
NS_IMETHOD GetRowGroupType(nsIAtom *& aType);
- /** return the number of contained rows */
- PRInt32 GetRowCount ();
+ /** set aCount to the number of child rows (not necessarily == number of child frames) */
+ NS_METHOD nsTableRowGroupFrame::GetRowCount(PRInt32 &aCount);
NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0, nsIListFilter *aFilter = nsnull) const;
@@ -168,13 +168,5 @@ private:
};
-//XXX: change this if row groups can contain non-row types
-// in this case, iterate through kids and add 1 if the kid's display type is "row"
-inline PRInt32 nsTableRowGroupFrame::GetRowCount ()
-{
- PRInt32 result = 0;
- ChildCount(result);
- return result;
-}
#endif
diff --git a/layout/tables/nsTableFrame.cpp b/layout/tables/nsTableFrame.cpp
index 4640d2e517d3..04dc3ebd0bbe 100644
--- a/layout/tables/nsTableFrame.cpp
+++ b/layout/tables/nsTableFrame.cpp
@@ -359,7 +359,11 @@ PRInt32 nsTableFrame::GetRowCount ()
if (NS_STYLE_DISPLAY_TABLE_ROW_GROUP == childDisplay->mDisplay ||
NS_STYLE_DISPLAY_TABLE_HEADER_GROUP == childDisplay->mDisplay ||
NS_STYLE_DISPLAY_TABLE_FOOTER_GROUP == childDisplay->mDisplay )
- rowCount += ((nsTableRowGroupFrame *)child)->GetRowCount ();
+ {
+ PRInt32 thisRowCount=0;
+ ((nsTableRowGroupFrame *)child)->GetRowCount(thisRowCount);
+ rowCount += thisRowCount;
+ }
child->GetNextSibling(child);
}
return rowCount;
@@ -449,6 +453,9 @@ PRInt32 nsTableFrame::GetEffectiveRowSpan (PRInt32 aRowIndex, nsTableCellFrame *
NS_PRECONDITION (nsnull!=aCell, "bad cell arg");
NS_PRECONDITION (0<=aRowIndex && aRowIndexGetRowSpan();
PRInt32 rowCount = GetRowCount();
if (rowCount < (aRowIndex + rowSpan))
diff --git a/layout/tables/nsTableRowGroupFrame.cpp b/layout/tables/nsTableRowGroupFrame.cpp
index 11615126d4d9..eff4da2972ba 100644
--- a/layout/tables/nsTableRowGroupFrame.cpp
+++ b/layout/tables/nsTableRowGroupFrame.cpp
@@ -107,6 +107,25 @@ NS_METHOD nsTableRowGroupFrame::GetRowGroupType(nsIAtom *& aType)
return NS_OK;
}
+NS_METHOD nsTableRowGroupFrame::GetRowCount(PRInt32 &aCount)
+{
+ // init out-param
+ aCount=0;
+
+ // loop through children, adding one to aCount for every legit row
+ nsIFrame *childFrame = mFirstChild;
+ while (PR_TRUE)
+ {
+ if (nsnull==childFrame)
+ break;
+ const nsStyleDisplay *childDisplay;
+ childFrame->GetStyleData(eStyleStruct_Display, ((nsStyleStruct *&)childDisplay));
+ if (NS_STYLE_DISPLAY_TABLE_ROW == childDisplay->mDisplay)
+ aCount++;
+ childFrame->GetNextSibling(childFrame);
+ }
+ return NS_OK;
+}
NS_METHOD nsTableRowGroupFrame::Paint(nsIPresContext& aPresContext,
nsIRenderingContext& aRenderingContext,
@@ -844,6 +863,7 @@ nsTableRowGroupFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext,
return result;
}
+#include "nsIPresShell.h"
/**
*/
void nsTableRowGroupFrame::ShrinkWrapChildren(nsIPresContext* aPresContext,
@@ -854,39 +874,41 @@ void nsTableRowGroupFrame::ShrinkWrapChildren(nsIPresContext* aPresContext,
nscoord topInnerMargin = 0;
nscoord bottomInnerMargin = 0;
PRInt32 numRows;
- ChildCount(numRows); //XXX: this doesn't work if we allow non-table row content.
- // we actually need to go through our content and count the
- // children that are display type == table row
+ GetRowCount(numRows);
PRInt32 *rowHeights = new PRInt32[numRows];
nsCRT::memset (rowHeights, 0, numRows*sizeof(PRInt32));
/* Step 1: get the height of the tallest cell in the row and save it for
* pass 2
*/
- nsTableRowFrame* rowFrame = (nsTableRowFrame*)mFirstChild;
- PRInt32 rowIndex = 0;
+ nsIFrame* rowFrame = mFirstChild;
+ PRInt32 rowIndex = 0;
while (nsnull != rowFrame)
{
- // get the height of the tallest cell in the row (excluding cells that span rows)
- nscoord maxCellHeight = rowFrame->GetTallestChild();
- nscoord maxCellTopMargin = rowFrame->GetChildMaxTopMargin();
- nscoord maxCellBottomMargin = rowFrame->GetChildMaxBottomMargin();
- nscoord maxRowHeight = maxCellHeight + maxCellTopMargin + maxCellBottomMargin;
+ const nsStyleDisplay *childDisplay;
+ rowFrame->GetStyleData(eStyleStruct_Display, ((nsStyleStruct *&)childDisplay));
+ if (NS_STYLE_DISPLAY_TABLE_ROW == childDisplay->mDisplay)
+ {
+ // get the height of the tallest cell in the row (excluding cells that span rows)
+ nscoord maxCellHeight = ((nsTableRowFrame*)rowFrame)->GetTallestChild();
+ nscoord maxCellTopMargin = ((nsTableRowFrame*)rowFrame)->GetChildMaxTopMargin();
+ nscoord maxCellBottomMargin = ((nsTableRowFrame*)rowFrame)->GetChildMaxBottomMargin();
+ nscoord maxRowHeight = maxCellHeight + maxCellTopMargin + maxCellBottomMargin;
- // save the row height for pass 2 below
- rowHeights[rowIndex] = maxRowHeight;
+ // save the row height for pass 2 below
+ rowHeights[rowIndex] = maxRowHeight;
- // Update top and bottom inner margin if applicable
- if (0 == rowIndex) {
- topInnerMargin = maxCellTopMargin;
+ // Update top and bottom inner margin if applicable
+ if (0 == rowIndex) {
+ topInnerMargin = maxCellTopMargin;
+ }
+ if ((rowIndex + 1) == numRows) {
+ bottomInnerMargin = maxCellBottomMargin;
+ }
+ rowIndex++;
}
- if ((rowIndex + 1) == numRows) {
- bottomInnerMargin = maxCellBottomMargin;
- }
-
// Get the next row
- rowFrame->GetNextSibling((nsIFrame*&)rowFrame);
- rowIndex++;
+ rowFrame->GetNextSibling(rowFrame);
}
/* Step 2: now account for cells that span rows.
@@ -902,88 +924,95 @@ void nsTableRowGroupFrame::ShrinkWrapChildren(nsIPresContext* aPresContext,
* There should be a "rational" check to terminate that kind of loop after n passes, probably 3 or 4.
*/
PRInt32 rowGroupHeight = 0;
- rowFrame = (nsTableRowFrame*)mFirstChild;
+ rowFrame = mFirstChild;
rowIndex = 0;
while (nsnull != rowFrame)
{
- // check this row for a cell with rowspans
- nsTableCellFrame* cellFrame;
- rowFrame->FirstChild((nsIFrame*&)cellFrame);
- while (nsnull != cellFrame)
+ const nsStyleDisplay *childDisplay;
+ rowFrame->GetStyleData(eStyleStruct_Display, ((nsStyleStruct *&)childDisplay));
+ if (NS_STYLE_DISPLAY_TABLE_ROW == childDisplay->mDisplay)
{
- PRInt32 rowSpan = ((nsTableFrame*)mGeometricParent)->GetEffectiveRowSpan(rowIndex,
- cellFrame);
- if (rowSpan > 1)
- { // found a cell with rowspan > 1, determine its height
- nscoord heightOfRowsSpanned = 0;
- PRInt32 i;
- for ( i = 0; i < rowSpan; i++)
- heightOfRowsSpanned += rowHeights[rowIndex + i];
+ // check this row for a cell with rowspans
+ nsIFrame *cellFrame;
+ rowFrame->FirstChild(cellFrame);
+ while (nsnull != cellFrame)
+ {
+ const nsStyleDisplay *childDisplay;
+ cellFrame->GetStyleData(eStyleStruct_Display, ((nsStyleStruct *&)childDisplay));
+ if (NS_STYLE_DISPLAY_TABLE_CELL == childDisplay->mDisplay)
+ {
+ PRInt32 rowSpan = ((nsTableFrame*)mGeometricParent)->
+ GetEffectiveRowSpan(rowIndex,(nsTableCellFrame*)cellFrame);
+ if (rowSpan > 1)
+ { // found a cell with rowspan > 1, determine its height
+ nscoord heightOfRowsSpanned = 0;
+ PRInt32 i;
+ for ( i = 0; i < rowSpan; i++)
+ heightOfRowsSpanned += rowHeights[rowIndex + i];
- heightOfRowsSpanned -= topInnerMargin + bottomInnerMargin;
+ heightOfRowsSpanned -= topInnerMargin + bottomInnerMargin;
- /* if the cell height fits in the rows, expand the spanning cell's height and slap it in */
- nsSize cellFrameSize;
- cellFrame->GetSize(cellFrameSize);
- if (heightOfRowsSpanned > cellFrameSize.height)
- {
- cellFrame->SizeTo(cellFrameSize.width, heightOfRowsSpanned);
- // Realign cell content based on new height
- cellFrame->VerticallyAlignChild(aPresContext);
- }
- /* otherwise, distribute the excess height to the rows effected.
- * push all subsequent rows down by the total change in height of all the rows above it
- */
- else
- {
- PRInt32 excessHeight = cellFrameSize.height - heightOfRowsSpanned;
- PRInt32 excessHeightPerRow = excessHeight/rowSpan;
-
- // for every row starting at the row with the spanning cell...
- nsTableRowFrame *rowFrameToBeResized = rowFrame;
- for (i = rowIndex; i < numRows; i++)
- {
- // if the row is within the spanned range, resize the row
- if (i < (rowIndex + rowSpan))
+ /* if the cell height fits in the rows, expand the spanning cell's height and slap it in */
+ nsSize cellFrameSize;
+ cellFrame->GetSize(cellFrameSize);
+ if (heightOfRowsSpanned > cellFrameSize.height)
{
- // update the row height
- rowHeights[i] += excessHeightPerRow;
-
- // adjust the height of the row
- nsSize rowFrameSize;
- rowFrameToBeResized->GetSize(rowFrameSize);
- rowFrameToBeResized->SizeTo(rowFrameSize.width, rowHeights[i]);
+ cellFrame->SizeTo(cellFrameSize.width, heightOfRowsSpanned);
+ // Realign cell content based on new height
+ ((nsTableCellFrame*)cellFrame)->VerticallyAlignChild(aPresContext);
}
-
- // if we're dealing with a row below the row containing the spanning cell,
- // push that row down by the amount we've expanded the cell heights by
- if ((i >= rowIndex) && (i != 0))
+ /* otherwise, distribute the excess height to the rows effected.
+ * push all subsequent rows down by the total change in height of all the rows above it
+ */
+ else
{
- nsRect rowRect;
+ PRInt32 excessHeight = cellFrameSize.height - heightOfRowsSpanned;
+ PRInt32 excessHeightPerRow = excessHeight/rowSpan;
+
+ // for every row starting at the row with the spanning cell...
+ nsTableRowFrame *rowFrameToBeResized = (nsTableRowFrame *)rowFrame;
+ for (i = rowIndex; i < numRows; i++)
+ {
+ // if the row is within the spanned range, resize the row
+ if (i < (rowIndex + rowSpan))
+ {
+ // update the row height
+ rowHeights[i] += excessHeightPerRow;
+
+ // adjust the height of the row
+ nsSize rowFrameSize;
+ rowFrameToBeResized->GetSize(rowFrameSize);
+ rowFrameToBeResized->SizeTo(rowFrameSize.width, rowHeights[i]);
+ }
+
+ // if we're dealing with a row below the row containing the spanning cell,
+ // push that row down by the amount we've expanded the cell heights by
+ if ((i >= rowIndex) && (i != 0))
+ {
+ nsRect rowRect;
- rowFrameToBeResized->GetRect(rowRect);
- nscoord delta = excessHeightPerRow * (i - rowIndex);
- if (delta > excessHeight)
- delta = excessHeight;
- rowFrameToBeResized->MoveTo(rowRect.x, rowRect.y + delta);
- }
+ rowFrameToBeResized->GetRect(rowRect);
+ nscoord delta = excessHeightPerRow * (i - rowIndex);
+ if (delta > excessHeight)
+ delta = excessHeight;
+ rowFrameToBeResized->MoveTo(rowRect.x, rowRect.y + delta);
+ }
- // Get the next row frame
- rowFrameToBeResized->GetNextSibling((nsIFrame*&)rowFrameToBeResized);
+ // Get the next row frame
+ rowFrameToBeResized->GetNextSibling((nsIFrame*&)rowFrameToBeResized);
+ }
+ }
}
}
+ // Get the next row child (cell frame)
+ cellFrame->GetNextSibling(cellFrame);
}
-
- // Get the next cell frame
- cellFrame->GetNextSibling((nsIFrame*&)cellFrame);
+ // Update the running row group height
+ rowGroupHeight += rowHeights[rowIndex];
+ rowIndex++;
}
-
- // Update the running row group height
- rowGroupHeight += rowHeights[rowIndex];
-
- // Get the next row
- rowFrame->GetNextSibling((nsIFrame*&)rowFrame);
- rowIndex++;
+ // Get the next rowgroup child (row frame)
+ rowFrame->GetNextSibling(rowFrame);
}
// Adjust our desired size
diff --git a/layout/tables/nsTableRowGroupFrame.h b/layout/tables/nsTableRowGroupFrame.h
index 5c3dc08f2932..7d20c18d5eab 100644
--- a/layout/tables/nsTableRowGroupFrame.h
+++ b/layout/tables/nsTableRowGroupFrame.h
@@ -92,8 +92,8 @@ public:
*/
NS_IMETHOD GetRowGroupType(nsIAtom *& aType);
- /** return the number of contained rows */
- PRInt32 GetRowCount ();
+ /** set aCount to the number of child rows (not necessarily == number of child frames) */
+ NS_METHOD nsTableRowGroupFrame::GetRowCount(PRInt32 &aCount);
NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0, nsIListFilter *aFilter = nsnull) const;
@@ -168,13 +168,5 @@ private:
};
-//XXX: change this if row groups can contain non-row types
-// in this case, iterate through kids and add 1 if the kid's display type is "row"
-inline PRInt32 nsTableRowGroupFrame::GetRowCount ()
-{
- PRInt32 result = 0;
- ChildCount(result);
- return result;
-}
#endif