diff --git a/mozilla/content/html/content/src/nsHTMLAtoms.cpp b/mozilla/content/html/content/src/nsHTMLAtoms.cpp index 6dea38bda1f..b7e8033bd81 100644 --- a/mozilla/content/html/content/src/nsHTMLAtoms.cpp +++ b/mozilla/content/html/content/src/nsHTMLAtoms.cpp @@ -19,6 +19,7 @@ // XXX make this be autogenerated. doh! +nsIAtom* nsHTMLAtoms::mozAnonymousBlock; nsIAtom* nsHTMLAtoms::_baseHref; nsIAtom* nsHTMLAtoms::_baseTarget; nsIAtom* nsHTMLAtoms::a; @@ -256,6 +257,8 @@ static nsrefcnt gRefCnt; void nsHTMLAtoms::AddrefAtoms() { if (0 == gRefCnt) { + mozAnonymousBlock = NS_NewAtom(":MOZ-ANONYMOUS-BLOCK"); + _baseHref = NS_NewAtom(NS_HTML_BASE_HREF); _baseTarget = NS_NewAtom(NS_HTML_BASE_TARGET); a = NS_NewAtom("A"); @@ -493,6 +496,7 @@ void nsHTMLAtoms::ReleaseAtoms() { NS_PRECONDITION(gRefCnt != 0, "bad release atoms"); if (--gRefCnt == 0) { + NS_RELEASE(mozAnonymousBlock); NS_RELEASE(_baseHref); NS_RELEASE(_baseTarget); NS_RELEASE(a); diff --git a/mozilla/content/html/content/src/nsHTMLAtoms.h b/mozilla/content/html/content/src/nsHTMLAtoms.h index 8bfc9838700..9a2da18d033 100644 --- a/mozilla/content/html/content/src/nsHTMLAtoms.h +++ b/mozilla/content/html/content/src/nsHTMLAtoms.h @@ -35,6 +35,8 @@ public: static void AddrefAtoms(); static void ReleaseAtoms(); + static nsIAtom* mozAnonymousBlock; + // Special attribute atoms static nsIAtom* _baseHref; static nsIAtom* _baseTarget; diff --git a/mozilla/content/shared/public/nsHTMLAtoms.h b/mozilla/content/shared/public/nsHTMLAtoms.h index 8bfc9838700..9a2da18d033 100644 --- a/mozilla/content/shared/public/nsHTMLAtoms.h +++ b/mozilla/content/shared/public/nsHTMLAtoms.h @@ -35,6 +35,8 @@ public: static void AddrefAtoms(); static void ReleaseAtoms(); + static nsIAtom* mozAnonymousBlock; + // Special attribute atoms static nsIAtom* _baseHref; static nsIAtom* _baseTarget; diff --git a/mozilla/content/shared/src/nsHTMLAtoms.cpp b/mozilla/content/shared/src/nsHTMLAtoms.cpp index 6dea38bda1f..b7e8033bd81 100644 --- a/mozilla/content/shared/src/nsHTMLAtoms.cpp +++ b/mozilla/content/shared/src/nsHTMLAtoms.cpp @@ -19,6 +19,7 @@ // XXX make this be autogenerated. doh! +nsIAtom* nsHTMLAtoms::mozAnonymousBlock; nsIAtom* nsHTMLAtoms::_baseHref; nsIAtom* nsHTMLAtoms::_baseTarget; nsIAtom* nsHTMLAtoms::a; @@ -256,6 +257,8 @@ static nsrefcnt gRefCnt; void nsHTMLAtoms::AddrefAtoms() { if (0 == gRefCnt) { + mozAnonymousBlock = NS_NewAtom(":MOZ-ANONYMOUS-BLOCK"); + _baseHref = NS_NewAtom(NS_HTML_BASE_HREF); _baseTarget = NS_NewAtom(NS_HTML_BASE_TARGET); a = NS_NewAtom("A"); @@ -493,6 +496,7 @@ void nsHTMLAtoms::ReleaseAtoms() { NS_PRECONDITION(gRefCnt != 0, "bad release atoms"); if (--gRefCnt == 0) { + NS_RELEASE(mozAnonymousBlock); NS_RELEASE(_baseHref); NS_RELEASE(_baseTarget); NS_RELEASE(a); diff --git a/mozilla/layout/generic/nsAreaFrame.cpp b/mozilla/layout/generic/nsAreaFrame.cpp index 64de9d7a233..a6126898cc7 100644 --- a/mozilla/layout/generic/nsAreaFrame.cpp +++ b/mozilla/layout/generic/nsAreaFrame.cpp @@ -66,7 +66,7 @@ nsAreaFrame::~nsAreaFrame() NS_IMETHODIMP nsAreaFrame::DeleteFrame(nsIPresContext& aPresContext) { - DeleteFrameList(aPresContext, &mAbsoluteFrames); + mAbsoluteFrames.DeleteFrames(aPresContext); return nsBlockFrame::DeleteFrame(aPresContext); } @@ -78,7 +78,7 @@ nsAreaFrame::SetInitialChildList(nsIPresContext& aPresContext, nsresult rv; if (nsLayoutAtoms::absoluteList == aListName) { - mAbsoluteFrames = aChildList; + mAbsoluteFrames.SetFrames(aChildList); rv = NS_OK; } else { rv = nsBlockFrame::SetInitialChildList(aPresContext, aListName, aChildList); @@ -108,7 +108,7 @@ NS_IMETHODIMP nsAreaFrame::FirstChild(nsIAtom* aListName, nsIFrame*& aFirstChild) const { if (aListName == nsLayoutAtoms::absoluteList) { - aFirstChild = mAbsoluteFrames; + aFirstChild = mAbsoluteFrames.FirstChild(); return NS_OK; } @@ -290,28 +290,8 @@ nsAreaFrame::Reflow(nsIPresContext& aPresContext, nsIFrame* childFrame; aReflowState.reflowCommand->GetChildFrame(childFrame); - // Find the frame in our list of absolutely positioned children - // and remove it - if (mAbsoluteFrames == childFrame) { - childFrame->GetNextSibling(mAbsoluteFrames); - - } else { - nsIFrame* prevSibling = nsnull; - for (nsIFrame* f = mAbsoluteFrames; nsnull != f; f->GetNextSibling(f)) { - if (f == childFrame) { - break; - } - prevSibling = f; - } - - NS_ASSERTION(nsnull != prevSibling, "didn't find frame"); - nsIFrame* nextSibling; - childFrame->GetNextSibling(nextSibling); - prevSibling->SetNextSibling(nextSibling); - } - - // Now go ahead and delete the child frame - childFrame->DeleteFrame(aPresContext); + PRBool zap = mAbsoluteFrames.DeleteFrame(aPresContext, childFrame); + NS_ASSERTION(zap, "didn't find frame"); // XXX We don't need to reflow all the absolutely positioned // frames. Compute the desired size and exit... @@ -327,15 +307,7 @@ nsAreaFrame::Reflow(nsIPresContext& aPresContext, aReflowState.reflowCommand->GetPrevSiblingFrame(prevSibling); // Insert the frame - if (nsnull == prevSibling) { - mAbsoluteFrames = childFrame; - } else { - nsIFrame* nextSibling; - - prevSibling->GetNextSibling(nextSibling); - prevSibling->SetNextSibling(childFrame); - childFrame->SetNextSibling(nextSibling); - } + mAbsoluteFrames.InsertFrame(nsnull, prevSibling, childFrame); wasHandled = PR_TRUE; } else { @@ -380,7 +352,8 @@ nsAreaFrame::Reflow(nsIPresContext& aPresContext, mStyleContext->GetStyleData(eStyleStruct_Display); if (NS_STYLE_OVERFLOW_HIDDEN != display->mOverflow) { - for (nsIFrame* f = mAbsoluteFrames; nsnull != f; f->GetNextSibling(f)) { + for (nsIFrame* f = mAbsoluteFrames.FirstChild(); nsnull != f; + f->GetNextSibling(f)) { nsRect rect; f->GetRect(rect); @@ -473,14 +446,7 @@ nsAreaFrame::CreateContinuingFrame(nsIPresContext& aPresContext, // Add the frame to the end of the child list void nsAreaFrame::AddAbsoluteFrame(nsIFrame* aFrame) { - if (nsnull == mAbsoluteFrames) { - mAbsoluteFrames = aFrame; - } else { - nsIFrame* lastChild = LastFrame(mAbsoluteFrames); - - lastChild->SetNextSibling(aFrame); - aFrame->SetNextSibling(nsnull); - } + mAbsoluteFrames.AppendFrames(nsnull, aFrame); } // Called at the end of the Reflow() member function so we can process @@ -489,7 +455,7 @@ void nsAreaFrame::ReflowAbsoluteItems(nsIPresContext& aPresContext, const nsHTMLReflowState& aReflowState) { - for (nsIFrame* absoluteFrame = mAbsoluteFrames; + for (nsIFrame* absoluteFrame = mAbsoluteFrames.FirstChild(); nsnull != absoluteFrame; absoluteFrame->GetNextSibling(absoluteFrame)) { PRBool placeFrame = PR_FALSE; @@ -735,17 +701,19 @@ nsAreaFrame::List(FILE* out, PRInt32 aIndent, nsIListFilter* aFilter) const nsresult rv = nsBlockFrame::List(out, aIndent, aFilter); // Output absolutely positioned frames - if (nsnull != mAbsoluteFrames) { - for (PRInt32 i = aIndent; --i >= 0; ) fputs(" ", out); + if (mAbsoluteFrames.NotEmpty()) { + IndentBy(out, aIndent); fprintf(out, "absolute-items <\n"); + + nsIFrame* f = mAbsoluteFrames.FirstChild(); + while (nsnull != f) { + f->List(out, aIndent+1, aFilter); + f->GetNextSibling(f); + } + + IndentBy(out, aIndent); + fputs(">\n", out); } - nsIFrame* f = mAbsoluteFrames; - while (nsnull != f) { - f->List(out, aIndent+1, aFilter); - f->GetNextSibling(f); - } - for (PRInt32 i = aIndent; --i >= 0; ) fputs(" ", out); - fputs(">\n", out); return rv; } diff --git a/mozilla/layout/generic/nsAreaFrame.h b/mozilla/layout/generic/nsAreaFrame.h index 8d144ac1b05..4ffd090af4b 100644 --- a/mozilla/layout/generic/nsAreaFrame.h +++ b/mozilla/layout/generic/nsAreaFrame.h @@ -95,7 +95,7 @@ protected: private: nsSpaceManager* mSpaceManager; - nsIFrame* mAbsoluteFrames; // additional named child list + nsFrameList mAbsoluteFrames; // additional named child list #ifdef NS_DEBUG struct BandData : public nsBandData { diff --git a/mozilla/layout/generic/nsBlockFrame.cpp b/mozilla/layout/generic/nsBlockFrame.cpp index 3328e0cfd94..93034aef62e 100644 --- a/mozilla/layout/generic/nsBlockFrame.cpp +++ b/mozilla/layout/generic/nsBlockFrame.cpp @@ -3449,7 +3449,7 @@ nsBaseIBFrame::MarkEmptyLines(nsIPresContext& aPresContext) } } -PRBool +void nsBaseIBFrame::DeleteChildsNextInFlow(nsIPresContext& aPresContext, nsIFrame* aChild) { @@ -3470,15 +3470,6 @@ nsBaseIBFrame::DeleteChildsNextInFlow(nsIPresContext& aPresContext, parent->DeleteChildsNextInFlow(aPresContext, nextInFlow); } -#ifdef NS_DEBUG - PRInt32 childCount; - nsIFrame* firstChild; - nextInFlow->FirstChild(nsnull, firstChild); - childCount = LengthOf(firstChild); - NS_ASSERTION((0 == childCount) && (nsnull == firstChild), - "deleting !empty next-in-flow"); -#endif - // Disconnect the next-in-flow from the flow list nextInFlow->BreakFromPrevFlow(); @@ -3516,7 +3507,6 @@ nsBaseIBFrame::DeleteChildsNextInFlow(nsIPresContext& aPresContext, aChild->GetNextInFlow(nextInFlow); NS_POSTCONDITION(nsnull == nextInFlow, "non null next-in-flow"); #endif - return PR_TRUE; } PRBool @@ -4142,7 +4132,7 @@ nsBlockFrame::DeleteFrame(nsIPresContext& aPresContext) mBullet = nsnull; } - DeleteFrameList(aPresContext, &mFloaters); + mFloaters.DeleteFrames(aPresContext); return nsBlockFrameSuper::DeleteFrame(aPresContext); } @@ -4380,12 +4370,12 @@ nsBlockFrame::List(FILE* out, PRInt32 aIndent, nsIListFilter *aFilter) const } // Output floaters next - if (nsnull != mFloaters) { + if (mFloaters.NotEmpty()) { if (outputMe) { for (i = aIndent; --i >= 0; ) fputs(" ", out); fprintf(out, "all-floaters <\n"); } - nsIFrame* floater = mFloaters; + nsIFrame* floater = mFloaters.FirstChild(); while (nsnull != floater) { floater->List(out, aIndent+1, aFilter); floater->GetNextSibling(floater); @@ -4447,7 +4437,7 @@ nsBlockFrame::FirstChild(nsIAtom* aListName, nsIFrame*& aFirstChild) const return NS_OK; } else if (aListName == nsLayoutAtoms::floaterList) { - aFirstChild = mFloaters; + aFirstChild = mFloaters.FirstChild(); return NS_OK; } else if (aListName == nsLayoutAtoms::bulletList) { @@ -4678,7 +4668,7 @@ nsBlockFrame::BuildFloaterList() if (nsnull != current) { current->SetNextSibling(nsnull); } - mFloaters = head; + mFloaters.SetFrames(head); } // XXX keep the text-run data in the first-in-flow of the block @@ -4946,7 +4936,7 @@ nsBlockFrame::GetFrameForPoint(const nsPoint& aPoint, nsIFrame** aFrame) return NS_OK; } } - if (nsnull != mFloaters) { + if (mFloaters.NotEmpty()) { rv = GetFrameForPointUsing(aPoint, nsLayoutAtoms::floaterList, aFrame); if (NS_OK == rv) { return NS_OK; diff --git a/mozilla/layout/generic/nsBlockFrame.h b/mozilla/layout/generic/nsBlockFrame.h index c11b5d4a5f1..997bb813ca3 100644 --- a/mozilla/layout/generic/nsBlockFrame.h +++ b/mozilla/layout/generic/nsBlockFrame.h @@ -93,8 +93,8 @@ public: #endif - virtual PRBool DeleteChildsNextInFlow(nsIPresContext& aPresContext, - nsIFrame* aNextInFlow); + virtual void DeleteChildsNextInFlow(nsIPresContext& aPresContext, + nsIFrame* aNextInFlow); protected: nsBaseIBFrame(); @@ -380,7 +380,7 @@ protected: nsTextRun* mTextRuns; // List of all floaters in this block - nsIFrame* mFloaters; + nsFrameList mFloaters; // XXX_fix_me: subclass one more time! // For list-item frames, this is the bullet frame. diff --git a/mozilla/layout/generic/nsBlockReflowState.cpp b/mozilla/layout/generic/nsBlockReflowState.cpp index 3328e0cfd94..93034aef62e 100644 --- a/mozilla/layout/generic/nsBlockReflowState.cpp +++ b/mozilla/layout/generic/nsBlockReflowState.cpp @@ -3449,7 +3449,7 @@ nsBaseIBFrame::MarkEmptyLines(nsIPresContext& aPresContext) } } -PRBool +void nsBaseIBFrame::DeleteChildsNextInFlow(nsIPresContext& aPresContext, nsIFrame* aChild) { @@ -3470,15 +3470,6 @@ nsBaseIBFrame::DeleteChildsNextInFlow(nsIPresContext& aPresContext, parent->DeleteChildsNextInFlow(aPresContext, nextInFlow); } -#ifdef NS_DEBUG - PRInt32 childCount; - nsIFrame* firstChild; - nextInFlow->FirstChild(nsnull, firstChild); - childCount = LengthOf(firstChild); - NS_ASSERTION((0 == childCount) && (nsnull == firstChild), - "deleting !empty next-in-flow"); -#endif - // Disconnect the next-in-flow from the flow list nextInFlow->BreakFromPrevFlow(); @@ -3516,7 +3507,6 @@ nsBaseIBFrame::DeleteChildsNextInFlow(nsIPresContext& aPresContext, aChild->GetNextInFlow(nextInFlow); NS_POSTCONDITION(nsnull == nextInFlow, "non null next-in-flow"); #endif - return PR_TRUE; } PRBool @@ -4142,7 +4132,7 @@ nsBlockFrame::DeleteFrame(nsIPresContext& aPresContext) mBullet = nsnull; } - DeleteFrameList(aPresContext, &mFloaters); + mFloaters.DeleteFrames(aPresContext); return nsBlockFrameSuper::DeleteFrame(aPresContext); } @@ -4380,12 +4370,12 @@ nsBlockFrame::List(FILE* out, PRInt32 aIndent, nsIListFilter *aFilter) const } // Output floaters next - if (nsnull != mFloaters) { + if (mFloaters.NotEmpty()) { if (outputMe) { for (i = aIndent; --i >= 0; ) fputs(" ", out); fprintf(out, "all-floaters <\n"); } - nsIFrame* floater = mFloaters; + nsIFrame* floater = mFloaters.FirstChild(); while (nsnull != floater) { floater->List(out, aIndent+1, aFilter); floater->GetNextSibling(floater); @@ -4447,7 +4437,7 @@ nsBlockFrame::FirstChild(nsIAtom* aListName, nsIFrame*& aFirstChild) const return NS_OK; } else if (aListName == nsLayoutAtoms::floaterList) { - aFirstChild = mFloaters; + aFirstChild = mFloaters.FirstChild(); return NS_OK; } else if (aListName == nsLayoutAtoms::bulletList) { @@ -4678,7 +4668,7 @@ nsBlockFrame::BuildFloaterList() if (nsnull != current) { current->SetNextSibling(nsnull); } - mFloaters = head; + mFloaters.SetFrames(head); } // XXX keep the text-run data in the first-in-flow of the block @@ -4946,7 +4936,7 @@ nsBlockFrame::GetFrameForPoint(const nsPoint& aPoint, nsIFrame** aFrame) return NS_OK; } } - if (nsnull != mFloaters) { + if (mFloaters.NotEmpty()) { rv = GetFrameForPointUsing(aPoint, nsLayoutAtoms::floaterList, aFrame); if (NS_OK == rv) { return NS_OK; diff --git a/mozilla/layout/generic/nsBlockReflowState.h b/mozilla/layout/generic/nsBlockReflowState.h index 3328e0cfd94..93034aef62e 100644 --- a/mozilla/layout/generic/nsBlockReflowState.h +++ b/mozilla/layout/generic/nsBlockReflowState.h @@ -3449,7 +3449,7 @@ nsBaseIBFrame::MarkEmptyLines(nsIPresContext& aPresContext) } } -PRBool +void nsBaseIBFrame::DeleteChildsNextInFlow(nsIPresContext& aPresContext, nsIFrame* aChild) { @@ -3470,15 +3470,6 @@ nsBaseIBFrame::DeleteChildsNextInFlow(nsIPresContext& aPresContext, parent->DeleteChildsNextInFlow(aPresContext, nextInFlow); } -#ifdef NS_DEBUG - PRInt32 childCount; - nsIFrame* firstChild; - nextInFlow->FirstChild(nsnull, firstChild); - childCount = LengthOf(firstChild); - NS_ASSERTION((0 == childCount) && (nsnull == firstChild), - "deleting !empty next-in-flow"); -#endif - // Disconnect the next-in-flow from the flow list nextInFlow->BreakFromPrevFlow(); @@ -3516,7 +3507,6 @@ nsBaseIBFrame::DeleteChildsNextInFlow(nsIPresContext& aPresContext, aChild->GetNextInFlow(nextInFlow); NS_POSTCONDITION(nsnull == nextInFlow, "non null next-in-flow"); #endif - return PR_TRUE; } PRBool @@ -4142,7 +4132,7 @@ nsBlockFrame::DeleteFrame(nsIPresContext& aPresContext) mBullet = nsnull; } - DeleteFrameList(aPresContext, &mFloaters); + mFloaters.DeleteFrames(aPresContext); return nsBlockFrameSuper::DeleteFrame(aPresContext); } @@ -4380,12 +4370,12 @@ nsBlockFrame::List(FILE* out, PRInt32 aIndent, nsIListFilter *aFilter) const } // Output floaters next - if (nsnull != mFloaters) { + if (mFloaters.NotEmpty()) { if (outputMe) { for (i = aIndent; --i >= 0; ) fputs(" ", out); fprintf(out, "all-floaters <\n"); } - nsIFrame* floater = mFloaters; + nsIFrame* floater = mFloaters.FirstChild(); while (nsnull != floater) { floater->List(out, aIndent+1, aFilter); floater->GetNextSibling(floater); @@ -4447,7 +4437,7 @@ nsBlockFrame::FirstChild(nsIAtom* aListName, nsIFrame*& aFirstChild) const return NS_OK; } else if (aListName == nsLayoutAtoms::floaterList) { - aFirstChild = mFloaters; + aFirstChild = mFloaters.FirstChild(); return NS_OK; } else if (aListName == nsLayoutAtoms::bulletList) { @@ -4678,7 +4668,7 @@ nsBlockFrame::BuildFloaterList() if (nsnull != current) { current->SetNextSibling(nsnull); } - mFloaters = head; + mFloaters.SetFrames(head); } // XXX keep the text-run data in the first-in-flow of the block @@ -4946,7 +4936,7 @@ nsBlockFrame::GetFrameForPoint(const nsPoint& aPoint, nsIFrame** aFrame) return NS_OK; } } - if (nsnull != mFloaters) { + if (mFloaters.NotEmpty()) { rv = GetFrameForPointUsing(aPoint, nsLayoutAtoms::floaterList, aFrame); if (NS_OK == rv) { return NS_OK; diff --git a/mozilla/layout/generic/nsContainerFrame.cpp b/mozilla/layout/generic/nsContainerFrame.cpp index 46eea193ec6..b9ab9daa6cc 100644 --- a/mozilla/layout/generic/nsContainerFrame.cpp +++ b/mozilla/layout/generic/nsContainerFrame.cpp @@ -28,6 +28,7 @@ #include "nsIView.h" #include "nsVoidArray.h" #include "nsISizeOfHandler.h" +#include "nsIReflowCommand.h" #include "nsHTMLIIDs.h" #ifdef NS_DEBUG @@ -36,12 +37,12 @@ #undef NOISY #endif -NS_IMETHODIMP -nsContainerFrame::SizeOf(nsISizeOfHandler* aHandler) const +nsContainerFrame::nsContainerFrame() +{ +} + +nsContainerFrame::~nsContainerFrame() { - aHandler->Add(sizeof(*this)); - nsContainerFrame::SizeOfWithoutThis(aHandler); - return NS_OK; } NS_IMETHODIMP @@ -49,18 +50,17 @@ nsContainerFrame::SetInitialChildList(nsIPresContext& aPresContext, nsIAtom* aListName, nsIFrame* aChildList) { - NS_PRECONDITION(nsnull == mFirstChild, "already initialized"); - nsresult result; + NS_PRECONDITION(mFrames.IsEmpty(), "already initialized"); - if (nsnull != mFirstChild) { + nsresult result; + if (nsnull != mFrames.FirstChild()) { result = NS_ERROR_UNEXPECTED; } else if (nsnull != aListName) { result = NS_ERROR_INVALID_ARG; } else { - mFirstChild = aChildList; + mFrames.SetFrames(aChildList); result = NS_OK; } - return result; } @@ -68,50 +68,19 @@ NS_IMETHODIMP nsContainerFrame::DeleteFrame(nsIPresContext& aPresContext) { // Prevent event dispatch during destruction - nsIView* view; + nsIView* view; GetView(view); if (nsnull != view) { view->SetClientData(nsnull); } // Delete the primary child list - DeleteFrameList(aPresContext, &mFirstChild); + mFrames.DeleteFrames(aPresContext); // Base class will delete the frame return nsFrame::DeleteFrame(aPresContext); } -/** - * Helper method to delete a frame list and keep the list sane during - * the deletion. - */ -void -nsContainerFrame::DeleteFrameList(nsIPresContext& aPresContext, - nsIFrame** aListP) -{ - nsIFrame* first; - while (nsnull != (first = *aListP)) { - nsIFrame* nextChild; - - first->GetNextSibling(nextChild); - first->DeleteFrame(aPresContext); - - // Once we've deleted the child frame make sure it's no longer in - // the child list - *aListP = nextChild; - } -} - -void -nsContainerFrame::SizeOfWithoutThis(nsISizeOfHandler* aHandler) const -{ - nsSplittableFrame::SizeOfWithoutThis(aHandler); - for (nsIFrame* child = mFirstChild; child; ) { - child->SizeOf(aHandler); - child->GetNextSibling(child); - } -} - NS_IMETHODIMP nsContainerFrame::DidReflow(nsIPresContext& aPresContext, nsDidReflowStatus aStatus) @@ -155,9 +124,8 @@ nsContainerFrame::FirstChild(nsIAtom* aListName, nsIFrame*& aFirstChild) const { // We only know about the unnamed principal child list if (nsnull == aListName) { - aFirstChild = mFirstChild; + aFirstChild = mFrames.FirstChild(); return NS_OK; - } else { aFirstChild = nsnull; return NS_ERROR_INVALID_ARG; @@ -183,7 +151,7 @@ nsContainerFrame::ReResolveStyleContext(nsIPresContext* aPresContext, } // Update overflow list too - child = mOverflowList; + child = mOverflowFrames.FirstChild(); while ((NS_SUCCEEDED(result)) && (nsnull != child)) { result = child->ReResolveStyleContext(aPresContext, mStyleContext); child->GetNextSibling(child); @@ -192,7 +160,7 @@ nsContainerFrame::ReResolveStyleContext(nsIPresContext* aPresContext, // And just to be complete, update our prev-in-flows overflow list // too (since in theory, those frames will become our frames) if (nsnull != mPrevInFlow) { - child = ((nsContainerFrame*)mPrevInFlow)->mOverflowList; + child = ((nsContainerFrame*)mPrevInFlow)->mOverflowFrames.FirstChild(); while ((NS_SUCCEEDED(result)) && (nsnull != child)) { result = child->ReResolveStyleContext(aPresContext, mStyleContext); child->GetNextSibling(child); @@ -203,7 +171,7 @@ nsContainerFrame::ReResolveStyleContext(nsIPresContext* aPresContext, } ///////////////////////////////////////////////////////////////////////////// -// Painting +// Painting/Events NS_IMETHODIMP nsContainerFrame::Paint(nsIPresContext& aPresContext, @@ -242,7 +210,7 @@ nsContainerFrame::PaintChildren(nsIPresContext& aPresContext, nsClipCombine_kIntersect, clipState); } - nsIFrame* kid = mFirstChild; + nsIFrame* kid = mFrames.FirstChild(); while (nsnull != kid) { PaintChild(aPresContext, aRenderingContext, aDirtyRect, kid, aWhichLayer); kid->GetNextSibling(kid); @@ -380,11 +348,11 @@ nsContainerFrame::ReflowChild(nsIFrame* aKidFrame, nsReflowStatus& aStatus) { NS_PRECONDITION(aReflowState.frame == aKidFrame, "bad reflow state"); + NS_PRECONDITION(IsChild(aKidFrame), "not my child"); // Query for the nsIHTMLReflow interface nsIHTMLReflow* htmlReflow; nsresult result; - result = aKidFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow); if (NS_FAILED(result)) { return result; @@ -392,13 +360,13 @@ nsContainerFrame::ReflowChild(nsIFrame* aKidFrame, // Send the WillReflow notification, and reflow the child frame htmlReflow->WillReflow(aPresContext); - result = htmlReflow->Reflow(aPresContext, aDesiredSize, aReflowState, aStatus); + result = htmlReflow->Reflow(aPresContext, aDesiredSize, aReflowState, + aStatus); // If the reflow was successful and the child frame is complete, delete any // next-in-flows if (NS_SUCCEEDED(result) && NS_FRAME_IS_COMPLETE(aStatus)) { nsIFrame* kidNextInFlow; - aKidFrame->GetNextInFlow(kidNextInFlow); if (nsnull != kidNextInFlow) { // Remove all of the childs next-in-flows. Make sure that we ask @@ -406,10 +374,10 @@ nsContainerFrame::ReflowChild(nsIFrame* aKidFrame, // parent is not this because we are executing pullup code) nsIFrame* parent; aKidFrame->GetParent(parent); - ((nsContainerFrame*)parent)->DeleteChildsNextInFlow(aPresContext, aKidFrame); + ((nsContainerFrame*)parent)->DeleteChildsNextInFlow(aPresContext, + aKidFrame); } } - return result; } @@ -423,8 +391,9 @@ nsContainerFrame::ReflowChild(nsIFrame* aKidFrame, * @param aChild child this child's next-in-flow * @return PR_TRUE if successful and PR_FALSE otherwise */ -PRBool -nsContainerFrame::DeleteChildsNextInFlow(nsIPresContext& aPresContext, nsIFrame* aChild) +void +nsContainerFrame::DeleteChildsNextInFlow(nsIPresContext& aPresContext, + nsIFrame* aChild) { NS_PRECONDITION(IsChild(aChild), "bad geometric parent"); @@ -444,36 +413,14 @@ nsContainerFrame::DeleteChildsNextInFlow(nsIPresContext& aPresContext, nsIFrame* parent->DeleteChildsNextInFlow(aPresContext, nextInFlow); } -#ifdef NS_DEBUG - PRInt32 childCount; - nsIFrame* firstChild; - - nextInFlow->FirstChild(nsnull, firstChild); - childCount = LengthOf(firstChild); - - if ((0 != childCount) || (nsnull != firstChild)) { - nsIFrame* top = nextInFlow; - for (;;) { - nsIFrame* parent; - top->GetParent(parent); - if (nsnull == parent) { - break; - } - top = parent; - } - top->List(stdout, 0, nsnull); - } - NS_ASSERTION((0 == childCount) && (nsnull == firstChild), - "deleting !empty next-in-flow"); -#endif - // Disconnect the next-in-flow from the flow list nextInFlow->BreakFromPrevFlow(); // Take the next-in-flow out of the parent's child list - if (parent->mFirstChild == nextInFlow) { - nextInFlow->GetNextSibling(parent->mFirstChild); - + if (parent->mFrames.FirstChild() == nextInFlow) { + nsIFrame* nextFrame; + nextInFlow->GetNextSibling(nextFrame); + parent->mFrames.SetFrames(nextFrame); } else { nsIFrame* nextSibling; @@ -491,18 +438,12 @@ nsContainerFrame::DeleteChildsNextInFlow(nsIPresContext& aPresContext, nsIFrame* } // Delete the next-in-flow frame - WillDeleteNextInFlowFrame(nextInFlow); nextInFlow->DeleteFrame(aPresContext); #ifdef NS_DEBUG aChild->GetNextInFlow(nextInFlow); NS_POSTCONDITION(nsnull == nextInFlow, "non null next-in-flow"); #endif - return PR_TRUE; -} - -void nsContainerFrame::WillDeleteNextInFlowFrame(nsIFrame* aNextInFlow) -{ } /** @@ -519,13 +460,13 @@ void nsContainerFrame::WillDeleteNextInFlowFrame(nsIFrame* aNextInFlow) * @param aPrevSibling aFromChild's previous sibling. Must not be null. It's * an error to push a parent's first child frame */ -void nsContainerFrame::PushChildren(nsIFrame* aFromChild, nsIFrame* aPrevSibling) +void +nsContainerFrame::PushChildren(nsIFrame* aFromChild, nsIFrame* aPrevSibling) { NS_PRECONDITION(nsnull != aFromChild, "null pointer"); NS_PRECONDITION(nsnull != aPrevSibling, "pushing first child"); #ifdef NS_DEBUG nsIFrame* prevNextSibling; - aPrevSibling->GetNextSibling(prevNextSibling); NS_PRECONDITION(prevNextSibling == aFromChild, "bad prev sibling"); #endif @@ -533,38 +474,14 @@ void nsContainerFrame::PushChildren(nsIFrame* aFromChild, nsIFrame* aPrevSibling // Disconnect aFromChild from its previous sibling aPrevSibling->SetNextSibling(nsnull); - // Do we have a next-in-flow? - nsContainerFrame* nextInFlow = (nsContainerFrame*)mNextInFlow; - if (nsnull != nextInFlow) { - PRInt32 numChildren = 0; - nsIFrame* lastChild = nsnull; - - // Compute the number of children being pushed, and for each child change - // its geometric parent. Remember the last child - for (nsIFrame* f = aFromChild; nsnull != f; f->GetNextSibling(f)) { - numChildren++; -#ifdef NOISY - printf(" "); - ((nsFrame*)f)->ListTag(stdout); - printf("\n"); -#endif - lastChild = f; - f->SetParent(nextInFlow); - } - NS_ASSERTION(numChildren > 0, "no children to push"); - - // Prepend the frames to our next-in-flow's child list - lastChild->SetNextSibling(nextInFlow->mFirstChild); - nextInFlow->mFirstChild = aFromChild; - - } else { + if (nsnull != mNextInFlow) { + nsContainerFrame* nextInFlow = (nsContainerFrame*)mNextInFlow; + nextInFlow->mFrames.InsertFrames(mNextInFlow, nsnull, aFromChild); + } + else { // Add the frames to our overflow list - NS_ASSERTION(nsnull == mOverflowList, "bad overflow list"); -#ifdef NOISY - ListTag(stdout); - printf(": pushing kids to my overflow list\n"); -#endif - mOverflowList = aFromChild; + NS_ASSERTION(mOverflowFrames.IsEmpty(), "bad overflow list"); + mOverflowFrames.SetFrames(aFromChild); } } @@ -576,63 +493,66 @@ void nsContainerFrame::PushChildren(nsIFrame* aFromChild, nsIFrame* aPrevSibling * * @return PR_TRUE if any frames were moved and PR_FALSE otherwise */ -PRBool nsContainerFrame::MoveOverflowToChildList() +PRBool +nsContainerFrame::MoveOverflowToChildList() { - PRBool result = PR_FALSE; + PRBool result = PR_FALSE; // Check for an overflow list with our prev-in-flow nsContainerFrame* prevInFlow = (nsContainerFrame*)mPrevInFlow; if (nsnull != prevInFlow) { - if (nsnull != prevInFlow->mOverflowList) { - NS_ASSERTION(nsnull == mFirstChild, "bad overflow list"); - AppendChildren(prevInFlow->mOverflowList); - prevInFlow->mOverflowList = nsnull; + if (prevInFlow->mOverflowFrames.NotEmpty()) { + NS_ASSERTION(mFrames.IsEmpty(), "bad overflow list"); + mFrames.Join(this, prevInFlow->mOverflowFrames); result = PR_TRUE; } } // It's also possible that we have an overflow list for ourselves - if (nsnull != mOverflowList) { - NS_ASSERTION(nsnull != mFirstChild, "overflow list but no mapped children"); - AppendChildren(mOverflowList, PR_FALSE); - mOverflowList = nsnull; + if (mOverflowFrames.NotEmpty()) { + NS_ASSERTION(mFrames.NotEmpty(), "overflow list w/o frames"); + mFrames.Join(nsnull, mOverflowFrames); result = PR_TRUE; } - return result; } -/** - * Append child list starting at aChild to this frame's child list. Used for - * processing of the overflow list. - * - * Updates this frame's child count and content mapping. - * - * @param aChild the beginning of the child list - * @param aSetParent if true each child's geometric (and content parent if - * they're the same) parent is set to this frame. - */ -void nsContainerFrame::AppendChildren(nsIFrame* aChild, PRBool aSetParent) +nsresult +nsContainerFrame::AddFrame(const nsHTMLReflowState& aReflowState, + nsIFrame * aAddedFrame) { - // Link the frames into our child frame list - if (nsnull == mFirstChild) { - // We have no children so aChild becomes the first child - mFirstChild = aChild; - } else { - nsIFrame* lastChild = LastFrame(mFirstChild); - lastChild->SetNextSibling(aChild); + nsresult rv=NS_OK; + nsIReflowCommand::ReflowType type; + aReflowState.reflowCommand->GetType(type); + + // we have a generic frame that gets inserted but doesn't effect + // reflow hook it up then ignore it + if (nsIReflowCommand::FrameAppended == type) { + // Append aAddedFrame to the list of frames + mFrames.AppendFrame(nsnull, aAddedFrame); } - - // Update our child count and last content offset - nsIFrame* lastChild; - for (nsIFrame* f = aChild; nsnull != f; f->GetNextSibling(f)) { - lastChild = f; - - // Reset the geometric parent if requested - if (aSetParent) { - f->SetParent(this); + else if (nsIReflowCommand::FrameInserted == type) { + // Insert aAddedFrame into the list of frames + nsIFrame *prevSibling=nsnull; + rv = aReflowState.reflowCommand->GetPrevSiblingFrame(prevSibling); + if (NS_SUCCEEDED(rv)) { + mFrames.InsertFrame(nsnull, prevSibling, aAddedFrame); } } + else + { + NS_ASSERTION(PR_FALSE, "bad reflow type"); + rv = NS_ERROR_UNEXPECTED; + } + return rv; +} + +nsresult +nsContainerFrame::RemoveFrame(nsIFrame* aRemovedFrame) +{ + PRBool zap = mFrames.RemoveFrame(aRemovedFrame); + NS_ASSERTION(zap, "failure to remove a frame"); + return NS_OK; } ///////////////////////////////////////////////////////////////////////////// @@ -680,14 +600,15 @@ nsContainerFrame::List(FILE* out, PRInt32 aIndent, } // Output the children - if (nsnull != mFirstChild) { + if (mFrames.NotEmpty()) { if (outputMe) { if (0 != mState) { fprintf(out, " [state=%08x]", mState); } fputs("<\n", out); } - for (nsIFrame* child = mFirstChild; child; child->GetNextSibling(child)) { + for (nsIFrame* child = mFrames.FirstChild(); child; + child->GetNextSibling(child)) { child->List(out, aIndent + 1, aFilter); } if (outputMe) { @@ -705,63 +626,3 @@ nsContainerFrame::List(FILE* out, PRInt32 aIndent, return NS_OK; } - -NS_IMETHODIMP -nsContainerFrame::VerifyTree() const -{ -#ifdef NS_DEBUG - NS_ASSERTION(0 == (mState & NS_FRAME_IN_REFLOW), "frame is in reflow"); - NS_ASSERTION(nsnull == mOverflowList, "bad overflow list"); -#endif - return NS_OK; -} - -PRInt32 nsContainerFrame::LengthOf(nsIFrame* aFrame) -{ - PRInt32 result = 0; - - while (nsnull != aFrame) { - result++; - aFrame->GetNextSibling(aFrame); - } - - return result; -} - -nsIFrame* nsContainerFrame::LastFrame(nsIFrame* aFrame) -{ - nsIFrame* lastChild = nsnull; - - while (nsnull != aFrame) { - lastChild = aFrame; - aFrame->GetNextSibling(aFrame); - } - - return lastChild; -} - -nsIFrame* nsContainerFrame::FrameAt(nsIFrame* aFrame, PRInt32 aIndex) -{ - while ((aIndex-- > 0) && (aFrame != nsnull)) { - aFrame->GetNextSibling(aFrame); - } - return aFrame; -} - -///////////////////////////////////////////////////////////////////////////// - -#ifdef NS_DEBUG - -PRBool nsContainerFrame::IsChild(const nsIFrame* aChild) const -{ - // Check the geometric parent - nsIFrame* parent; - - aChild->GetParent(parent); - if (parent != (nsIFrame*)this) { - return PR_FALSE; - } - - return PR_TRUE; -} -#endif diff --git a/mozilla/layout/generic/nsContainerFrame.h b/mozilla/layout/generic/nsContainerFrame.h index 944b5012a3e..78d9f6c992f 100644 --- a/mozilla/layout/generic/nsContainerFrame.h +++ b/mozilla/layout/generic/nsContainerFrame.h @@ -19,6 +19,7 @@ #define nsContainerFrame_h___ #include "nsSplittableFrame.h" +#include "nsFrameList.h" /** * Implementation of a container frame. @@ -26,68 +27,45 @@ class nsContainerFrame : public nsSplittableFrame { public: - NS_IMETHOD SizeOf(nsISizeOfHandler* aHandler) const; - + // nsIFrame overrides NS_IMETHOD SetInitialChildList(nsIPresContext& aPresContext, nsIAtom* aListName, nsIFrame* aChildList); - + NS_IMETHOD FirstChild(nsIAtom* aListName, nsIFrame*& aFirstChild) const; NS_IMETHOD DeleteFrame(nsIPresContext& aPresContext); - - NS_IMETHOD DidReflow(nsIPresContext& aPresContext, - nsDidReflowStatus aStatus); - - // Painting NS_IMETHOD Paint(nsIPresContext& aPresContext, nsIRenderingContext& aRenderingContext, const nsRect& aDirtyRect, nsFramePaintLayer aWhichLayer); - - /** - * Find the correct child frame. - */ NS_IMETHOD GetFrameForPoint(const nsPoint& aPoint, nsIFrame** aFrame); + NS_IMETHOD ReResolveStyleContext(nsIPresContext* aPresContext, + nsIStyleContext* aParentContext); + NS_IMETHOD List(FILE* out, PRInt32 aIndent, nsIListFilter *aFilter) const; - // Child frame enumeration. - NS_IMETHOD FirstChild(nsIAtom* aListName, nsIFrame*& aFirstChild) const; + // nsIHTMLReflow overrides + NS_IMETHOD DidReflow(nsIPresContext& aPresContext, + nsDidReflowStatus aStatus); - // re-resolve style context for self and children as necessary - // Subclasses need to override if they add child lists or - // if they alter normal style context inheritance - NS_IMETHOD ReResolveStyleContext(nsIPresContext* aPresContext, - nsIStyleContext* aParentContext); + // nsContainerFrame methods + virtual void DeleteChildsNextInFlow(nsIPresContext& aPresContext, + nsIFrame* aChild); - // Debugging - NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0, nsIListFilter *aFilter = nsnull) const; - NS_IMETHOD VerifyTree() const; + static PRInt32 LengthOf(nsIFrame* aFrameList) { + nsFrameList tmp(aFrameList); + return tmp.GetLength(); + } - /** - * Return the number of children in the sibling list, starting at aChild. - * Returns zero if aChild is nsnull. - */ - static PRInt32 LengthOf(nsIFrame* aChild); - - /** - * Return the last frame in the sibling list. - * Returns nsnullif aChild is nsnull. - */ - static nsIFrame* LastFrame(nsIFrame* aChild); - - /** - * Returns the frame at the specified index relative to aFrame - */ - static nsIFrame* FrameAt(nsIFrame* aFrame, PRInt32 aIndex); - - // XXX needs to be virtual so that nsBlockFrame can override it - virtual PRBool DeleteChildsNextInFlow(nsIPresContext& aPresContext, - nsIFrame* aChild); +#if XXX + static nsIFrame* FrameAt(nsIFrame* aFrameList, PRInt32 aIndex) { + nsFrameList tmp(aFrameList); + return tmp.FrameAt(aIndex); + } +#endif protected: - void DeleteFrameList(nsIPresContext& aPresContext, - nsIFrame** aListP); - - void SizeOfWithoutThis(nsISizeOfHandler* aHandler) const; + nsContainerFrame(); + ~nsContainerFrame(); nsresult GetFrameForPointUsing(const nsPoint& aPoint, nsIAtom* aList, @@ -116,56 +94,61 @@ protected: const nsHTMLReflowState& aReflowState, nsReflowStatus& aStatus); - /** - * Moves any frames on both the prev-in-flow's overflow list and the receiver's - * overflow to the receiver's child list. - * - * Resets the overlist pointers to nsnull, and updates the receiver's child - * count and content mapping. - * - * @return PR_TRUE if any frames were moved and PR_FALSE otherwise - */ + /** + * Moves any frames on both the prev-in-flow's overflow list and the + * receiver's overflow to the receiver's child list. + * + * Resets the overlist pointers to nsnull, and updates the receiver's child + * count and content mapping. + * + * @return PR_TRUE if any frames were moved and PR_FALSE otherwise + */ PRBool MoveOverflowToChildList(); - /** - * Push aFromChild and its next siblings to the next-in-flow. Change the - * geometric parent of each frame that's pushed. If there is no next-in-flow - * the frames are placed on the overflow list (and the geometric parent is - * left unchanged). - * - * Updates the next-in-flow's child count. Does not update the - * pusher's child count. - * - * @param aFromChild the first child frame to push. It is disconnected from - * aPrevSibling - * @param aPrevSibling aFromChild's previous sibling. Must not be null. It's - * an error to push a parent's first child frame - */ + /** + * Push aFromChild and its next siblings to the next-in-flow. Change + * the geometric parent of each frame that's pushed. If there is no + * next-in-flow the frames are placed on the overflow list (and the + * geometric parent is left unchanged). + * + * Updates the next-in-flow's child count. Does not update the + * pusher's child count. + * + * @param aFromChild the first child frame to push. It is disconnected from + * aPrevSibling + * @param aPrevSibling aFromChild's previous sibling. Must not be null. + * It's an error to push a parent's first child frame + */ void PushChildren(nsIFrame* aFromChild, nsIFrame* aPrevSibling); /** - * Append child list starting at aChild to this frame's child list. Used for - * processing of the overflow list. - * - * Updates this frame's child count and content mapping. + * Append child list starting at aChild to this frame's child list. * * @param aChild the beginning of the child list - * @param aSetParent if true each child's geometric (and content parent if - * they're the same) parent is set to this frame. + * @param aSetParent if true each child's parent is set to this frame. */ - void AppendChildren(nsIFrame* aChild, PRBool aSetParent = PR_TRUE); + void AppendChildren(nsIFrame* aChild, PRBool aSetParent) { + mFrames.AppendFrames(aSetParent ? this : nsnull, aChild); + } - virtual void WillDeleteNextInFlowFrame(nsIFrame* aNextInFlow); + /** + */ + nsresult AddFrame(const nsHTMLReflowState& aReflowState, + nsIFrame * aAddedFrame); + + /** + */ + nsresult RemoveFrame(nsIFrame * aRemovedFrame); -#ifdef NS_DEBUG /** * Returns PR_TRUE if aChild is a child of this frame. */ - PRBool IsChild(const nsIFrame* aChild) const; -#endif + PRBool IsChild(const nsIFrame* aChild) const { + return mFrames.ContainsFrame(aChild); + } - nsIFrame* mFirstChild; - nsIFrame* mOverflowList; + nsFrameList mFrames; + nsFrameList mOverflowFrames; }; #endif /* nsContainerFrame_h___ */ diff --git a/mozilla/layout/generic/nsFrameFrame.cpp b/mozilla/layout/generic/nsFrameFrame.cpp index 9031b477968..fb74b673251 100644 --- a/mozilla/layout/generic/nsFrameFrame.cpp +++ b/mozilla/layout/generic/nsFrameFrame.cpp @@ -211,8 +211,9 @@ nscoord nsHTMLFrameOuterFrame::GetBorderWidth(nsIPresContext& aPresContext) { if (IsInline()) { - if (nsnull != mFirstChild) { - if (eFrameborder_No != ((nsHTMLFrameInnerFrame*)mFirstChild)->GetFrameBorder(eCompatibility_Standard)) { + nsIFrame* firstChild = mFrames.FirstChild(); + if (nsnull != FirstChild) { + if (eFrameborder_No != ((nsHTMLFrameInnerFrame*)firstChild)->GetFrameBorder(eCompatibility_Standard)) { const nsStyleSpacing* spacing = (const nsStyleSpacing*)mStyleContext->GetStyleData(eStyleStruct_Spacing); nsStyleCoord leftBorder; @@ -281,9 +282,10 @@ nsHTMLFrameOuterFrame::Paint(nsIPresContext& aPresContext, nsFramePaintLayer aWhichLayer) { //printf("outer paint %X (%d,%d,%d,%d) \n", this, aDirtyRect.x, aDirtyRect.y, aDirtyRect.width, aDirtyRect.height); - if (nsnull != mFirstChild) { - mFirstChild->Paint(aPresContext, aRenderingContext, aDirtyRect, - aWhichLayer); + nsIFrame* firstChild = mFrames.FirstChild(); + if (nsnull != firstChild) { + firstChild->Paint(aPresContext, aRenderingContext, aDirtyRect, + aWhichLayer); } if (IsInline()) { return nsHTMLContainerFrame::Paint(aPresContext, aRenderingContext, @@ -316,10 +318,12 @@ nsHTMLFrameOuterFrame::Reflow(nsIPresContext& aPresContext, aDesiredSize.height = aReflowState.availableHeight; } - if (nsnull == mFirstChild) { - mFirstChild = new nsHTMLFrameInnerFrame; + nsIFrame* firstChild = mFrames.FirstChild(); + if (nsnull == firstChild) { + firstChild = new nsHTMLFrameInnerFrame; + mFrames.SetFrames(firstChild); // XXX temporary! use style system to get correct style! - mFirstChild->Init(aPresContext, mContent, this, mStyleContext); + firstChild->Init(aPresContext, mContent, this, mStyleContext); } // nsContainerFrame::PaintBorder has some problems, kludge it here @@ -329,17 +333,17 @@ nsHTMLFrameOuterFrame::Reflow(nsIPresContext& aPresContext, // Reflow the child and get its desired size nsHTMLReflowMetrics kidMetrics(aDesiredSize.maxElementSize); - nsHTMLReflowState kidReflowState(aPresContext, mFirstChild, aReflowState, + nsHTMLReflowState kidReflowState(aPresContext, firstChild, aReflowState, innerSize); nsIHTMLReflow* htmlReflow; - if (NS_OK == mFirstChild->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { - ReflowChild(mFirstChild, aPresContext, kidMetrics, kidReflowState, aStatus); + if (NS_OK == firstChild->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { + ReflowChild(firstChild, aPresContext, kidMetrics, kidReflowState, aStatus); NS_ASSERTION(NS_FRAME_IS_COMPLETE(aStatus), "bad status"); // Place and size the child nsRect rect(borderWidth, borderWidth, innerSize.width, innerSize.height); - mFirstChild->SetRect(rect); + firstChild->SetRect(rect); } // XXX what should the max-element-size of an iframe be? Shouldn't @@ -373,8 +377,9 @@ nsHTMLFrameOuterFrame::AttributeChanged(nsIPresContext* aPresContext, { if (nsHTMLAtoms::src == aAttribute) { printf("got a request\n"); - if (nsnull != mFirstChild) { - ((nsHTMLFrameInnerFrame*)mFirstChild)->ReloadURL(); + nsIFrame* firstChild = mFrames.FirstChild(); + if (nsnull != firstChild) { + ((nsHTMLFrameInnerFrame*)firstChild)->ReloadURL(); } } return NS_OK; diff --git a/mozilla/layout/generic/nsFrameSetFrame.cpp b/mozilla/layout/generic/nsFrameSetFrame.cpp index 2231798136c..43aecdc1221 100644 --- a/mozilla/layout/generic/nsFrameSetFrame.cpp +++ b/mozilla/layout/generic/nsFrameSetFrame.cpp @@ -416,7 +416,8 @@ void nsHTMLFramesetFrame::GetSizeOfChild(nsIFrame* aChild, // Reflow only creates children frames for and content. // this assumption is used here int i = 0; - for (nsIFrame* child = mFirstChild; child; child->GetNextSibling(child)) { + for (nsIFrame* child = mFrames.FirstChild(); child; + child->GetNextSibling(child)) { if (aChild == child) { nsPoint ignore; GetSizeOfChildAt(i, aSize, ignore); @@ -962,7 +963,7 @@ nsHTMLFramesetFrame::Reflow(nsIPresContext& aPresContext, } if (nsnull == lastChild) { - mFirstChild = frame; + mFrames.SetFrames(frame); } else { lastChild->SetNextSibling(frame); } @@ -983,7 +984,7 @@ nsHTMLFramesetFrame::Reflow(nsIPresContext& aPresContext, NS_RELEASE(pseudoStyleContext); if (nsnull == lastChild) { - mFirstChild = blankFrame; + mFrames.SetFrames(blankFrame); } else { lastChild->SetNextSibling(blankFrame); } @@ -1003,7 +1004,7 @@ nsHTMLFramesetFrame::Reflow(nsIPresContext& aPresContext, nsHTMLFramesetBorderFrame* borderFrame = nsnull; nsPoint offset(0,0); nsSize size, lastSize; - nsIFrame* child = mFirstChild; + nsIFrame* child = mFrames.FirstChild(); for (PRInt32 childX = 0; childX < mNonBorderChildCount; childX++) { nsPoint cellIndex; @@ -1028,7 +1029,7 @@ nsHTMLFramesetFrame::Reflow(nsIPresContext& aPresContext, borderFrame->mPrevNeighbor = lastRow; borderFrame->mNextNeighbor = cellIndex.y; } else { - borderFrame = (nsHTMLFramesetBorderFrame*)FrameAt(mFirstChild, borderChildX); + borderFrame = (nsHTMLFramesetBorderFrame*)mFrames.FrameAt(borderChildX); borderChildX++; } nsSize borderSize(aDesiredSize.width, borderWidth); @@ -1053,7 +1054,7 @@ nsHTMLFramesetFrame::Reflow(nsIPresContext& aPresContext, borderFrame->mPrevNeighbor = lastCol; borderFrame->mNextNeighbor = cellIndex.x; } else { - borderFrame = (nsHTMLFramesetBorderFrame*)FrameAt(mFirstChild, borderChildX); + borderFrame = (nsHTMLFramesetBorderFrame*)mFrames.FrameAt(borderChildX); borderChildX++; } nsSize borderSize(borderWidth, aDesiredSize.height); @@ -1211,7 +1212,7 @@ nsHTMLFramesetFrame::CanResize(PRBool aVertical, PRBool aLeft) if (aVertical) { startX = (aLeft) ? 0 : mNumCols-1; for (childX = startX; childX < mNonBorderChildCount; childX += mNumCols) { - child = FrameAt(mFirstChild, childX); + child = mFrames.FrameAt(childX); if (!CanChildResize(aVertical, aLeft, childX, ChildIsFrameset(child))) { return PR_FALSE; } @@ -1220,7 +1221,7 @@ nsHTMLFramesetFrame::CanResize(PRBool aVertical, PRBool aLeft) startX = (aLeft) ? 0 : (mNumRows - 1) * mNumCols; PRInt32 endX = startX + mNumCols; for (childX = startX; childX < endX; childX++) { - child = FrameAt(mFirstChild, childX); + child = mFrames.FrameAt(childX); if (!CanChildResize(aVertical, aLeft, childX, ChildIsFrameset(child))) { return PR_FALSE; } @@ -1253,7 +1254,7 @@ nsHTMLFramesetFrame::GetNoResize(nsIFrame* aChildFrame) PRBool nsHTMLFramesetFrame::CanChildResize(PRBool aVertical, PRBool aLeft, PRInt32 aChildX, PRBool aFrameset) { - nsIFrame* child = FrameAt(mFirstChild, aChildX); + nsIFrame* child = mFrames.FrameAt(aChildX); if (aFrameset) { return ((nsHTMLFramesetFrame*)child)->CanResize(aVertical, aLeft); } else { diff --git a/mozilla/layout/generic/nsHTMLContainerFrame.cpp b/mozilla/layout/generic/nsHTMLContainerFrame.cpp index 36ef2236ddd..8ace5c5364b 100644 --- a/mozilla/layout/generic/nsHTMLContainerFrame.cpp +++ b/mozilla/layout/generic/nsHTMLContainerFrame.cpp @@ -136,75 +136,6 @@ nsHTMLContainerFrame::MoveFrameOutOfFlow(nsIPresContext& aPresContext, return PR_FALSE; } -//XXX handle replace reflow command -NS_METHOD nsHTMLContainerFrame::AddFrame(const nsHTMLReflowState& aReflowState, - nsIFrame * aAddedFrame) -{ - nsresult rv=NS_OK; - nsIReflowCommand::ReflowType type; - aReflowState.reflowCommand->GetType(type); - // we have a generic frame that gets inserted but doesn't effect reflow - // hook it up then ignore it - if (nsIReflowCommand::FrameAppended==type) - { // frameAppended reflow -- find the last child and make aInsertedFrame its next sibling - nsIFrame *lastChild=mFirstChild; - nsIFrame *nextChild=mFirstChild; - while (nsnull!=nextChild) - { - lastChild=nextChild; - nextChild->GetNextSibling(nextChild); - } - if (nsnull==lastChild) - mFirstChild = aAddedFrame; - else - lastChild->SetNextSibling(aAddedFrame); - } - else if (nsIReflowCommand::FrameInserted==type) - { // frameInserted reflow -- hook up aInsertedFrame as prevSibling's next sibling, - // and be sure to hook in aInsertedFrame's nextSibling (from prevSibling) - nsIFrame *prevSibling=nsnull; - rv = aReflowState.reflowCommand->GetPrevSiblingFrame(prevSibling); - if (NS_SUCCEEDED(rv) && (nsnull!=prevSibling)) - { - nsIFrame *nextSibling=nsnull; - prevSibling->GetNextSibling(nextSibling); - prevSibling->SetNextSibling(aAddedFrame); - aAddedFrame->SetNextSibling(nextSibling); - } - else - { - nsIFrame *nextSibling = mFirstChild; - mFirstChild = aAddedFrame; - aAddedFrame->SetNextSibling(nextSibling); - } - } - else - { - NS_ASSERTION(PR_FALSE, "bad reflow type"); - rv = NS_ERROR_UNEXPECTED; - } - return rv; -} - /** */ -NS_METHOD nsHTMLContainerFrame::RemoveFrame(nsIFrame * aRemovedFrame) -{ - nsIFrame *prevChild=nsnull; - nsIFrame *nextChild=mFirstChild; - while (nextChild!=aRemovedFrame) - { - prevChild=nextChild; - nextChild->GetNextSibling(nextChild); - } - nextChild=nsnull; - aRemovedFrame->GetNextSibling(nextChild); - if (nsnull==prevChild) // objectFrame was first child - mFirstChild = nextChild; - else - prevChild->SetNextSibling(nextChild); - return NS_OK;; -} - - /** * Create a next-in-flow for aFrame. Will return the newly created * frame in aNextInFlowResult if and only if a new frame is diff --git a/mozilla/layout/generic/nsHTMLContainerFrame.h b/mozilla/layout/generic/nsHTMLContainerFrame.h index 009a155893b..2c2b8006b37 100644 --- a/mozilla/layout/generic/nsHTMLContainerFrame.h +++ b/mozilla/layout/generic/nsHTMLContainerFrame.h @@ -33,28 +33,22 @@ public: nsIRenderingContext& aRenderingContext, const nsRect& aDirtyRect, nsFramePaintLayer aWhichLayer); + nsPlaceholderFrame* CreatePlaceholderFrame(nsIPresContext& aPresContext, nsIFrame* aFloatedFrame); - // If the frame should be floated or absolutely positioned creates a placeholder - // frame and returns PR_TRUE. The sibling list is modified so aFrame's next - // sibling pointer is set to nsnull, and aPlaceholderFrame's sibling pointer - // is set to what aFrame's sibling pointer was. It's up to the caller to adjust - // any previous sibling pointers. + // If the frame should be floated or absolutely positioned creates a + // placeholder frame and returns PR_TRUE. The sibling list is + // modified so aFrame's next sibling pointer is set to nsnull, and + // aPlaceholderFrame's sibling pointer is set to what aFrame's + // sibling pointer was. It's up to the caller to adjust any previous + // sibling pointers. PRBool MoveFrameOutOfFlow(nsIPresContext& aPresContext, nsIFrame* aFrame, const nsStyleDisplay* aDisplay, const nsStylePosition* aPosition, nsIFrame*& aPlaceholderFrame); - /* helper methods for incremental reflow */ - /** */ - NS_IMETHOD AddFrame(const nsHTMLReflowState& aReflowState, - nsIFrame * aAddedFrame); - /** */ - NS_IMETHOD RemoveFrame(nsIFrame * aRemovedFrame); - - // Helper method to create next-in-flows if necessary static nsresult CreateNextInFlow(nsIPresContext& aPresContext, nsIFrame* aOuterFrame, diff --git a/mozilla/layout/generic/nsHTMLFrame.cpp b/mozilla/layout/generic/nsHTMLFrame.cpp index a790a36fefd..65b05695ad2 100644 --- a/mozilla/layout/generic/nsHTMLFrame.cpp +++ b/mozilla/layout/generic/nsHTMLFrame.cpp @@ -93,7 +93,7 @@ RootFrame::SetInitialChildList(nsIPresContext& aPresContext, nsIAtom* aListName, nsIFrame* aChildList) { - mFirstChild = aChildList; + mFrames.SetFrames(aChildList); return NS_OK; } @@ -126,11 +126,11 @@ RootFrame::Reflow(nsIPresContext& aPresContext, if ((nsIReflowCommand::FrameAppended == reflowType) || (nsIReflowCommand::FrameInserted == reflowType)) { - NS_ASSERTION(nsnull == mFirstChild, "only one child frame allowed"); + NS_ASSERTION(mFrames.IsEmpty(), "only one child frame allowed"); // Insert the frame into the child list aReflowState.reflowCommand->GetChildFrame(childFrame); - mFirstChild = childFrame; + mFrames.SetFrames(childFrame); // It's the child frame's initial reflow isChildInitialReflow = PR_TRUE; @@ -140,19 +140,16 @@ RootFrame::Reflow(nsIPresContext& aPresContext, // Get the child frame we should delete aReflowState.reflowCommand->GetChildFrame(deletedFrame); - NS_ASSERTION(deletedFrame == mFirstChild, "not a child frame"); + NS_ASSERTION(deletedFrame == mFrames.FirstChild(), "not a child frame"); // Remove it from the child list - if (deletedFrame == mFirstChild) { - mFirstChild = nsnull; - + if (deletedFrame == mFrames.FirstChild()) { // Damage the area occupied by the deleted frame nsRect damageRect; deletedFrame->GetRect(damageRect); Invalidate(damageRect, PR_FALSE); - // Delete the frame - deletedFrame->DeleteFrame(aPresContext); + mFrames.DeleteFrame(aPresContext, deletedFrame); } } @@ -160,17 +157,20 @@ RootFrame::Reflow(nsIPresContext& aPresContext, nsIFrame* nextFrame; // Get the next frame in the reflow chain aReflowState.reflowCommand->GetNext(nextFrame); - NS_ASSERTION(nextFrame == mFirstChild, "unexpected next reflow command frame"); + NS_ASSERTION(nextFrame == mFrames.FirstChild(), "unexpected next reflow command frame"); } } // Reflow our one and only child frame - if (nsnull != mFirstChild) { + if (mFrames.NotEmpty()) { + nsIFrame* myOnlyChild = mFrames.FirstChild(); + // Note: the root frame does not have border or padding... nsHTMLReflowMetrics desiredSize(nsnull); // We must pass in that the available height is unconstrained, because // constrained is only for when we're paginated... - nsHTMLReflowState kidReflowState(aPresContext, mFirstChild, aReflowState, + nsHTMLReflowState kidReflowState(aPresContext, myOnlyChild, + aReflowState, nsSize(aReflowState.availableWidth, NS_UNCONSTRAINEDSIZE)); if (isChildInitialReflow) { kidReflowState.reason = eReflowReason_Initial; @@ -186,18 +186,19 @@ RootFrame::Reflow(nsIPresContext& aPresContext, // Computed height is for the content area so reduce it by the amount of // space taken up by border and padding nsMargin borderPadding; - kidReflowState.ComputeBorderPaddingFor(mFirstChild, &aReflowState, borderPadding); + kidReflowState.ComputeBorderPaddingFor(myOnlyChild, &aReflowState, borderPadding); kidReflowState.computedHeight -= borderPadding.top + borderPadding.bottom; } // Reflow the frame nsIHTMLReflow* htmlReflow; - if (NS_OK == mFirstChild->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { - ReflowChild(mFirstChild, aPresContext, desiredSize, kidReflowState, aStatus); + if (NS_OK == myOnlyChild->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { + ReflowChild(myOnlyChild, aPresContext, desiredSize, kidReflowState, + aStatus); nsRect rect(kidReflowState.computedLeftMargin, kidReflowState.computedTopMargin, desiredSize.width, desiredSize.height); - mFirstChild->SetRect(rect); + myOnlyChild->SetRect(rect); // XXX We should resolve the details of who/when DidReflow() // notifications are sent... diff --git a/mozilla/layout/generic/nsPageFrame.cpp b/mozilla/layout/generic/nsPageFrame.cpp index 68da48b3a64..b8ca5f23e46 100644 --- a/mozilla/layout/generic/nsPageFrame.cpp +++ b/mozilla/layout/generic/nsPageFrame.cpp @@ -45,16 +45,18 @@ NS_METHOD nsPageFrame::Reflow(nsIPresContext& aPresContext, // Verify the next reflow command frame is our one and only child frame nsIFrame* next; aReflowState.reflowCommand->GetNext(next); - NS_ASSERTION(next == mFirstChild, "bad reflow frame"); + NS_ASSERTION(next == mFrames.FirstChild(), "bad reflow frame"); // Dispatch the reflow command to our content child. Allow it to be as high // as it wants nsSize maxSize(aReflowState.availableWidth, NS_UNCONSTRAINEDSIZE); - nsHTMLReflowState kidReflowState(aPresContext, mFirstChild, aReflowState, + nsHTMLReflowState kidReflowState(aPresContext, mFrames.FirstChild(), + aReflowState, maxSize); kidReflowState.isTopOfPage = PR_TRUE; - ReflowChild(mFirstChild, aPresContext, aDesiredSize, kidReflowState, aStatus); + ReflowChild(mFrames.FirstChild(), aPresContext, aDesiredSize, + kidReflowState, aStatus); // Place and size the child. Make sure the child is at least as // tall as our max size (the containing window) @@ -63,36 +65,40 @@ NS_METHOD nsPageFrame::Reflow(nsIPresContext& aPresContext, } nsRect rect(0, 0, aDesiredSize.width, aDesiredSize.height); - mFirstChild->SetRect(rect); + mFrames.FirstChild()->SetRect(rect); } else { // Do we have any children? // XXX We should use the overflow list instead... - if ((nsnull == mFirstChild) && (nsnull != mPrevInFlow)) { + if (mFrames.IsEmpty() && (nsnull != mPrevInFlow)) { nsPageFrame* prevPage = (nsPageFrame*)mPrevInFlow; - nsIFrame* prevLastChild = prevPage->LastFrame(prevPage->mFirstChild); + nsIFrame* prevLastChild = prevPage->mFrames.LastChild(); // Create a continuing child of the previous page's last child nsIStyleContext* kidSC; prevLastChild->GetStyleContext(kidSC); + nsIFrame* newFrame; nsresult rv = prevLastChild->CreateContinuingFrame(aPresContext, this, - kidSC, mFirstChild); + kidSC, + newFrame); + mFrames.SetFrames(newFrame); NS_RELEASE(kidSC); } // Resize our frame allowing it only to be as big as we are // XXX Pay attention to the page's border and padding... - if (nsnull != mFirstChild) { + if (mFrames.NotEmpty()) { + nsIFrame* frame = mFrames.FirstChild(); nsSize maxSize(aReflowState.availableWidth, aReflowState.availableHeight); - nsHTMLReflowState kidReflowState(aPresContext, mFirstChild, aReflowState, + nsHTMLReflowState kidReflowState(aPresContext, frame, aReflowState, maxSize); kidReflowState.isTopOfPage = PR_TRUE; nsIHTMLReflow* htmlReflow; - if (NS_OK == mFirstChild->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { + if (NS_OK == frame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { // Get the child's desired size - ReflowChild(mFirstChild, aPresContext, aDesiredSize, kidReflowState, aStatus); + ReflowChild(frame, aPresContext, aDesiredSize, kidReflowState, aStatus); // Make sure the child is at least as tall as our max size (the containing window) if (aDesiredSize.height < aReflowState.availableHeight) { @@ -101,7 +107,7 @@ NS_METHOD nsPageFrame::Reflow(nsIPresContext& aPresContext, // Place and size the child nsRect rect(0, 0, aDesiredSize.width, aDesiredSize.height); - mFirstChild->SetRect(rect); + frame->SetRect(rect); // XXX Should we be sending the DidReflow? htmlReflow->DidReflow(aPresContext, NS_FRAME_REFLOW_FINISHED); @@ -109,7 +115,7 @@ NS_METHOD nsPageFrame::Reflow(nsIPresContext& aPresContext, if (NS_FRAME_IS_COMPLETE(aStatus)) { nsIFrame* childNextInFlow; - mFirstChild->GetNextInFlow(childNextInFlow); + frame->GetNextInFlow(childNextInFlow); NS_ASSERTION(nsnull == childNextInFlow, "bad child flow list"); } } diff --git a/mozilla/layout/generic/nsSimplePageSequence.cpp b/mozilla/layout/generic/nsSimplePageSequence.cpp index 32da367e450..afdcc277fbe 100644 --- a/mozilla/layout/generic/nsSimplePageSequence.cpp +++ b/mozilla/layout/generic/nsSimplePageSequence.cpp @@ -87,7 +87,8 @@ nsSimplePageSequenceFrame::Reflow(nsIPresContext& aPresContext, aReflowState.reflowCommand->GetNext(nextFrame); // Compute the y-offset of this page - for (nsIFrame* f = mFirstChild; f != nextFrame; f->GetNextSibling(f)) { + for (nsIFrame* f = mFrames.FirstChild(); f != nextFrame; + f->GetNextSibling(f)) { nsSize size; f->GetSize(size); @@ -124,7 +125,7 @@ nsSimplePageSequenceFrame::Reflow(nsIPresContext& aPresContext, // Tile the pages vertically nsHTMLReflowMetrics kidSize(nsnull); - for (nsIFrame* kidFrame = mFirstChild; nsnull != kidFrame; ) { + for (nsIFrame* kidFrame = mFrames.FirstChild(); nsnull != kidFrame; ) { // Reflow the page nsHTMLReflowState kidReflowState(aPresContext, kidFrame, aReflowState, pageSize, @@ -258,7 +259,7 @@ nsSimplePageSequenceFrame::Print(nsIPresContext& aPresContext, { // If printing a range of pages make sure at least the starting page // number is valid - PRInt32 totalPages = LengthOf(mFirstChild); + PRInt32 totalPages = mFrames.GetLength(); if (ePrintRange_SpecifiedRange == aPrintOptions.range) { if (aPrintOptions.startPage > totalPages) { @@ -275,7 +276,7 @@ nsSimplePageSequenceFrame::Print(nsIPresContext& aPresContext, // Print each specified page PRInt32 pageNum = 1; - for (nsIFrame* page = mFirstChild; nsnull != page; page->GetNextSibling(page)) { + for (nsIFrame* page = mFrames.FirstChild(); nsnull != page; page->GetNextSibling(page)) { // See whether we should print this page PRBool printThisPage = PR_TRUE; diff --git a/mozilla/layout/html/base/src/nsAreaFrame.cpp b/mozilla/layout/html/base/src/nsAreaFrame.cpp index 64de9d7a233..a6126898cc7 100644 --- a/mozilla/layout/html/base/src/nsAreaFrame.cpp +++ b/mozilla/layout/html/base/src/nsAreaFrame.cpp @@ -66,7 +66,7 @@ nsAreaFrame::~nsAreaFrame() NS_IMETHODIMP nsAreaFrame::DeleteFrame(nsIPresContext& aPresContext) { - DeleteFrameList(aPresContext, &mAbsoluteFrames); + mAbsoluteFrames.DeleteFrames(aPresContext); return nsBlockFrame::DeleteFrame(aPresContext); } @@ -78,7 +78,7 @@ nsAreaFrame::SetInitialChildList(nsIPresContext& aPresContext, nsresult rv; if (nsLayoutAtoms::absoluteList == aListName) { - mAbsoluteFrames = aChildList; + mAbsoluteFrames.SetFrames(aChildList); rv = NS_OK; } else { rv = nsBlockFrame::SetInitialChildList(aPresContext, aListName, aChildList); @@ -108,7 +108,7 @@ NS_IMETHODIMP nsAreaFrame::FirstChild(nsIAtom* aListName, nsIFrame*& aFirstChild) const { if (aListName == nsLayoutAtoms::absoluteList) { - aFirstChild = mAbsoluteFrames; + aFirstChild = mAbsoluteFrames.FirstChild(); return NS_OK; } @@ -290,28 +290,8 @@ nsAreaFrame::Reflow(nsIPresContext& aPresContext, nsIFrame* childFrame; aReflowState.reflowCommand->GetChildFrame(childFrame); - // Find the frame in our list of absolutely positioned children - // and remove it - if (mAbsoluteFrames == childFrame) { - childFrame->GetNextSibling(mAbsoluteFrames); - - } else { - nsIFrame* prevSibling = nsnull; - for (nsIFrame* f = mAbsoluteFrames; nsnull != f; f->GetNextSibling(f)) { - if (f == childFrame) { - break; - } - prevSibling = f; - } - - NS_ASSERTION(nsnull != prevSibling, "didn't find frame"); - nsIFrame* nextSibling; - childFrame->GetNextSibling(nextSibling); - prevSibling->SetNextSibling(nextSibling); - } - - // Now go ahead and delete the child frame - childFrame->DeleteFrame(aPresContext); + PRBool zap = mAbsoluteFrames.DeleteFrame(aPresContext, childFrame); + NS_ASSERTION(zap, "didn't find frame"); // XXX We don't need to reflow all the absolutely positioned // frames. Compute the desired size and exit... @@ -327,15 +307,7 @@ nsAreaFrame::Reflow(nsIPresContext& aPresContext, aReflowState.reflowCommand->GetPrevSiblingFrame(prevSibling); // Insert the frame - if (nsnull == prevSibling) { - mAbsoluteFrames = childFrame; - } else { - nsIFrame* nextSibling; - - prevSibling->GetNextSibling(nextSibling); - prevSibling->SetNextSibling(childFrame); - childFrame->SetNextSibling(nextSibling); - } + mAbsoluteFrames.InsertFrame(nsnull, prevSibling, childFrame); wasHandled = PR_TRUE; } else { @@ -380,7 +352,8 @@ nsAreaFrame::Reflow(nsIPresContext& aPresContext, mStyleContext->GetStyleData(eStyleStruct_Display); if (NS_STYLE_OVERFLOW_HIDDEN != display->mOverflow) { - for (nsIFrame* f = mAbsoluteFrames; nsnull != f; f->GetNextSibling(f)) { + for (nsIFrame* f = mAbsoluteFrames.FirstChild(); nsnull != f; + f->GetNextSibling(f)) { nsRect rect; f->GetRect(rect); @@ -473,14 +446,7 @@ nsAreaFrame::CreateContinuingFrame(nsIPresContext& aPresContext, // Add the frame to the end of the child list void nsAreaFrame::AddAbsoluteFrame(nsIFrame* aFrame) { - if (nsnull == mAbsoluteFrames) { - mAbsoluteFrames = aFrame; - } else { - nsIFrame* lastChild = LastFrame(mAbsoluteFrames); - - lastChild->SetNextSibling(aFrame); - aFrame->SetNextSibling(nsnull); - } + mAbsoluteFrames.AppendFrames(nsnull, aFrame); } // Called at the end of the Reflow() member function so we can process @@ -489,7 +455,7 @@ void nsAreaFrame::ReflowAbsoluteItems(nsIPresContext& aPresContext, const nsHTMLReflowState& aReflowState) { - for (nsIFrame* absoluteFrame = mAbsoluteFrames; + for (nsIFrame* absoluteFrame = mAbsoluteFrames.FirstChild(); nsnull != absoluteFrame; absoluteFrame->GetNextSibling(absoluteFrame)) { PRBool placeFrame = PR_FALSE; @@ -735,17 +701,19 @@ nsAreaFrame::List(FILE* out, PRInt32 aIndent, nsIListFilter* aFilter) const nsresult rv = nsBlockFrame::List(out, aIndent, aFilter); // Output absolutely positioned frames - if (nsnull != mAbsoluteFrames) { - for (PRInt32 i = aIndent; --i >= 0; ) fputs(" ", out); + if (mAbsoluteFrames.NotEmpty()) { + IndentBy(out, aIndent); fprintf(out, "absolute-items <\n"); + + nsIFrame* f = mAbsoluteFrames.FirstChild(); + while (nsnull != f) { + f->List(out, aIndent+1, aFilter); + f->GetNextSibling(f); + } + + IndentBy(out, aIndent); + fputs(">\n", out); } - nsIFrame* f = mAbsoluteFrames; - while (nsnull != f) { - f->List(out, aIndent+1, aFilter); - f->GetNextSibling(f); - } - for (PRInt32 i = aIndent; --i >= 0; ) fputs(" ", out); - fputs(">\n", out); return rv; } diff --git a/mozilla/layout/html/base/src/nsAreaFrame.h b/mozilla/layout/html/base/src/nsAreaFrame.h index 8d144ac1b05..4ffd090af4b 100644 --- a/mozilla/layout/html/base/src/nsAreaFrame.h +++ b/mozilla/layout/html/base/src/nsAreaFrame.h @@ -95,7 +95,7 @@ protected: private: nsSpaceManager* mSpaceManager; - nsIFrame* mAbsoluteFrames; // additional named child list + nsFrameList mAbsoluteFrames; // additional named child list #ifdef NS_DEBUG struct BandData : public nsBandData { diff --git a/mozilla/layout/html/base/src/nsBlockFrame.cpp b/mozilla/layout/html/base/src/nsBlockFrame.cpp index 3328e0cfd94..93034aef62e 100644 --- a/mozilla/layout/html/base/src/nsBlockFrame.cpp +++ b/mozilla/layout/html/base/src/nsBlockFrame.cpp @@ -3449,7 +3449,7 @@ nsBaseIBFrame::MarkEmptyLines(nsIPresContext& aPresContext) } } -PRBool +void nsBaseIBFrame::DeleteChildsNextInFlow(nsIPresContext& aPresContext, nsIFrame* aChild) { @@ -3470,15 +3470,6 @@ nsBaseIBFrame::DeleteChildsNextInFlow(nsIPresContext& aPresContext, parent->DeleteChildsNextInFlow(aPresContext, nextInFlow); } -#ifdef NS_DEBUG - PRInt32 childCount; - nsIFrame* firstChild; - nextInFlow->FirstChild(nsnull, firstChild); - childCount = LengthOf(firstChild); - NS_ASSERTION((0 == childCount) && (nsnull == firstChild), - "deleting !empty next-in-flow"); -#endif - // Disconnect the next-in-flow from the flow list nextInFlow->BreakFromPrevFlow(); @@ -3516,7 +3507,6 @@ nsBaseIBFrame::DeleteChildsNextInFlow(nsIPresContext& aPresContext, aChild->GetNextInFlow(nextInFlow); NS_POSTCONDITION(nsnull == nextInFlow, "non null next-in-flow"); #endif - return PR_TRUE; } PRBool @@ -4142,7 +4132,7 @@ nsBlockFrame::DeleteFrame(nsIPresContext& aPresContext) mBullet = nsnull; } - DeleteFrameList(aPresContext, &mFloaters); + mFloaters.DeleteFrames(aPresContext); return nsBlockFrameSuper::DeleteFrame(aPresContext); } @@ -4380,12 +4370,12 @@ nsBlockFrame::List(FILE* out, PRInt32 aIndent, nsIListFilter *aFilter) const } // Output floaters next - if (nsnull != mFloaters) { + if (mFloaters.NotEmpty()) { if (outputMe) { for (i = aIndent; --i >= 0; ) fputs(" ", out); fprintf(out, "all-floaters <\n"); } - nsIFrame* floater = mFloaters; + nsIFrame* floater = mFloaters.FirstChild(); while (nsnull != floater) { floater->List(out, aIndent+1, aFilter); floater->GetNextSibling(floater); @@ -4447,7 +4437,7 @@ nsBlockFrame::FirstChild(nsIAtom* aListName, nsIFrame*& aFirstChild) const return NS_OK; } else if (aListName == nsLayoutAtoms::floaterList) { - aFirstChild = mFloaters; + aFirstChild = mFloaters.FirstChild(); return NS_OK; } else if (aListName == nsLayoutAtoms::bulletList) { @@ -4678,7 +4668,7 @@ nsBlockFrame::BuildFloaterList() if (nsnull != current) { current->SetNextSibling(nsnull); } - mFloaters = head; + mFloaters.SetFrames(head); } // XXX keep the text-run data in the first-in-flow of the block @@ -4946,7 +4936,7 @@ nsBlockFrame::GetFrameForPoint(const nsPoint& aPoint, nsIFrame** aFrame) return NS_OK; } } - if (nsnull != mFloaters) { + if (mFloaters.NotEmpty()) { rv = GetFrameForPointUsing(aPoint, nsLayoutAtoms::floaterList, aFrame); if (NS_OK == rv) { return NS_OK; diff --git a/mozilla/layout/html/base/src/nsBlockFrame.h b/mozilla/layout/html/base/src/nsBlockFrame.h index c11b5d4a5f1..997bb813ca3 100644 --- a/mozilla/layout/html/base/src/nsBlockFrame.h +++ b/mozilla/layout/html/base/src/nsBlockFrame.h @@ -93,8 +93,8 @@ public: #endif - virtual PRBool DeleteChildsNextInFlow(nsIPresContext& aPresContext, - nsIFrame* aNextInFlow); + virtual void DeleteChildsNextInFlow(nsIPresContext& aPresContext, + nsIFrame* aNextInFlow); protected: nsBaseIBFrame(); @@ -380,7 +380,7 @@ protected: nsTextRun* mTextRuns; // List of all floaters in this block - nsIFrame* mFloaters; + nsFrameList mFloaters; // XXX_fix_me: subclass one more time! // For list-item frames, this is the bullet frame. diff --git a/mozilla/layout/html/base/src/nsBlockReflowState.cpp b/mozilla/layout/html/base/src/nsBlockReflowState.cpp index 3328e0cfd94..93034aef62e 100644 --- a/mozilla/layout/html/base/src/nsBlockReflowState.cpp +++ b/mozilla/layout/html/base/src/nsBlockReflowState.cpp @@ -3449,7 +3449,7 @@ nsBaseIBFrame::MarkEmptyLines(nsIPresContext& aPresContext) } } -PRBool +void nsBaseIBFrame::DeleteChildsNextInFlow(nsIPresContext& aPresContext, nsIFrame* aChild) { @@ -3470,15 +3470,6 @@ nsBaseIBFrame::DeleteChildsNextInFlow(nsIPresContext& aPresContext, parent->DeleteChildsNextInFlow(aPresContext, nextInFlow); } -#ifdef NS_DEBUG - PRInt32 childCount; - nsIFrame* firstChild; - nextInFlow->FirstChild(nsnull, firstChild); - childCount = LengthOf(firstChild); - NS_ASSERTION((0 == childCount) && (nsnull == firstChild), - "deleting !empty next-in-flow"); -#endif - // Disconnect the next-in-flow from the flow list nextInFlow->BreakFromPrevFlow(); @@ -3516,7 +3507,6 @@ nsBaseIBFrame::DeleteChildsNextInFlow(nsIPresContext& aPresContext, aChild->GetNextInFlow(nextInFlow); NS_POSTCONDITION(nsnull == nextInFlow, "non null next-in-flow"); #endif - return PR_TRUE; } PRBool @@ -4142,7 +4132,7 @@ nsBlockFrame::DeleteFrame(nsIPresContext& aPresContext) mBullet = nsnull; } - DeleteFrameList(aPresContext, &mFloaters); + mFloaters.DeleteFrames(aPresContext); return nsBlockFrameSuper::DeleteFrame(aPresContext); } @@ -4380,12 +4370,12 @@ nsBlockFrame::List(FILE* out, PRInt32 aIndent, nsIListFilter *aFilter) const } // Output floaters next - if (nsnull != mFloaters) { + if (mFloaters.NotEmpty()) { if (outputMe) { for (i = aIndent; --i >= 0; ) fputs(" ", out); fprintf(out, "all-floaters <\n"); } - nsIFrame* floater = mFloaters; + nsIFrame* floater = mFloaters.FirstChild(); while (nsnull != floater) { floater->List(out, aIndent+1, aFilter); floater->GetNextSibling(floater); @@ -4447,7 +4437,7 @@ nsBlockFrame::FirstChild(nsIAtom* aListName, nsIFrame*& aFirstChild) const return NS_OK; } else if (aListName == nsLayoutAtoms::floaterList) { - aFirstChild = mFloaters; + aFirstChild = mFloaters.FirstChild(); return NS_OK; } else if (aListName == nsLayoutAtoms::bulletList) { @@ -4678,7 +4668,7 @@ nsBlockFrame::BuildFloaterList() if (nsnull != current) { current->SetNextSibling(nsnull); } - mFloaters = head; + mFloaters.SetFrames(head); } // XXX keep the text-run data in the first-in-flow of the block @@ -4946,7 +4936,7 @@ nsBlockFrame::GetFrameForPoint(const nsPoint& aPoint, nsIFrame** aFrame) return NS_OK; } } - if (nsnull != mFloaters) { + if (mFloaters.NotEmpty()) { rv = GetFrameForPointUsing(aPoint, nsLayoutAtoms::floaterList, aFrame); if (NS_OK == rv) { return NS_OK; diff --git a/mozilla/layout/html/base/src/nsBlockReflowState.h b/mozilla/layout/html/base/src/nsBlockReflowState.h index 3328e0cfd94..93034aef62e 100644 --- a/mozilla/layout/html/base/src/nsBlockReflowState.h +++ b/mozilla/layout/html/base/src/nsBlockReflowState.h @@ -3449,7 +3449,7 @@ nsBaseIBFrame::MarkEmptyLines(nsIPresContext& aPresContext) } } -PRBool +void nsBaseIBFrame::DeleteChildsNextInFlow(nsIPresContext& aPresContext, nsIFrame* aChild) { @@ -3470,15 +3470,6 @@ nsBaseIBFrame::DeleteChildsNextInFlow(nsIPresContext& aPresContext, parent->DeleteChildsNextInFlow(aPresContext, nextInFlow); } -#ifdef NS_DEBUG - PRInt32 childCount; - nsIFrame* firstChild; - nextInFlow->FirstChild(nsnull, firstChild); - childCount = LengthOf(firstChild); - NS_ASSERTION((0 == childCount) && (nsnull == firstChild), - "deleting !empty next-in-flow"); -#endif - // Disconnect the next-in-flow from the flow list nextInFlow->BreakFromPrevFlow(); @@ -3516,7 +3507,6 @@ nsBaseIBFrame::DeleteChildsNextInFlow(nsIPresContext& aPresContext, aChild->GetNextInFlow(nextInFlow); NS_POSTCONDITION(nsnull == nextInFlow, "non null next-in-flow"); #endif - return PR_TRUE; } PRBool @@ -4142,7 +4132,7 @@ nsBlockFrame::DeleteFrame(nsIPresContext& aPresContext) mBullet = nsnull; } - DeleteFrameList(aPresContext, &mFloaters); + mFloaters.DeleteFrames(aPresContext); return nsBlockFrameSuper::DeleteFrame(aPresContext); } @@ -4380,12 +4370,12 @@ nsBlockFrame::List(FILE* out, PRInt32 aIndent, nsIListFilter *aFilter) const } // Output floaters next - if (nsnull != mFloaters) { + if (mFloaters.NotEmpty()) { if (outputMe) { for (i = aIndent; --i >= 0; ) fputs(" ", out); fprintf(out, "all-floaters <\n"); } - nsIFrame* floater = mFloaters; + nsIFrame* floater = mFloaters.FirstChild(); while (nsnull != floater) { floater->List(out, aIndent+1, aFilter); floater->GetNextSibling(floater); @@ -4447,7 +4437,7 @@ nsBlockFrame::FirstChild(nsIAtom* aListName, nsIFrame*& aFirstChild) const return NS_OK; } else if (aListName == nsLayoutAtoms::floaterList) { - aFirstChild = mFloaters; + aFirstChild = mFloaters.FirstChild(); return NS_OK; } else if (aListName == nsLayoutAtoms::bulletList) { @@ -4678,7 +4668,7 @@ nsBlockFrame::BuildFloaterList() if (nsnull != current) { current->SetNextSibling(nsnull); } - mFloaters = head; + mFloaters.SetFrames(head); } // XXX keep the text-run data in the first-in-flow of the block @@ -4946,7 +4936,7 @@ nsBlockFrame::GetFrameForPoint(const nsPoint& aPoint, nsIFrame** aFrame) return NS_OK; } } - if (nsnull != mFloaters) { + if (mFloaters.NotEmpty()) { rv = GetFrameForPointUsing(aPoint, nsLayoutAtoms::floaterList, aFrame); if (NS_OK == rv) { return NS_OK; diff --git a/mozilla/layout/html/base/src/nsContainerFrame.cpp b/mozilla/layout/html/base/src/nsContainerFrame.cpp index 46eea193ec6..b9ab9daa6cc 100644 --- a/mozilla/layout/html/base/src/nsContainerFrame.cpp +++ b/mozilla/layout/html/base/src/nsContainerFrame.cpp @@ -28,6 +28,7 @@ #include "nsIView.h" #include "nsVoidArray.h" #include "nsISizeOfHandler.h" +#include "nsIReflowCommand.h" #include "nsHTMLIIDs.h" #ifdef NS_DEBUG @@ -36,12 +37,12 @@ #undef NOISY #endif -NS_IMETHODIMP -nsContainerFrame::SizeOf(nsISizeOfHandler* aHandler) const +nsContainerFrame::nsContainerFrame() +{ +} + +nsContainerFrame::~nsContainerFrame() { - aHandler->Add(sizeof(*this)); - nsContainerFrame::SizeOfWithoutThis(aHandler); - return NS_OK; } NS_IMETHODIMP @@ -49,18 +50,17 @@ nsContainerFrame::SetInitialChildList(nsIPresContext& aPresContext, nsIAtom* aListName, nsIFrame* aChildList) { - NS_PRECONDITION(nsnull == mFirstChild, "already initialized"); - nsresult result; + NS_PRECONDITION(mFrames.IsEmpty(), "already initialized"); - if (nsnull != mFirstChild) { + nsresult result; + if (nsnull != mFrames.FirstChild()) { result = NS_ERROR_UNEXPECTED; } else if (nsnull != aListName) { result = NS_ERROR_INVALID_ARG; } else { - mFirstChild = aChildList; + mFrames.SetFrames(aChildList); result = NS_OK; } - return result; } @@ -68,50 +68,19 @@ NS_IMETHODIMP nsContainerFrame::DeleteFrame(nsIPresContext& aPresContext) { // Prevent event dispatch during destruction - nsIView* view; + nsIView* view; GetView(view); if (nsnull != view) { view->SetClientData(nsnull); } // Delete the primary child list - DeleteFrameList(aPresContext, &mFirstChild); + mFrames.DeleteFrames(aPresContext); // Base class will delete the frame return nsFrame::DeleteFrame(aPresContext); } -/** - * Helper method to delete a frame list and keep the list sane during - * the deletion. - */ -void -nsContainerFrame::DeleteFrameList(nsIPresContext& aPresContext, - nsIFrame** aListP) -{ - nsIFrame* first; - while (nsnull != (first = *aListP)) { - nsIFrame* nextChild; - - first->GetNextSibling(nextChild); - first->DeleteFrame(aPresContext); - - // Once we've deleted the child frame make sure it's no longer in - // the child list - *aListP = nextChild; - } -} - -void -nsContainerFrame::SizeOfWithoutThis(nsISizeOfHandler* aHandler) const -{ - nsSplittableFrame::SizeOfWithoutThis(aHandler); - for (nsIFrame* child = mFirstChild; child; ) { - child->SizeOf(aHandler); - child->GetNextSibling(child); - } -} - NS_IMETHODIMP nsContainerFrame::DidReflow(nsIPresContext& aPresContext, nsDidReflowStatus aStatus) @@ -155,9 +124,8 @@ nsContainerFrame::FirstChild(nsIAtom* aListName, nsIFrame*& aFirstChild) const { // We only know about the unnamed principal child list if (nsnull == aListName) { - aFirstChild = mFirstChild; + aFirstChild = mFrames.FirstChild(); return NS_OK; - } else { aFirstChild = nsnull; return NS_ERROR_INVALID_ARG; @@ -183,7 +151,7 @@ nsContainerFrame::ReResolveStyleContext(nsIPresContext* aPresContext, } // Update overflow list too - child = mOverflowList; + child = mOverflowFrames.FirstChild(); while ((NS_SUCCEEDED(result)) && (nsnull != child)) { result = child->ReResolveStyleContext(aPresContext, mStyleContext); child->GetNextSibling(child); @@ -192,7 +160,7 @@ nsContainerFrame::ReResolveStyleContext(nsIPresContext* aPresContext, // And just to be complete, update our prev-in-flows overflow list // too (since in theory, those frames will become our frames) if (nsnull != mPrevInFlow) { - child = ((nsContainerFrame*)mPrevInFlow)->mOverflowList; + child = ((nsContainerFrame*)mPrevInFlow)->mOverflowFrames.FirstChild(); while ((NS_SUCCEEDED(result)) && (nsnull != child)) { result = child->ReResolveStyleContext(aPresContext, mStyleContext); child->GetNextSibling(child); @@ -203,7 +171,7 @@ nsContainerFrame::ReResolveStyleContext(nsIPresContext* aPresContext, } ///////////////////////////////////////////////////////////////////////////// -// Painting +// Painting/Events NS_IMETHODIMP nsContainerFrame::Paint(nsIPresContext& aPresContext, @@ -242,7 +210,7 @@ nsContainerFrame::PaintChildren(nsIPresContext& aPresContext, nsClipCombine_kIntersect, clipState); } - nsIFrame* kid = mFirstChild; + nsIFrame* kid = mFrames.FirstChild(); while (nsnull != kid) { PaintChild(aPresContext, aRenderingContext, aDirtyRect, kid, aWhichLayer); kid->GetNextSibling(kid); @@ -380,11 +348,11 @@ nsContainerFrame::ReflowChild(nsIFrame* aKidFrame, nsReflowStatus& aStatus) { NS_PRECONDITION(aReflowState.frame == aKidFrame, "bad reflow state"); + NS_PRECONDITION(IsChild(aKidFrame), "not my child"); // Query for the nsIHTMLReflow interface nsIHTMLReflow* htmlReflow; nsresult result; - result = aKidFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow); if (NS_FAILED(result)) { return result; @@ -392,13 +360,13 @@ nsContainerFrame::ReflowChild(nsIFrame* aKidFrame, // Send the WillReflow notification, and reflow the child frame htmlReflow->WillReflow(aPresContext); - result = htmlReflow->Reflow(aPresContext, aDesiredSize, aReflowState, aStatus); + result = htmlReflow->Reflow(aPresContext, aDesiredSize, aReflowState, + aStatus); // If the reflow was successful and the child frame is complete, delete any // next-in-flows if (NS_SUCCEEDED(result) && NS_FRAME_IS_COMPLETE(aStatus)) { nsIFrame* kidNextInFlow; - aKidFrame->GetNextInFlow(kidNextInFlow); if (nsnull != kidNextInFlow) { // Remove all of the childs next-in-flows. Make sure that we ask @@ -406,10 +374,10 @@ nsContainerFrame::ReflowChild(nsIFrame* aKidFrame, // parent is not this because we are executing pullup code) nsIFrame* parent; aKidFrame->GetParent(parent); - ((nsContainerFrame*)parent)->DeleteChildsNextInFlow(aPresContext, aKidFrame); + ((nsContainerFrame*)parent)->DeleteChildsNextInFlow(aPresContext, + aKidFrame); } } - return result; } @@ -423,8 +391,9 @@ nsContainerFrame::ReflowChild(nsIFrame* aKidFrame, * @param aChild child this child's next-in-flow * @return PR_TRUE if successful and PR_FALSE otherwise */ -PRBool -nsContainerFrame::DeleteChildsNextInFlow(nsIPresContext& aPresContext, nsIFrame* aChild) +void +nsContainerFrame::DeleteChildsNextInFlow(nsIPresContext& aPresContext, + nsIFrame* aChild) { NS_PRECONDITION(IsChild(aChild), "bad geometric parent"); @@ -444,36 +413,14 @@ nsContainerFrame::DeleteChildsNextInFlow(nsIPresContext& aPresContext, nsIFrame* parent->DeleteChildsNextInFlow(aPresContext, nextInFlow); } -#ifdef NS_DEBUG - PRInt32 childCount; - nsIFrame* firstChild; - - nextInFlow->FirstChild(nsnull, firstChild); - childCount = LengthOf(firstChild); - - if ((0 != childCount) || (nsnull != firstChild)) { - nsIFrame* top = nextInFlow; - for (;;) { - nsIFrame* parent; - top->GetParent(parent); - if (nsnull == parent) { - break; - } - top = parent; - } - top->List(stdout, 0, nsnull); - } - NS_ASSERTION((0 == childCount) && (nsnull == firstChild), - "deleting !empty next-in-flow"); -#endif - // Disconnect the next-in-flow from the flow list nextInFlow->BreakFromPrevFlow(); // Take the next-in-flow out of the parent's child list - if (parent->mFirstChild == nextInFlow) { - nextInFlow->GetNextSibling(parent->mFirstChild); - + if (parent->mFrames.FirstChild() == nextInFlow) { + nsIFrame* nextFrame; + nextInFlow->GetNextSibling(nextFrame); + parent->mFrames.SetFrames(nextFrame); } else { nsIFrame* nextSibling; @@ -491,18 +438,12 @@ nsContainerFrame::DeleteChildsNextInFlow(nsIPresContext& aPresContext, nsIFrame* } // Delete the next-in-flow frame - WillDeleteNextInFlowFrame(nextInFlow); nextInFlow->DeleteFrame(aPresContext); #ifdef NS_DEBUG aChild->GetNextInFlow(nextInFlow); NS_POSTCONDITION(nsnull == nextInFlow, "non null next-in-flow"); #endif - return PR_TRUE; -} - -void nsContainerFrame::WillDeleteNextInFlowFrame(nsIFrame* aNextInFlow) -{ } /** @@ -519,13 +460,13 @@ void nsContainerFrame::WillDeleteNextInFlowFrame(nsIFrame* aNextInFlow) * @param aPrevSibling aFromChild's previous sibling. Must not be null. It's * an error to push a parent's first child frame */ -void nsContainerFrame::PushChildren(nsIFrame* aFromChild, nsIFrame* aPrevSibling) +void +nsContainerFrame::PushChildren(nsIFrame* aFromChild, nsIFrame* aPrevSibling) { NS_PRECONDITION(nsnull != aFromChild, "null pointer"); NS_PRECONDITION(nsnull != aPrevSibling, "pushing first child"); #ifdef NS_DEBUG nsIFrame* prevNextSibling; - aPrevSibling->GetNextSibling(prevNextSibling); NS_PRECONDITION(prevNextSibling == aFromChild, "bad prev sibling"); #endif @@ -533,38 +474,14 @@ void nsContainerFrame::PushChildren(nsIFrame* aFromChild, nsIFrame* aPrevSibling // Disconnect aFromChild from its previous sibling aPrevSibling->SetNextSibling(nsnull); - // Do we have a next-in-flow? - nsContainerFrame* nextInFlow = (nsContainerFrame*)mNextInFlow; - if (nsnull != nextInFlow) { - PRInt32 numChildren = 0; - nsIFrame* lastChild = nsnull; - - // Compute the number of children being pushed, and for each child change - // its geometric parent. Remember the last child - for (nsIFrame* f = aFromChild; nsnull != f; f->GetNextSibling(f)) { - numChildren++; -#ifdef NOISY - printf(" "); - ((nsFrame*)f)->ListTag(stdout); - printf("\n"); -#endif - lastChild = f; - f->SetParent(nextInFlow); - } - NS_ASSERTION(numChildren > 0, "no children to push"); - - // Prepend the frames to our next-in-flow's child list - lastChild->SetNextSibling(nextInFlow->mFirstChild); - nextInFlow->mFirstChild = aFromChild; - - } else { + if (nsnull != mNextInFlow) { + nsContainerFrame* nextInFlow = (nsContainerFrame*)mNextInFlow; + nextInFlow->mFrames.InsertFrames(mNextInFlow, nsnull, aFromChild); + } + else { // Add the frames to our overflow list - NS_ASSERTION(nsnull == mOverflowList, "bad overflow list"); -#ifdef NOISY - ListTag(stdout); - printf(": pushing kids to my overflow list\n"); -#endif - mOverflowList = aFromChild; + NS_ASSERTION(mOverflowFrames.IsEmpty(), "bad overflow list"); + mOverflowFrames.SetFrames(aFromChild); } } @@ -576,63 +493,66 @@ void nsContainerFrame::PushChildren(nsIFrame* aFromChild, nsIFrame* aPrevSibling * * @return PR_TRUE if any frames were moved and PR_FALSE otherwise */ -PRBool nsContainerFrame::MoveOverflowToChildList() +PRBool +nsContainerFrame::MoveOverflowToChildList() { - PRBool result = PR_FALSE; + PRBool result = PR_FALSE; // Check for an overflow list with our prev-in-flow nsContainerFrame* prevInFlow = (nsContainerFrame*)mPrevInFlow; if (nsnull != prevInFlow) { - if (nsnull != prevInFlow->mOverflowList) { - NS_ASSERTION(nsnull == mFirstChild, "bad overflow list"); - AppendChildren(prevInFlow->mOverflowList); - prevInFlow->mOverflowList = nsnull; + if (prevInFlow->mOverflowFrames.NotEmpty()) { + NS_ASSERTION(mFrames.IsEmpty(), "bad overflow list"); + mFrames.Join(this, prevInFlow->mOverflowFrames); result = PR_TRUE; } } // It's also possible that we have an overflow list for ourselves - if (nsnull != mOverflowList) { - NS_ASSERTION(nsnull != mFirstChild, "overflow list but no mapped children"); - AppendChildren(mOverflowList, PR_FALSE); - mOverflowList = nsnull; + if (mOverflowFrames.NotEmpty()) { + NS_ASSERTION(mFrames.NotEmpty(), "overflow list w/o frames"); + mFrames.Join(nsnull, mOverflowFrames); result = PR_TRUE; } - return result; } -/** - * Append child list starting at aChild to this frame's child list. Used for - * processing of the overflow list. - * - * Updates this frame's child count and content mapping. - * - * @param aChild the beginning of the child list - * @param aSetParent if true each child's geometric (and content parent if - * they're the same) parent is set to this frame. - */ -void nsContainerFrame::AppendChildren(nsIFrame* aChild, PRBool aSetParent) +nsresult +nsContainerFrame::AddFrame(const nsHTMLReflowState& aReflowState, + nsIFrame * aAddedFrame) { - // Link the frames into our child frame list - if (nsnull == mFirstChild) { - // We have no children so aChild becomes the first child - mFirstChild = aChild; - } else { - nsIFrame* lastChild = LastFrame(mFirstChild); - lastChild->SetNextSibling(aChild); + nsresult rv=NS_OK; + nsIReflowCommand::ReflowType type; + aReflowState.reflowCommand->GetType(type); + + // we have a generic frame that gets inserted but doesn't effect + // reflow hook it up then ignore it + if (nsIReflowCommand::FrameAppended == type) { + // Append aAddedFrame to the list of frames + mFrames.AppendFrame(nsnull, aAddedFrame); } - - // Update our child count and last content offset - nsIFrame* lastChild; - for (nsIFrame* f = aChild; nsnull != f; f->GetNextSibling(f)) { - lastChild = f; - - // Reset the geometric parent if requested - if (aSetParent) { - f->SetParent(this); + else if (nsIReflowCommand::FrameInserted == type) { + // Insert aAddedFrame into the list of frames + nsIFrame *prevSibling=nsnull; + rv = aReflowState.reflowCommand->GetPrevSiblingFrame(prevSibling); + if (NS_SUCCEEDED(rv)) { + mFrames.InsertFrame(nsnull, prevSibling, aAddedFrame); } } + else + { + NS_ASSERTION(PR_FALSE, "bad reflow type"); + rv = NS_ERROR_UNEXPECTED; + } + return rv; +} + +nsresult +nsContainerFrame::RemoveFrame(nsIFrame* aRemovedFrame) +{ + PRBool zap = mFrames.RemoveFrame(aRemovedFrame); + NS_ASSERTION(zap, "failure to remove a frame"); + return NS_OK; } ///////////////////////////////////////////////////////////////////////////// @@ -680,14 +600,15 @@ nsContainerFrame::List(FILE* out, PRInt32 aIndent, } // Output the children - if (nsnull != mFirstChild) { + if (mFrames.NotEmpty()) { if (outputMe) { if (0 != mState) { fprintf(out, " [state=%08x]", mState); } fputs("<\n", out); } - for (nsIFrame* child = mFirstChild; child; child->GetNextSibling(child)) { + for (nsIFrame* child = mFrames.FirstChild(); child; + child->GetNextSibling(child)) { child->List(out, aIndent + 1, aFilter); } if (outputMe) { @@ -705,63 +626,3 @@ nsContainerFrame::List(FILE* out, PRInt32 aIndent, return NS_OK; } - -NS_IMETHODIMP -nsContainerFrame::VerifyTree() const -{ -#ifdef NS_DEBUG - NS_ASSERTION(0 == (mState & NS_FRAME_IN_REFLOW), "frame is in reflow"); - NS_ASSERTION(nsnull == mOverflowList, "bad overflow list"); -#endif - return NS_OK; -} - -PRInt32 nsContainerFrame::LengthOf(nsIFrame* aFrame) -{ - PRInt32 result = 0; - - while (nsnull != aFrame) { - result++; - aFrame->GetNextSibling(aFrame); - } - - return result; -} - -nsIFrame* nsContainerFrame::LastFrame(nsIFrame* aFrame) -{ - nsIFrame* lastChild = nsnull; - - while (nsnull != aFrame) { - lastChild = aFrame; - aFrame->GetNextSibling(aFrame); - } - - return lastChild; -} - -nsIFrame* nsContainerFrame::FrameAt(nsIFrame* aFrame, PRInt32 aIndex) -{ - while ((aIndex-- > 0) && (aFrame != nsnull)) { - aFrame->GetNextSibling(aFrame); - } - return aFrame; -} - -///////////////////////////////////////////////////////////////////////////// - -#ifdef NS_DEBUG - -PRBool nsContainerFrame::IsChild(const nsIFrame* aChild) const -{ - // Check the geometric parent - nsIFrame* parent; - - aChild->GetParent(parent); - if (parent != (nsIFrame*)this) { - return PR_FALSE; - } - - return PR_TRUE; -} -#endif diff --git a/mozilla/layout/html/base/src/nsContainerFrame.h b/mozilla/layout/html/base/src/nsContainerFrame.h index 944b5012a3e..78d9f6c992f 100644 --- a/mozilla/layout/html/base/src/nsContainerFrame.h +++ b/mozilla/layout/html/base/src/nsContainerFrame.h @@ -19,6 +19,7 @@ #define nsContainerFrame_h___ #include "nsSplittableFrame.h" +#include "nsFrameList.h" /** * Implementation of a container frame. @@ -26,68 +27,45 @@ class nsContainerFrame : public nsSplittableFrame { public: - NS_IMETHOD SizeOf(nsISizeOfHandler* aHandler) const; - + // nsIFrame overrides NS_IMETHOD SetInitialChildList(nsIPresContext& aPresContext, nsIAtom* aListName, nsIFrame* aChildList); - + NS_IMETHOD FirstChild(nsIAtom* aListName, nsIFrame*& aFirstChild) const; NS_IMETHOD DeleteFrame(nsIPresContext& aPresContext); - - NS_IMETHOD DidReflow(nsIPresContext& aPresContext, - nsDidReflowStatus aStatus); - - // Painting NS_IMETHOD Paint(nsIPresContext& aPresContext, nsIRenderingContext& aRenderingContext, const nsRect& aDirtyRect, nsFramePaintLayer aWhichLayer); - - /** - * Find the correct child frame. - */ NS_IMETHOD GetFrameForPoint(const nsPoint& aPoint, nsIFrame** aFrame); + NS_IMETHOD ReResolveStyleContext(nsIPresContext* aPresContext, + nsIStyleContext* aParentContext); + NS_IMETHOD List(FILE* out, PRInt32 aIndent, nsIListFilter *aFilter) const; - // Child frame enumeration. - NS_IMETHOD FirstChild(nsIAtom* aListName, nsIFrame*& aFirstChild) const; + // nsIHTMLReflow overrides + NS_IMETHOD DidReflow(nsIPresContext& aPresContext, + nsDidReflowStatus aStatus); - // re-resolve style context for self and children as necessary - // Subclasses need to override if they add child lists or - // if they alter normal style context inheritance - NS_IMETHOD ReResolveStyleContext(nsIPresContext* aPresContext, - nsIStyleContext* aParentContext); + // nsContainerFrame methods + virtual void DeleteChildsNextInFlow(nsIPresContext& aPresContext, + nsIFrame* aChild); - // Debugging - NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0, nsIListFilter *aFilter = nsnull) const; - NS_IMETHOD VerifyTree() const; + static PRInt32 LengthOf(nsIFrame* aFrameList) { + nsFrameList tmp(aFrameList); + return tmp.GetLength(); + } - /** - * Return the number of children in the sibling list, starting at aChild. - * Returns zero if aChild is nsnull. - */ - static PRInt32 LengthOf(nsIFrame* aChild); - - /** - * Return the last frame in the sibling list. - * Returns nsnullif aChild is nsnull. - */ - static nsIFrame* LastFrame(nsIFrame* aChild); - - /** - * Returns the frame at the specified index relative to aFrame - */ - static nsIFrame* FrameAt(nsIFrame* aFrame, PRInt32 aIndex); - - // XXX needs to be virtual so that nsBlockFrame can override it - virtual PRBool DeleteChildsNextInFlow(nsIPresContext& aPresContext, - nsIFrame* aChild); +#if XXX + static nsIFrame* FrameAt(nsIFrame* aFrameList, PRInt32 aIndex) { + nsFrameList tmp(aFrameList); + return tmp.FrameAt(aIndex); + } +#endif protected: - void DeleteFrameList(nsIPresContext& aPresContext, - nsIFrame** aListP); - - void SizeOfWithoutThis(nsISizeOfHandler* aHandler) const; + nsContainerFrame(); + ~nsContainerFrame(); nsresult GetFrameForPointUsing(const nsPoint& aPoint, nsIAtom* aList, @@ -116,56 +94,61 @@ protected: const nsHTMLReflowState& aReflowState, nsReflowStatus& aStatus); - /** - * Moves any frames on both the prev-in-flow's overflow list and the receiver's - * overflow to the receiver's child list. - * - * Resets the overlist pointers to nsnull, and updates the receiver's child - * count and content mapping. - * - * @return PR_TRUE if any frames were moved and PR_FALSE otherwise - */ + /** + * Moves any frames on both the prev-in-flow's overflow list and the + * receiver's overflow to the receiver's child list. + * + * Resets the overlist pointers to nsnull, and updates the receiver's child + * count and content mapping. + * + * @return PR_TRUE if any frames were moved and PR_FALSE otherwise + */ PRBool MoveOverflowToChildList(); - /** - * Push aFromChild and its next siblings to the next-in-flow. Change the - * geometric parent of each frame that's pushed. If there is no next-in-flow - * the frames are placed on the overflow list (and the geometric parent is - * left unchanged). - * - * Updates the next-in-flow's child count. Does not update the - * pusher's child count. - * - * @param aFromChild the first child frame to push. It is disconnected from - * aPrevSibling - * @param aPrevSibling aFromChild's previous sibling. Must not be null. It's - * an error to push a parent's first child frame - */ + /** + * Push aFromChild and its next siblings to the next-in-flow. Change + * the geometric parent of each frame that's pushed. If there is no + * next-in-flow the frames are placed on the overflow list (and the + * geometric parent is left unchanged). + * + * Updates the next-in-flow's child count. Does not update the + * pusher's child count. + * + * @param aFromChild the first child frame to push. It is disconnected from + * aPrevSibling + * @param aPrevSibling aFromChild's previous sibling. Must not be null. + * It's an error to push a parent's first child frame + */ void PushChildren(nsIFrame* aFromChild, nsIFrame* aPrevSibling); /** - * Append child list starting at aChild to this frame's child list. Used for - * processing of the overflow list. - * - * Updates this frame's child count and content mapping. + * Append child list starting at aChild to this frame's child list. * * @param aChild the beginning of the child list - * @param aSetParent if true each child's geometric (and content parent if - * they're the same) parent is set to this frame. + * @param aSetParent if true each child's parent is set to this frame. */ - void AppendChildren(nsIFrame* aChild, PRBool aSetParent = PR_TRUE); + void AppendChildren(nsIFrame* aChild, PRBool aSetParent) { + mFrames.AppendFrames(aSetParent ? this : nsnull, aChild); + } - virtual void WillDeleteNextInFlowFrame(nsIFrame* aNextInFlow); + /** + */ + nsresult AddFrame(const nsHTMLReflowState& aReflowState, + nsIFrame * aAddedFrame); + + /** + */ + nsresult RemoveFrame(nsIFrame * aRemovedFrame); -#ifdef NS_DEBUG /** * Returns PR_TRUE if aChild is a child of this frame. */ - PRBool IsChild(const nsIFrame* aChild) const; -#endif + PRBool IsChild(const nsIFrame* aChild) const { + return mFrames.ContainsFrame(aChild); + } - nsIFrame* mFirstChild; - nsIFrame* mOverflowList; + nsFrameList mFrames; + nsFrameList mOverflowFrames; }; #endif /* nsContainerFrame_h___ */ diff --git a/mozilla/layout/html/base/src/nsFrameList.cpp b/mozilla/layout/html/base/src/nsFrameList.cpp index e83a523985c..fd47d88a029 100644 --- a/mozilla/layout/html/base/src/nsFrameList.cpp +++ b/mozilla/layout/html/base/src/nsFrameList.cpp @@ -26,8 +26,7 @@ nsFrameList::DeleteFrames(nsIPresContext& aPresContext) nsIFrame* next; frame->GetNextSibling(next); frame->DeleteFrame(aPresContext); - delete frame; - frame = next; + mFirstChild = frame = next; } } @@ -93,13 +92,24 @@ nsFrameList::RemoveFrame(nsIFrame* aFrame) return PR_FALSE; } +PRBool +nsFrameList::RemoveFirstChild() +{ + if (nsnull != mFirstChild) { + nsIFrame* nextFrame; + mFirstChild->GetNextSibling(nextFrame); + mFirstChild = nextFrame; + return PR_TRUE; + } + return PR_FALSE; +} + PRBool nsFrameList::DeleteFrame(nsIPresContext& aPresContext, nsIFrame* aFrame) { NS_PRECONDITION(nsnull != aFrame, "null ptr"); if (RemoveFrame(aFrame)) { aFrame->DeleteFrame(aPresContext); - delete aFrame; return PR_TRUE; } return PR_FALSE; @@ -197,7 +207,6 @@ nsFrameList::ReplaceAndDeleteFrame(nsIPresContext& aPresContext, NS_PRECONDITION(nsnull != aNewFrame, "null ptr"); if (ReplaceFrame(aParent, aOldFrame, aNewFrame)) { aNewFrame->DeleteFrame(aPresContext); - delete aNewFrame; return PR_TRUE; } return PR_FALSE; @@ -254,8 +263,20 @@ nsFrameList::LastChild() const return frame; } +nsIFrame* +nsFrameList::FrameAt(PRInt32 aIndex) const +{ + NS_PRECONDITION(aIndex >= 0, "invalid arg"); + if (aIndex < 0) return nsnull; + nsIFrame* frame = mFirstChild; + while ((aIndex-- > 0) && (nsnull != frame)) { + frame->GetNextSibling(frame); + } + return frame; +} + PRBool -nsFrameList::ContainsFrame(nsIFrame* aFrame) const +nsFrameList::ContainsFrame(const nsIFrame* aFrame) const { NS_PRECONDITION(nsnull != aFrame, "null ptr"); nsIFrame* frame = mFirstChild; diff --git a/mozilla/layout/html/base/src/nsFrameList.h b/mozilla/layout/html/base/src/nsFrameList.h index 58ff000c2bc..3f0325cd7ed 100644 --- a/mozilla/layout/html/base/src/nsFrameList.h +++ b/mozilla/layout/html/base/src/nsFrameList.h @@ -40,6 +40,10 @@ public: void DeleteFrames(nsIPresContext& aPresContext); + void SetFrames(nsIFrame* aFrameList) { + mFirstChild = aFrameList; + } + void AppendFrames(nsIFrame* aParent, nsIFrame* aFrameList); void AppendFrames(nsIFrame* aParent, nsFrameList& aFrameList) { @@ -50,6 +54,8 @@ public: PRBool RemoveFrame(nsIFrame* aFrame); + PRBool RemoveFirstChild(); + PRBool DeleteFrame(nsIPresContext& aPresContext, nsIFrame* aFrame); void InsertFrame(nsIFrame* aParent, @@ -86,11 +92,17 @@ public: nsIFrame* LastChild() const; + nsIFrame* FrameAt(PRInt32 aIndex) const; + PRBool IsEmpty() const { return nsnull == mFirstChild; } - PRBool ContainsFrame(nsIFrame* aFrame) const; + PRBool NotEmpty() const { + return nsnull != mFirstChild; + } + + PRBool ContainsFrame(const nsIFrame* aFrame) const; PRInt32 GetLength() const; diff --git a/mozilla/layout/html/base/src/nsHTMLAtoms.cpp b/mozilla/layout/html/base/src/nsHTMLAtoms.cpp index 6dea38bda1f..b7e8033bd81 100644 --- a/mozilla/layout/html/base/src/nsHTMLAtoms.cpp +++ b/mozilla/layout/html/base/src/nsHTMLAtoms.cpp @@ -19,6 +19,7 @@ // XXX make this be autogenerated. doh! +nsIAtom* nsHTMLAtoms::mozAnonymousBlock; nsIAtom* nsHTMLAtoms::_baseHref; nsIAtom* nsHTMLAtoms::_baseTarget; nsIAtom* nsHTMLAtoms::a; @@ -256,6 +257,8 @@ static nsrefcnt gRefCnt; void nsHTMLAtoms::AddrefAtoms() { if (0 == gRefCnt) { + mozAnonymousBlock = NS_NewAtom(":MOZ-ANONYMOUS-BLOCK"); + _baseHref = NS_NewAtom(NS_HTML_BASE_HREF); _baseTarget = NS_NewAtom(NS_HTML_BASE_TARGET); a = NS_NewAtom("A"); @@ -493,6 +496,7 @@ void nsHTMLAtoms::ReleaseAtoms() { NS_PRECONDITION(gRefCnt != 0, "bad release atoms"); if (--gRefCnt == 0) { + NS_RELEASE(mozAnonymousBlock); NS_RELEASE(_baseHref); NS_RELEASE(_baseTarget); NS_RELEASE(a); diff --git a/mozilla/layout/html/base/src/nsHTMLAtoms.h b/mozilla/layout/html/base/src/nsHTMLAtoms.h index 8bfc9838700..9a2da18d033 100644 --- a/mozilla/layout/html/base/src/nsHTMLAtoms.h +++ b/mozilla/layout/html/base/src/nsHTMLAtoms.h @@ -35,6 +35,8 @@ public: static void AddrefAtoms(); static void ReleaseAtoms(); + static nsIAtom* mozAnonymousBlock; + // Special attribute atoms static nsIAtom* _baseHref; static nsIAtom* _baseTarget; diff --git a/mozilla/layout/html/base/src/nsHTMLContainerFrame.cpp b/mozilla/layout/html/base/src/nsHTMLContainerFrame.cpp index 36ef2236ddd..8ace5c5364b 100644 --- a/mozilla/layout/html/base/src/nsHTMLContainerFrame.cpp +++ b/mozilla/layout/html/base/src/nsHTMLContainerFrame.cpp @@ -136,75 +136,6 @@ nsHTMLContainerFrame::MoveFrameOutOfFlow(nsIPresContext& aPresContext, return PR_FALSE; } -//XXX handle replace reflow command -NS_METHOD nsHTMLContainerFrame::AddFrame(const nsHTMLReflowState& aReflowState, - nsIFrame * aAddedFrame) -{ - nsresult rv=NS_OK; - nsIReflowCommand::ReflowType type; - aReflowState.reflowCommand->GetType(type); - // we have a generic frame that gets inserted but doesn't effect reflow - // hook it up then ignore it - if (nsIReflowCommand::FrameAppended==type) - { // frameAppended reflow -- find the last child and make aInsertedFrame its next sibling - nsIFrame *lastChild=mFirstChild; - nsIFrame *nextChild=mFirstChild; - while (nsnull!=nextChild) - { - lastChild=nextChild; - nextChild->GetNextSibling(nextChild); - } - if (nsnull==lastChild) - mFirstChild = aAddedFrame; - else - lastChild->SetNextSibling(aAddedFrame); - } - else if (nsIReflowCommand::FrameInserted==type) - { // frameInserted reflow -- hook up aInsertedFrame as prevSibling's next sibling, - // and be sure to hook in aInsertedFrame's nextSibling (from prevSibling) - nsIFrame *prevSibling=nsnull; - rv = aReflowState.reflowCommand->GetPrevSiblingFrame(prevSibling); - if (NS_SUCCEEDED(rv) && (nsnull!=prevSibling)) - { - nsIFrame *nextSibling=nsnull; - prevSibling->GetNextSibling(nextSibling); - prevSibling->SetNextSibling(aAddedFrame); - aAddedFrame->SetNextSibling(nextSibling); - } - else - { - nsIFrame *nextSibling = mFirstChild; - mFirstChild = aAddedFrame; - aAddedFrame->SetNextSibling(nextSibling); - } - } - else - { - NS_ASSERTION(PR_FALSE, "bad reflow type"); - rv = NS_ERROR_UNEXPECTED; - } - return rv; -} - /** */ -NS_METHOD nsHTMLContainerFrame::RemoveFrame(nsIFrame * aRemovedFrame) -{ - nsIFrame *prevChild=nsnull; - nsIFrame *nextChild=mFirstChild; - while (nextChild!=aRemovedFrame) - { - prevChild=nextChild; - nextChild->GetNextSibling(nextChild); - } - nextChild=nsnull; - aRemovedFrame->GetNextSibling(nextChild); - if (nsnull==prevChild) // objectFrame was first child - mFirstChild = nextChild; - else - prevChild->SetNextSibling(nextChild); - return NS_OK;; -} - - /** * Create a next-in-flow for aFrame. Will return the newly created * frame in aNextInFlowResult if and only if a new frame is diff --git a/mozilla/layout/html/base/src/nsHTMLContainerFrame.h b/mozilla/layout/html/base/src/nsHTMLContainerFrame.h index 009a155893b..2c2b8006b37 100644 --- a/mozilla/layout/html/base/src/nsHTMLContainerFrame.h +++ b/mozilla/layout/html/base/src/nsHTMLContainerFrame.h @@ -33,28 +33,22 @@ public: nsIRenderingContext& aRenderingContext, const nsRect& aDirtyRect, nsFramePaintLayer aWhichLayer); + nsPlaceholderFrame* CreatePlaceholderFrame(nsIPresContext& aPresContext, nsIFrame* aFloatedFrame); - // If the frame should be floated or absolutely positioned creates a placeholder - // frame and returns PR_TRUE. The sibling list is modified so aFrame's next - // sibling pointer is set to nsnull, and aPlaceholderFrame's sibling pointer - // is set to what aFrame's sibling pointer was. It's up to the caller to adjust - // any previous sibling pointers. + // If the frame should be floated or absolutely positioned creates a + // placeholder frame and returns PR_TRUE. The sibling list is + // modified so aFrame's next sibling pointer is set to nsnull, and + // aPlaceholderFrame's sibling pointer is set to what aFrame's + // sibling pointer was. It's up to the caller to adjust any previous + // sibling pointers. PRBool MoveFrameOutOfFlow(nsIPresContext& aPresContext, nsIFrame* aFrame, const nsStyleDisplay* aDisplay, const nsStylePosition* aPosition, nsIFrame*& aPlaceholderFrame); - /* helper methods for incremental reflow */ - /** */ - NS_IMETHOD AddFrame(const nsHTMLReflowState& aReflowState, - nsIFrame * aAddedFrame); - /** */ - NS_IMETHOD RemoveFrame(nsIFrame * aRemovedFrame); - - // Helper method to create next-in-flows if necessary static nsresult CreateNextInFlow(nsIPresContext& aPresContext, nsIFrame* aOuterFrame, diff --git a/mozilla/layout/html/base/src/nsHTMLFrame.cpp b/mozilla/layout/html/base/src/nsHTMLFrame.cpp index a790a36fefd..65b05695ad2 100644 --- a/mozilla/layout/html/base/src/nsHTMLFrame.cpp +++ b/mozilla/layout/html/base/src/nsHTMLFrame.cpp @@ -93,7 +93,7 @@ RootFrame::SetInitialChildList(nsIPresContext& aPresContext, nsIAtom* aListName, nsIFrame* aChildList) { - mFirstChild = aChildList; + mFrames.SetFrames(aChildList); return NS_OK; } @@ -126,11 +126,11 @@ RootFrame::Reflow(nsIPresContext& aPresContext, if ((nsIReflowCommand::FrameAppended == reflowType) || (nsIReflowCommand::FrameInserted == reflowType)) { - NS_ASSERTION(nsnull == mFirstChild, "only one child frame allowed"); + NS_ASSERTION(mFrames.IsEmpty(), "only one child frame allowed"); // Insert the frame into the child list aReflowState.reflowCommand->GetChildFrame(childFrame); - mFirstChild = childFrame; + mFrames.SetFrames(childFrame); // It's the child frame's initial reflow isChildInitialReflow = PR_TRUE; @@ -140,19 +140,16 @@ RootFrame::Reflow(nsIPresContext& aPresContext, // Get the child frame we should delete aReflowState.reflowCommand->GetChildFrame(deletedFrame); - NS_ASSERTION(deletedFrame == mFirstChild, "not a child frame"); + NS_ASSERTION(deletedFrame == mFrames.FirstChild(), "not a child frame"); // Remove it from the child list - if (deletedFrame == mFirstChild) { - mFirstChild = nsnull; - + if (deletedFrame == mFrames.FirstChild()) { // Damage the area occupied by the deleted frame nsRect damageRect; deletedFrame->GetRect(damageRect); Invalidate(damageRect, PR_FALSE); - // Delete the frame - deletedFrame->DeleteFrame(aPresContext); + mFrames.DeleteFrame(aPresContext, deletedFrame); } } @@ -160,17 +157,20 @@ RootFrame::Reflow(nsIPresContext& aPresContext, nsIFrame* nextFrame; // Get the next frame in the reflow chain aReflowState.reflowCommand->GetNext(nextFrame); - NS_ASSERTION(nextFrame == mFirstChild, "unexpected next reflow command frame"); + NS_ASSERTION(nextFrame == mFrames.FirstChild(), "unexpected next reflow command frame"); } } // Reflow our one and only child frame - if (nsnull != mFirstChild) { + if (mFrames.NotEmpty()) { + nsIFrame* myOnlyChild = mFrames.FirstChild(); + // Note: the root frame does not have border or padding... nsHTMLReflowMetrics desiredSize(nsnull); // We must pass in that the available height is unconstrained, because // constrained is only for when we're paginated... - nsHTMLReflowState kidReflowState(aPresContext, mFirstChild, aReflowState, + nsHTMLReflowState kidReflowState(aPresContext, myOnlyChild, + aReflowState, nsSize(aReflowState.availableWidth, NS_UNCONSTRAINEDSIZE)); if (isChildInitialReflow) { kidReflowState.reason = eReflowReason_Initial; @@ -186,18 +186,19 @@ RootFrame::Reflow(nsIPresContext& aPresContext, // Computed height is for the content area so reduce it by the amount of // space taken up by border and padding nsMargin borderPadding; - kidReflowState.ComputeBorderPaddingFor(mFirstChild, &aReflowState, borderPadding); + kidReflowState.ComputeBorderPaddingFor(myOnlyChild, &aReflowState, borderPadding); kidReflowState.computedHeight -= borderPadding.top + borderPadding.bottom; } // Reflow the frame nsIHTMLReflow* htmlReflow; - if (NS_OK == mFirstChild->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { - ReflowChild(mFirstChild, aPresContext, desiredSize, kidReflowState, aStatus); + if (NS_OK == myOnlyChild->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { + ReflowChild(myOnlyChild, aPresContext, desiredSize, kidReflowState, + aStatus); nsRect rect(kidReflowState.computedLeftMargin, kidReflowState.computedTopMargin, desiredSize.width, desiredSize.height); - mFirstChild->SetRect(rect); + myOnlyChild->SetRect(rect); // XXX We should resolve the details of who/when DidReflow() // notifications are sent... diff --git a/mozilla/layout/html/base/src/nsPageFrame.cpp b/mozilla/layout/html/base/src/nsPageFrame.cpp index 68da48b3a64..b8ca5f23e46 100644 --- a/mozilla/layout/html/base/src/nsPageFrame.cpp +++ b/mozilla/layout/html/base/src/nsPageFrame.cpp @@ -45,16 +45,18 @@ NS_METHOD nsPageFrame::Reflow(nsIPresContext& aPresContext, // Verify the next reflow command frame is our one and only child frame nsIFrame* next; aReflowState.reflowCommand->GetNext(next); - NS_ASSERTION(next == mFirstChild, "bad reflow frame"); + NS_ASSERTION(next == mFrames.FirstChild(), "bad reflow frame"); // Dispatch the reflow command to our content child. Allow it to be as high // as it wants nsSize maxSize(aReflowState.availableWidth, NS_UNCONSTRAINEDSIZE); - nsHTMLReflowState kidReflowState(aPresContext, mFirstChild, aReflowState, + nsHTMLReflowState kidReflowState(aPresContext, mFrames.FirstChild(), + aReflowState, maxSize); kidReflowState.isTopOfPage = PR_TRUE; - ReflowChild(mFirstChild, aPresContext, aDesiredSize, kidReflowState, aStatus); + ReflowChild(mFrames.FirstChild(), aPresContext, aDesiredSize, + kidReflowState, aStatus); // Place and size the child. Make sure the child is at least as // tall as our max size (the containing window) @@ -63,36 +65,40 @@ NS_METHOD nsPageFrame::Reflow(nsIPresContext& aPresContext, } nsRect rect(0, 0, aDesiredSize.width, aDesiredSize.height); - mFirstChild->SetRect(rect); + mFrames.FirstChild()->SetRect(rect); } else { // Do we have any children? // XXX We should use the overflow list instead... - if ((nsnull == mFirstChild) && (nsnull != mPrevInFlow)) { + if (mFrames.IsEmpty() && (nsnull != mPrevInFlow)) { nsPageFrame* prevPage = (nsPageFrame*)mPrevInFlow; - nsIFrame* prevLastChild = prevPage->LastFrame(prevPage->mFirstChild); + nsIFrame* prevLastChild = prevPage->mFrames.LastChild(); // Create a continuing child of the previous page's last child nsIStyleContext* kidSC; prevLastChild->GetStyleContext(kidSC); + nsIFrame* newFrame; nsresult rv = prevLastChild->CreateContinuingFrame(aPresContext, this, - kidSC, mFirstChild); + kidSC, + newFrame); + mFrames.SetFrames(newFrame); NS_RELEASE(kidSC); } // Resize our frame allowing it only to be as big as we are // XXX Pay attention to the page's border and padding... - if (nsnull != mFirstChild) { + if (mFrames.NotEmpty()) { + nsIFrame* frame = mFrames.FirstChild(); nsSize maxSize(aReflowState.availableWidth, aReflowState.availableHeight); - nsHTMLReflowState kidReflowState(aPresContext, mFirstChild, aReflowState, + nsHTMLReflowState kidReflowState(aPresContext, frame, aReflowState, maxSize); kidReflowState.isTopOfPage = PR_TRUE; nsIHTMLReflow* htmlReflow; - if (NS_OK == mFirstChild->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { + if (NS_OK == frame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { // Get the child's desired size - ReflowChild(mFirstChild, aPresContext, aDesiredSize, kidReflowState, aStatus); + ReflowChild(frame, aPresContext, aDesiredSize, kidReflowState, aStatus); // Make sure the child is at least as tall as our max size (the containing window) if (aDesiredSize.height < aReflowState.availableHeight) { @@ -101,7 +107,7 @@ NS_METHOD nsPageFrame::Reflow(nsIPresContext& aPresContext, // Place and size the child nsRect rect(0, 0, aDesiredSize.width, aDesiredSize.height); - mFirstChild->SetRect(rect); + frame->SetRect(rect); // XXX Should we be sending the DidReflow? htmlReflow->DidReflow(aPresContext, NS_FRAME_REFLOW_FINISHED); @@ -109,7 +115,7 @@ NS_METHOD nsPageFrame::Reflow(nsIPresContext& aPresContext, if (NS_FRAME_IS_COMPLETE(aStatus)) { nsIFrame* childNextInFlow; - mFirstChild->GetNextInFlow(childNextInFlow); + frame->GetNextInFlow(childNextInFlow); NS_ASSERTION(nsnull == childNextInFlow, "bad child flow list"); } } diff --git a/mozilla/layout/html/base/src/nsScrollFrame.cpp b/mozilla/layout/html/base/src/nsScrollFrame.cpp index 0f2c9a6a2ed..ed9b213d641 100644 --- a/mozilla/layout/html/base/src/nsScrollFrame.cpp +++ b/mozilla/layout/html/base/src/nsScrollFrame.cpp @@ -99,20 +99,21 @@ nsScrollFrame::SetInitialChildList(nsIPresContext& aPresContext, nsresult rv = nsHTMLContainerFrame::SetInitialChildList(aPresContext, aListName, aChildList); + nsIFrame* frame = mFrames.FirstChild(); + #ifdef NS_DEBUG // Verify that the scrolled frame has a view nsIView* scrolledView; - - mFirstChild->GetView(scrolledView); + frame->GetView(scrolledView); NS_ASSERTION(nsnull != scrolledView, "no view"); #endif // We need to allow the view's position to be different than the // frame's position nsFrameState state; - mFirstChild->GetFrameState(state); + frame->GetFrameState(state); state &= ~NS_FRAME_SYNC_FRAME_AND_VIEW; - mFirstChild->SetFrameState(state); + frame->SetFrameState(state); return rv; } @@ -129,9 +130,10 @@ nsScrollFrame::DidReflow(nsIPresContext& aPresContext, rv = nsFrame::DidReflow(aPresContext, aStatus); // Send the DidReflow notification to the scrolled frame's view + nsIFrame* frame = mFrames.FirstChild(); nsIHTMLReflow* htmlReflow; - - mFirstChild->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow); + + frame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow); htmlReflow->DidReflow(aPresContext, aStatus); // Size the scrolled frame's view. Leave its position alone @@ -139,8 +141,8 @@ nsScrollFrame::DidReflow(nsIPresContext& aPresContext, nsIViewManager* vm; nsIView* scrolledView; - mFirstChild->GetSize(size); - mFirstChild->GetView(scrolledView); + frame->GetSize(size); + frame->GetView(scrolledView); scrolledView->GetViewManager(vm); vm->ResizeView(scrolledView, size.width, size.height); NS_RELEASE(vm); @@ -267,7 +269,7 @@ nsScrollFrame::Reflow(nsIPresContext& aPresContext, // Get the next frame in the reflow chain, and verify that it's our // child frame aReflowState.reflowCommand->GetNext(nextFrame); - NS_ASSERTION(nextFrame == mFirstChild, "unexpected reflow command next-frame"); + NS_ASSERTION(nextFrame == mFrames.FirstChild(), "unexpected reflow command next-frame"); } // Calculate the amount of space needed for borders @@ -316,12 +318,14 @@ nsScrollFrame::Reflow(nsIPresContext& aPresContext, // Reflow the child and get its desired size. Let it be as high as it // wants + nsIFrame* myOnlyChild = mFrames.FirstChild(); nsSize kidReflowSize(scrollAreaSize.width, NS_UNCONSTRAINEDSIZE); - nsHTMLReflowState kidReflowState(aPresContext, mFirstChild, aReflowState, + nsHTMLReflowState kidReflowState(aPresContext, myOnlyChild, aReflowState, kidReflowSize); nsHTMLReflowMetrics kidDesiredSize(aDesiredSize.maxElementSize); - ReflowChild(mFirstChild, aPresContext, kidDesiredSize, kidReflowState, aStatus); + ReflowChild(myOnlyChild, aPresContext, kidDesiredSize, kidReflowState, + aStatus); NS_ASSERTION(NS_FRAME_IS_COMPLETE(aStatus), "bad status"); // Make sure the height of the scrolled frame fills the entire scroll area, @@ -356,7 +360,7 @@ nsScrollFrame::Reflow(nsIPresContext& aPresContext, // Place and size the child. nsRect rect(border.left, border.top, kidDesiredSize.width, kidDesiredSize.height); - mFirstChild->SetRect(rect); + myOnlyChild->SetRect(rect); // XXX Moved to root frame #if 0 diff --git a/mozilla/layout/html/base/src/nsSimplePageSequence.cpp b/mozilla/layout/html/base/src/nsSimplePageSequence.cpp index 32da367e450..afdcc277fbe 100644 --- a/mozilla/layout/html/base/src/nsSimplePageSequence.cpp +++ b/mozilla/layout/html/base/src/nsSimplePageSequence.cpp @@ -87,7 +87,8 @@ nsSimplePageSequenceFrame::Reflow(nsIPresContext& aPresContext, aReflowState.reflowCommand->GetNext(nextFrame); // Compute the y-offset of this page - for (nsIFrame* f = mFirstChild; f != nextFrame; f->GetNextSibling(f)) { + for (nsIFrame* f = mFrames.FirstChild(); f != nextFrame; + f->GetNextSibling(f)) { nsSize size; f->GetSize(size); @@ -124,7 +125,7 @@ nsSimplePageSequenceFrame::Reflow(nsIPresContext& aPresContext, // Tile the pages vertically nsHTMLReflowMetrics kidSize(nsnull); - for (nsIFrame* kidFrame = mFirstChild; nsnull != kidFrame; ) { + for (nsIFrame* kidFrame = mFrames.FirstChild(); nsnull != kidFrame; ) { // Reflow the page nsHTMLReflowState kidReflowState(aPresContext, kidFrame, aReflowState, pageSize, @@ -258,7 +259,7 @@ nsSimplePageSequenceFrame::Print(nsIPresContext& aPresContext, { // If printing a range of pages make sure at least the starting page // number is valid - PRInt32 totalPages = LengthOf(mFirstChild); + PRInt32 totalPages = mFrames.GetLength(); if (ePrintRange_SpecifiedRange == aPrintOptions.range) { if (aPrintOptions.startPage > totalPages) { @@ -275,7 +276,7 @@ nsSimplePageSequenceFrame::Print(nsIPresContext& aPresContext, // Print each specified page PRInt32 pageNum = 1; - for (nsIFrame* page = mFirstChild; nsnull != page; page->GetNextSibling(page)) { + for (nsIFrame* page = mFrames.FirstChild(); nsnull != page; page->GetNextSibling(page)) { // See whether we should print this page PRBool printThisPage = PR_TRUE; diff --git a/mozilla/layout/html/document/src/nsFrameFrame.cpp b/mozilla/layout/html/document/src/nsFrameFrame.cpp index 9031b477968..fb74b673251 100644 --- a/mozilla/layout/html/document/src/nsFrameFrame.cpp +++ b/mozilla/layout/html/document/src/nsFrameFrame.cpp @@ -211,8 +211,9 @@ nscoord nsHTMLFrameOuterFrame::GetBorderWidth(nsIPresContext& aPresContext) { if (IsInline()) { - if (nsnull != mFirstChild) { - if (eFrameborder_No != ((nsHTMLFrameInnerFrame*)mFirstChild)->GetFrameBorder(eCompatibility_Standard)) { + nsIFrame* firstChild = mFrames.FirstChild(); + if (nsnull != FirstChild) { + if (eFrameborder_No != ((nsHTMLFrameInnerFrame*)firstChild)->GetFrameBorder(eCompatibility_Standard)) { const nsStyleSpacing* spacing = (const nsStyleSpacing*)mStyleContext->GetStyleData(eStyleStruct_Spacing); nsStyleCoord leftBorder; @@ -281,9 +282,10 @@ nsHTMLFrameOuterFrame::Paint(nsIPresContext& aPresContext, nsFramePaintLayer aWhichLayer) { //printf("outer paint %X (%d,%d,%d,%d) \n", this, aDirtyRect.x, aDirtyRect.y, aDirtyRect.width, aDirtyRect.height); - if (nsnull != mFirstChild) { - mFirstChild->Paint(aPresContext, aRenderingContext, aDirtyRect, - aWhichLayer); + nsIFrame* firstChild = mFrames.FirstChild(); + if (nsnull != firstChild) { + firstChild->Paint(aPresContext, aRenderingContext, aDirtyRect, + aWhichLayer); } if (IsInline()) { return nsHTMLContainerFrame::Paint(aPresContext, aRenderingContext, @@ -316,10 +318,12 @@ nsHTMLFrameOuterFrame::Reflow(nsIPresContext& aPresContext, aDesiredSize.height = aReflowState.availableHeight; } - if (nsnull == mFirstChild) { - mFirstChild = new nsHTMLFrameInnerFrame; + nsIFrame* firstChild = mFrames.FirstChild(); + if (nsnull == firstChild) { + firstChild = new nsHTMLFrameInnerFrame; + mFrames.SetFrames(firstChild); // XXX temporary! use style system to get correct style! - mFirstChild->Init(aPresContext, mContent, this, mStyleContext); + firstChild->Init(aPresContext, mContent, this, mStyleContext); } // nsContainerFrame::PaintBorder has some problems, kludge it here @@ -329,17 +333,17 @@ nsHTMLFrameOuterFrame::Reflow(nsIPresContext& aPresContext, // Reflow the child and get its desired size nsHTMLReflowMetrics kidMetrics(aDesiredSize.maxElementSize); - nsHTMLReflowState kidReflowState(aPresContext, mFirstChild, aReflowState, + nsHTMLReflowState kidReflowState(aPresContext, firstChild, aReflowState, innerSize); nsIHTMLReflow* htmlReflow; - if (NS_OK == mFirstChild->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { - ReflowChild(mFirstChild, aPresContext, kidMetrics, kidReflowState, aStatus); + if (NS_OK == firstChild->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { + ReflowChild(firstChild, aPresContext, kidMetrics, kidReflowState, aStatus); NS_ASSERTION(NS_FRAME_IS_COMPLETE(aStatus), "bad status"); // Place and size the child nsRect rect(borderWidth, borderWidth, innerSize.width, innerSize.height); - mFirstChild->SetRect(rect); + firstChild->SetRect(rect); } // XXX what should the max-element-size of an iframe be? Shouldn't @@ -373,8 +377,9 @@ nsHTMLFrameOuterFrame::AttributeChanged(nsIPresContext* aPresContext, { if (nsHTMLAtoms::src == aAttribute) { printf("got a request\n"); - if (nsnull != mFirstChild) { - ((nsHTMLFrameInnerFrame*)mFirstChild)->ReloadURL(); + nsIFrame* firstChild = mFrames.FirstChild(); + if (nsnull != firstChild) { + ((nsHTMLFrameInnerFrame*)firstChild)->ReloadURL(); } } return NS_OK; diff --git a/mozilla/layout/html/document/src/nsFrameSetFrame.cpp b/mozilla/layout/html/document/src/nsFrameSetFrame.cpp index 2231798136c..43aecdc1221 100644 --- a/mozilla/layout/html/document/src/nsFrameSetFrame.cpp +++ b/mozilla/layout/html/document/src/nsFrameSetFrame.cpp @@ -416,7 +416,8 @@ void nsHTMLFramesetFrame::GetSizeOfChild(nsIFrame* aChild, // Reflow only creates children frames for and content. // this assumption is used here int i = 0; - for (nsIFrame* child = mFirstChild; child; child->GetNextSibling(child)) { + for (nsIFrame* child = mFrames.FirstChild(); child; + child->GetNextSibling(child)) { if (aChild == child) { nsPoint ignore; GetSizeOfChildAt(i, aSize, ignore); @@ -962,7 +963,7 @@ nsHTMLFramesetFrame::Reflow(nsIPresContext& aPresContext, } if (nsnull == lastChild) { - mFirstChild = frame; + mFrames.SetFrames(frame); } else { lastChild->SetNextSibling(frame); } @@ -983,7 +984,7 @@ nsHTMLFramesetFrame::Reflow(nsIPresContext& aPresContext, NS_RELEASE(pseudoStyleContext); if (nsnull == lastChild) { - mFirstChild = blankFrame; + mFrames.SetFrames(blankFrame); } else { lastChild->SetNextSibling(blankFrame); } @@ -1003,7 +1004,7 @@ nsHTMLFramesetFrame::Reflow(nsIPresContext& aPresContext, nsHTMLFramesetBorderFrame* borderFrame = nsnull; nsPoint offset(0,0); nsSize size, lastSize; - nsIFrame* child = mFirstChild; + nsIFrame* child = mFrames.FirstChild(); for (PRInt32 childX = 0; childX < mNonBorderChildCount; childX++) { nsPoint cellIndex; @@ -1028,7 +1029,7 @@ nsHTMLFramesetFrame::Reflow(nsIPresContext& aPresContext, borderFrame->mPrevNeighbor = lastRow; borderFrame->mNextNeighbor = cellIndex.y; } else { - borderFrame = (nsHTMLFramesetBorderFrame*)FrameAt(mFirstChild, borderChildX); + borderFrame = (nsHTMLFramesetBorderFrame*)mFrames.FrameAt(borderChildX); borderChildX++; } nsSize borderSize(aDesiredSize.width, borderWidth); @@ -1053,7 +1054,7 @@ nsHTMLFramesetFrame::Reflow(nsIPresContext& aPresContext, borderFrame->mPrevNeighbor = lastCol; borderFrame->mNextNeighbor = cellIndex.x; } else { - borderFrame = (nsHTMLFramesetBorderFrame*)FrameAt(mFirstChild, borderChildX); + borderFrame = (nsHTMLFramesetBorderFrame*)mFrames.FrameAt(borderChildX); borderChildX++; } nsSize borderSize(borderWidth, aDesiredSize.height); @@ -1211,7 +1212,7 @@ nsHTMLFramesetFrame::CanResize(PRBool aVertical, PRBool aLeft) if (aVertical) { startX = (aLeft) ? 0 : mNumCols-1; for (childX = startX; childX < mNonBorderChildCount; childX += mNumCols) { - child = FrameAt(mFirstChild, childX); + child = mFrames.FrameAt(childX); if (!CanChildResize(aVertical, aLeft, childX, ChildIsFrameset(child))) { return PR_FALSE; } @@ -1220,7 +1221,7 @@ nsHTMLFramesetFrame::CanResize(PRBool aVertical, PRBool aLeft) startX = (aLeft) ? 0 : (mNumRows - 1) * mNumCols; PRInt32 endX = startX + mNumCols; for (childX = startX; childX < endX; childX++) { - child = FrameAt(mFirstChild, childX); + child = mFrames.FrameAt(childX); if (!CanChildResize(aVertical, aLeft, childX, ChildIsFrameset(child))) { return PR_FALSE; } @@ -1253,7 +1254,7 @@ nsHTMLFramesetFrame::GetNoResize(nsIFrame* aChildFrame) PRBool nsHTMLFramesetFrame::CanChildResize(PRBool aVertical, PRBool aLeft, PRInt32 aChildX, PRBool aFrameset) { - nsIFrame* child = FrameAt(mFirstChild, aChildX); + nsIFrame* child = mFrames.FrameAt(aChildX); if (aFrameset) { return ((nsHTMLFramesetFrame*)child)->CanResize(aVertical, aLeft); } else {