From 38ee9372e23fb9e5b294fba413d1c192e7500306 Mon Sep 17 00:00:00 2001 From: buster Date: Tue, 7 Jul 1998 01:06:51 +0000 Subject: [PATCH] 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 --- mozilla/layout/html/table/src/nsCellMap.cpp | 3 +-- .../layout/html/table/src/nsTableCellFrame.cpp | 3 +++ mozilla/layout/html/table/src/nsTableCellFrame.h | 15 +++++++++++++++ mozilla/layout/html/table/src/nsTableRowFrame.cpp | 9 ++++----- mozilla/layout/tables/nsCellMap.cpp | 3 +-- mozilla/layout/tables/nsTableCellFrame.cpp | 3 +++ mozilla/layout/tables/nsTableCellFrame.h | 15 +++++++++++++++ mozilla/layout/tables/nsTableRowFrame.cpp | 9 ++++----- 8 files changed, 46 insertions(+), 14 deletions(-) diff --git a/mozilla/layout/html/table/src/nsCellMap.cpp b/mozilla/layout/html/table/src/nsCellMap.cpp index 11ea1372da0..3098842597e 100644 --- a/mozilla/layout/html/table/src/nsCellMap.cpp +++ b/mozilla/layout/html/table/src/nsCellMap.cpp @@ -17,8 +17,7 @@ */ #include "nsCRT.h" #include "nsCellMap.h" -#include "nsTablePart.h" -#include /* XXX */ // for printf +#include "nsTableFrame.h" #ifdef NS_DEBUG static PRBool gsDebug1 = PR_FALSE; diff --git a/mozilla/layout/html/table/src/nsTableCellFrame.cpp b/mozilla/layout/html/table/src/nsTableCellFrame.cpp index 00676145a18..a66a2fcbe6c 100644 --- a/mozilla/layout/html/table/src/nsTableCellFrame.cpp +++ b/mozilla/layout/html/table/src/nsTableCellFrame.cpp @@ -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) { diff --git a/mozilla/layout/html/table/src/nsTableCellFrame.h b/mozilla/layout/html/table/src/nsTableCellFrame.h index 1d86f6be1c6..ecdf04fce00 100644 --- a/mozilla/layout/html/table/src/nsTableCellFrame.h +++ b/mozilla/layout/html/table/src/nsTableCellFrame.h @@ -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 diff --git a/mozilla/layout/html/table/src/nsTableRowFrame.cpp b/mozilla/layout/html/table/src/nsTableRowFrame.cpp index eda17101fc1..c38c0fd6b9f 100644 --- a/mozilla/layout/html/table/src/nsTableRowFrame.cpp +++ b/mozilla/layout/html/table/src/nsTableRowFrame.cpp @@ -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; colIndexGetRect(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! } diff --git a/mozilla/layout/tables/nsCellMap.cpp b/mozilla/layout/tables/nsCellMap.cpp index 11ea1372da0..3098842597e 100644 --- a/mozilla/layout/tables/nsCellMap.cpp +++ b/mozilla/layout/tables/nsCellMap.cpp @@ -17,8 +17,7 @@ */ #include "nsCRT.h" #include "nsCellMap.h" -#include "nsTablePart.h" -#include /* XXX */ // for printf +#include "nsTableFrame.h" #ifdef NS_DEBUG static PRBool gsDebug1 = PR_FALSE; diff --git a/mozilla/layout/tables/nsTableCellFrame.cpp b/mozilla/layout/tables/nsTableCellFrame.cpp index 00676145a18..a66a2fcbe6c 100644 --- a/mozilla/layout/tables/nsTableCellFrame.cpp +++ b/mozilla/layout/tables/nsTableCellFrame.cpp @@ -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) { diff --git a/mozilla/layout/tables/nsTableCellFrame.h b/mozilla/layout/tables/nsTableCellFrame.h index 1d86f6be1c6..ecdf04fce00 100644 --- a/mozilla/layout/tables/nsTableCellFrame.h +++ b/mozilla/layout/tables/nsTableCellFrame.h @@ -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 diff --git a/mozilla/layout/tables/nsTableRowFrame.cpp b/mozilla/layout/tables/nsTableRowFrame.cpp index eda17101fc1..c38c0fd6b9f 100644 --- a/mozilla/layout/tables/nsTableRowFrame.cpp +++ b/mozilla/layout/tables/nsTableRowFrame.cpp @@ -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; colIndexGetRect(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! }