fixed 3 dumb bugs I introduced recently.
1. cellmap couldn't properly delete CellData because definition was unavailable 2. optimized table cells made taller wouldn't shrink when they should because we were not remembering the previous desired height of the cell. 3. rows were placing cells on the left edge, and not adding in the left margin.
This commit is contained in:
@@ -17,8 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
#include "nsCRT.h"
|
#include "nsCRT.h"
|
||||||
#include "nsCellMap.h"
|
#include "nsCellMap.h"
|
||||||
#include "nsTablePart.h"
|
#include "nsTableFrame.h"
|
||||||
#include <stdio.h>/* XXX */ // for printf
|
|
||||||
|
|
||||||
#ifdef NS_DEBUG
|
#ifdef NS_DEBUG
|
||||||
static PRBool gsDebug1 = PR_FALSE;
|
static PRBool gsDebug1 = PR_FALSE;
|
||||||
|
|||||||
@@ -60,6 +60,8 @@ nsTableCellFrame::nsTableCellFrame(nsIContent* aContent,
|
|||||||
mColSpan=1;
|
mColSpan=1;
|
||||||
mColIndex=0;
|
mColIndex=0;
|
||||||
mPriorAvailWidth=0;
|
mPriorAvailWidth=0;
|
||||||
|
mPriorDesiredSize.width=0;
|
||||||
|
mPriorDesiredSize.height=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsTableCellFrame::~nsTableCellFrame()
|
nsTableCellFrame::~nsTableCellFrame()
|
||||||
@@ -289,6 +291,7 @@ NS_METHOD nsTableCellFrame::Reflow(nsIPresContext* aPresContext,
|
|||||||
mFirstChild->WillReflow(*aPresContext);
|
mFirstChild->WillReflow(*aPresContext);
|
||||||
mFirstChild->MoveTo(leftInset, topInset);
|
mFirstChild->MoveTo(leftInset, topInset);
|
||||||
aStatus = ReflowChild(mFirstChild, aPresContext, kidSize, kidReflowState);
|
aStatus = ReflowChild(mFirstChild, aPresContext, kidSize, kidReflowState);
|
||||||
|
SetPriorDesiredSize(kidSize);
|
||||||
|
|
||||||
if (PR_TRUE==gsDebug || PR_TRUE==gsDebugNT)
|
if (PR_TRUE==gsDebug || PR_TRUE==gsDebugNT)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -84,6 +84,10 @@ public:
|
|||||||
|
|
||||||
virtual void SetPriorAvailWidth(nscoord aPriorAvailWidth);
|
virtual void SetPriorAvailWidth(nscoord aPriorAvailWidth);
|
||||||
|
|
||||||
|
virtual nsSize GetPriorDesiredSize();
|
||||||
|
|
||||||
|
virtual void SetPriorDesiredSize(const nsReflowMetrics & aDesiredSize);
|
||||||
|
|
||||||
virtual ~nsTableCellFrame();
|
virtual ~nsTableCellFrame();
|
||||||
|
|
||||||
// Get the TableFrame that contains this cell frame
|
// Get the TableFrame that contains this cell frame
|
||||||
@@ -128,6 +132,8 @@ protected:
|
|||||||
/** the available width we were given in our previous reflow */
|
/** the available width we were given in our previous reflow */
|
||||||
nscoord mPriorAvailWidth;
|
nscoord mPriorAvailWidth;
|
||||||
|
|
||||||
|
nsSize mPriorDesiredSize;
|
||||||
|
|
||||||
nsCellLayoutData *mCellLayoutData;
|
nsCellLayoutData *mCellLayoutData;
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -169,4 +175,13 @@ inline nscoord nsTableCellFrame::GetPriorAvailWidth()
|
|||||||
inline void nsTableCellFrame::SetPriorAvailWidth(nscoord aPriorAvailWidth)
|
inline void nsTableCellFrame::SetPriorAvailWidth(nscoord aPriorAvailWidth)
|
||||||
{ mPriorAvailWidth = aPriorAvailWidth;}
|
{ mPriorAvailWidth = aPriorAvailWidth;}
|
||||||
|
|
||||||
|
inline nsSize nsTableCellFrame::GetPriorDesiredSize()
|
||||||
|
{ return mPriorDesiredSize; }
|
||||||
|
|
||||||
|
inline void nsTableCellFrame::SetPriorDesiredSize(const nsReflowMetrics & aDesiredSize)
|
||||||
|
{
|
||||||
|
mPriorDesiredSize.width = aDesiredSize.width;
|
||||||
|
mPriorDesiredSize.height = aDesiredSize.height;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -410,7 +410,7 @@ PRBool nsTableRowFrame::ReflowMappedChildren(nsIPresContext* aPresContext,
|
|||||||
|
|
||||||
// Compute the x-origin for the child, taking into account straddlers (cells from prior
|
// Compute the x-origin for the child, taking into account straddlers (cells from prior
|
||||||
// rows with rowspans > 1)
|
// rows with rowspans > 1)
|
||||||
nscoord x = 0;
|
nscoord x = kidMargin.left;
|
||||||
PRInt32 cellColIndex = ((nsTableCellFrame *)kidFrame)->GetColIndex();
|
PRInt32 cellColIndex = ((nsTableCellFrame *)kidFrame)->GetColIndex();
|
||||||
for (PRInt32 colIndex=0; colIndex<cellColIndex; colIndex++)
|
for (PRInt32 colIndex=0; colIndex<cellColIndex; colIndex++)
|
||||||
{
|
{
|
||||||
@@ -452,10 +452,9 @@ PRBool nsTableRowFrame::ReflowMappedChildren(nsIPresContext* aPresContext,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
nsRect cellRect;
|
nsSize priorSize = ((nsTableCellFrame *)kidFrame)->GetPriorDesiredSize();
|
||||||
kidFrame->GetRect(cellRect);
|
desiredSize.width = priorSize.width;
|
||||||
desiredSize.width = cellRect.width;
|
desiredSize.height = priorSize.height;
|
||||||
desiredSize.height = cellRect.height;
|
|
||||||
status = NS_FRAME_COMPLETE; // XXX: in paginated world, this doesn't work!
|
status = NS_FRAME_COMPLETE; // XXX: in paginated world, this doesn't work!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,8 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
#include "nsCRT.h"
|
#include "nsCRT.h"
|
||||||
#include "nsCellMap.h"
|
#include "nsCellMap.h"
|
||||||
#include "nsTablePart.h"
|
#include "nsTableFrame.h"
|
||||||
#include <stdio.h>/* XXX */ // for printf
|
|
||||||
|
|
||||||
#ifdef NS_DEBUG
|
#ifdef NS_DEBUG
|
||||||
static PRBool gsDebug1 = PR_FALSE;
|
static PRBool gsDebug1 = PR_FALSE;
|
||||||
|
|||||||
@@ -60,6 +60,8 @@ nsTableCellFrame::nsTableCellFrame(nsIContent* aContent,
|
|||||||
mColSpan=1;
|
mColSpan=1;
|
||||||
mColIndex=0;
|
mColIndex=0;
|
||||||
mPriorAvailWidth=0;
|
mPriorAvailWidth=0;
|
||||||
|
mPriorDesiredSize.width=0;
|
||||||
|
mPriorDesiredSize.height=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsTableCellFrame::~nsTableCellFrame()
|
nsTableCellFrame::~nsTableCellFrame()
|
||||||
@@ -289,6 +291,7 @@ NS_METHOD nsTableCellFrame::Reflow(nsIPresContext* aPresContext,
|
|||||||
mFirstChild->WillReflow(*aPresContext);
|
mFirstChild->WillReflow(*aPresContext);
|
||||||
mFirstChild->MoveTo(leftInset, topInset);
|
mFirstChild->MoveTo(leftInset, topInset);
|
||||||
aStatus = ReflowChild(mFirstChild, aPresContext, kidSize, kidReflowState);
|
aStatus = ReflowChild(mFirstChild, aPresContext, kidSize, kidReflowState);
|
||||||
|
SetPriorDesiredSize(kidSize);
|
||||||
|
|
||||||
if (PR_TRUE==gsDebug || PR_TRUE==gsDebugNT)
|
if (PR_TRUE==gsDebug || PR_TRUE==gsDebugNT)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -84,6 +84,10 @@ public:
|
|||||||
|
|
||||||
virtual void SetPriorAvailWidth(nscoord aPriorAvailWidth);
|
virtual void SetPriorAvailWidth(nscoord aPriorAvailWidth);
|
||||||
|
|
||||||
|
virtual nsSize GetPriorDesiredSize();
|
||||||
|
|
||||||
|
virtual void SetPriorDesiredSize(const nsReflowMetrics & aDesiredSize);
|
||||||
|
|
||||||
virtual ~nsTableCellFrame();
|
virtual ~nsTableCellFrame();
|
||||||
|
|
||||||
// Get the TableFrame that contains this cell frame
|
// Get the TableFrame that contains this cell frame
|
||||||
@@ -128,6 +132,8 @@ protected:
|
|||||||
/** the available width we were given in our previous reflow */
|
/** the available width we were given in our previous reflow */
|
||||||
nscoord mPriorAvailWidth;
|
nscoord mPriorAvailWidth;
|
||||||
|
|
||||||
|
nsSize mPriorDesiredSize;
|
||||||
|
|
||||||
nsCellLayoutData *mCellLayoutData;
|
nsCellLayoutData *mCellLayoutData;
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -169,4 +175,13 @@ inline nscoord nsTableCellFrame::GetPriorAvailWidth()
|
|||||||
inline void nsTableCellFrame::SetPriorAvailWidth(nscoord aPriorAvailWidth)
|
inline void nsTableCellFrame::SetPriorAvailWidth(nscoord aPriorAvailWidth)
|
||||||
{ mPriorAvailWidth = aPriorAvailWidth;}
|
{ mPriorAvailWidth = aPriorAvailWidth;}
|
||||||
|
|
||||||
|
inline nsSize nsTableCellFrame::GetPriorDesiredSize()
|
||||||
|
{ return mPriorDesiredSize; }
|
||||||
|
|
||||||
|
inline void nsTableCellFrame::SetPriorDesiredSize(const nsReflowMetrics & aDesiredSize)
|
||||||
|
{
|
||||||
|
mPriorDesiredSize.width = aDesiredSize.width;
|
||||||
|
mPriorDesiredSize.height = aDesiredSize.height;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -410,7 +410,7 @@ PRBool nsTableRowFrame::ReflowMappedChildren(nsIPresContext* aPresContext,
|
|||||||
|
|
||||||
// Compute the x-origin for the child, taking into account straddlers (cells from prior
|
// Compute the x-origin for the child, taking into account straddlers (cells from prior
|
||||||
// rows with rowspans > 1)
|
// rows with rowspans > 1)
|
||||||
nscoord x = 0;
|
nscoord x = kidMargin.left;
|
||||||
PRInt32 cellColIndex = ((nsTableCellFrame *)kidFrame)->GetColIndex();
|
PRInt32 cellColIndex = ((nsTableCellFrame *)kidFrame)->GetColIndex();
|
||||||
for (PRInt32 colIndex=0; colIndex<cellColIndex; colIndex++)
|
for (PRInt32 colIndex=0; colIndex<cellColIndex; colIndex++)
|
||||||
{
|
{
|
||||||
@@ -452,10 +452,9 @@ PRBool nsTableRowFrame::ReflowMappedChildren(nsIPresContext* aPresContext,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
nsRect cellRect;
|
nsSize priorSize = ((nsTableCellFrame *)kidFrame)->GetPriorDesiredSize();
|
||||||
kidFrame->GetRect(cellRect);
|
desiredSize.width = priorSize.width;
|
||||||
desiredSize.width = cellRect.width;
|
desiredSize.height = priorSize.height;
|
||||||
desiredSize.height = cellRect.height;
|
|
||||||
status = NS_FRAME_COMPLETE; // XXX: in paginated world, this doesn't work!
|
status = NS_FRAME_COMPLETE; // XXX: in paginated world, this doesn't work!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user