diff --git a/layout/html/table/src/BasicTableLayoutStrategy.cpp b/layout/html/table/src/BasicTableLayoutStrategy.cpp
index 7a41775436db..7b53936185e6 100644
--- a/layout/html/table/src/BasicTableLayoutStrategy.cpp
+++ b/layout/html/table/src/BasicTableLayoutStrategy.cpp
@@ -258,6 +258,13 @@ PRBool BasicTableLayoutStrategy::AssignPreliminaryColumnWidths()
maxColWidthArray = new PRInt32[mNumCols];
}
+ const nsStyleTable* tableStyle;
+ mTableFrame->GetStyleData(eStyleStruct_Table, (const nsStyleStruct*&)tableStyle);
+ nscoord cellPadding=0;
+ if (eStyleUnit_Coord==tableStyle->mCellPadding.GetUnit())
+ cellPadding=tableStyle->mCellPadding.GetCoordValue();
+ if (gsDebug) printf ("table cell padding = %d\n", cellPadding);
+
PRInt32 numRows = mTableFrame->GetRowCount();
PRInt32 colIndex, rowIndex;
@@ -291,6 +298,7 @@ PRBool BasicTableLayoutStrategy::AssignPreliminaryColumnWidths()
{
haveColWidth = PR_TRUE;
specifiedFixedColWidth = colPosition->mWidth.GetCoordValue();
+ specifiedFixedColWidth += (cellPadding*2);
}
/* Scan the column, simulatneously assigning column widths
diff --git a/layout/html/table/src/nsTableCellFrame.cpp b/layout/html/table/src/nsTableCellFrame.cpp
index 606e68321779..a0ca2f141ffe 100644
--- a/layout/html/table/src/nsTableCellFrame.cpp
+++ b/layout/html/table/src/nsTableCellFrame.cpp
@@ -345,6 +345,19 @@ NS_METHOD nsTableCellFrame::Reflow(nsIPresContext& aPresContext,
printf(" content returned desired width %d given avail width %d\n",
kidSize.width, availSize.width);
}
+ // Nav4 hack for 0 width cells.
+ // Empty cells are assigned a width of 3px
+ // see testcase "cellHeights.html"
+ if (0==kidSize.width)
+ {
+ float p2t;
+ aPresContext.GetScaledPixelsToTwips(p2t);
+ kidSize.width=NSIntPixelsToTwips(3, p2t);
+ if (nsnull!=aDesiredSize.maxElementSize && 0==pMaxElementSize->width)
+ pMaxElementSize->width=NSIntPixelsToTwips(3, p2t);
+ if (gsDebug) printf ("setting child width from 0 to %d for nav4 compatibility\n", NSIntPixelsToTwips(1, p2t));
+ }
+ // end Nav4 hack for 0 width cells
#endif
if (PR_TRUE==gsDebug || PR_TRUE==gsDebugNT)
{
@@ -378,34 +391,6 @@ NS_METHOD nsTableCellFrame::Reflow(nsIPresContext& aPresContext,
// next determine the cell's width
nscoord cellWidth = kidSize.width; // at this point, we've factored in the cell's style attributes
- // Nav4 hack for 0 width cells. If the cell has any content, it must have a desired width of at least 1
- // see testcase "cellHeights.html"
- /*
- if (0==cellWidth)
- {
- PRInt32 childCount;
- mFirstChild->ChildCount(childCount);
- if (0!=childCount)
- {
- nsIFrame *grandChild;
- mFirstChild->FirstChild(grandChild);
- grandChild->ChildCount(childCount);
- if (0!=childCount)
- {
- float p2t;
- aPresContext.GetScaledPixelsToTwips(p2t);
- nscoord one = ((nscoord)(NSIntPixelsToTwips(1, p2t)));
- cellWidth = 1;
- if (gsDebug)
- printf ("setting cellWidth=1 because it was 0 but there's some content\n");
- if (nsnull!=aDesiredSize.maxElementSize && 0==pMaxElementSize->width)
- pMaxElementSize->width=1; // insets added in below
- }
- }
- }
- */
- // end Nav4 hack for 0 width cells
-
// NAV4 compatibility: only add insets if cell content was not 0 width
if (0!=cellWidth)
cellWidth += leftInset + rightInset; // factor in insets
@@ -459,20 +444,6 @@ NS_METHOD nsTableCellFrame::IR_StyleChanged(nsIPresContext& aPresContex
tableFrame->InvalidateFirstPassCache();
}
- // we are obligated to pass along the reflow command to our children before doing anything else
- /*
- nsIFrame *childFrame = mFirstChild;
- while (nsnull!=childFrame)
- {
- nsHTMLReflowState childReflowState(aPresContext, childFrame, aReflowState,
- aReflowState.maxSize, eReflowReason_Incremental);
- rv = ReflowChild(childFrame, aPresContext, aDesiredSize, childReflowState, aStatus);
- if (NS_FAILED(rv))
- break;
- // the returned desired size is irrelevant, because we'll do a resize reflow in a moment
- childFrame->GetNextSibling(childFrame);
- }
- */
return rv;
}
diff --git a/layout/html/table/src/nsTableFrame.cpp b/layout/html/table/src/nsTableFrame.cpp
index c1f4b8837967..4d4c3b01dcfc 100644
--- a/layout/html/table/src/nsTableFrame.cpp
+++ b/layout/html/table/src/nsTableFrame.cpp
@@ -2698,7 +2698,13 @@ void nsTableFrame::BalanceColumnWidths(nsIPresContext& aPresContext,
const nsStylePosition* position =
(const nsStylePosition*)mStyleContext->GetStyleData(eStyleStruct_Position);
if (eStyleUnit_Coord==position->mWidth.GetUnit())
- maxWidth = position->mWidth.GetCoordValue();
+ {
+ nscoord coordWidth=0;
+ coordWidth = position->mWidth.GetCoordValue();
+ // NAV4 compatibility: 0-coord-width == auto-width
+ if (0!=coordWidth)
+ maxWidth = coordWidth;
+ }
if (0>maxWidth) // nonsense style specification
maxWidth = 0;
@@ -3860,13 +3866,19 @@ PRBool nsTableFrame::TableIsAutoWidth(nsTableFrame *aTableFrame,
break;
case eStyleUnit_Coord:
- // XXX: subtract out this table frame's borderpadding?
- aSpecifiedTableWidth = tablePosition->mWidth.GetCoordValue();
- aReflowState.frame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)spacing);
- spacing->CalcBorderPaddingFor(aReflowState.frame, borderPadding);
- aSpecifiedTableWidth -= (borderPadding.right + borderPadding.left);
- result = PR_FALSE;
- break;
+ {
+ nscoord coordWidth = tablePosition->mWidth.GetCoordValue();
+ // NAV4 compatibility. If coord width is 0, do nothing so we get same result as "auto"
+ if (0!=coordWidth)
+ {
+ aSpecifiedTableWidth = coordWidth;
+ aReflowState.frame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)spacing);
+ spacing->CalcBorderPaddingFor(aReflowState.frame, borderPadding);
+ aSpecifiedTableWidth -= (borderPadding.right + borderPadding.left);
+ result = PR_FALSE;
+ }
+ }
+ break;
case eStyleUnit_Percent:
// set aSpecifiedTableWidth to be the given percent of the parent.
diff --git a/layout/html/table/src/nsTableOuterFrame.cpp b/layout/html/table/src/nsTableOuterFrame.cpp
index 964f640baf06..cc2bcd4afc51 100644
--- a/layout/html/table/src/nsTableOuterFrame.cpp
+++ b/layout/html/table/src/nsTableOuterFrame.cpp
@@ -864,6 +864,9 @@ nscoord nsTableOuterFrame::GetTableWidth(const nsHTMLReflowState& aReflowState)
switch (position->mWidth.GetUnit()) {
case eStyleUnit_Coord:
maxWidth = position->mWidth.GetCoordValue();
+ // NAV4 compatibility: 0-coord-width == auto-width
+ if (0==maxWidth)
+ maxWidth = aReflowState.maxSize.width;
break;
case eStyleUnit_Auto:
@@ -873,6 +876,9 @@ nscoord nsTableOuterFrame::GetTableWidth(const nsHTMLReflowState& aReflowState)
case eStyleUnit_Percent:
maxWidth = (nscoord)((float)aReflowState.maxSize.width *
position->mWidth.GetPercentValue());
+ // NAV4 compatibility: 0-percent-width == auto-width
+ if (0==maxWidth)
+ maxWidth = aReflowState.maxSize.width;
break;
case eStyleUnit_Proportional:
diff --git a/layout/tables/BasicTableLayoutStrategy.cpp b/layout/tables/BasicTableLayoutStrategy.cpp
index 7a41775436db..7b53936185e6 100644
--- a/layout/tables/BasicTableLayoutStrategy.cpp
+++ b/layout/tables/BasicTableLayoutStrategy.cpp
@@ -258,6 +258,13 @@ PRBool BasicTableLayoutStrategy::AssignPreliminaryColumnWidths()
maxColWidthArray = new PRInt32[mNumCols];
}
+ const nsStyleTable* tableStyle;
+ mTableFrame->GetStyleData(eStyleStruct_Table, (const nsStyleStruct*&)tableStyle);
+ nscoord cellPadding=0;
+ if (eStyleUnit_Coord==tableStyle->mCellPadding.GetUnit())
+ cellPadding=tableStyle->mCellPadding.GetCoordValue();
+ if (gsDebug) printf ("table cell padding = %d\n", cellPadding);
+
PRInt32 numRows = mTableFrame->GetRowCount();
PRInt32 colIndex, rowIndex;
@@ -291,6 +298,7 @@ PRBool BasicTableLayoutStrategy::AssignPreliminaryColumnWidths()
{
haveColWidth = PR_TRUE;
specifiedFixedColWidth = colPosition->mWidth.GetCoordValue();
+ specifiedFixedColWidth += (cellPadding*2);
}
/* Scan the column, simulatneously assigning column widths
diff --git a/layout/tables/nsTableCellFrame.cpp b/layout/tables/nsTableCellFrame.cpp
index 606e68321779..a0ca2f141ffe 100644
--- a/layout/tables/nsTableCellFrame.cpp
+++ b/layout/tables/nsTableCellFrame.cpp
@@ -345,6 +345,19 @@ NS_METHOD nsTableCellFrame::Reflow(nsIPresContext& aPresContext,
printf(" content returned desired width %d given avail width %d\n",
kidSize.width, availSize.width);
}
+ // Nav4 hack for 0 width cells.
+ // Empty cells are assigned a width of 3px
+ // see testcase "cellHeights.html"
+ if (0==kidSize.width)
+ {
+ float p2t;
+ aPresContext.GetScaledPixelsToTwips(p2t);
+ kidSize.width=NSIntPixelsToTwips(3, p2t);
+ if (nsnull!=aDesiredSize.maxElementSize && 0==pMaxElementSize->width)
+ pMaxElementSize->width=NSIntPixelsToTwips(3, p2t);
+ if (gsDebug) printf ("setting child width from 0 to %d for nav4 compatibility\n", NSIntPixelsToTwips(1, p2t));
+ }
+ // end Nav4 hack for 0 width cells
#endif
if (PR_TRUE==gsDebug || PR_TRUE==gsDebugNT)
{
@@ -378,34 +391,6 @@ NS_METHOD nsTableCellFrame::Reflow(nsIPresContext& aPresContext,
// next determine the cell's width
nscoord cellWidth = kidSize.width; // at this point, we've factored in the cell's style attributes
- // Nav4 hack for 0 width cells. If the cell has any content, it must have a desired width of at least 1
- // see testcase "cellHeights.html"
- /*
- if (0==cellWidth)
- {
- PRInt32 childCount;
- mFirstChild->ChildCount(childCount);
- if (0!=childCount)
- {
- nsIFrame *grandChild;
- mFirstChild->FirstChild(grandChild);
- grandChild->ChildCount(childCount);
- if (0!=childCount)
- {
- float p2t;
- aPresContext.GetScaledPixelsToTwips(p2t);
- nscoord one = ((nscoord)(NSIntPixelsToTwips(1, p2t)));
- cellWidth = 1;
- if (gsDebug)
- printf ("setting cellWidth=1 because it was 0 but there's some content\n");
- if (nsnull!=aDesiredSize.maxElementSize && 0==pMaxElementSize->width)
- pMaxElementSize->width=1; // insets added in below
- }
- }
- }
- */
- // end Nav4 hack for 0 width cells
-
// NAV4 compatibility: only add insets if cell content was not 0 width
if (0!=cellWidth)
cellWidth += leftInset + rightInset; // factor in insets
@@ -459,20 +444,6 @@ NS_METHOD nsTableCellFrame::IR_StyleChanged(nsIPresContext& aPresContex
tableFrame->InvalidateFirstPassCache();
}
- // we are obligated to pass along the reflow command to our children before doing anything else
- /*
- nsIFrame *childFrame = mFirstChild;
- while (nsnull!=childFrame)
- {
- nsHTMLReflowState childReflowState(aPresContext, childFrame, aReflowState,
- aReflowState.maxSize, eReflowReason_Incremental);
- rv = ReflowChild(childFrame, aPresContext, aDesiredSize, childReflowState, aStatus);
- if (NS_FAILED(rv))
- break;
- // the returned desired size is irrelevant, because we'll do a resize reflow in a moment
- childFrame->GetNextSibling(childFrame);
- }
- */
return rv;
}
diff --git a/layout/tables/nsTableFrame.cpp b/layout/tables/nsTableFrame.cpp
index c1f4b8837967..4d4c3b01dcfc 100644
--- a/layout/tables/nsTableFrame.cpp
+++ b/layout/tables/nsTableFrame.cpp
@@ -2698,7 +2698,13 @@ void nsTableFrame::BalanceColumnWidths(nsIPresContext& aPresContext,
const nsStylePosition* position =
(const nsStylePosition*)mStyleContext->GetStyleData(eStyleStruct_Position);
if (eStyleUnit_Coord==position->mWidth.GetUnit())
- maxWidth = position->mWidth.GetCoordValue();
+ {
+ nscoord coordWidth=0;
+ coordWidth = position->mWidth.GetCoordValue();
+ // NAV4 compatibility: 0-coord-width == auto-width
+ if (0!=coordWidth)
+ maxWidth = coordWidth;
+ }
if (0>maxWidth) // nonsense style specification
maxWidth = 0;
@@ -3860,13 +3866,19 @@ PRBool nsTableFrame::TableIsAutoWidth(nsTableFrame *aTableFrame,
break;
case eStyleUnit_Coord:
- // XXX: subtract out this table frame's borderpadding?
- aSpecifiedTableWidth = tablePosition->mWidth.GetCoordValue();
- aReflowState.frame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)spacing);
- spacing->CalcBorderPaddingFor(aReflowState.frame, borderPadding);
- aSpecifiedTableWidth -= (borderPadding.right + borderPadding.left);
- result = PR_FALSE;
- break;
+ {
+ nscoord coordWidth = tablePosition->mWidth.GetCoordValue();
+ // NAV4 compatibility. If coord width is 0, do nothing so we get same result as "auto"
+ if (0!=coordWidth)
+ {
+ aSpecifiedTableWidth = coordWidth;
+ aReflowState.frame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)spacing);
+ spacing->CalcBorderPaddingFor(aReflowState.frame, borderPadding);
+ aSpecifiedTableWidth -= (borderPadding.right + borderPadding.left);
+ result = PR_FALSE;
+ }
+ }
+ break;
case eStyleUnit_Percent:
// set aSpecifiedTableWidth to be the given percent of the parent.
diff --git a/layout/tables/nsTableOuterFrame.cpp b/layout/tables/nsTableOuterFrame.cpp
index 964f640baf06..cc2bcd4afc51 100644
--- a/layout/tables/nsTableOuterFrame.cpp
+++ b/layout/tables/nsTableOuterFrame.cpp
@@ -864,6 +864,9 @@ nscoord nsTableOuterFrame::GetTableWidth(const nsHTMLReflowState& aReflowState)
switch (position->mWidth.GetUnit()) {
case eStyleUnit_Coord:
maxWidth = position->mWidth.GetCoordValue();
+ // NAV4 compatibility: 0-coord-width == auto-width
+ if (0==maxWidth)
+ maxWidth = aReflowState.maxSize.width;
break;
case eStyleUnit_Auto:
@@ -873,6 +876,9 @@ nscoord nsTableOuterFrame::GetTableWidth(const nsHTMLReflowState& aReflowState)
case eStyleUnit_Percent:
maxWidth = (nscoord)((float)aReflowState.maxSize.width *
position->mWidth.GetPercentValue());
+ // NAV4 compatibility: 0-percent-width == auto-width
+ if (0==maxWidth)
+ maxWidth = aReflowState.maxSize.width;
break;
case eStyleUnit_Proportional: