зеркало из https://github.com/mozilla/gecko-dev.git
2 Nav4 compatibility additions:
1. width=0 is treated as width=auto, not width=min 2. empty cells <td></td> are assigned a width of (2*borderWidth + 2*cellspacing + 3) pixels The "3" is a fudge factor added by Nav and IE.
This commit is contained in:
Родитель
1817d840b0
Коммит
3ddfe1c165
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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:
|
||||
|
|
Загрузка…
Ссылка в новой задаче