support for Nav4 compatibility -- auto-width cells with 0-width content are 1 pixel wide

This commit is contained in:
buster 1998-06-26 23:31:33 +00:00
Родитель 15df59cc18
Коммит 8cb2f20cbf
6 изменённых файлов: 64 добавлений и 10 удалений

Просмотреть файл

@ -16,7 +16,6 @@
* Reserved.
*/
#include <stdio.h>
#include "BasicTableLayoutStrategy.h"
#include "nsTableFrame.h"
#include "nsTableColFrame.h"
@ -946,8 +945,12 @@ PRBool BasicTableLayoutStrategy::BalanceColumnsTableFits(nsIPresContext* aPresCo
{
PRInt32 colIndex = autoColumns[i];
nscoord oldColWidth = mTableFrame->GetColumnWidth(colIndex);
float percent = (float)oldColWidth/(float)totalWidthOfAutoColumns;
nscoord excessForThisColumn = excess*percent;
float percent;
if (0!=totalWidthOfAutoColumns)
percent = (float)oldColWidth/(float)totalWidthOfAutoColumns;
else
percent = (float)1/(float)numAutoColumns;
nscoord excessForThisColumn = (nscoord)(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);

Просмотреть файл

@ -367,6 +367,25 @@ NS_METHOD nsTableCellFrame::Reflow(nsIPresContext* aPresContext,
cellWidth = kidSize.width; // at this point, we've factored in the cell's style attributes
if (NS_UNCONSTRAINEDSIZE!=cellWidth)
cellWidth += leftInset + rightInset;
// Nav4 hack for 0 width cells. If the cell has any content, it must have a desired width of at least 1
if (0==cellWidth)
{
PRInt32 childCount;
mFirstChild->ChildCount(childCount);
if (0!=childCount)
{
nsIFrame *grandChild;
mFirstChild->FirstChild(grandChild);
grandChild->ChildCount(childCount);
if (0!=childCount)
{
cellWidth=1;
if (nsnull!=aDesiredSize.maxElementSize && 0==pMaxElementSize->width)
pMaxElementSize->width=1;
}
}
}
// end Nav4 hack for 0 width cells
// set the cell's desired size and max element size
aDesiredSize.width = cellWidth;

Просмотреть файл

@ -2160,13 +2160,18 @@ void nsTableFrame::BalanceColumnWidths(nsIPresContext* aPresContext,
case eStyleUnit_Coord:
maxWidth = position->mWidth.GetCoordValue();
break;
case eStyleUnit_Auto:
maxWidth = aMaxSize.width;
break;
case eStyleUnit_Percent:
case eStyleUnit_Proportional:
case eStyleUnit_Inherit:
// XXX for now these fall through
default:
case eStyleUnit_Auto:
case eStyleUnit_Inherit:
maxWidth = aMaxSize.width;
break;
}

Просмотреть файл

@ -16,7 +16,6 @@
* Reserved.
*/
#include <stdio.h>
#include "BasicTableLayoutStrategy.h"
#include "nsTableFrame.h"
#include "nsTableColFrame.h"
@ -946,8 +945,12 @@ PRBool BasicTableLayoutStrategy::BalanceColumnsTableFits(nsIPresContext* aPresCo
{
PRInt32 colIndex = autoColumns[i];
nscoord oldColWidth = mTableFrame->GetColumnWidth(colIndex);
float percent = (float)oldColWidth/(float)totalWidthOfAutoColumns;
nscoord excessForThisColumn = excess*percent;
float percent;
if (0!=totalWidthOfAutoColumns)
percent = (float)oldColWidth/(float)totalWidthOfAutoColumns;
else
percent = (float)1/(float)numAutoColumns;
nscoord excessForThisColumn = (nscoord)(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);

Просмотреть файл

@ -367,6 +367,25 @@ NS_METHOD nsTableCellFrame::Reflow(nsIPresContext* aPresContext,
cellWidth = kidSize.width; // at this point, we've factored in the cell's style attributes
if (NS_UNCONSTRAINEDSIZE!=cellWidth)
cellWidth += leftInset + rightInset;
// Nav4 hack for 0 width cells. If the cell has any content, it must have a desired width of at least 1
if (0==cellWidth)
{
PRInt32 childCount;
mFirstChild->ChildCount(childCount);
if (0!=childCount)
{
nsIFrame *grandChild;
mFirstChild->FirstChild(grandChild);
grandChild->ChildCount(childCount);
if (0!=childCount)
{
cellWidth=1;
if (nsnull!=aDesiredSize.maxElementSize && 0==pMaxElementSize->width)
pMaxElementSize->width=1;
}
}
}
// end Nav4 hack for 0 width cells
// set the cell's desired size and max element size
aDesiredSize.width = cellWidth;

Просмотреть файл

@ -2160,13 +2160,18 @@ void nsTableFrame::BalanceColumnWidths(nsIPresContext* aPresContext,
case eStyleUnit_Coord:
maxWidth = position->mWidth.GetCoordValue();
break;
case eStyleUnit_Auto:
maxWidth = aMaxSize.width;
break;
case eStyleUnit_Percent:
case eStyleUnit_Proportional:
case eStyleUnit_Inherit:
// XXX for now these fall through
default:
case eStyleUnit_Auto:
case eStyleUnit_Inherit:
maxWidth = aMaxSize.width;
break;
}