diff --git a/mozilla/layout/html/table/src/BasicTableLayoutStrategy.cpp b/mozilla/layout/html/table/src/BasicTableLayoutStrategy.cpp index 78c926b37f8..69d2994bec3 100644 --- a/mozilla/layout/html/table/src/BasicTableLayoutStrategy.cpp +++ b/mozilla/layout/html/table/src/BasicTableLayoutStrategy.cpp @@ -931,14 +931,24 @@ PRBool BasicTableLayoutStrategy::BalanceColumnsTableFits(nsIPresContext* aPresCo mTableFrame->GetColumnsByType(eStyleUnit_Auto, numAutoColumns, autoColumns); if (0!=numAutoColumns) { - // TODO - should extra space be proportionately distributed? - nscoord excessPerColumn = excess/numAutoColumns; + // proportionately distributed extra space, based on the column's desired size + nscoord totalWidthOfAutoColumns = 0; if (gsDebug==PR_TRUE) printf(" aTableFixedWidth specified as %d, expanding columns by excess = %d\n", aTableFixedWidth, excess); + // first, get the total width for (PRInt32 i = 0; iGetColumnWidth(colIndex); + totalWidthOfAutoColumns += mTableFrame->GetColumnWidth(colIndex); + } + // next, compute the proportion to be added to each column, and add it + for (i = 0; iGetColumnWidth(colIndex); + float percent = (float)oldColWidth/(float)totalWidthOfAutoColumns; + nscoord excessForThisColumn = excess*percent; + nscoord colWidth = excessForThisColumn+oldColWidth; if (gsDebug==PR_TRUE) printf(" column %d was %d, now set to %d\n", colIndex, mTableFrame->GetColumnWidth(colIndex), colWidth); mTableFrame->SetColumnWidth(colIndex, colWidth); @@ -1171,7 +1181,7 @@ PRBool BasicTableLayoutStrategy::BalanceColumnsConstrained( nsIPresContext* aPre PRUint32 D = aMaxTableWidth - aMinTableWidth; if (0==D) // fixed-size table D=1; - PRUint32 d = maxColWidth - minColWidth; + PRUint32 d = maxColWidth - minColWidth; // XXX: if this is 0, set to minColWidth? PRInt32 width = (d*W)/D; mTableFrame->SetColumnWidth(colIndex, minColWidth + width); if (gsDebug==PR_TRUE) diff --git a/mozilla/layout/html/table/src/nsTableCellFrame.cpp b/mozilla/layout/html/table/src/nsTableCellFrame.cpp index 2fefde9ab0a..5c4715ebac7 100644 --- a/mozilla/layout/html/table/src/nsTableCellFrame.cpp +++ b/mozilla/layout/html/table/src/nsTableCellFrame.cpp @@ -259,13 +259,6 @@ NS_METHOD nsTableCellFrame::Reflow(nsIPresContext* aPresContext, nsTableFrame* tableFrame = GetTableFrame(); tableFrame->GetCellMarginData(this,margin); - // reduce available space by insets - - if (NS_UNCONSTRAINEDSIZE!=availSize.width) - availSize.width -= leftInset+rightInset+margin.left+margin.right; - if (NS_UNCONSTRAINEDSIZE!=availSize.height) - availSize.height -= topInset+bottomInset+margin.top+margin.bottom; - mLastContentIsComplete = PR_TRUE; // get frame, creating one if needed @@ -276,11 +269,10 @@ NS_METHOD nsTableCellFrame::Reflow(nsIPresContext* aPresContext, // Determine the width we have to work with nscoord cellWidth = -1; - if (NS_UNCONSTRAINEDSIZE!=availSize.width) + //if (NS_UNCONSTRAINEDSIZE!=availSize.width) { - /* - nsStylePosition* kidPosition = (nsStylePosition*) - mStyleContext->GetData(eStyleStruct_Position); + const nsStylePosition* kidPosition = (const nsStylePosition*) + (mStyleContext->GetStyleData(eStyleStruct_Position)); switch (kidPosition->mWidth.GetUnit()) { case eStyleUnit_Coord: cellWidth = kidPosition->mWidth.GetCoordValue(); @@ -305,11 +297,17 @@ NS_METHOD nsTableCellFrame::Reflow(nsIPresContext* aPresContext, case eStyleUnit_Auto: break; } - */ if (-1!=cellWidth) availSize.width = cellWidth; } + // reduce available space by insets + + if (NS_UNCONSTRAINEDSIZE!=availSize.width) + availSize.width -= leftInset+rightInset+margin.left+margin.right; + if (NS_UNCONSTRAINEDSIZE!=availSize.height) + availSize.height -= topInset+bottomInset+margin.top+margin.bottom; + // Try to reflow the child into the available space. It might not // fit or might need continuing. if (availSize.height < 0) diff --git a/mozilla/layout/html/table/src/nsTableFrame.cpp b/mozilla/layout/html/table/src/nsTableFrame.cpp index a4356a63bac..6b1ca7dd376 100644 --- a/mozilla/layout/html/table/src/nsTableFrame.cpp +++ b/mozilla/layout/html/table/src/nsTableFrame.cpp @@ -551,9 +551,12 @@ void nsTableFrame::BuildCellMap () ChildAt (groupIndex, (nsIFrame *&)rowGroup); nsTableRowFrame *row; rowGroup->ChildAt (0, (nsIFrame *&)row); - mColCount = row->GetMaxColumns (); - if (gsDebug==PR_TRUE) - printf("mColCount=0 at start. Guessing col count to be %d from a row.\n", mColCount); + if (nsnull!=row) + { + mColCount = row->GetMaxColumns (); + if (gsDebug==PR_TRUE) + printf("mColCount=0 at start. Guessing col count to be %d from a row.\n", mColCount); + } } if (nsnull==mCellMap) mCellMap = new nsCellMap(rowCount, mColCount); @@ -3204,80 +3207,100 @@ nscoord nsTableFrame::GetTableContainerWidth(const nsReflowState& aReflowState) // or if it's another table (we're nested) use its computed width if (rs->frame!=aReflowState.frame) { - nsIFrame* table = nsnull; - rs->frame->QueryInterface(kTableFrameCID, (void**) &table); - if (nsnull != table) { - /* We found the nearest containing table (actually, the inner table). - This defines what our percentage size is relative to. Use its desired width - as the basis for computing our width. - ********************************************************************************** - Nav4 compatibility code: if the inner table has a percent width and the outer - table has an auto width, the parentWidth is the width the containing cell would be - without the inner table. - ********************************************************************************** - */ + nsMargin borderPadding; + const nsStylePosition* tablePosition; + const nsStyleSpacing* spacing; + nsIFrame* cell = nsnull; + rs->frame->QueryInterface(kTableCellFrameCID, (void**) &cell); + if (nsnull != cell) { // Compute and subtract out the insets (sum of border and padding) for the table - nsMargin borderPadding; - /* the following hack is because the outer table really holds the position info */ - // begin REMOVE_ME_WHEN_TABLE_STYLE_IS_RESOLVED! - nsIFrame * outerTableFrame = nsnull; - table->GetGeometricParent(outerTableFrame); - const nsStylePosition* tablePosition; - outerTableFrame->GetStyleData(eStyleStruct_Position, ((nsStyleStruct *&)tablePosition)); - const nsStyleSpacing* spacing; - outerTableFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)spacing); - // end REMOVE_ME_WHEN_TABLE_STYLE_IS_RESOLVED! - - if (eStyleUnit_Auto == tablePosition->mWidth.GetUnit()) + cell->GetStyleData(eStyleStruct_Position, ((nsStyleStruct *&)tablePosition)); + if (eStyleUnit_Coord == tablePosition->mWidth.GetUnit()) { - parentWidth = 0; - if (nsnull != ((nsTableFrame*)table)->mColumnWidths) + parentWidth = tablePosition->mWidth.GetCoordValue(); + // subtract out cell border and padding + cell->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)spacing); + spacing->CalcBorderPaddingFor(cell, borderPadding); + parentWidth -= (borderPadding.right + borderPadding.left); + if (PR_TRUE==gsDebugNT) + printf("%p: found a cell frame %p with fixed coord width %d, returning parentWidth %d\n", + aReflowState.frame, cell, tablePosition->mWidth.GetCoordValue(), parentWidth); + break; + } + } + else + { + nsIFrame* table = nsnull; + rs->frame->QueryInterface(kTableFrameCID, (void**) &table); + if (nsnull != table) { + /* We found the nearest containing table (actually, the inner table). + This defines what our percentage size is relative to. Use its desired width + as the basis for computing our width. + ********************************************************************************** + Nav4 compatibility code: if the inner table has a percent width and the outer + table has an auto width, the parentWidth is the width the containing cell would be + without the inner table. + ********************************************************************************** + */ + // Compute and subtract out the insets (sum of border and padding) for the table + /* the following hack is because the outer table really holds the position info */ + // begin REMOVE_ME_WHEN_TABLE_STYLE_IS_RESOLVED! + nsIFrame * outerTableFrame = nsnull; + table->GetGeometricParent(outerTableFrame); + outerTableFrame->GetStyleData(eStyleStruct_Position, ((nsStyleStruct *&)tablePosition)); + outerTableFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)spacing); + // end REMOVE_ME_WHEN_TABLE_STYLE_IS_RESOLVED! + + if (eStyleUnit_Auto == tablePosition->mWidth.GetUnit()) { - PRInt32 colIndex = ((nsTableCellFrame *)greatgrandchildFrame)->GetColIndex(); - PRInt32 colSpan = ((nsTableCellFrame *)greatgrandchildFrame)->GetColSpan(); - for (PRInt32 i = 0; iGetColumnWidth(i+colIndex); - // subtract out cell border and padding - greatgrandchildFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)spacing); - spacing->CalcBorderPaddingFor(greatgrandchildFrame, borderPadding); - parentWidth -= (borderPadding.right + borderPadding.left); - if (PR_TRUE==gsDebugNT) - printf("%p: found a table frame %p with auto width, returning parentWidth %d from cell in col %d with span %d\n", - aReflowState.frame, table, parentWidth, colIndex, colSpan); + parentWidth = 0; + if (nsnull != ((nsTableFrame*)table)->mColumnWidths) + { + PRInt32 colIndex = ((nsTableCellFrame *)greatgrandchildFrame)->GetColIndex(); + PRInt32 colSpan = ((nsTableCellFrame *)greatgrandchildFrame)->GetColSpan(); + for (PRInt32 i = 0; iGetColumnWidth(i+colIndex); + // subtract out cell border and padding + greatgrandchildFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)spacing); + spacing->CalcBorderPaddingFor(greatgrandchildFrame, borderPadding); + parentWidth -= (borderPadding.right + borderPadding.left); + if (PR_TRUE==gsDebugNT) + printf("%p: found a table frame %p with auto width, returning parentWidth %d from cell in col %d with span %d\n", + aReflowState.frame, table, parentWidth, colIndex, colSpan); + } + else + { + if (PR_TRUE==gsDebugNT) + printf("%p: found a table frame %p with auto width, returning parentWidth %d because parent has no info yet.\n", + aReflowState.frame, table, parentWidth); + } } else { + nsSize tableSize; + table->GetSize(tableSize); + parentWidth = tableSize.width; + spacing->CalcBorderPaddingFor(rs->frame, borderPadding); + parentWidth -= (borderPadding.right + borderPadding.left); + // same for the row group + childFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)spacing); + spacing->CalcBorderPaddingFor(childFrame, borderPadding); + parentWidth -= (borderPadding.right + borderPadding.left); + // same for the row + grandchildFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)spacing); + spacing->CalcBorderPaddingFor(grandchildFrame, borderPadding); + parentWidth -= (borderPadding.right + borderPadding.left); + // same for the cell + greatgrandchildFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)spacing); + spacing->CalcBorderPaddingFor(greatgrandchildFrame, borderPadding); + parentWidth -= (borderPadding.right + borderPadding.left); + if (PR_TRUE==gsDebugNT) - printf("%p: found a table frame %p with auto width, returning parentWidth %d because parent has no info yet.\n", - aReflowState.frame, table, parentWidth); + printf("%p: found a table frame %p, returning parentWidth %d from frame width %d\n", + aReflowState.frame, table, parentWidth, tableSize.width); } - + break; } - else - { - nsSize tableSize; - table->GetSize(tableSize); - parentWidth = tableSize.width; - spacing->CalcBorderPaddingFor(rs->frame, borderPadding); - parentWidth -= (borderPadding.right + borderPadding.left); - // same for the row group - childFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)spacing); - spacing->CalcBorderPaddingFor(childFrame, borderPadding); - parentWidth -= (borderPadding.right + borderPadding.left); - // same for the row - grandchildFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)spacing); - spacing->CalcBorderPaddingFor(grandchildFrame, borderPadding); - parentWidth -= (borderPadding.right + borderPadding.left); - // same for the cell - greatgrandchildFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)spacing); - spacing->CalcBorderPaddingFor(greatgrandchildFrame, borderPadding); - parentWidth -= (borderPadding.right + borderPadding.left); - - if (PR_TRUE==gsDebugNT) - printf("%p: found a table frame %p, returning parentWidth %d from frame width %d\n", - aReflowState.frame, table, parentWidth, tableSize.width); - } - break; } } diff --git a/mozilla/layout/html/table/src/nsTableRowFrame.cpp b/mozilla/layout/html/table/src/nsTableRowFrame.cpp index cf2c6b87d23..04f6e740d28 100644 --- a/mozilla/layout/html/table/src/nsTableRowFrame.cpp +++ b/mozilla/layout/html/table/src/nsTableRowFrame.cpp @@ -212,8 +212,7 @@ nscoord nsTableRowFrame::GetChildMaxBottomMargin() const PRInt32 nsTableRowFrame::GetMaxColumns() const { int sum = 0; - nsTableCellFrame *cell=nsnull; - ChildAt(0, (nsIFrame *&)cell); + nsTableCellFrame *cell=(nsTableCellFrame *)mFirstChild; while (nsnull!=cell) { sum += cell->GetColSpan(); cell->GetNextSibling((nsIFrame *&)cell); diff --git a/mozilla/layout/tables/BasicTableLayoutStrategy.cpp b/mozilla/layout/tables/BasicTableLayoutStrategy.cpp index 78c926b37f8..69d2994bec3 100644 --- a/mozilla/layout/tables/BasicTableLayoutStrategy.cpp +++ b/mozilla/layout/tables/BasicTableLayoutStrategy.cpp @@ -931,14 +931,24 @@ PRBool BasicTableLayoutStrategy::BalanceColumnsTableFits(nsIPresContext* aPresCo mTableFrame->GetColumnsByType(eStyleUnit_Auto, numAutoColumns, autoColumns); if (0!=numAutoColumns) { - // TODO - should extra space be proportionately distributed? - nscoord excessPerColumn = excess/numAutoColumns; + // proportionately distributed extra space, based on the column's desired size + nscoord totalWidthOfAutoColumns = 0; if (gsDebug==PR_TRUE) printf(" aTableFixedWidth specified as %d, expanding columns by excess = %d\n", aTableFixedWidth, excess); + // first, get the total width for (PRInt32 i = 0; iGetColumnWidth(colIndex); + totalWidthOfAutoColumns += mTableFrame->GetColumnWidth(colIndex); + } + // next, compute the proportion to be added to each column, and add it + for (i = 0; iGetColumnWidth(colIndex); + float percent = (float)oldColWidth/(float)totalWidthOfAutoColumns; + nscoord excessForThisColumn = excess*percent; + nscoord colWidth = excessForThisColumn+oldColWidth; if (gsDebug==PR_TRUE) printf(" column %d was %d, now set to %d\n", colIndex, mTableFrame->GetColumnWidth(colIndex), colWidth); mTableFrame->SetColumnWidth(colIndex, colWidth); @@ -1171,7 +1181,7 @@ PRBool BasicTableLayoutStrategy::BalanceColumnsConstrained( nsIPresContext* aPre PRUint32 D = aMaxTableWidth - aMinTableWidth; if (0==D) // fixed-size table D=1; - PRUint32 d = maxColWidth - minColWidth; + PRUint32 d = maxColWidth - minColWidth; // XXX: if this is 0, set to minColWidth? PRInt32 width = (d*W)/D; mTableFrame->SetColumnWidth(colIndex, minColWidth + width); if (gsDebug==PR_TRUE) diff --git a/mozilla/layout/tables/nsTableCellFrame.cpp b/mozilla/layout/tables/nsTableCellFrame.cpp index 2fefde9ab0a..5c4715ebac7 100644 --- a/mozilla/layout/tables/nsTableCellFrame.cpp +++ b/mozilla/layout/tables/nsTableCellFrame.cpp @@ -259,13 +259,6 @@ NS_METHOD nsTableCellFrame::Reflow(nsIPresContext* aPresContext, nsTableFrame* tableFrame = GetTableFrame(); tableFrame->GetCellMarginData(this,margin); - // reduce available space by insets - - if (NS_UNCONSTRAINEDSIZE!=availSize.width) - availSize.width -= leftInset+rightInset+margin.left+margin.right; - if (NS_UNCONSTRAINEDSIZE!=availSize.height) - availSize.height -= topInset+bottomInset+margin.top+margin.bottom; - mLastContentIsComplete = PR_TRUE; // get frame, creating one if needed @@ -276,11 +269,10 @@ NS_METHOD nsTableCellFrame::Reflow(nsIPresContext* aPresContext, // Determine the width we have to work with nscoord cellWidth = -1; - if (NS_UNCONSTRAINEDSIZE!=availSize.width) + //if (NS_UNCONSTRAINEDSIZE!=availSize.width) { - /* - nsStylePosition* kidPosition = (nsStylePosition*) - mStyleContext->GetData(eStyleStruct_Position); + const nsStylePosition* kidPosition = (const nsStylePosition*) + (mStyleContext->GetStyleData(eStyleStruct_Position)); switch (kidPosition->mWidth.GetUnit()) { case eStyleUnit_Coord: cellWidth = kidPosition->mWidth.GetCoordValue(); @@ -305,11 +297,17 @@ NS_METHOD nsTableCellFrame::Reflow(nsIPresContext* aPresContext, case eStyleUnit_Auto: break; } - */ if (-1!=cellWidth) availSize.width = cellWidth; } + // reduce available space by insets + + if (NS_UNCONSTRAINEDSIZE!=availSize.width) + availSize.width -= leftInset+rightInset+margin.left+margin.right; + if (NS_UNCONSTRAINEDSIZE!=availSize.height) + availSize.height -= topInset+bottomInset+margin.top+margin.bottom; + // Try to reflow the child into the available space. It might not // fit or might need continuing. if (availSize.height < 0) diff --git a/mozilla/layout/tables/nsTableFrame.cpp b/mozilla/layout/tables/nsTableFrame.cpp index a4356a63bac..6b1ca7dd376 100644 --- a/mozilla/layout/tables/nsTableFrame.cpp +++ b/mozilla/layout/tables/nsTableFrame.cpp @@ -551,9 +551,12 @@ void nsTableFrame::BuildCellMap () ChildAt (groupIndex, (nsIFrame *&)rowGroup); nsTableRowFrame *row; rowGroup->ChildAt (0, (nsIFrame *&)row); - mColCount = row->GetMaxColumns (); - if (gsDebug==PR_TRUE) - printf("mColCount=0 at start. Guessing col count to be %d from a row.\n", mColCount); + if (nsnull!=row) + { + mColCount = row->GetMaxColumns (); + if (gsDebug==PR_TRUE) + printf("mColCount=0 at start. Guessing col count to be %d from a row.\n", mColCount); + } } if (nsnull==mCellMap) mCellMap = new nsCellMap(rowCount, mColCount); @@ -3204,80 +3207,100 @@ nscoord nsTableFrame::GetTableContainerWidth(const nsReflowState& aReflowState) // or if it's another table (we're nested) use its computed width if (rs->frame!=aReflowState.frame) { - nsIFrame* table = nsnull; - rs->frame->QueryInterface(kTableFrameCID, (void**) &table); - if (nsnull != table) { - /* We found the nearest containing table (actually, the inner table). - This defines what our percentage size is relative to. Use its desired width - as the basis for computing our width. - ********************************************************************************** - Nav4 compatibility code: if the inner table has a percent width and the outer - table has an auto width, the parentWidth is the width the containing cell would be - without the inner table. - ********************************************************************************** - */ + nsMargin borderPadding; + const nsStylePosition* tablePosition; + const nsStyleSpacing* spacing; + nsIFrame* cell = nsnull; + rs->frame->QueryInterface(kTableCellFrameCID, (void**) &cell); + if (nsnull != cell) { // Compute and subtract out the insets (sum of border and padding) for the table - nsMargin borderPadding; - /* the following hack is because the outer table really holds the position info */ - // begin REMOVE_ME_WHEN_TABLE_STYLE_IS_RESOLVED! - nsIFrame * outerTableFrame = nsnull; - table->GetGeometricParent(outerTableFrame); - const nsStylePosition* tablePosition; - outerTableFrame->GetStyleData(eStyleStruct_Position, ((nsStyleStruct *&)tablePosition)); - const nsStyleSpacing* spacing; - outerTableFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)spacing); - // end REMOVE_ME_WHEN_TABLE_STYLE_IS_RESOLVED! - - if (eStyleUnit_Auto == tablePosition->mWidth.GetUnit()) + cell->GetStyleData(eStyleStruct_Position, ((nsStyleStruct *&)tablePosition)); + if (eStyleUnit_Coord == tablePosition->mWidth.GetUnit()) { - parentWidth = 0; - if (nsnull != ((nsTableFrame*)table)->mColumnWidths) + parentWidth = tablePosition->mWidth.GetCoordValue(); + // subtract out cell border and padding + cell->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)spacing); + spacing->CalcBorderPaddingFor(cell, borderPadding); + parentWidth -= (borderPadding.right + borderPadding.left); + if (PR_TRUE==gsDebugNT) + printf("%p: found a cell frame %p with fixed coord width %d, returning parentWidth %d\n", + aReflowState.frame, cell, tablePosition->mWidth.GetCoordValue(), parentWidth); + break; + } + } + else + { + nsIFrame* table = nsnull; + rs->frame->QueryInterface(kTableFrameCID, (void**) &table); + if (nsnull != table) { + /* We found the nearest containing table (actually, the inner table). + This defines what our percentage size is relative to. Use its desired width + as the basis for computing our width. + ********************************************************************************** + Nav4 compatibility code: if the inner table has a percent width and the outer + table has an auto width, the parentWidth is the width the containing cell would be + without the inner table. + ********************************************************************************** + */ + // Compute and subtract out the insets (sum of border and padding) for the table + /* the following hack is because the outer table really holds the position info */ + // begin REMOVE_ME_WHEN_TABLE_STYLE_IS_RESOLVED! + nsIFrame * outerTableFrame = nsnull; + table->GetGeometricParent(outerTableFrame); + outerTableFrame->GetStyleData(eStyleStruct_Position, ((nsStyleStruct *&)tablePosition)); + outerTableFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)spacing); + // end REMOVE_ME_WHEN_TABLE_STYLE_IS_RESOLVED! + + if (eStyleUnit_Auto == tablePosition->mWidth.GetUnit()) { - PRInt32 colIndex = ((nsTableCellFrame *)greatgrandchildFrame)->GetColIndex(); - PRInt32 colSpan = ((nsTableCellFrame *)greatgrandchildFrame)->GetColSpan(); - for (PRInt32 i = 0; iGetColumnWidth(i+colIndex); - // subtract out cell border and padding - greatgrandchildFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)spacing); - spacing->CalcBorderPaddingFor(greatgrandchildFrame, borderPadding); - parentWidth -= (borderPadding.right + borderPadding.left); - if (PR_TRUE==gsDebugNT) - printf("%p: found a table frame %p with auto width, returning parentWidth %d from cell in col %d with span %d\n", - aReflowState.frame, table, parentWidth, colIndex, colSpan); + parentWidth = 0; + if (nsnull != ((nsTableFrame*)table)->mColumnWidths) + { + PRInt32 colIndex = ((nsTableCellFrame *)greatgrandchildFrame)->GetColIndex(); + PRInt32 colSpan = ((nsTableCellFrame *)greatgrandchildFrame)->GetColSpan(); + for (PRInt32 i = 0; iGetColumnWidth(i+colIndex); + // subtract out cell border and padding + greatgrandchildFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)spacing); + spacing->CalcBorderPaddingFor(greatgrandchildFrame, borderPadding); + parentWidth -= (borderPadding.right + borderPadding.left); + if (PR_TRUE==gsDebugNT) + printf("%p: found a table frame %p with auto width, returning parentWidth %d from cell in col %d with span %d\n", + aReflowState.frame, table, parentWidth, colIndex, colSpan); + } + else + { + if (PR_TRUE==gsDebugNT) + printf("%p: found a table frame %p with auto width, returning parentWidth %d because parent has no info yet.\n", + aReflowState.frame, table, parentWidth); + } } else { + nsSize tableSize; + table->GetSize(tableSize); + parentWidth = tableSize.width; + spacing->CalcBorderPaddingFor(rs->frame, borderPadding); + parentWidth -= (borderPadding.right + borderPadding.left); + // same for the row group + childFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)spacing); + spacing->CalcBorderPaddingFor(childFrame, borderPadding); + parentWidth -= (borderPadding.right + borderPadding.left); + // same for the row + grandchildFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)spacing); + spacing->CalcBorderPaddingFor(grandchildFrame, borderPadding); + parentWidth -= (borderPadding.right + borderPadding.left); + // same for the cell + greatgrandchildFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)spacing); + spacing->CalcBorderPaddingFor(greatgrandchildFrame, borderPadding); + parentWidth -= (borderPadding.right + borderPadding.left); + if (PR_TRUE==gsDebugNT) - printf("%p: found a table frame %p with auto width, returning parentWidth %d because parent has no info yet.\n", - aReflowState.frame, table, parentWidth); + printf("%p: found a table frame %p, returning parentWidth %d from frame width %d\n", + aReflowState.frame, table, parentWidth, tableSize.width); } - + break; } - else - { - nsSize tableSize; - table->GetSize(tableSize); - parentWidth = tableSize.width; - spacing->CalcBorderPaddingFor(rs->frame, borderPadding); - parentWidth -= (borderPadding.right + borderPadding.left); - // same for the row group - childFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)spacing); - spacing->CalcBorderPaddingFor(childFrame, borderPadding); - parentWidth -= (borderPadding.right + borderPadding.left); - // same for the row - grandchildFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)spacing); - spacing->CalcBorderPaddingFor(grandchildFrame, borderPadding); - parentWidth -= (borderPadding.right + borderPadding.left); - // same for the cell - greatgrandchildFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)spacing); - spacing->CalcBorderPaddingFor(greatgrandchildFrame, borderPadding); - parentWidth -= (borderPadding.right + borderPadding.left); - - if (PR_TRUE==gsDebugNT) - printf("%p: found a table frame %p, returning parentWidth %d from frame width %d\n", - aReflowState.frame, table, parentWidth, tableSize.width); - } - break; } } diff --git a/mozilla/layout/tables/nsTableRowFrame.cpp b/mozilla/layout/tables/nsTableRowFrame.cpp index cf2c6b87d23..04f6e740d28 100644 --- a/mozilla/layout/tables/nsTableRowFrame.cpp +++ b/mozilla/layout/tables/nsTableRowFrame.cpp @@ -212,8 +212,7 @@ nscoord nsTableRowFrame::GetChildMaxBottomMargin() const PRInt32 nsTableRowFrame::GetMaxColumns() const { int sum = 0; - nsTableCellFrame *cell=nsnull; - ChildAt(0, (nsIFrame *&)cell); + nsTableCellFrame *cell=(nsTableCellFrame *)mFirstChild; while (nsnull!=cell) { sum += cell->GetColSpan(); cell->GetNextSibling((nsIFrame *&)cell);