From 3b069db273817bbf3f852ee92906f6744db76284 Mon Sep 17 00:00:00 2001 From: "bzbarsky%mit.edu" Date: Thu, 16 Jan 2003 02:59:04 +0000 Subject: [PATCH] Move GetFirstInFlow/GetLastInFlow up to nsIFrame. Bug 187117, r=roc+moz, sr=dbaron --- layout/base/nsCSSFrameConstructor.cpp | 40 +++---------------- layout/base/nsFrameContentIterator.cpp | 10 +---- layout/base/nsLayoutUtils.cpp | 18 ++------- layout/base/public/nsIFrame.h | 14 +++++++ layout/base/src/nsLayoutUtils.cpp | 18 ++------- layout/generic/nsFrame.cpp | 8 +--- layout/generic/nsIFrame.h | 14 +++++++ layout/generic/nsSplittableFrame.cpp | 8 ++-- layout/generic/nsSplittableFrame.h | 4 +- layout/generic/nsTextFrame.cpp | 33 ++++++++++----- layout/html/base/src/nsFrame.cpp | 8 +--- layout/html/base/src/nsSplittableFrame.cpp | 8 ++-- layout/html/base/src/nsSplittableFrame.h | 4 +- layout/html/base/src/nsTextFrame.cpp | 33 ++++++++++----- .../html/style/src/nsCSSFrameConstructor.cpp | 40 +++---------------- .../html/style/src/nsFrameContentIterator.cpp | 10 +---- 16 files changed, 108 insertions(+), 162 deletions(-) diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index 68234bc4ef6c..77b58fa99fe1 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -378,13 +378,7 @@ GetSpecialSibling(nsIFrameManager* aFrameManager, nsIFrame* aFrame, nsIFrame** a { // We only store the "special sibling" annotation with the first // frame in the flow. Walk back to find that frame now. - while (1) { - nsIFrame* prev = aFrame; - aFrame->GetPrevInFlow(&prev); - if (! prev) - break; - aFrame = prev; - } + aFrame = aFrame->GetFirstInFlow(); void* value; aFrameManager->GetFrameProperty(aFrame, nsLayoutAtoms::IBSplitSpecialSibling, 0, &value); @@ -7930,13 +7924,7 @@ FindPreviousAnonymousSibling(nsIPresShell* aPresShell, if (prevSibling) { // The frame may have a continuation. If so, we want the // last-in-flow as our previous sibling. - nsIFrame* nextInFlow; - while (1) { - prevSibling->GetNextInFlow(&nextInFlow); - if (! nextInFlow) - break; - prevSibling = nextInFlow; - } + prevSibling = prevSibling->GetLastInFlow(); // If the frame is out-of-flow, GPFF() will have returned the // out-of-flow frame; we want the placeholder. @@ -8134,13 +8122,7 @@ nsCSSFrameConstructor::FindPreviousSibling(nsIPresShell* aPresShell, if (prevSibling) { // The frame may have a continuation. Get the last-in-flow - nsIFrame* nextInFlow; - while (1) { - prevSibling->GetNextInFlow(&nextInFlow); - if (! nextInFlow) - break; - prevSibling = nextInFlow; - } + prevSibling = prevSibling->GetLastInFlow(); // If the frame is out-of-flow, GPFF() will have returned the // out-of-flow frame; we want the placeholder. @@ -8501,13 +8483,7 @@ nsCSSFrameConstructor::ContentAppended(nsIPresContext* aPresContext, } // Get the parent frame's last-in-flow - nsIFrame* nextInFlow = parentFrame; - while (nsnull != nextInFlow) { - parentFrame->GetNextInFlow(&nextInFlow); - if (nsnull != nextInFlow) { - parentFrame = nextInFlow; - } - } + parentFrame = parentFrame->GetLastInFlow(); // If we didn't process children when we originally created the frame, // then don't do any processing now @@ -14113,13 +14089,7 @@ nsCSSFrameConstructor::SplitToContainingBlock(nsIPresContext* aPresContext, // newly created anonymous frames. We need to create the linkage // between the first in flow, so if we're a continuation frame, walk // back to find it. - nsIFrame* firstInFlow = aFrame; - while (1) { - nsIFrame* prevInFlow; - firstInFlow->GetPrevInFlow(&prevInFlow); - if (! prevInFlow) break; - firstInFlow = prevInFlow; - } + nsIFrame* firstInFlow = aFrame->GetFirstInFlow(); SetFrameIsSpecial(aState.mFrameManager, firstInFlow, blockFrame); SetFrameIsSpecial(aState.mFrameManager, blockFrame, inlineFrame); diff --git a/layout/base/nsFrameContentIterator.cpp b/layout/base/nsFrameContentIterator.cpp index a8b7fff2fa5e..3bdf2f76e1bf 100644 --- a/layout/base/nsFrameContentIterator.cpp +++ b/layout/base/nsFrameContentIterator.cpp @@ -97,15 +97,7 @@ GetNextChildFrame(nsIPresContext* aPresContext, nsIFrame* aFrame) NS_PRECONDITION(aFrame, "null pointer"); // Get the last-in-flow - while (PR_TRUE) { - nsIFrame* nextInFlow; - aFrame->GetNextInFlow(&nextInFlow); - if (nextInFlow) { - aFrame = nextInFlow; - } else { - break; - } - } + aFrame = aFrame->GetLastInFlow(); // Get its next sibling nsIFrame* nextSibling; diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index 27bcdd55356e..368b9db91641 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -93,11 +93,7 @@ GetLastChildFrame(nsIPresContext* aPresContext, NS_PRECONDITION(aFrame, "NULL frame pointer"); // Get the last in flow frame - nsIFrame* lastInFlow; - do { - lastInFlow = aFrame; - lastInFlow->GetNextInFlow(&aFrame); - } while (aFrame); + nsIFrame* lastInFlow = aFrame->GetLastInFlow(); // Get the last child frame nsIFrame* firstChildFrame; @@ -110,16 +106,8 @@ GetLastChildFrame(nsIPresContext* aPresContext, // Get the frame's first-in-flow. This matters in case the frame has // been continuted across multiple lines - while (PR_TRUE) { - nsIFrame* prevInFlow; - lastChildFrame->GetPrevInFlow(&prevInFlow); - if (prevInFlow) { - lastChildFrame = prevInFlow; - } else { - break; - } - } - + lastChildFrame = lastChildFrame->GetFirstInFlow(); + // If the last child frame is a pseudo-frame, then return its last child. // Note that the frame we create for the generated content is also a // pseudo-frame and so don't drill down in that case diff --git a/layout/base/public/nsIFrame.h b/layout/base/public/nsIFrame.h index dc08f38859d3..adb6fceba853 100644 --- a/layout/base/public/nsIFrame.h +++ b/layout/base/public/nsIFrame.h @@ -877,6 +877,20 @@ public: NS_IMETHOD GetNextInFlow(nsIFrame** aNextInFlow) const = 0; NS_IMETHOD SetNextInFlow(nsIFrame*) = 0; + /** + * Return the first frame in our current flow. + */ + virtual nsIFrame* GetFirstInFlow() const { + return NS_CONST_CAST(nsIFrame*, this); + } + + /** + * Return the last frame in our current flow. + */ + virtual nsIFrame* GetLastInFlow() const { + return NS_CONST_CAST(nsIFrame*, this); + } + /** * Pre-reflow hook. Before a frame is reflowed this method will be called. * This call will always be invoked at least once before a subsequent Reflow diff --git a/layout/base/src/nsLayoutUtils.cpp b/layout/base/src/nsLayoutUtils.cpp index 27bcdd55356e..368b9db91641 100644 --- a/layout/base/src/nsLayoutUtils.cpp +++ b/layout/base/src/nsLayoutUtils.cpp @@ -93,11 +93,7 @@ GetLastChildFrame(nsIPresContext* aPresContext, NS_PRECONDITION(aFrame, "NULL frame pointer"); // Get the last in flow frame - nsIFrame* lastInFlow; - do { - lastInFlow = aFrame; - lastInFlow->GetNextInFlow(&aFrame); - } while (aFrame); + nsIFrame* lastInFlow = aFrame->GetLastInFlow(); // Get the last child frame nsIFrame* firstChildFrame; @@ -110,16 +106,8 @@ GetLastChildFrame(nsIPresContext* aPresContext, // Get the frame's first-in-flow. This matters in case the frame has // been continuted across multiple lines - while (PR_TRUE) { - nsIFrame* prevInFlow; - lastChildFrame->GetPrevInFlow(&prevInFlow); - if (prevInFlow) { - lastChildFrame = prevInFlow; - } else { - break; - } - } - + lastChildFrame = lastChildFrame->GetFirstInFlow(); + // If the last child frame is a pseudo-frame, then return its last child. // Note that the frame we create for the generated content is also a // pseudo-frame and so don't drill down in that case diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index 0586ea901d62..334e3c9a80ce 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -4432,13 +4432,7 @@ GetIBSpecialSibling(nsIPresContext* aPresContext, // Find the first-in-flow of the frame. (Ugh. This ends up // being O(N^2) when it is called O(N) times.) - for (;;) { - nsIFrame *prevInFlow; - aFrame->GetPrevInFlow(&prevInFlow); - if (!prevInFlow) - break; - aFrame = prevInFlow; - } + aFrame = aFrame->GetFirstInFlow(); /* * Now look up the nsLayoutAtoms::IBSplitSpecialPrevSibling diff --git a/layout/generic/nsIFrame.h b/layout/generic/nsIFrame.h index dc08f38859d3..adb6fceba853 100644 --- a/layout/generic/nsIFrame.h +++ b/layout/generic/nsIFrame.h @@ -877,6 +877,20 @@ public: NS_IMETHOD GetNextInFlow(nsIFrame** aNextInFlow) const = 0; NS_IMETHOD SetNextInFlow(nsIFrame*) = 0; + /** + * Return the first frame in our current flow. + */ + virtual nsIFrame* GetFirstInFlow() const { + return NS_CONST_CAST(nsIFrame*, this); + } + + /** + * Return the last frame in our current flow. + */ + virtual nsIFrame* GetLastInFlow() const { + return NS_CONST_CAST(nsIFrame*, this); + } + /** * Pre-reflow hook. Before a frame is reflowed this method will be called. * This call will always be invoked at least once before a subsequent Reflow diff --git a/layout/generic/nsSplittableFrame.cpp b/layout/generic/nsSplittableFrame.cpp index 3b1ed03bb4a1..19a8a63b790a 100644 --- a/layout/generic/nsSplittableFrame.cpp +++ b/layout/generic/nsSplittableFrame.cpp @@ -107,11 +107,11 @@ nsIFrame* nsSplittableFrame::GetFirstInFlow() const { nsSplittableFrame* firstInFlow; nsSplittableFrame* prevInFlow = (nsSplittableFrame*)this; - while (nsnull!=prevInFlow) { + while (prevInFlow) { firstInFlow = prevInFlow; prevInFlow = (nsSplittableFrame*)firstInFlow->mPrevInFlow; } - NS_POSTCONDITION(nsnull!=firstInFlow, "illegal state in flow chain."); + NS_POSTCONDITION(firstInFlow, "illegal state in flow chain."); return firstInFlow; } @@ -119,11 +119,11 @@ nsIFrame* nsSplittableFrame::GetLastInFlow() const { nsSplittableFrame* lastInFlow; nsSplittableFrame* nextInFlow = (nsSplittableFrame*)this; - while (nsnull!=nextInFlow) { + while (nextInFlow) { lastInFlow = nextInFlow; nextInFlow = (nsSplittableFrame*)lastInFlow->mNextInFlow; } - NS_POSTCONDITION(nsnull!=lastInFlow, "illegal state in flow chain."); + NS_POSTCONDITION(lastInFlow, "illegal state in flow chain."); return lastInFlow; } diff --git a/layout/generic/nsSplittableFrame.h b/layout/generic/nsSplittableFrame.h index 9ea0f2673ea4..cb402792b036 100644 --- a/layout/generic/nsSplittableFrame.h +++ b/layout/generic/nsSplittableFrame.h @@ -66,12 +66,12 @@ public: /** * Return the first frame in our current flow. */ - nsIFrame* GetFirstInFlow() const; + virtual nsIFrame* GetFirstInFlow() const; /** * Return the last frame in our current flow. */ - nsIFrame* GetLastInFlow() const; + virtual nsIFrame* GetLastInFlow() const; // Remove the frame from the flow. Connects the frame's prev-in-flow // and its next-in-flow diff --git a/layout/generic/nsTextFrame.cpp b/layout/generic/nsTextFrame.cpp index 8f5211fa0574..dd8dc39512ba 100644 --- a/layout/generic/nsTextFrame.cpp +++ b/layout/generic/nsTextFrame.cpp @@ -431,6 +431,7 @@ public: mNextInFlow = aNextInFlow; return NS_OK; } + virtual nsIFrame* GetLastInFlow() const; NS_IMETHOD IsSplittable(nsSplittableType& aIsSplittable) const { aIsSplittable = NS_FRAME_SPLITTABLE; @@ -893,7 +894,8 @@ public: mPrevInFlow = aPrevInFlow; return NS_OK; } - + virtual nsIFrame* GetFirstInFlow() const; + #ifdef DEBUG NS_IMETHOD SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const; #endif @@ -961,6 +963,19 @@ nsContinuingTextFrame::Destroy(nsIPresContext* aPresContext) return nsFrame::Destroy(aPresContext); } +nsIFrame* +nsContinuingTextFrame::GetFirstInFlow() const +{ + nsContinuingTextFrame* firstInFlow; + nsContinuingTextFrame* prevInFlow = (nsContinuingTextFrame*)this; + while (prevInFlow) { + firstInFlow = prevInFlow; + prevInFlow = (nsContinuingTextFrame*)firstInFlow->mPrevInFlow; + } + NS_POSTCONDITION(firstInFlow, "illegal state in flow chain."); + return firstInFlow; +} + #ifdef DEBUG NS_IMETHODIMP nsContinuingTextFrame::SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const @@ -1427,16 +1442,16 @@ nsTextFrame::GetCursor(nsIPresContext* aPresContext, return NS_OK; } -static nsIFrame* -GetLastInFlow(nsIFrame* aFrame) +nsIFrame* +nsTextFrame::GetLastInFlow() const { - nsIFrame* lastInFlow; - nsIFrame* nextInFlow = aFrame; - while (nsnull!=nextInFlow) { + nsTextFrame* lastInFlow; + nsTextFrame* nextInFlow = (nsTextFrame*)this; + while (nextInFlow) { lastInFlow = nextInFlow; - lastInFlow->GetNextInFlow(&nextInFlow); + nextInFlow = (nsTextFrame*)lastInFlow->mNextInFlow; } - NS_POSTCONDITION(nsnull!=lastInFlow, "illegal state in flow chain."); + NS_POSTCONDITION(lastInFlow, "illegal state in flow chain."); return lastInFlow; } @@ -1455,7 +1470,7 @@ nsTextFrame::ContentChanged(nsIPresContext* aPresContext, tccd->GetChangeType(&type); if (nsITextContentChangeData::Append == type) { markAllDirty = PR_FALSE; - nsTextFrame* frame = (nsTextFrame*)::GetLastInFlow(this); + nsTextFrame* frame = (nsTextFrame*)GetLastInFlow(); frame->mState |= NS_FRAME_IS_DIRTY; targetTextFrame = frame; } diff --git a/layout/html/base/src/nsFrame.cpp b/layout/html/base/src/nsFrame.cpp index 0586ea901d62..334e3c9a80ce 100644 --- a/layout/html/base/src/nsFrame.cpp +++ b/layout/html/base/src/nsFrame.cpp @@ -4432,13 +4432,7 @@ GetIBSpecialSibling(nsIPresContext* aPresContext, // Find the first-in-flow of the frame. (Ugh. This ends up // being O(N^2) when it is called O(N) times.) - for (;;) { - nsIFrame *prevInFlow; - aFrame->GetPrevInFlow(&prevInFlow); - if (!prevInFlow) - break; - aFrame = prevInFlow; - } + aFrame = aFrame->GetFirstInFlow(); /* * Now look up the nsLayoutAtoms::IBSplitSpecialPrevSibling diff --git a/layout/html/base/src/nsSplittableFrame.cpp b/layout/html/base/src/nsSplittableFrame.cpp index 3b1ed03bb4a1..19a8a63b790a 100644 --- a/layout/html/base/src/nsSplittableFrame.cpp +++ b/layout/html/base/src/nsSplittableFrame.cpp @@ -107,11 +107,11 @@ nsIFrame* nsSplittableFrame::GetFirstInFlow() const { nsSplittableFrame* firstInFlow; nsSplittableFrame* prevInFlow = (nsSplittableFrame*)this; - while (nsnull!=prevInFlow) { + while (prevInFlow) { firstInFlow = prevInFlow; prevInFlow = (nsSplittableFrame*)firstInFlow->mPrevInFlow; } - NS_POSTCONDITION(nsnull!=firstInFlow, "illegal state in flow chain."); + NS_POSTCONDITION(firstInFlow, "illegal state in flow chain."); return firstInFlow; } @@ -119,11 +119,11 @@ nsIFrame* nsSplittableFrame::GetLastInFlow() const { nsSplittableFrame* lastInFlow; nsSplittableFrame* nextInFlow = (nsSplittableFrame*)this; - while (nsnull!=nextInFlow) { + while (nextInFlow) { lastInFlow = nextInFlow; nextInFlow = (nsSplittableFrame*)lastInFlow->mNextInFlow; } - NS_POSTCONDITION(nsnull!=lastInFlow, "illegal state in flow chain."); + NS_POSTCONDITION(lastInFlow, "illegal state in flow chain."); return lastInFlow; } diff --git a/layout/html/base/src/nsSplittableFrame.h b/layout/html/base/src/nsSplittableFrame.h index 9ea0f2673ea4..cb402792b036 100644 --- a/layout/html/base/src/nsSplittableFrame.h +++ b/layout/html/base/src/nsSplittableFrame.h @@ -66,12 +66,12 @@ public: /** * Return the first frame in our current flow. */ - nsIFrame* GetFirstInFlow() const; + virtual nsIFrame* GetFirstInFlow() const; /** * Return the last frame in our current flow. */ - nsIFrame* GetLastInFlow() const; + virtual nsIFrame* GetLastInFlow() const; // Remove the frame from the flow. Connects the frame's prev-in-flow // and its next-in-flow diff --git a/layout/html/base/src/nsTextFrame.cpp b/layout/html/base/src/nsTextFrame.cpp index 8f5211fa0574..dd8dc39512ba 100644 --- a/layout/html/base/src/nsTextFrame.cpp +++ b/layout/html/base/src/nsTextFrame.cpp @@ -431,6 +431,7 @@ public: mNextInFlow = aNextInFlow; return NS_OK; } + virtual nsIFrame* GetLastInFlow() const; NS_IMETHOD IsSplittable(nsSplittableType& aIsSplittable) const { aIsSplittable = NS_FRAME_SPLITTABLE; @@ -893,7 +894,8 @@ public: mPrevInFlow = aPrevInFlow; return NS_OK; } - + virtual nsIFrame* GetFirstInFlow() const; + #ifdef DEBUG NS_IMETHOD SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const; #endif @@ -961,6 +963,19 @@ nsContinuingTextFrame::Destroy(nsIPresContext* aPresContext) return nsFrame::Destroy(aPresContext); } +nsIFrame* +nsContinuingTextFrame::GetFirstInFlow() const +{ + nsContinuingTextFrame* firstInFlow; + nsContinuingTextFrame* prevInFlow = (nsContinuingTextFrame*)this; + while (prevInFlow) { + firstInFlow = prevInFlow; + prevInFlow = (nsContinuingTextFrame*)firstInFlow->mPrevInFlow; + } + NS_POSTCONDITION(firstInFlow, "illegal state in flow chain."); + return firstInFlow; +} + #ifdef DEBUG NS_IMETHODIMP nsContinuingTextFrame::SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const @@ -1427,16 +1442,16 @@ nsTextFrame::GetCursor(nsIPresContext* aPresContext, return NS_OK; } -static nsIFrame* -GetLastInFlow(nsIFrame* aFrame) +nsIFrame* +nsTextFrame::GetLastInFlow() const { - nsIFrame* lastInFlow; - nsIFrame* nextInFlow = aFrame; - while (nsnull!=nextInFlow) { + nsTextFrame* lastInFlow; + nsTextFrame* nextInFlow = (nsTextFrame*)this; + while (nextInFlow) { lastInFlow = nextInFlow; - lastInFlow->GetNextInFlow(&nextInFlow); + nextInFlow = (nsTextFrame*)lastInFlow->mNextInFlow; } - NS_POSTCONDITION(nsnull!=lastInFlow, "illegal state in flow chain."); + NS_POSTCONDITION(lastInFlow, "illegal state in flow chain."); return lastInFlow; } @@ -1455,7 +1470,7 @@ nsTextFrame::ContentChanged(nsIPresContext* aPresContext, tccd->GetChangeType(&type); if (nsITextContentChangeData::Append == type) { markAllDirty = PR_FALSE; - nsTextFrame* frame = (nsTextFrame*)::GetLastInFlow(this); + nsTextFrame* frame = (nsTextFrame*)GetLastInFlow(); frame->mState |= NS_FRAME_IS_DIRTY; targetTextFrame = frame; } diff --git a/layout/html/style/src/nsCSSFrameConstructor.cpp b/layout/html/style/src/nsCSSFrameConstructor.cpp index 68234bc4ef6c..77b58fa99fe1 100644 --- a/layout/html/style/src/nsCSSFrameConstructor.cpp +++ b/layout/html/style/src/nsCSSFrameConstructor.cpp @@ -378,13 +378,7 @@ GetSpecialSibling(nsIFrameManager* aFrameManager, nsIFrame* aFrame, nsIFrame** a { // We only store the "special sibling" annotation with the first // frame in the flow. Walk back to find that frame now. - while (1) { - nsIFrame* prev = aFrame; - aFrame->GetPrevInFlow(&prev); - if (! prev) - break; - aFrame = prev; - } + aFrame = aFrame->GetFirstInFlow(); void* value; aFrameManager->GetFrameProperty(aFrame, nsLayoutAtoms::IBSplitSpecialSibling, 0, &value); @@ -7930,13 +7924,7 @@ FindPreviousAnonymousSibling(nsIPresShell* aPresShell, if (prevSibling) { // The frame may have a continuation. If so, we want the // last-in-flow as our previous sibling. - nsIFrame* nextInFlow; - while (1) { - prevSibling->GetNextInFlow(&nextInFlow); - if (! nextInFlow) - break; - prevSibling = nextInFlow; - } + prevSibling = prevSibling->GetLastInFlow(); // If the frame is out-of-flow, GPFF() will have returned the // out-of-flow frame; we want the placeholder. @@ -8134,13 +8122,7 @@ nsCSSFrameConstructor::FindPreviousSibling(nsIPresShell* aPresShell, if (prevSibling) { // The frame may have a continuation. Get the last-in-flow - nsIFrame* nextInFlow; - while (1) { - prevSibling->GetNextInFlow(&nextInFlow); - if (! nextInFlow) - break; - prevSibling = nextInFlow; - } + prevSibling = prevSibling->GetLastInFlow(); // If the frame is out-of-flow, GPFF() will have returned the // out-of-flow frame; we want the placeholder. @@ -8501,13 +8483,7 @@ nsCSSFrameConstructor::ContentAppended(nsIPresContext* aPresContext, } // Get the parent frame's last-in-flow - nsIFrame* nextInFlow = parentFrame; - while (nsnull != nextInFlow) { - parentFrame->GetNextInFlow(&nextInFlow); - if (nsnull != nextInFlow) { - parentFrame = nextInFlow; - } - } + parentFrame = parentFrame->GetLastInFlow(); // If we didn't process children when we originally created the frame, // then don't do any processing now @@ -14113,13 +14089,7 @@ nsCSSFrameConstructor::SplitToContainingBlock(nsIPresContext* aPresContext, // newly created anonymous frames. We need to create the linkage // between the first in flow, so if we're a continuation frame, walk // back to find it. - nsIFrame* firstInFlow = aFrame; - while (1) { - nsIFrame* prevInFlow; - firstInFlow->GetPrevInFlow(&prevInFlow); - if (! prevInFlow) break; - firstInFlow = prevInFlow; - } + nsIFrame* firstInFlow = aFrame->GetFirstInFlow(); SetFrameIsSpecial(aState.mFrameManager, firstInFlow, blockFrame); SetFrameIsSpecial(aState.mFrameManager, blockFrame, inlineFrame); diff --git a/layout/html/style/src/nsFrameContentIterator.cpp b/layout/html/style/src/nsFrameContentIterator.cpp index a8b7fff2fa5e..3bdf2f76e1bf 100644 --- a/layout/html/style/src/nsFrameContentIterator.cpp +++ b/layout/html/style/src/nsFrameContentIterator.cpp @@ -97,15 +97,7 @@ GetNextChildFrame(nsIPresContext* aPresContext, nsIFrame* aFrame) NS_PRECONDITION(aFrame, "null pointer"); // Get the last-in-flow - while (PR_TRUE) { - nsIFrame* nextInFlow; - aFrame->GetNextInFlow(&nextInFlow); - if (nextInFlow) { - aFrame = nextInFlow; - } else { - break; - } - } + aFrame = aFrame->GetLastInFlow(); // Get its next sibling nsIFrame* nextSibling;