DeleteFrame() now takes a pres context.

This commit is contained in:
michaelp%netscape.com 1998-08-28 03:02:39 +00:00
parent 31c7923449
commit ca017f19d0
17 changed files with 60 additions and 42 deletions

View File

@ -107,6 +107,7 @@ class nsContainerFrame : public nsSplittableFrame
public:
NS_IMETHOD SizeOf(nsISizeOfHandler* aHandler) const;
NS_IMETHOD DeleteFrame(nsIPresContext& aPresContext);
/**
* Default implementation is to use the content delegate to create a new
* frame. After the frame is created it uses PrepareContinuingFrame() to
@ -245,7 +246,7 @@ protected:
*
* @param aChild child this child's next-in-flow
*/
PRBool DeleteChildsNextInFlow(nsIFrame* aChild);
PRBool DeleteChildsNextInFlow(nsIPresContext& aPresContext, nsIFrame* aChild);
/**
* Push aFromChild and its next siblings to the next-in-flow. Change the

View File

@ -105,7 +105,7 @@ public:
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
// nsIFrame
NS_IMETHOD DeleteFrame();
NS_IMETHOD DeleteFrame(nsIPresContext& aPresContext);
NS_IMETHOD SizeOf(nsISizeOfHandler* aHandler) const;
NS_IMETHOD GetContent(nsIContent*& aContent) const;
NS_IMETHOD GetContentIndex(PRInt32& aIndexInParent) const;

View File

@ -21,6 +21,7 @@
#include "nscoord.h"
#include "nsContainerFrame.h"
#include "nsIContent.h"
#include "nsIPresContext.h"
static NS_DEFINE_IID(kIContentIID, NS_ICONTENT_IID);
@ -128,7 +129,7 @@ public:
// Allow public access to protected member functions
void PushChildren(nsIFrame* aFromChild, nsIFrame* aPrevSibling, PRBool aLastIsComplete);
PRBool DeleteChildsNextInFlow(nsIFrame* aChild);
PRBool DeleteChildsNextInFlow(nsIPresContext& aPresContext, nsIFrame* aChild);
};
SimpleContainer::SimpleContainer(nsIContent* aContent)
@ -150,9 +151,9 @@ void SimpleContainer::PushChildren(nsIFrame* aFromChild, nsIFrame* aPrevSibling,
nsContainerFrame::PushChildren(aFromChild, aPrevSibling, aLastIsComplete);
}
PRBool SimpleContainer::DeleteChildsNextInFlow(nsIFrame* aChild)
PRBool SimpleContainer::DeleteChildsNextInFlow(nsIPresContext& aPresContext, nsIFrame* aChild)
{
return nsContainerFrame::DeleteChildsNextInFlow(aChild);
return nsContainerFrame::DeleteChildsNextInFlow(aPresContext, aChild);
}
///////////////////////////////////////////////////////////////////////////////
@ -470,6 +471,9 @@ TestDeleteChildsNext()
SimpleContent* childContent = new SimpleContent;
nsFrame* c1 = new SimpleSplittableFrame(childContent, f);
nsFrame* c11 = new SimpleSplittableFrame(childContent, f);
nsIPresContext *context;
NS_NewGalleyContext(&context);
///////////////////////////////////////////////////////////////////////////
// #1a
@ -480,7 +484,7 @@ TestDeleteChildsNext()
f->SetFirstChild(c1, 2);
// Delete the next-in-flow
f->DeleteChildsNextInFlow(c1);
f->DeleteChildsNextInFlow(*context, c1);
// Verify the child count
PRInt32 childCount;
@ -532,7 +536,7 @@ TestDeleteChildsNext()
f1->AppendToFlow(f);
// Delete the next-in-flow
f->DeleteChildsNextInFlow(c1);
f->DeleteChildsNextInFlow(*context, c1);
// Verify that the second container frame is empty
nsIFrame* firstChild;
@ -567,7 +571,7 @@ TestDeleteChildsNext()
f->SetLastContentOffset(1);
// Delete the next-in-flow
f->DeleteChildsNextInFlow(c1);
f->DeleteChildsNextInFlow(*context, c1);
// Verify the child count
f->ChildCount(childCount);
@ -619,7 +623,7 @@ TestDeleteChildsNext()
f1->AppendToFlow(f);
// Delete the next-in-flow
f->DeleteChildsNextInFlow(c1);
f->DeleteChildsNextInFlow(*context, c1);
// Verify the next-in-flow pointer is null
c1->GetNextInFlow(nextInFlow);
@ -669,7 +673,7 @@ TestDeleteChildsNext()
f->SetLastContentOffset(1);
// Delete the next-in-flow
f->DeleteChildsNextInFlow(c1);
f->DeleteChildsNextInFlow(*context, c1);
// Verify the next-in-flow pointer is null
c1->GetNextInFlow(nextInFlow);
@ -710,6 +714,8 @@ TestDeleteChildsNext()
return PR_FALSE;
}
NS_IF_RELEASE(context);
return PR_TRUE;
}

View File

@ -107,6 +107,7 @@ public:
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
// nsIFrame
NS_IMETHOD DeleteFrame(nsIPresContext& aPresContext);
NS_IMETHOD ChildCount(PRInt32& aChildCount) const;
NS_IMETHOD ChildAt(PRInt32 aIndex, nsIFrame*& aFrame) const;
NS_IMETHOD IndexOf(const nsIFrame* aChild, PRInt32& aIndex) const;
@ -168,7 +169,7 @@ protected:
PRBool GetLastContentIsComplete() const;
#endif
virtual PRBool DeleteNextInFlowsFor(nsIFrame* aNextInFlow);
virtual PRBool DeleteNextInFlowsFor(nsIPresContext& aPresContext, nsIFrame* aNextInFlow);
PRBool DrainOverflowLines();
@ -550,7 +551,7 @@ VerifyChildCount(LineData* aLines, PRBool aEmptyOK = PR_FALSE)
#endif
static void
DeleteLineList(LineData* aLine)
DeleteLineList(nsIPresContext& aPresContext, LineData* aLine)
{
if (nsnull != aLine) {
// Delete our child frames before doing anything else. In particular
@ -559,7 +560,7 @@ DeleteLineList(LineData* aLine)
for (nsIFrame* child = aLine->mFirstChild; child; ) {
nsIFrame* nextChild;
child->GetNextSibling(nextChild);
child->DeleteFrame();
child->DeleteFrame(aPresContext);
child = nextChild;
}
@ -927,8 +928,6 @@ nsCSSBlockFrame::nsCSSBlockFrame(nsIContent* aContent, nsIFrame* aParent)
nsCSSBlockFrame::~nsCSSBlockFrame()
{
DeleteLineList(mLines);
DeleteLineList(mOverflowLines);
// if (nsnull != mRunInFloaters) {
// delete mRunInFloaters;
// }
@ -958,6 +957,17 @@ nsCSSBlockFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
return nsCSSBlockFrameSuper::QueryInterface(aIID, aInstancePtr);
}
NS_IMETHODIMP
nsCSSBlockFrame::DeleteFrame(nsIPresContext& aPresContext)
{
DeleteLineList(aPresContext, mLines);
DeleteLineList(aPresContext, mOverflowLines);
nsCSSBlockFrameSuper::DeleteFrame(aPresContext);
return NS_OK;
}
PRBool
nsCSSBlockFrame::IsPseudoFrame() const
{
@ -2347,7 +2357,7 @@ nsCSSBlockFrame::ReflowBlockFrame(nsCSSBlockReflowState& aState,
// parent is not this because we are executing pullup code)
nsIFrame* parent;
aFrame->GetGeometricParent(parent);
((nsCSSBlockFrame*)parent)->DeleteNextInFlowsFor(aFrame);
((nsCSSBlockFrame*)parent)->DeleteNextInFlowsFor(*aState.mPresContext, aFrame);
}
aLine->SetLastContentIsComplete();
aReflowResult = NS_FRAME_COMPLETE;
@ -3327,7 +3337,7 @@ nsCSSBlockFrame::ContentDeleted(nsIPresShell* aShell,
if (nsnull != nextInFlow) {
deadFrame->BreakFromNextFlow();
}
deadFrame->DeleteFrame();
deadFrame->DeleteFrame(*aPresContext);
deadFrame = nextInFlow;
// If line is empty, remove it now
@ -3409,7 +3419,7 @@ nsCSSBlockFrame::ContentDeleted(nsIPresShell* aShell,
}
PRBool
nsCSSBlockFrame::DeleteNextInFlowsFor(nsIFrame* aChild)
nsCSSBlockFrame::DeleteNextInFlowsFor(nsIPresContext& aPresContext, nsIFrame* aChild)
{
NS_PRECONDITION(IsChild(aChild), "bad geometric parent");
@ -3425,7 +3435,7 @@ nsCSSBlockFrame::DeleteNextInFlowsFor(nsIFrame* aChild)
nsIFrame* nextNextInFlow;
nextInFlow->GetNextInFlow(nextNextInFlow);
if (nsnull != nextNextInFlow) {
parent->DeleteNextInFlowsFor(nextInFlow);
parent->DeleteNextInFlowsFor(aPresContext, nextInFlow);
}
#ifdef NS_DEBUG
@ -3473,7 +3483,7 @@ nsCSSBlockFrame::DeleteNextInFlowsFor(nsIFrame* aChild)
#endif
// Delete the next-in-flow frame and adjust its parents child count
nextInFlow->DeleteFrame();
nextInFlow->DeleteFrame(aPresContext);
#ifdef NS_DEBUG
aChild->GetNextInFlow(nextInFlow);

View File

@ -24,7 +24,7 @@
class nsCSSContainerFrame : public nsHTMLContainerFrame {
public:
virtual PRBool DeleteNextInFlowsFor(nsIFrame* aChild) = 0;
virtual PRBool DeleteNextInFlowsFor(nsIPresContext& aPresContext, nsIFrame* aChild) = 0;
protected:
nsCSSContainerFrame(nsIContent* aContent, nsIFrame* aParent);

View File

@ -160,9 +160,9 @@ nsCSSInlineFrame::CreateContinuingFrame(nsIPresContext& aCX,
}
PRBool
nsCSSInlineFrame::DeleteNextInFlowsFor(nsIFrame* aChild)
nsCSSInlineFrame::DeleteNextInFlowsFor(nsIPresContext& aPresContext, nsIFrame* aChild)
{
return DeleteChildsNextInFlow(aChild);
return DeleteChildsNextInFlow(aPresContext, aChild);
}
NS_IMETHODIMP

View File

@ -81,7 +81,7 @@ public:
const nsReflowState& aReflowState);
// nsCSSContainerFrame
virtual PRBool DeleteNextInFlowsFor(nsIFrame* aChild);
virtual PRBool DeleteNextInFlowsFor(nsIPresContext& aPresContext, nsIFrame* aChild);
protected:
nsCSSInlineFrame(nsIContent* aContent, nsIFrame* aParent);

View File

@ -316,7 +316,8 @@ nsCSSInlineLayout::ReflowFrame(nsIFrame* aKidFrame,
// parent is not this because we are executing pullup code)
nsIFrame* parent;
aKidFrame->GetGeometricParent(parent);
((nsCSSContainerFrame*)parent)->DeleteNextInFlowsFor(aKidFrame);
((nsCSSContainerFrame*)parent)->DeleteNextInFlowsFor(*mLineLayout.mPresContext,
aKidFrame);
}
}

View File

@ -332,7 +332,7 @@ nsHTMLContainerFrame::ContentDeleted(nsIPresShell* aShell,
nsIFrame* nextInFlow;
deadFrame->GetNextInFlow(nextInFlow);
deadFrame->BreakFromNextFlow();
deadFrame->DeleteFrame();
deadFrame->DeleteFrame(*aPresContext);
deadFrame = nextInFlow;
if (nsnull != deadFrame) {

View File

@ -225,7 +225,7 @@ NS_METHOD nsBodyFrame::Reflow(nsIPresContext& aPresContext,
mFirstChild->GetNextInFlow(kidNextInFlow);
if (nsnull != kidNextInFlow) {
// Remove all of the childs next-in-flows
DeleteChildsNextInFlow(mFirstChild);
DeleteChildsNextInFlow(aPresContext, mFirstChild);
}
}
else {

View File

@ -75,7 +75,7 @@ public:
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
// nsIFrame
NS_IMETHOD DeleteFrame();
NS_IMETHOD DeleteFrame(nsIPresContext& aPresContext);
NS_IMETHOD Paint(nsIPresContext &aCX,
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect);
@ -194,11 +194,11 @@ BulletFrame::QueryInterface(REFNSIID aIID, void** aInstancePtrResult)
}
NS_METHOD
BulletFrame::DeleteFrame()
BulletFrame::DeleteFrame(nsIPresContext& aPresContext)
{
// Release image loader first so that it's refcnt can go to zero
mImageLoader.DestroyLoader();
return nsFrame::DeleteFrame();
return nsFrame::DeleteFrame(aPresContext);
}
NS_METHOD

View File

@ -332,7 +332,7 @@ nsHTMLContainerFrame::ContentDeleted(nsIPresShell* aShell,
nsIFrame* nextInFlow;
deadFrame->GetNextInFlow(nextInFlow);
deadFrame->BreakFromNextFlow();
deadFrame->DeleteFrame();
deadFrame->DeleteFrame(*aPresContext);
deadFrame = nextInFlow;
if (nsnull != deadFrame) {

View File

@ -96,7 +96,7 @@ class ImageFrame : public ImageFrameSuper {
public:
ImageFrame(nsIContent* aContent, nsIFrame* aParentFrame);
NS_IMETHOD DeleteFrame();
NS_IMETHOD DeleteFrame(nsIPresContext& aPresContext);
NS_IMETHOD SizeOf(nsISizeOfHandler* aHandler) const;
NS_IMETHOD Paint(nsIPresContext& aPresContext,
nsIRenderingContext& aRenderingContext,
@ -377,14 +377,14 @@ ImageFrame::~ImageFrame()
}
NS_METHOD
ImageFrame::DeleteFrame()
ImageFrame::DeleteFrame(nsIPresContext& aPresContext)
{
NS_IF_RELEASE(mImageMap);
// Release image loader first so that it's refcnt can go to zero
mImageLoader.DestroyLoader();
return nsLeafFrame::DeleteFrame();
return nsLeafFrame::DeleteFrame(aPresContext);
}
NS_IMETHODIMP

View File

@ -722,7 +722,7 @@ NS_METHOD nsTableOuterFrame::VerifyTree() const
* @param aChild child this child's next-in-flow
* @return PR_TRUE if successful and PR_FALSE otherwise
*/
PRBool nsTableOuterFrame::DeleteChildsNextInFlow(nsIFrame* aChild)
PRBool nsTableOuterFrame::DeleteChildsNextInFlow(nsIPresContext& aPresContext, nsIFrame* aChild)
{
NS_PRECONDITION(IsChild(aChild), "bad geometric parent");
@ -741,7 +741,7 @@ PRBool nsTableOuterFrame::DeleteChildsNextInFlow(nsIFrame* aChild)
nextInFlow->GetNextInFlow(nextNextInFlow);
if (nsnull != nextNextInFlow) {
parent->DeleteChildsNextInFlow(nextInFlow);
parent->DeleteChildsNextInFlow(aPresContext, nextInFlow);
}
#ifdef NS_DEBUG
@ -800,7 +800,7 @@ PRBool nsTableOuterFrame::DeleteChildsNextInFlow(nsIFrame* aChild)
}
// Delete the next-in-flow frame and adjust it's parent's child count
nextInFlow->DeleteFrame();
nextInFlow->DeleteFrame(aPresContext);
parent->mChildCount--;
#ifdef NS_DEBUG

View File

@ -116,7 +116,7 @@ protected:
* @param aChild child this child's next-in-flow
* @return PR_TRUE if successful and PR_FALSE otherwise
*/
PRBool DeleteChildsNextInFlow(nsIFrame* aChild);
PRBool DeleteChildsNextInFlow(nsIPresContext& aPresContext, nsIFrame* aChild);
/**
* Create the inner table frame (nsTableFrame). Handles initial

View File

@ -722,7 +722,7 @@ NS_METHOD nsTableOuterFrame::VerifyTree() const
* @param aChild child this child's next-in-flow
* @return PR_TRUE if successful and PR_FALSE otherwise
*/
PRBool nsTableOuterFrame::DeleteChildsNextInFlow(nsIFrame* aChild)
PRBool nsTableOuterFrame::DeleteChildsNextInFlow(nsIPresContext& aPresContext, nsIFrame* aChild)
{
NS_PRECONDITION(IsChild(aChild), "bad geometric parent");
@ -741,7 +741,7 @@ PRBool nsTableOuterFrame::DeleteChildsNextInFlow(nsIFrame* aChild)
nextInFlow->GetNextInFlow(nextNextInFlow);
if (nsnull != nextNextInFlow) {
parent->DeleteChildsNextInFlow(nextInFlow);
parent->DeleteChildsNextInFlow(aPresContext, nextInFlow);
}
#ifdef NS_DEBUG
@ -800,7 +800,7 @@ PRBool nsTableOuterFrame::DeleteChildsNextInFlow(nsIFrame* aChild)
}
// Delete the next-in-flow frame and adjust it's parent's child count
nextInFlow->DeleteFrame();
nextInFlow->DeleteFrame(aPresContext);
parent->mChildCount--;
#ifdef NS_DEBUG

View File

@ -116,7 +116,7 @@ protected:
* @param aChild child this child's next-in-flow
* @return PR_TRUE if successful and PR_FALSE otherwise
*/
PRBool DeleteChildsNextInFlow(nsIFrame* aChild);
PRBool DeleteChildsNextInFlow(nsIPresContext& aPresContext, nsIFrame* aChild);
/**
* Create the inner table frame (nsTableFrame). Handles initial