Move GetFirstInFlow/GetLastInFlow up to nsIFrame. Bug 187117, r=roc+moz, sr=dbaron

This commit is contained in:
bzbarsky%mit.edu 2003-01-16 02:59:04 +00:00
Родитель 49aa319c25
Коммит c36d682610
16 изменённых файлов: 108 добавлений и 162 удалений

Просмотреть файл

@ -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);

Просмотреть файл

@ -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;

Просмотреть файл

@ -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

Просмотреть файл

@ -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

Просмотреть файл

@ -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

Просмотреть файл

@ -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

Просмотреть файл

@ -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

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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);

Просмотреть файл

@ -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;