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.


git-svn-id: svn://10.0.0.236/trunk@5082 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
buster
1998-07-07 01:06:51 +00:00
parent 3b5b47465b
commit 38ee9372e2
8 changed files with 46 additions and 14 deletions

View File

@@ -17,8 +17,7 @@
*/
#include "nsCRT.h"
#include "nsCellMap.h"
#include "nsTablePart.h"
#include <stdio.h>/* XXX */ // for printf
#include "nsTableFrame.h"
#ifdef NS_DEBUG
static PRBool gsDebug1 = PR_FALSE;

View File

@@ -60,6 +60,8 @@ nsTableCellFrame::nsTableCellFrame(nsIContent* aContent,
mColSpan=1;
mColIndex=0;
mPriorAvailWidth=0;
mPriorDesiredSize.width=0;
mPriorDesiredSize.height=0;
}
nsTableCellFrame::~nsTableCellFrame()
@@ -289,6 +291,7 @@ NS_METHOD nsTableCellFrame::Reflow(nsIPresContext* aPresContext,
mFirstChild->WillReflow(*aPresContext);
mFirstChild->MoveTo(leftInset, topInset);
aStatus = ReflowChild(mFirstChild, aPresContext, kidSize, kidReflowState);
SetPriorDesiredSize(kidSize);
if (PR_TRUE==gsDebug || PR_TRUE==gsDebugNT)
{

View File

@@ -84,6 +84,10 @@ public:
virtual void SetPriorAvailWidth(nscoord aPriorAvailWidth);
virtual nsSize GetPriorDesiredSize();
virtual void SetPriorDesiredSize(const nsReflowMetrics & aDesiredSize);
virtual ~nsTableCellFrame();
// Get the TableFrame that contains this cell frame
@@ -128,6 +132,8 @@ protected:
/** the available width we were given in our previous reflow */
nscoord mPriorAvailWidth;
nsSize mPriorDesiredSize;
nsCellLayoutData *mCellLayoutData;
};
@@ -169,4 +175,13 @@ inline nscoord nsTableCellFrame::GetPriorAvailWidth()
inline void nsTableCellFrame::SetPriorAvailWidth(nscoord 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

View File

@@ -410,7 +410,7 @@ PRBool nsTableRowFrame::ReflowMappedChildren(nsIPresContext* aPresContext,
// Compute the x-origin for the child, taking into account straddlers (cells from prior
// rows with rowspans > 1)
nscoord x = 0;
nscoord x = kidMargin.left;
PRInt32 cellColIndex = ((nsTableCellFrame *)kidFrame)->GetColIndex();
for (PRInt32 colIndex=0; colIndex<cellColIndex; colIndex++)
{
@@ -452,10 +452,9 @@ PRBool nsTableRowFrame::ReflowMappedChildren(nsIPresContext* aPresContext,
}
else
{
nsRect cellRect;
kidFrame->GetRect(cellRect);
desiredSize.width = cellRect.width;
desiredSize.height = cellRect.height;
nsSize priorSize = ((nsTableCellFrame *)kidFrame)->GetPriorDesiredSize();
desiredSize.width = priorSize.width;
desiredSize.height = priorSize.height;
status = NS_FRAME_COMPLETE; // XXX: in paginated world, this doesn't work!
}

View File

@@ -17,8 +17,7 @@
*/
#include "nsCRT.h"
#include "nsCellMap.h"
#include "nsTablePart.h"
#include <stdio.h>/* XXX */ // for printf
#include "nsTableFrame.h"
#ifdef NS_DEBUG
static PRBool gsDebug1 = PR_FALSE;

View File

@@ -60,6 +60,8 @@ nsTableCellFrame::nsTableCellFrame(nsIContent* aContent,
mColSpan=1;
mColIndex=0;
mPriorAvailWidth=0;
mPriorDesiredSize.width=0;
mPriorDesiredSize.height=0;
}
nsTableCellFrame::~nsTableCellFrame()
@@ -289,6 +291,7 @@ NS_METHOD nsTableCellFrame::Reflow(nsIPresContext* aPresContext,
mFirstChild->WillReflow(*aPresContext);
mFirstChild->MoveTo(leftInset, topInset);
aStatus = ReflowChild(mFirstChild, aPresContext, kidSize, kidReflowState);
SetPriorDesiredSize(kidSize);
if (PR_TRUE==gsDebug || PR_TRUE==gsDebugNT)
{

View File

@@ -84,6 +84,10 @@ public:
virtual void SetPriorAvailWidth(nscoord aPriorAvailWidth);
virtual nsSize GetPriorDesiredSize();
virtual void SetPriorDesiredSize(const nsReflowMetrics & aDesiredSize);
virtual ~nsTableCellFrame();
// Get the TableFrame that contains this cell frame
@@ -128,6 +132,8 @@ protected:
/** the available width we were given in our previous reflow */
nscoord mPriorAvailWidth;
nsSize mPriorDesiredSize;
nsCellLayoutData *mCellLayoutData;
};
@@ -169,4 +175,13 @@ inline nscoord nsTableCellFrame::GetPriorAvailWidth()
inline void nsTableCellFrame::SetPriorAvailWidth(nscoord 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

View File

@@ -410,7 +410,7 @@ PRBool nsTableRowFrame::ReflowMappedChildren(nsIPresContext* aPresContext,
// Compute the x-origin for the child, taking into account straddlers (cells from prior
// rows with rowspans > 1)
nscoord x = 0;
nscoord x = kidMargin.left;
PRInt32 cellColIndex = ((nsTableCellFrame *)kidFrame)->GetColIndex();
for (PRInt32 colIndex=0; colIndex<cellColIndex; colIndex++)
{
@@ -452,10 +452,9 @@ PRBool nsTableRowFrame::ReflowMappedChildren(nsIPresContext* aPresContext,
}
else
{
nsRect cellRect;
kidFrame->GetRect(cellRect);
desiredSize.width = cellRect.width;
desiredSize.height = cellRect.height;
nsSize priorSize = ((nsTableCellFrame *)kidFrame)->GetPriorDesiredSize();
desiredSize.width = priorSize.width;
desiredSize.height = priorSize.height;
status = NS_FRAME_COMPLETE; // XXX: in paginated world, this doesn't work!
}