зеркало из https://github.com/mozilla/pjs.git
made allocation of mColumnWidths more flexible
This commit is contained in:
Родитель
ecd4d1df2f
Коммит
d3ab71c37f
|
@ -64,6 +64,8 @@ NS_DEF_PTR(nsIContent);
|
|||
|
||||
const nsIID kTableFrameCID = NS_TABLEFRAME_CID;
|
||||
|
||||
static const PRInt32 kColumnWidthIncrement=100;
|
||||
|
||||
/* ----------- CellData ---------- */
|
||||
|
||||
/* CellData is the info stored in the cell map */
|
||||
|
@ -263,13 +265,14 @@ nsTableFrame::nsTableFrame(nsIContent* aContent, nsIFrame* aParentFrame)
|
|||
: nsContainerFrame(aContent, aParentFrame),
|
||||
mCellMap(nsnull),
|
||||
mColCache(nsnull),
|
||||
mColumnWidths(nsnull),
|
||||
mTableLayoutStrategy(nsnull),
|
||||
mFirstPassValid(PR_FALSE),
|
||||
mPass(kPASS_UNDEFINED),
|
||||
mIsInvariantWidth(PR_FALSE)
|
||||
{
|
||||
mEffectiveColCount = -1; // -1 means uninitialized
|
||||
mColumnWidthsLength = kColumnWidthIncrement;
|
||||
mColumnWidths = new PRInt32[mColumnWidthsLength];
|
||||
nsCRT::memset (mColumnWidths, 0, mColumnWidthsLength*sizeof(PRInt32));
|
||||
mCellMap = new nsCellMap(0, 0);
|
||||
}
|
||||
|
||||
|
@ -1546,7 +1549,6 @@ NS_METHOD nsTableFrame::Reflow(nsIPresContext& aPresContext,
|
|||
#if 1
|
||||
// XXX For the time being just fall through and treat it like a
|
||||
// pass 2 reflow...
|
||||
mPass = kPASS_SECOND;
|
||||
// calling intialize here resets all the cached info based on new table content
|
||||
if (nsnull!=mTableLayoutStrategy)
|
||||
{
|
||||
|
@ -1569,11 +1571,9 @@ NS_METHOD nsTableFrame::Reflow(nsIPresContext& aPresContext,
|
|||
// XXX TROY: we used to rebuild the cellmap here for incremental reflow.
|
||||
// now that the cellmap is built in the constructor
|
||||
// we need to reset the cellmap during incremental reflow before we get here
|
||||
mPass = kPASS_FIRST;
|
||||
aStatus = ResizeReflowPass1(&aPresContext, aDesiredSize, aReflowState, aStatus);
|
||||
// check result
|
||||
}
|
||||
mPass = kPASS_SECOND;
|
||||
|
||||
if (nsnull==mPrevInFlow)
|
||||
{
|
||||
|
@ -1589,8 +1589,6 @@ NS_METHOD nsTableFrame::Reflow(nsIPresContext& aPresContext,
|
|||
nsHTMLReflowState reflowState(aReflowState);
|
||||
reflowState.maxSize.width = mRect.width;
|
||||
aStatus = ResizeReflowPass2(&aPresContext, aDesiredSize, reflowState);
|
||||
|
||||
mPass = kPASS_UNDEFINED;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1799,8 +1797,6 @@ nsReflowStatus nsTableFrame::ResizeReflowPass2(nsIPresContext* aPresContext,
|
|||
}
|
||||
}
|
||||
|
||||
mPass = kPASS_UNDEFINED; // we're no longer in-process
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
//PostReflowCheck(status);
|
||||
#endif
|
||||
|
@ -2232,13 +2228,20 @@ void nsTableFrame::BalanceColumnWidths(nsIPresContext* aPresContext,
|
|||
{
|
||||
NS_ASSERTION(nsnull==mPrevInFlow, "never ever call me on a continuing frame!");
|
||||
NS_ASSERTION(nsnull!=mCellMap, "never ever call me until the cell map is built!");
|
||||
NS_ASSERTION(nsnull!=mColumnWidths, "never ever call me until the col widths array is built!");
|
||||
|
||||
PRInt32 numCols = GetColCount();
|
||||
if (nsnull==mColumnWidths)
|
||||
if (numCols>mColumnWidthsLength)
|
||||
{
|
||||
mColumnWidths = new PRInt32[numCols];
|
||||
nsCRT::memset (mColumnWidths, 0, numCols*sizeof(PRInt32));
|
||||
}
|
||||
PRInt32 priorColumnWidthsLength=mColumnWidthsLength;
|
||||
while (numCols>mColumnWidthsLength)
|
||||
mColumnWidthsLength += kColumnWidthIncrement;
|
||||
PRInt32 * newColumnWidthsArray = new PRInt32[mColumnWidthsLength];
|
||||
nsCRT::memset (newColumnWidthsArray, 0, mColumnWidthsLength*sizeof(PRInt32));
|
||||
nsCRT::memcpy (newColumnWidthsArray, mColumnWidths, priorColumnWidthsLength*sizeof(PRInt32));
|
||||
delete [] mColumnWidths;
|
||||
mColumnWidths = newColumnWidthsArray;
|
||||
}
|
||||
|
||||
const nsStyleSpacing* spacing =
|
||||
(const nsStyleSpacing*)mStyleContext->GetStyleData(eStyleStruct_Spacing);
|
||||
|
@ -2589,20 +2592,6 @@ void nsTableFrame::BuildColumnCache( nsIPresContext* aPresContext,
|
|||
}
|
||||
}
|
||||
|
||||
PRInt32 nsTableFrame::GetReflowPass() const
|
||||
{
|
||||
nsTableFrame * firstInFlow = (nsTableFrame *)GetFirstInFlow();
|
||||
NS_ASSERTION(nsnull!=firstInFlow, "illegal state -- no first in flow");
|
||||
return firstInFlow->mPass;
|
||||
}
|
||||
|
||||
void nsTableFrame::SetReflowPass(PRInt32 aReflowPass)
|
||||
{
|
||||
nsTableFrame * firstInFlow = (nsTableFrame *)GetFirstInFlow();
|
||||
NS_ASSERTION(nsnull!=firstInFlow, "illegal state -- no first in flow");
|
||||
firstInFlow->mPass = aReflowPass;
|
||||
}
|
||||
|
||||
PRBool nsTableFrame::IsFirstPassValid() const
|
||||
{
|
||||
nsTableFrame * firstInFlow = (nsTableFrame *)GetFirstInFlow();
|
||||
|
|
|
@ -344,12 +344,6 @@ protected:
|
|||
/** given the new parent size, do I really need to do a reflow? */
|
||||
virtual PRBool NeedsReflow(const nsSize& aMaxSize);
|
||||
|
||||
/** what stage of reflow is currently in process? */
|
||||
virtual PRInt32 GetReflowPass() const;
|
||||
|
||||
/** sets the reflow pass flag. use with caution! */
|
||||
virtual void SetReflowPass(PRInt32 aReflowPass);
|
||||
|
||||
/** returns PR_TRUE if the cached pass 1 data is still valid */
|
||||
virtual PRBool IsFirstPassValid() const;
|
||||
|
||||
|
@ -488,21 +482,16 @@ public: /* ----- Cell Map public methods ----- */
|
|||
private:
|
||||
void DebugPrintCount() const; // Debugging routine
|
||||
|
||||
|
||||
/** table reflow is a multi-pass operation. Use these constants to keep track of
|
||||
* which pass is currently being executed.
|
||||
*/
|
||||
enum {kPASS_UNDEFINED=0, kPASS_FIRST=1, kPASS_SECOND=2, kPASS_THIRD=3, kPASS_INCREMENTAL=4};
|
||||
|
||||
// data members
|
||||
PRInt32 *mColumnWidths; // widths of each column
|
||||
ColumnInfoCache *mColCache; // cached information about the table columns
|
||||
PRInt32 mColumnWidthsLength; // the number of column lengths this frame has allocated
|
||||
PRBool mFirstPassValid; // PR_TRUE if first pass data is still legit
|
||||
PRInt32 mPass; // which Reflow pass are we currently in?
|
||||
PRBool mIsInvariantWidth; // PR_TRUE if table width cannot change
|
||||
nsITableLayoutStrategy * mTableLayoutStrategy; // the layout strategy for this frame
|
||||
PRInt32 mColCount; // the number of columns in this table
|
||||
PRInt32 mEffectiveColCount; // the number of columns in this table adjusted for weird table attributes
|
||||
nsCellMap* mCellMap; // maintains the relationships between rows, cols, and cells
|
||||
ColumnInfoCache *mColCache; // cached information about the table columns
|
||||
nsITableLayoutStrategy * mTableLayoutStrategy; // the layout strategy for this frame
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -64,6 +64,8 @@ NS_DEF_PTR(nsIContent);
|
|||
|
||||
const nsIID kTableFrameCID = NS_TABLEFRAME_CID;
|
||||
|
||||
static const PRInt32 kColumnWidthIncrement=100;
|
||||
|
||||
/* ----------- CellData ---------- */
|
||||
|
||||
/* CellData is the info stored in the cell map */
|
||||
|
@ -263,13 +265,14 @@ nsTableFrame::nsTableFrame(nsIContent* aContent, nsIFrame* aParentFrame)
|
|||
: nsContainerFrame(aContent, aParentFrame),
|
||||
mCellMap(nsnull),
|
||||
mColCache(nsnull),
|
||||
mColumnWidths(nsnull),
|
||||
mTableLayoutStrategy(nsnull),
|
||||
mFirstPassValid(PR_FALSE),
|
||||
mPass(kPASS_UNDEFINED),
|
||||
mIsInvariantWidth(PR_FALSE)
|
||||
{
|
||||
mEffectiveColCount = -1; // -1 means uninitialized
|
||||
mColumnWidthsLength = kColumnWidthIncrement;
|
||||
mColumnWidths = new PRInt32[mColumnWidthsLength];
|
||||
nsCRT::memset (mColumnWidths, 0, mColumnWidthsLength*sizeof(PRInt32));
|
||||
mCellMap = new nsCellMap(0, 0);
|
||||
}
|
||||
|
||||
|
@ -1546,7 +1549,6 @@ NS_METHOD nsTableFrame::Reflow(nsIPresContext& aPresContext,
|
|||
#if 1
|
||||
// XXX For the time being just fall through and treat it like a
|
||||
// pass 2 reflow...
|
||||
mPass = kPASS_SECOND;
|
||||
// calling intialize here resets all the cached info based on new table content
|
||||
if (nsnull!=mTableLayoutStrategy)
|
||||
{
|
||||
|
@ -1569,11 +1571,9 @@ NS_METHOD nsTableFrame::Reflow(nsIPresContext& aPresContext,
|
|||
// XXX TROY: we used to rebuild the cellmap here for incremental reflow.
|
||||
// now that the cellmap is built in the constructor
|
||||
// we need to reset the cellmap during incremental reflow before we get here
|
||||
mPass = kPASS_FIRST;
|
||||
aStatus = ResizeReflowPass1(&aPresContext, aDesiredSize, aReflowState, aStatus);
|
||||
// check result
|
||||
}
|
||||
mPass = kPASS_SECOND;
|
||||
|
||||
if (nsnull==mPrevInFlow)
|
||||
{
|
||||
|
@ -1589,8 +1589,6 @@ NS_METHOD nsTableFrame::Reflow(nsIPresContext& aPresContext,
|
|||
nsHTMLReflowState reflowState(aReflowState);
|
||||
reflowState.maxSize.width = mRect.width;
|
||||
aStatus = ResizeReflowPass2(&aPresContext, aDesiredSize, reflowState);
|
||||
|
||||
mPass = kPASS_UNDEFINED;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1799,8 +1797,6 @@ nsReflowStatus nsTableFrame::ResizeReflowPass2(nsIPresContext* aPresContext,
|
|||
}
|
||||
}
|
||||
|
||||
mPass = kPASS_UNDEFINED; // we're no longer in-process
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
//PostReflowCheck(status);
|
||||
#endif
|
||||
|
@ -2232,13 +2228,20 @@ void nsTableFrame::BalanceColumnWidths(nsIPresContext* aPresContext,
|
|||
{
|
||||
NS_ASSERTION(nsnull==mPrevInFlow, "never ever call me on a continuing frame!");
|
||||
NS_ASSERTION(nsnull!=mCellMap, "never ever call me until the cell map is built!");
|
||||
NS_ASSERTION(nsnull!=mColumnWidths, "never ever call me until the col widths array is built!");
|
||||
|
||||
PRInt32 numCols = GetColCount();
|
||||
if (nsnull==mColumnWidths)
|
||||
if (numCols>mColumnWidthsLength)
|
||||
{
|
||||
mColumnWidths = new PRInt32[numCols];
|
||||
nsCRT::memset (mColumnWidths, 0, numCols*sizeof(PRInt32));
|
||||
}
|
||||
PRInt32 priorColumnWidthsLength=mColumnWidthsLength;
|
||||
while (numCols>mColumnWidthsLength)
|
||||
mColumnWidthsLength += kColumnWidthIncrement;
|
||||
PRInt32 * newColumnWidthsArray = new PRInt32[mColumnWidthsLength];
|
||||
nsCRT::memset (newColumnWidthsArray, 0, mColumnWidthsLength*sizeof(PRInt32));
|
||||
nsCRT::memcpy (newColumnWidthsArray, mColumnWidths, priorColumnWidthsLength*sizeof(PRInt32));
|
||||
delete [] mColumnWidths;
|
||||
mColumnWidths = newColumnWidthsArray;
|
||||
}
|
||||
|
||||
const nsStyleSpacing* spacing =
|
||||
(const nsStyleSpacing*)mStyleContext->GetStyleData(eStyleStruct_Spacing);
|
||||
|
@ -2589,20 +2592,6 @@ void nsTableFrame::BuildColumnCache( nsIPresContext* aPresContext,
|
|||
}
|
||||
}
|
||||
|
||||
PRInt32 nsTableFrame::GetReflowPass() const
|
||||
{
|
||||
nsTableFrame * firstInFlow = (nsTableFrame *)GetFirstInFlow();
|
||||
NS_ASSERTION(nsnull!=firstInFlow, "illegal state -- no first in flow");
|
||||
return firstInFlow->mPass;
|
||||
}
|
||||
|
||||
void nsTableFrame::SetReflowPass(PRInt32 aReflowPass)
|
||||
{
|
||||
nsTableFrame * firstInFlow = (nsTableFrame *)GetFirstInFlow();
|
||||
NS_ASSERTION(nsnull!=firstInFlow, "illegal state -- no first in flow");
|
||||
firstInFlow->mPass = aReflowPass;
|
||||
}
|
||||
|
||||
PRBool nsTableFrame::IsFirstPassValid() const
|
||||
{
|
||||
nsTableFrame * firstInFlow = (nsTableFrame *)GetFirstInFlow();
|
||||
|
|
|
@ -344,12 +344,6 @@ protected:
|
|||
/** given the new parent size, do I really need to do a reflow? */
|
||||
virtual PRBool NeedsReflow(const nsSize& aMaxSize);
|
||||
|
||||
/** what stage of reflow is currently in process? */
|
||||
virtual PRInt32 GetReflowPass() const;
|
||||
|
||||
/** sets the reflow pass flag. use with caution! */
|
||||
virtual void SetReflowPass(PRInt32 aReflowPass);
|
||||
|
||||
/** returns PR_TRUE if the cached pass 1 data is still valid */
|
||||
virtual PRBool IsFirstPassValid() const;
|
||||
|
||||
|
@ -488,21 +482,16 @@ public: /* ----- Cell Map public methods ----- */
|
|||
private:
|
||||
void DebugPrintCount() const; // Debugging routine
|
||||
|
||||
|
||||
/** table reflow is a multi-pass operation. Use these constants to keep track of
|
||||
* which pass is currently being executed.
|
||||
*/
|
||||
enum {kPASS_UNDEFINED=0, kPASS_FIRST=1, kPASS_SECOND=2, kPASS_THIRD=3, kPASS_INCREMENTAL=4};
|
||||
|
||||
// data members
|
||||
PRInt32 *mColumnWidths; // widths of each column
|
||||
ColumnInfoCache *mColCache; // cached information about the table columns
|
||||
PRInt32 mColumnWidthsLength; // the number of column lengths this frame has allocated
|
||||
PRBool mFirstPassValid; // PR_TRUE if first pass data is still legit
|
||||
PRInt32 mPass; // which Reflow pass are we currently in?
|
||||
PRBool mIsInvariantWidth; // PR_TRUE if table width cannot change
|
||||
nsITableLayoutStrategy * mTableLayoutStrategy; // the layout strategy for this frame
|
||||
PRInt32 mColCount; // the number of columns in this table
|
||||
PRInt32 mEffectiveColCount; // the number of columns in this table adjusted for weird table attributes
|
||||
nsCellMap* mCellMap; // maintains the relationships between rows, cols, and cells
|
||||
ColumnInfoCache *mColCache; // cached information about the table columns
|
||||
nsITableLayoutStrategy * mTableLayoutStrategy; // the layout strategy for this frame
|
||||
};
|
||||
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче