From 86cf521ec9b8574ef52a64063544e2079fe1df4f Mon Sep 17 00:00:00 2001 From: "waterson%netscape.com" Date: Thu, 27 Jul 2000 05:16:08 +0000 Subject: [PATCH] Bug 19051. Remove code that computed and maintained nsTextRun. Instead, compute 'next text' when required by crawling the frame tree in nsLineLayout::FindNextText(). r=roc+moz@cs.cmu.edu git-svn-id: svn://10.0.0.236/trunk@74887 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/base/public/nsIFrame.h | 4 - mozilla/layout/generic/nsBlockFrame.cpp | 75 +------ mozilla/layout/generic/nsBlockFrame.h | 6 - mozilla/layout/generic/nsBlockReflowState.cpp | 75 +------ mozilla/layout/generic/nsBlockReflowState.h | 75 +------ mozilla/layout/generic/nsContainerFrame.cpp | 3 + mozilla/layout/generic/nsFirstLetterFrame.cpp | 12 -- mozilla/layout/generic/nsFrame.cpp | 11 +- mozilla/layout/generic/nsFrame.h | 1 - mozilla/layout/generic/nsIFrame.h | 4 - mozilla/layout/generic/nsInlineFrame.cpp | 11 - mozilla/layout/generic/nsInlineFrame.h | 1 - mozilla/layout/generic/nsLineLayout.cpp | 202 +++++++----------- mozilla/layout/generic/nsLineLayout.h | 34 +-- mozilla/layout/generic/nsPlaceholderFrame.cpp | 3 + mozilla/layout/generic/nsTextFrame.cpp | 20 +- mozilla/layout/generic/nsTextTransformer.h | 1 - mozilla/layout/html/base/src/nsBlockFrame.cpp | 75 +------ mozilla/layout/html/base/src/nsBlockFrame.h | 6 - .../html/base/src/nsBlockReflowState.cpp | 75 +------ .../layout/html/base/src/nsBlockReflowState.h | 75 +------ .../layout/html/base/src/nsContainerFrame.cpp | 3 + .../html/base/src/nsFirstLetterFrame.cpp | 12 -- mozilla/layout/html/base/src/nsFrame.cpp | 11 +- mozilla/layout/html/base/src/nsFrame.h | 1 - .../layout/html/base/src/nsInlineFrame.cpp | 11 - mozilla/layout/html/base/src/nsInlineFrame.h | 1 - mozilla/layout/html/base/src/nsLineLayout.cpp | 202 +++++++----------- mozilla/layout/html/base/src/nsLineLayout.h | 34 +-- .../html/base/src/nsPlaceholderFrame.cpp | 3 + mozilla/layout/html/base/src/nsTextFrame.cpp | 20 +- mozilla/layout/html/base/src/nsTextRun.h | 89 -------- .../layout/html/base/src/nsTextTransformer.h | 1 - 33 files changed, 204 insertions(+), 953 deletions(-) delete mode 100644 mozilla/layout/html/base/src/nsTextRun.h diff --git a/mozilla/layout/base/public/nsIFrame.h b/mozilla/layout/base/public/nsIFrame.h index 7923efcf078..2a313985c9e 100644 --- a/mozilla/layout/base/public/nsIFrame.h +++ b/mozilla/layout/base/public/nsIFrame.h @@ -915,10 +915,6 @@ public: // XXX Maybe these three should be a separate interface? - // Helper method used by block reflow to identify runs of text so that - // proper word-breaking can be done. - NS_IMETHOD FindTextRuns(nsLineLayout& aLineLayout) = 0; - // Justification helper method used to distribute extra space in a // line to leaf frames. aUsedSpace is filled in with the amount of // space actually used. diff --git a/mozilla/layout/generic/nsBlockFrame.cpp b/mozilla/layout/generic/nsBlockFrame.cpp index 3956f2e2a74..ff07b406e4d 100644 --- a/mozilla/layout/generic/nsBlockFrame.cpp +++ b/mozilla/layout/generic/nsBlockFrame.cpp @@ -69,7 +69,6 @@ static PRBool gReallyNoisyReflow; static PRBool gNoisySpaceManager; static PRBool gVerifyLines; static PRBool gDisableResizeOpt; -static PRBool gListTextRuns; struct BlockDebugFlags { const char* name; @@ -86,7 +85,6 @@ static BlockDebugFlags gFlags[] = { { "lame-paint-metrics", &gLamePaintMetrics }, { "lame-reflow-metrics", &gLameReflowMetrics }, { "disable-resize-opt", &gDisableResizeOpt }, - { "list-text-runs", &gListTextRuns }, }; #define NUM_DEBUG_FLAGS (sizeof(gFlags) / sizeof(gFlags[0])) @@ -1200,8 +1198,6 @@ nsBlockFrame::nsBlockFrame() nsBlockFrame::~nsBlockFrame() { - - nsTextRun::DeleteTextRuns(mTextRuns); } NS_IMETHODIMP @@ -1262,20 +1258,14 @@ nsBlockFrame::IsSplittable(nsSplittableType& aIsSplittable) const } #ifdef DEBUG -static void -ListTextRuns(FILE* out, PRInt32 aIndent, nsTextRun* aRuns) -{ - while (nsnull != aRuns) { - aRuns->List(out, aIndent); - aRuns = aRuns->GetNext(); - } -} - NS_METHOD nsBlockFrame::List(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent) const { IndentBy(out, aIndent); ListTag(out); +#ifdef DEBUG_waterson + fprintf(out, " [parent=%p]", mParent); +#endif nsIView* view; GetView(aPresContext, &view); if (nsnull != view) { @@ -1355,17 +1345,6 @@ nsBlockFrame::List(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent) con NS_IF_RELEASE(listName); } - // Output the text-runs - if (gListTextRuns && mTextRuns) { - IndentBy(out, aIndent); - fputs("text-runs <\n", out); - - ListTextRuns(out, aIndent + 1, mTextRuns); - - IndentBy(out, aIndent); - fputs(">\n", out); - } - aIndent--; IndentBy(out, aIndent); fputs(">\n", out); @@ -1629,7 +1608,6 @@ nsBlockFrame::Reflow(nsIPresContext* aPresContext, if (eReflowReason_Resize != aReflowState.reason) { RenumberLists(aPresContext); - ComputeTextRuns(aPresContext); } nsresult rv = NS_OK; @@ -4157,7 +4135,6 @@ nsBlockFrame::DoReflowInlineFramesMalloc(nsBlockReflowState& aState, return NS_ERROR_OUT_OF_MEMORY; } ll->Init(&aState, aState.mMinLineHeight, aState.mLineNumber); - ll->SetReflowTextRuns(mTextRuns); nsresult rv = DoReflowInlineFrames(aState, *ll, aLine, aKeepReflowGoing, aLineReflowStatus, aUpdateMaximumWidth, aDamageDirtyArea); ll->EndLineReflow(); @@ -4178,7 +4155,6 @@ nsBlockFrame::DoReflowInlineFramesAuto(nsBlockReflowState& aState, &aState.mReflowState, aState.GetFlag(BRS_COMPUTEMAXELEMENTSIZE)); lineLayout.Init(&aState, aState.mMinLineHeight, aState.mLineNumber); - lineLayout.SetReflowTextRuns(mTextRuns); nsresult rv = DoReflowInlineFrames(aState, lineLayout, aLine, aKeepReflowGoing, aLineReflowStatus, aUpdateMaximumWidth, aDamageDirtyArea); @@ -6801,15 +6777,6 @@ nsBlockFrame::SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const line = line->mNext; } - // Add in text-run data - nsTextRun* runs = mTextRuns; - while (runs) { - PRUint32 runSize; - runs->SizeOf(aHandler, &runSize); - aHandler->AddSize(nsLayoutAtoms::textRun, runSize); - runs = runs->GetNext(); - } - *aResult = sum; return NS_OK; } @@ -7161,42 +7128,6 @@ nsBlockFrame::BuildFloaterList() // XXX keep the text-run data in the first-in-flow of the block -// XXX Switch to an interface to pass to child frames -or- do the -// grovelling directly ourselves? -nsresult -nsBlockFrame::ComputeTextRuns(nsIPresContext* aPresContext) -{ - // Destroy old run information first - nsTextRun::DeleteTextRuns(mTextRuns); - mTextRuns = nsnull; - - nsLineLayout textRunThingy(aPresContext); - - // Ask each child to find its text runs - nsLineBox* line = mLines; - while (nsnull != line) { - if (!line->IsBlock()) { - nsIFrame* frame = line->mFirstChild; - PRInt32 n = line->GetChildCount(); - while (--n >= 0) { - frame->FindTextRuns(textRunThingy); - frame->GetNextSibling(&frame); - } - } - else { - // A block frame isn't text therefore it will end an open text - // run. - textRunThingy.EndTextRun(); - } - line = line->mNext; - } - textRunThingy.EndTextRun(); - - // Now take the text-runs away from the line layout engine. - mTextRuns = textRunThingy.TakeTextRuns(); - return NS_OK; -} - #ifdef DEBUG void nsBlockFrame::VerifyLines(PRBool aFinalCheckOK) diff --git a/mozilla/layout/generic/nsBlockFrame.h b/mozilla/layout/generic/nsBlockFrame.h index 82107ed212a..ed393effe7c 100644 --- a/mozilla/layout/generic/nsBlockFrame.h +++ b/mozilla/layout/generic/nsBlockFrame.h @@ -29,7 +29,6 @@ class nsBlockReflowState; class nsBulletFrame; class nsLineBox; -class nsTextRun; class nsFirstLineFrame; /** @@ -391,8 +390,6 @@ protected: const nsRect& aOldCombinedArea, nscoord aDeltaY); - nsresult ComputeTextRuns(nsIPresContext* aPresContext); - void BuildFloaterList(); //---------------------------------------- @@ -441,9 +438,6 @@ protected: nsLineBox* mLines; - // Text run information - nsTextRun* mTextRuns; - // List of all floaters in this block nsFrameList mFloaters; diff --git a/mozilla/layout/generic/nsBlockReflowState.cpp b/mozilla/layout/generic/nsBlockReflowState.cpp index 3956f2e2a74..ff07b406e4d 100644 --- a/mozilla/layout/generic/nsBlockReflowState.cpp +++ b/mozilla/layout/generic/nsBlockReflowState.cpp @@ -69,7 +69,6 @@ static PRBool gReallyNoisyReflow; static PRBool gNoisySpaceManager; static PRBool gVerifyLines; static PRBool gDisableResizeOpt; -static PRBool gListTextRuns; struct BlockDebugFlags { const char* name; @@ -86,7 +85,6 @@ static BlockDebugFlags gFlags[] = { { "lame-paint-metrics", &gLamePaintMetrics }, { "lame-reflow-metrics", &gLameReflowMetrics }, { "disable-resize-opt", &gDisableResizeOpt }, - { "list-text-runs", &gListTextRuns }, }; #define NUM_DEBUG_FLAGS (sizeof(gFlags) / sizeof(gFlags[0])) @@ -1200,8 +1198,6 @@ nsBlockFrame::nsBlockFrame() nsBlockFrame::~nsBlockFrame() { - - nsTextRun::DeleteTextRuns(mTextRuns); } NS_IMETHODIMP @@ -1262,20 +1258,14 @@ nsBlockFrame::IsSplittable(nsSplittableType& aIsSplittable) const } #ifdef DEBUG -static void -ListTextRuns(FILE* out, PRInt32 aIndent, nsTextRun* aRuns) -{ - while (nsnull != aRuns) { - aRuns->List(out, aIndent); - aRuns = aRuns->GetNext(); - } -} - NS_METHOD nsBlockFrame::List(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent) const { IndentBy(out, aIndent); ListTag(out); +#ifdef DEBUG_waterson + fprintf(out, " [parent=%p]", mParent); +#endif nsIView* view; GetView(aPresContext, &view); if (nsnull != view) { @@ -1355,17 +1345,6 @@ nsBlockFrame::List(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent) con NS_IF_RELEASE(listName); } - // Output the text-runs - if (gListTextRuns && mTextRuns) { - IndentBy(out, aIndent); - fputs("text-runs <\n", out); - - ListTextRuns(out, aIndent + 1, mTextRuns); - - IndentBy(out, aIndent); - fputs(">\n", out); - } - aIndent--; IndentBy(out, aIndent); fputs(">\n", out); @@ -1629,7 +1608,6 @@ nsBlockFrame::Reflow(nsIPresContext* aPresContext, if (eReflowReason_Resize != aReflowState.reason) { RenumberLists(aPresContext); - ComputeTextRuns(aPresContext); } nsresult rv = NS_OK; @@ -4157,7 +4135,6 @@ nsBlockFrame::DoReflowInlineFramesMalloc(nsBlockReflowState& aState, return NS_ERROR_OUT_OF_MEMORY; } ll->Init(&aState, aState.mMinLineHeight, aState.mLineNumber); - ll->SetReflowTextRuns(mTextRuns); nsresult rv = DoReflowInlineFrames(aState, *ll, aLine, aKeepReflowGoing, aLineReflowStatus, aUpdateMaximumWidth, aDamageDirtyArea); ll->EndLineReflow(); @@ -4178,7 +4155,6 @@ nsBlockFrame::DoReflowInlineFramesAuto(nsBlockReflowState& aState, &aState.mReflowState, aState.GetFlag(BRS_COMPUTEMAXELEMENTSIZE)); lineLayout.Init(&aState, aState.mMinLineHeight, aState.mLineNumber); - lineLayout.SetReflowTextRuns(mTextRuns); nsresult rv = DoReflowInlineFrames(aState, lineLayout, aLine, aKeepReflowGoing, aLineReflowStatus, aUpdateMaximumWidth, aDamageDirtyArea); @@ -6801,15 +6777,6 @@ nsBlockFrame::SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const line = line->mNext; } - // Add in text-run data - nsTextRun* runs = mTextRuns; - while (runs) { - PRUint32 runSize; - runs->SizeOf(aHandler, &runSize); - aHandler->AddSize(nsLayoutAtoms::textRun, runSize); - runs = runs->GetNext(); - } - *aResult = sum; return NS_OK; } @@ -7161,42 +7128,6 @@ nsBlockFrame::BuildFloaterList() // XXX keep the text-run data in the first-in-flow of the block -// XXX Switch to an interface to pass to child frames -or- do the -// grovelling directly ourselves? -nsresult -nsBlockFrame::ComputeTextRuns(nsIPresContext* aPresContext) -{ - // Destroy old run information first - nsTextRun::DeleteTextRuns(mTextRuns); - mTextRuns = nsnull; - - nsLineLayout textRunThingy(aPresContext); - - // Ask each child to find its text runs - nsLineBox* line = mLines; - while (nsnull != line) { - if (!line->IsBlock()) { - nsIFrame* frame = line->mFirstChild; - PRInt32 n = line->GetChildCount(); - while (--n >= 0) { - frame->FindTextRuns(textRunThingy); - frame->GetNextSibling(&frame); - } - } - else { - // A block frame isn't text therefore it will end an open text - // run. - textRunThingy.EndTextRun(); - } - line = line->mNext; - } - textRunThingy.EndTextRun(); - - // Now take the text-runs away from the line layout engine. - mTextRuns = textRunThingy.TakeTextRuns(); - return NS_OK; -} - #ifdef DEBUG void nsBlockFrame::VerifyLines(PRBool aFinalCheckOK) diff --git a/mozilla/layout/generic/nsBlockReflowState.h b/mozilla/layout/generic/nsBlockReflowState.h index 3956f2e2a74..ff07b406e4d 100644 --- a/mozilla/layout/generic/nsBlockReflowState.h +++ b/mozilla/layout/generic/nsBlockReflowState.h @@ -69,7 +69,6 @@ static PRBool gReallyNoisyReflow; static PRBool gNoisySpaceManager; static PRBool gVerifyLines; static PRBool gDisableResizeOpt; -static PRBool gListTextRuns; struct BlockDebugFlags { const char* name; @@ -86,7 +85,6 @@ static BlockDebugFlags gFlags[] = { { "lame-paint-metrics", &gLamePaintMetrics }, { "lame-reflow-metrics", &gLameReflowMetrics }, { "disable-resize-opt", &gDisableResizeOpt }, - { "list-text-runs", &gListTextRuns }, }; #define NUM_DEBUG_FLAGS (sizeof(gFlags) / sizeof(gFlags[0])) @@ -1200,8 +1198,6 @@ nsBlockFrame::nsBlockFrame() nsBlockFrame::~nsBlockFrame() { - - nsTextRun::DeleteTextRuns(mTextRuns); } NS_IMETHODIMP @@ -1262,20 +1258,14 @@ nsBlockFrame::IsSplittable(nsSplittableType& aIsSplittable) const } #ifdef DEBUG -static void -ListTextRuns(FILE* out, PRInt32 aIndent, nsTextRun* aRuns) -{ - while (nsnull != aRuns) { - aRuns->List(out, aIndent); - aRuns = aRuns->GetNext(); - } -} - NS_METHOD nsBlockFrame::List(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent) const { IndentBy(out, aIndent); ListTag(out); +#ifdef DEBUG_waterson + fprintf(out, " [parent=%p]", mParent); +#endif nsIView* view; GetView(aPresContext, &view); if (nsnull != view) { @@ -1355,17 +1345,6 @@ nsBlockFrame::List(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent) con NS_IF_RELEASE(listName); } - // Output the text-runs - if (gListTextRuns && mTextRuns) { - IndentBy(out, aIndent); - fputs("text-runs <\n", out); - - ListTextRuns(out, aIndent + 1, mTextRuns); - - IndentBy(out, aIndent); - fputs(">\n", out); - } - aIndent--; IndentBy(out, aIndent); fputs(">\n", out); @@ -1629,7 +1608,6 @@ nsBlockFrame::Reflow(nsIPresContext* aPresContext, if (eReflowReason_Resize != aReflowState.reason) { RenumberLists(aPresContext); - ComputeTextRuns(aPresContext); } nsresult rv = NS_OK; @@ -4157,7 +4135,6 @@ nsBlockFrame::DoReflowInlineFramesMalloc(nsBlockReflowState& aState, return NS_ERROR_OUT_OF_MEMORY; } ll->Init(&aState, aState.mMinLineHeight, aState.mLineNumber); - ll->SetReflowTextRuns(mTextRuns); nsresult rv = DoReflowInlineFrames(aState, *ll, aLine, aKeepReflowGoing, aLineReflowStatus, aUpdateMaximumWidth, aDamageDirtyArea); ll->EndLineReflow(); @@ -4178,7 +4155,6 @@ nsBlockFrame::DoReflowInlineFramesAuto(nsBlockReflowState& aState, &aState.mReflowState, aState.GetFlag(BRS_COMPUTEMAXELEMENTSIZE)); lineLayout.Init(&aState, aState.mMinLineHeight, aState.mLineNumber); - lineLayout.SetReflowTextRuns(mTextRuns); nsresult rv = DoReflowInlineFrames(aState, lineLayout, aLine, aKeepReflowGoing, aLineReflowStatus, aUpdateMaximumWidth, aDamageDirtyArea); @@ -6801,15 +6777,6 @@ nsBlockFrame::SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const line = line->mNext; } - // Add in text-run data - nsTextRun* runs = mTextRuns; - while (runs) { - PRUint32 runSize; - runs->SizeOf(aHandler, &runSize); - aHandler->AddSize(nsLayoutAtoms::textRun, runSize); - runs = runs->GetNext(); - } - *aResult = sum; return NS_OK; } @@ -7161,42 +7128,6 @@ nsBlockFrame::BuildFloaterList() // XXX keep the text-run data in the first-in-flow of the block -// XXX Switch to an interface to pass to child frames -or- do the -// grovelling directly ourselves? -nsresult -nsBlockFrame::ComputeTextRuns(nsIPresContext* aPresContext) -{ - // Destroy old run information first - nsTextRun::DeleteTextRuns(mTextRuns); - mTextRuns = nsnull; - - nsLineLayout textRunThingy(aPresContext); - - // Ask each child to find its text runs - nsLineBox* line = mLines; - while (nsnull != line) { - if (!line->IsBlock()) { - nsIFrame* frame = line->mFirstChild; - PRInt32 n = line->GetChildCount(); - while (--n >= 0) { - frame->FindTextRuns(textRunThingy); - frame->GetNextSibling(&frame); - } - } - else { - // A block frame isn't text therefore it will end an open text - // run. - textRunThingy.EndTextRun(); - } - line = line->mNext; - } - textRunThingy.EndTextRun(); - - // Now take the text-runs away from the line layout engine. - mTextRuns = textRunThingy.TakeTextRuns(); - return NS_OK; -} - #ifdef DEBUG void nsBlockFrame::VerifyLines(PRBool aFinalCheckOK) diff --git a/mozilla/layout/generic/nsContainerFrame.cpp b/mozilla/layout/generic/nsContainerFrame.cpp index 2586a8a16e9..6a9ec3d0054 100644 --- a/mozilla/layout/generic/nsContainerFrame.cpp +++ b/mozilla/layout/generic/nsContainerFrame.cpp @@ -1041,6 +1041,9 @@ nsContainerFrame::List(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent) { IndentBy(out, aIndent); ListTag(out); +#ifdef DEBUG_waterson + fprintf(out, " [parent=%p]", mParent); +#endif nsIView* view; GetView(aPresContext, &view); if (nsnull != view) { diff --git a/mozilla/layout/generic/nsFirstLetterFrame.cpp b/mozilla/layout/generic/nsFirstLetterFrame.cpp index 38a6346713f..47ce6558cc2 100644 --- a/mozilla/layout/generic/nsFirstLetterFrame.cpp +++ b/mozilla/layout/generic/nsFirstLetterFrame.cpp @@ -55,7 +55,6 @@ public: NS_IMETHOD SetSelected(nsIPresContext* aPresContext, nsIDOMRange *aRange,PRBool aSelected, nsSpread aSpread); - NS_IMETHOD FindTextRuns(nsLineLayout& aLineLayout); //override of nsFrame method NS_IMETHOD GetChildFrameContainingOffset(PRInt32 inContentOffset, PRBool inHint, @@ -178,17 +177,6 @@ nsFirstLetterFrame::SetSelected(nsIPresContext* aPresContext, nsIDOMRange *aRang return NS_OK; } -NS_IMETHODIMP -nsFirstLetterFrame::FindTextRuns(nsLineLayout& aLineLayout) -{ - nsIFrame* frame = mFrames.FirstChild(); - while (nsnull != frame) { - frame->FindTextRuns(aLineLayout); - frame->GetNextSibling(&frame); - } - return NS_OK; -} - NS_IMETHODIMP nsFirstLetterFrame::GetChildFrameContainingOffset(PRInt32 inContentOffset, PRBool inHint, diff --git a/mozilla/layout/generic/nsFrame.cpp b/mozilla/layout/generic/nsFrame.cpp index 64e8f8d6eeb..4a8854cd8da 100644 --- a/mozilla/layout/generic/nsFrame.cpp +++ b/mozilla/layout/generic/nsFrame.cpp @@ -1684,13 +1684,6 @@ nsFrame::Reflow(nsIPresContext* aPresContext, return NS_OK; } -NS_IMETHODIMP -nsFrame::FindTextRuns(nsLineLayout& aLineLayout) -{ - aLineLayout.EndTextRun(); - return NS_OK; -} - NS_IMETHODIMP nsFrame::AdjustFrameSize(nscoord aExtraSpace, nscoord& aUsedSpace) { @@ -2073,7 +2066,9 @@ nsFrame::List(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent) const { IndentBy(out, aIndent); ListTag(out); - +#ifdef DEBUG_waterson + fprintf(out, " [parent=%p]", mParent); +#endif nsIView* view; GetView(aPresContext, &view); if (view) { diff --git a/mozilla/layout/generic/nsFrame.h b/mozilla/layout/generic/nsFrame.h index 9c69a0cf171..49b727197a2 100644 --- a/mozilla/layout/generic/nsFrame.h +++ b/mozilla/layout/generic/nsFrame.h @@ -279,7 +279,6 @@ public: nsReflowStatus& aStatus); NS_IMETHOD DidReflow(nsIPresContext* aPresContext, nsDidReflowStatus aStatus); - NS_IMETHOD FindTextRuns(nsLineLayout& aLineLayout); NS_IMETHOD AdjustFrameSize(nscoord aExtraSpace, nscoord& aUsedSpace); NS_IMETHOD TrimTrailingWhiteSpace(nsIPresContext* aPresContext, nsIRenderingContext& aRC, diff --git a/mozilla/layout/generic/nsIFrame.h b/mozilla/layout/generic/nsIFrame.h index 7923efcf078..2a313985c9e 100644 --- a/mozilla/layout/generic/nsIFrame.h +++ b/mozilla/layout/generic/nsIFrame.h @@ -915,10 +915,6 @@ public: // XXX Maybe these three should be a separate interface? - // Helper method used by block reflow to identify runs of text so that - // proper word-breaking can be done. - NS_IMETHOD FindTextRuns(nsLineLayout& aLineLayout) = 0; - // Justification helper method used to distribute extra space in a // line to leaf frames. aUsedSpace is filled in with the amount of // space actually used. diff --git a/mozilla/layout/generic/nsInlineFrame.cpp b/mozilla/layout/generic/nsInlineFrame.cpp index cbf5b9d3895..3842dad40ae 100644 --- a/mozilla/layout/generic/nsInlineFrame.cpp +++ b/mozilla/layout/generic/nsInlineFrame.cpp @@ -328,17 +328,6 @@ nsInlineFrame::Reflow(nsIPresContext* aPresContext, return rv; } -NS_IMETHODIMP -nsInlineFrame::FindTextRuns(nsLineLayout& aLineLayout) -{ - nsIFrame* frame = mFrames.FirstChild(); - while (nsnull != frame) { - frame->FindTextRuns(aLineLayout); - frame->GetNextSibling(&frame); - } - return NS_OK; -} - NS_IMETHODIMP nsInlineFrame::ReflowDirtyChild(nsIPresShell* aPresShell, nsIFrame* aChild) { diff --git a/mozilla/layout/generic/nsInlineFrame.h b/mozilla/layout/generic/nsInlineFrame.h index a9f0989a37e..5b07b0920e7 100644 --- a/mozilla/layout/generic/nsInlineFrame.h +++ b/mozilla/layout/generic/nsInlineFrame.h @@ -78,7 +78,6 @@ public: nsHTMLReflowMetrics& aDesiredSize, const nsHTMLReflowState& aReflowState, nsReflowStatus& aStatus); - NS_IMETHOD FindTextRuns(nsLineLayout& aLineLayout); static nsIID kInlineFrameCID; diff --git a/mozilla/layout/generic/nsLineLayout.cpp b/mozilla/layout/generic/nsLineLayout.cpp index 1568e9ea1a7..57709a4cd8e 100644 --- a/mozilla/layout/generic/nsLineLayout.cpp +++ b/mozilla/layout/generic/nsLineLayout.cpp @@ -61,42 +61,6 @@ #undef REALLY_NOISY_TRIM #endif -MOZ_DECL_CTOR_COUNTER(nsTextRun); - -nsTextRun::nsTextRun() -{ - MOZ_COUNT_CTOR(nsTextRun); - mNext = nsnull; -} - -nsTextRun::~nsTextRun() -{ - MOZ_COUNT_DTOR(nsTextRun); -} - -#ifdef DEBUG -void -nsTextRun::List(FILE* out, PRInt32 aIndent) -{ - PRInt32 i; - for (i = aIndent; --i >= 0; ) fputs(" ", out); - PRInt32 n = mArray.Count(); - fprintf(out, "%p: count=%d <", this, n); - for (i = 0; i < n; i++) { - nsIFrame* text = (nsIFrame*) mArray.ElementAt(i); - nsAutoString tmp; - nsIFrameDebug* frameDebug; - - if (NS_SUCCEEDED(text->QueryInterface(NS_GET_IID(nsIFrameDebug), (void**)&frameDebug))) { - frameDebug->GetFrameName(tmp); - fputs(tmp, out); - } - printf("@%p ", text); - } - fputs(">\n", out); -} -#endif - //---------------------------------------------------------------------- #define PLACED_LEFT 0x1 @@ -128,8 +92,6 @@ nsLineLayout::nsLineLayout(nsIPresContext* aPresContext, mPlacedFloaters = 0; mTotalPlacedFrames = 0; mTopEdge = mBottomEdge = 0; - mReflowTextRuns = nsnull; - mTextRun = nsnull; // Instead of always pre-initializing the free-lists for frames and // spans, we do it on demand so that situations that only use a few @@ -142,9 +104,6 @@ nsLineLayout::nsLineLayout(nsIPresContext* aPresContext, mCurrentSpan = mRootSpan = nsnull; mSpanDepth = 0; - mTextRuns = nsnull; - mTextRunP = &mTextRuns; - mNewTextRun = nsnull; SetFlag(LL_KNOWSTRICTMODE, PR_FALSE); } @@ -153,9 +112,6 @@ nsLineLayout::nsLineLayout(nsIPresContext* aPresContext) { MOZ_COUNT_CTOR(nsLineLayout); - mTextRuns = nsnull; - mTextRunP = &mTextRuns; - mNewTextRun = nsnull; mRootSpan = nsnull; mSpanFreeList = nsnull; mFrameFreeList = nsnull; @@ -166,7 +122,6 @@ nsLineLayout::~nsLineLayout() MOZ_COUNT_DTOR(nsLineLayout); NS_ASSERTION(nsnull == mRootSpan, "bad line-layout user"); - nsTextRun::DeleteTextRuns(mTextRuns); // Free up all of the per-span-data items that were allocated on the heap PerSpanData* psd = mSpanFreeList; @@ -2828,95 +2783,94 @@ nsLineLayout::ForgetWordFrame(nsIFrame* aFrame) } nsIFrame* -nsLineLayout::FindNextText(nsIFrame* aFrame) +nsLineLayout::FindNextText(nsIPresContext* aPresContext, nsIFrame* aFrame) { - // Only the first-in-flows are present in the text run list so - // backup from the argument frame to its first-in-flow. + // Grovel through the frame hierarchy to find a text frame that is + // "adjacent" to aFrame. + + // So this is kind of funky. During reflow, overflow frames will + // have their parent pointers set up lazily. We assume that, on + // entry, aFrame has it's parent pointer set correctly (as do all of + // its ancestors). Starting from that, we need to make sure that as + // we traverse through frames trying to find the next text frame, we + // leave the frames with their parent pointers set correctly, so the + // *next* time we come through here, we're good to go. + + // Build a path from the enclosing block frame down to aFrame. We'll + // use this to walk the frame tree. (XXXwaterson if I was clever, I + // wouldn't need to build this up before hand, and could incorporate + // this logic into the walking code directly.) + nsAutoVoidArray stack; for (;;) { - nsIFrame* prevInFlow; - aFrame->GetPrevInFlow(&prevInFlow); - if (nsnull == prevInFlow) { + stack.InsertElementAt(aFrame, 0); + + aFrame->GetParent(&aFrame); + + NS_ASSERTION(aFrame != nsnull, "wow, no block frame found"); + if (! aFrame) + break; + + nsCOMPtr frameType; + aFrame->GetFrameType(getter_AddRefs(frameType)); + + if (nsLayoutAtoms::blockFrame == frameType.get()) break; - } - aFrame = prevInFlow; } - // Now look for the frame that follows aFrame's first-in-flow - nsTextRun* run = mReflowTextRuns; - while (nsnull != run) { - PRInt32 ix = run->mArray.IndexOf(aFrame); - if (ix >= 0) { - if (ix < run->mArray.Count() - 1) { - return (nsIFrame*) run->mArray[ix + 1]; - } + // Using the path we've built up, walk the frame tree looking for + // the text frame that follows aFrame. + PRInt32 count; + while ((count = stack.Count()) != 0) { + PRInt32 lastIndex = count - 1; + nsIFrame* top = NS_STATIC_CAST(nsIFrame*, stack.ElementAt(lastIndex)); + + nsIFrame* next; + top->GetNextSibling(&next); + + if (! next) { + // No next. Pop the top element. + stack.RemoveElementAt(lastIndex); + continue; } - run = run->mNext; + + // We know top's parent is good, but next's might not be. So let's + // set it to be sure. + nsIFrame* parent; + top->GetParent(&parent); + next->SetParent(parent); + + // Save next at the top of the stack... + stack.ReplaceElementAt(next, lastIndex); + + // ...and prowl down to next's deepest child + for (;;) { + nsIFrame* child; + next->FirstChild(aPresContext, nsnull, &child); + + if (! child) + break; + + stack.AppendElement(child); + next = child; + } + + // Ignore continuing frames + nsIFrame* prevInFlow; + next->GetPrevInFlow(&prevInFlow); + if (prevInFlow) + continue; + + // If this is a text frame, return it. + nsCOMPtr frameType; + next->GetFrameType(getter_AddRefs(frameType)); + if (nsLayoutAtoms::textFrame == frameType.get()) + return next; } + + // If we get here, then there are no more text frames in this block. return nsnull; } -nsresult -nsLineLayout::AddText(nsIFrame* aTextFrame) -{ - if (nsnull == mNewTextRun) { - mNewTextRun = new nsTextRun(); - if (nsnull == mNewTextRun) { - return NS_ERROR_OUT_OF_MEMORY; - } - *mTextRunP = mNewTextRun; - mTextRunP = &mNewTextRun->mNext; - } -#ifdef DEBUG_ADD_TEXT - { - // Check that text-frame is not already there - PRInt32 ix = mNewTextRun->mArray.IndexOf((void*)aTextFrame); - NS_ASSERTION(ix < 0, "text frame already in text run"); - } -#endif - mNewTextRun->mArray.AppendElement(aTextFrame);/* XXX out-of-memory */ - return NS_OK; -} - -void -nsLineLayout::EndTextRun() -{ - if (mNewTextRun) { - PRInt32 numTextInRun = mNewTextRun->mArray.Count(); - if (numTextInRun < 2) { - // Don't bother remembering empty text-runs: reset the array - // back to zero elements. This effectively prepares this - // text-run for the next round. If it turns out there is no next - // round then we will get rid of it later in TakeTextRuns. - mNewTextRun->mArray.Clear(); - } - } - mNewTextRun = nsnull; -} - -nsTextRun* -nsLineLayout::TakeTextRuns() -{ - nsTextRun* result = mTextRuns; - mTextRuns = nsnull; - mTextRunP = &mTextRuns; - mNewTextRun = nsnull; - - // Eliminate any text-runs that are empty - nsTextRun** rp = &result; - nsTextRun* run = *rp; - while (run) { - if (0 == run->mArray.Count()) { - *rp = run->mNext; - delete run; - } - else { - rp = &run->mNext; - } - run = *rp; - } - - return result; -} PRBool nsLineLayout::TreatFrameAsBlock(nsIFrame* aFrame) diff --git a/mozilla/layout/generic/nsLineLayout.h b/mozilla/layout/generic/nsLineLayout.h index 4a2e4c2b100..cc5fc73845c 100644 --- a/mozilla/layout/generic/nsLineLayout.h +++ b/mozilla/layout/generic/nsLineLayout.h @@ -32,7 +32,6 @@ #include "nsFrame.h" #include "nsVoidArray.h" -#include "nsTextRun.h" #include "nsLineBox.h" class nsISpaceManager; @@ -215,7 +214,7 @@ public: mWordFrames.Clear(); } - nsIFrame* FindNextText(nsIFrame* aFrame); + nsIFrame* FindNextText(nsIPresContext* aPresContext, nsIFrame* aFrame); PRBool CanPlaceFloaterNow() const; @@ -253,35 +252,12 @@ public: mFirstLetterFrame = aFrame; } - //---------------------------------------- - // Text run usage methods. These methods are using during reflow to - // track the current text run and to advance through text runs. - - void SetReflowTextRuns(nsTextRun* aTextRuns) { - mReflowTextRuns = aTextRuns; - } - //---------------------------------------- static PRBool TreatFrameAsBlock(nsIFrame* aFrame); //---------------------------------------- - // XXX Move this out of line-layout; make some little interface to - // deal with it... - - // Add another piece of text to a text-run during FindTextRuns. - // Note: continuation frames must NOT add themselves; just the - // first-in-flow - nsresult AddText(nsIFrame* aTextFrame); - - // Close out a text-run during FindTextRuns. - void EndTextRun(); - - // This returns the first nsTextRun found during a FindTextRuns. The - // internal text-run state is reset. - nsTextRun* TakeTextRuns(); - nsIPresContext* mPresContext; protected: @@ -318,9 +294,6 @@ protected: // the block has been called. nscoord mFinalLineHeight; - nsTextRun* mReflowTextRuns; - nsTextRun* mTextRun; - // Per-frame data recorded by the line-layout reflow logic. This // state is the state needed to post-process the line after reflow // has completed (vertical alignment, horizontal alignment, @@ -458,11 +431,6 @@ protected: PRInt32 mFramesAllocated, mFramesFreed; #endif - // XXX These slots are used ONLY during FindTextRuns - nsTextRun* mTextRuns; - nsTextRun** mTextRunP; - nsTextRun* mNewTextRun; - nsresult NewPerFrameData(PerFrameData** aResult); nsresult NewPerSpanData(PerSpanData** aResult); diff --git a/mozilla/layout/generic/nsPlaceholderFrame.cpp b/mozilla/layout/generic/nsPlaceholderFrame.cpp index e3be5a1fad4..bdb583a9ba6 100644 --- a/mozilla/layout/generic/nsPlaceholderFrame.cpp +++ b/mozilla/layout/generic/nsPlaceholderFrame.cpp @@ -104,6 +104,9 @@ nsPlaceholderFrame::List(nsIPresContext* aPresContext, FILE* out, PRInt32 aInden { IndentBy(out, aIndent); ListTag(out); +#ifdef DEBUG_waterson + fprintf(out, " [parent=%p]", mParent); +#endif nsIView* view; GetView(aPresContext, &view); if (nsnull != view) { diff --git a/mozilla/layout/generic/nsTextFrame.cpp b/mozilla/layout/generic/nsTextFrame.cpp index 4498a5d4b3e..1fc88d29287 100644 --- a/mozilla/layout/generic/nsTextFrame.cpp +++ b/mozilla/layout/generic/nsTextFrame.cpp @@ -53,7 +53,6 @@ #include "nsIWordBreaker.h" #include "nsITextContent.h" -#include "nsTextRun.h" #include "nsTextFragment.h" #include "nsTextTransformer.h" #include "nsLayoutAtoms.h" @@ -431,7 +430,6 @@ public: nsIFrame* *outChildFrame); // nsIHTMLReflow - NS_IMETHOD FindTextRuns(nsLineLayout& aLineLayout); NS_IMETHOD Reflow(nsIPresContext* aPresContext, nsHTMLReflowMetrics& aMetrics, const nsHTMLReflowState& aReflowState, @@ -2609,17 +2607,6 @@ nsTextFrame::PaintAsciiText(nsIPresContext* aPresContext, } } -NS_IMETHODIMP -nsTextFrame::FindTextRuns(nsLineLayout& aLineLayout) -{ - nsIFrame* prevInFlow; - GetPrevInFlow(&prevInFlow); - if (nsnull == prevInFlow) { - aLineLayout.AddText(this); - } - return NS_OK; -} - //--------------------------------------------------- // Uses a binary search for find where the cursor falls in the line of text // It also keeps track of the part of the string that has already been measured @@ -3978,7 +3965,7 @@ nsTextFrame::MeasureText(nsIPresContext* aPresContext, // There is room for this word fragment. It's possible that // this word fragment is the end of the text-run. If it's not // then we continue with the look-ahead processing. - nsIFrame* next = lineLayout.FindNextText(this); + nsIFrame* next = lineLayout.FindNextText(aPresContext, this); if (nsnull != next) { #ifdef DEBUG_WORD_WRAPPING nsAutoString tmp(aTx.GetWordBuffer(), lastWordLen); @@ -4503,7 +4490,7 @@ nsTextFrame::ComputeTotalWordWidth(nsIPresContext* aPresContext, } // Move on to the next frame in the text-run - aNextFrame = aLineLayout.FindNextText(aNextFrame); + aNextFrame = aLineLayout.FindNextText(aPresContext, aNextFrame); } done:; @@ -4691,6 +4678,9 @@ nsTextFrame::List(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent) cons // Output the tag IndentBy(out, aIndent); ListTag(out); +#ifdef DEBUG_waterson + fprintf(out, " [parent=%p]", mParent); +#endif nsIView* view; GetView(aPresContext, &view); if (nsnull != view) { diff --git a/mozilla/layout/generic/nsTextTransformer.h b/mozilla/layout/generic/nsTextTransformer.h index 5acc332f2dc..56ad601950d 100644 --- a/mozilla/layout/generic/nsTextTransformer.h +++ b/mozilla/layout/generic/nsTextTransformer.h @@ -27,7 +27,6 @@ class nsIContent; class nsIFrame; -class nsTextRun; class nsILineBreaker; class nsIWordBreaker; diff --git a/mozilla/layout/html/base/src/nsBlockFrame.cpp b/mozilla/layout/html/base/src/nsBlockFrame.cpp index 3956f2e2a74..ff07b406e4d 100644 --- a/mozilla/layout/html/base/src/nsBlockFrame.cpp +++ b/mozilla/layout/html/base/src/nsBlockFrame.cpp @@ -69,7 +69,6 @@ static PRBool gReallyNoisyReflow; static PRBool gNoisySpaceManager; static PRBool gVerifyLines; static PRBool gDisableResizeOpt; -static PRBool gListTextRuns; struct BlockDebugFlags { const char* name; @@ -86,7 +85,6 @@ static BlockDebugFlags gFlags[] = { { "lame-paint-metrics", &gLamePaintMetrics }, { "lame-reflow-metrics", &gLameReflowMetrics }, { "disable-resize-opt", &gDisableResizeOpt }, - { "list-text-runs", &gListTextRuns }, }; #define NUM_DEBUG_FLAGS (sizeof(gFlags) / sizeof(gFlags[0])) @@ -1200,8 +1198,6 @@ nsBlockFrame::nsBlockFrame() nsBlockFrame::~nsBlockFrame() { - - nsTextRun::DeleteTextRuns(mTextRuns); } NS_IMETHODIMP @@ -1262,20 +1258,14 @@ nsBlockFrame::IsSplittable(nsSplittableType& aIsSplittable) const } #ifdef DEBUG -static void -ListTextRuns(FILE* out, PRInt32 aIndent, nsTextRun* aRuns) -{ - while (nsnull != aRuns) { - aRuns->List(out, aIndent); - aRuns = aRuns->GetNext(); - } -} - NS_METHOD nsBlockFrame::List(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent) const { IndentBy(out, aIndent); ListTag(out); +#ifdef DEBUG_waterson + fprintf(out, " [parent=%p]", mParent); +#endif nsIView* view; GetView(aPresContext, &view); if (nsnull != view) { @@ -1355,17 +1345,6 @@ nsBlockFrame::List(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent) con NS_IF_RELEASE(listName); } - // Output the text-runs - if (gListTextRuns && mTextRuns) { - IndentBy(out, aIndent); - fputs("text-runs <\n", out); - - ListTextRuns(out, aIndent + 1, mTextRuns); - - IndentBy(out, aIndent); - fputs(">\n", out); - } - aIndent--; IndentBy(out, aIndent); fputs(">\n", out); @@ -1629,7 +1608,6 @@ nsBlockFrame::Reflow(nsIPresContext* aPresContext, if (eReflowReason_Resize != aReflowState.reason) { RenumberLists(aPresContext); - ComputeTextRuns(aPresContext); } nsresult rv = NS_OK; @@ -4157,7 +4135,6 @@ nsBlockFrame::DoReflowInlineFramesMalloc(nsBlockReflowState& aState, return NS_ERROR_OUT_OF_MEMORY; } ll->Init(&aState, aState.mMinLineHeight, aState.mLineNumber); - ll->SetReflowTextRuns(mTextRuns); nsresult rv = DoReflowInlineFrames(aState, *ll, aLine, aKeepReflowGoing, aLineReflowStatus, aUpdateMaximumWidth, aDamageDirtyArea); ll->EndLineReflow(); @@ -4178,7 +4155,6 @@ nsBlockFrame::DoReflowInlineFramesAuto(nsBlockReflowState& aState, &aState.mReflowState, aState.GetFlag(BRS_COMPUTEMAXELEMENTSIZE)); lineLayout.Init(&aState, aState.mMinLineHeight, aState.mLineNumber); - lineLayout.SetReflowTextRuns(mTextRuns); nsresult rv = DoReflowInlineFrames(aState, lineLayout, aLine, aKeepReflowGoing, aLineReflowStatus, aUpdateMaximumWidth, aDamageDirtyArea); @@ -6801,15 +6777,6 @@ nsBlockFrame::SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const line = line->mNext; } - // Add in text-run data - nsTextRun* runs = mTextRuns; - while (runs) { - PRUint32 runSize; - runs->SizeOf(aHandler, &runSize); - aHandler->AddSize(nsLayoutAtoms::textRun, runSize); - runs = runs->GetNext(); - } - *aResult = sum; return NS_OK; } @@ -7161,42 +7128,6 @@ nsBlockFrame::BuildFloaterList() // XXX keep the text-run data in the first-in-flow of the block -// XXX Switch to an interface to pass to child frames -or- do the -// grovelling directly ourselves? -nsresult -nsBlockFrame::ComputeTextRuns(nsIPresContext* aPresContext) -{ - // Destroy old run information first - nsTextRun::DeleteTextRuns(mTextRuns); - mTextRuns = nsnull; - - nsLineLayout textRunThingy(aPresContext); - - // Ask each child to find its text runs - nsLineBox* line = mLines; - while (nsnull != line) { - if (!line->IsBlock()) { - nsIFrame* frame = line->mFirstChild; - PRInt32 n = line->GetChildCount(); - while (--n >= 0) { - frame->FindTextRuns(textRunThingy); - frame->GetNextSibling(&frame); - } - } - else { - // A block frame isn't text therefore it will end an open text - // run. - textRunThingy.EndTextRun(); - } - line = line->mNext; - } - textRunThingy.EndTextRun(); - - // Now take the text-runs away from the line layout engine. - mTextRuns = textRunThingy.TakeTextRuns(); - return NS_OK; -} - #ifdef DEBUG void nsBlockFrame::VerifyLines(PRBool aFinalCheckOK) diff --git a/mozilla/layout/html/base/src/nsBlockFrame.h b/mozilla/layout/html/base/src/nsBlockFrame.h index 82107ed212a..ed393effe7c 100644 --- a/mozilla/layout/html/base/src/nsBlockFrame.h +++ b/mozilla/layout/html/base/src/nsBlockFrame.h @@ -29,7 +29,6 @@ class nsBlockReflowState; class nsBulletFrame; class nsLineBox; -class nsTextRun; class nsFirstLineFrame; /** @@ -391,8 +390,6 @@ protected: const nsRect& aOldCombinedArea, nscoord aDeltaY); - nsresult ComputeTextRuns(nsIPresContext* aPresContext); - void BuildFloaterList(); //---------------------------------------- @@ -441,9 +438,6 @@ protected: nsLineBox* mLines; - // Text run information - nsTextRun* mTextRuns; - // List of all floaters in this block nsFrameList mFloaters; diff --git a/mozilla/layout/html/base/src/nsBlockReflowState.cpp b/mozilla/layout/html/base/src/nsBlockReflowState.cpp index 3956f2e2a74..ff07b406e4d 100644 --- a/mozilla/layout/html/base/src/nsBlockReflowState.cpp +++ b/mozilla/layout/html/base/src/nsBlockReflowState.cpp @@ -69,7 +69,6 @@ static PRBool gReallyNoisyReflow; static PRBool gNoisySpaceManager; static PRBool gVerifyLines; static PRBool gDisableResizeOpt; -static PRBool gListTextRuns; struct BlockDebugFlags { const char* name; @@ -86,7 +85,6 @@ static BlockDebugFlags gFlags[] = { { "lame-paint-metrics", &gLamePaintMetrics }, { "lame-reflow-metrics", &gLameReflowMetrics }, { "disable-resize-opt", &gDisableResizeOpt }, - { "list-text-runs", &gListTextRuns }, }; #define NUM_DEBUG_FLAGS (sizeof(gFlags) / sizeof(gFlags[0])) @@ -1200,8 +1198,6 @@ nsBlockFrame::nsBlockFrame() nsBlockFrame::~nsBlockFrame() { - - nsTextRun::DeleteTextRuns(mTextRuns); } NS_IMETHODIMP @@ -1262,20 +1258,14 @@ nsBlockFrame::IsSplittable(nsSplittableType& aIsSplittable) const } #ifdef DEBUG -static void -ListTextRuns(FILE* out, PRInt32 aIndent, nsTextRun* aRuns) -{ - while (nsnull != aRuns) { - aRuns->List(out, aIndent); - aRuns = aRuns->GetNext(); - } -} - NS_METHOD nsBlockFrame::List(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent) const { IndentBy(out, aIndent); ListTag(out); +#ifdef DEBUG_waterson + fprintf(out, " [parent=%p]", mParent); +#endif nsIView* view; GetView(aPresContext, &view); if (nsnull != view) { @@ -1355,17 +1345,6 @@ nsBlockFrame::List(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent) con NS_IF_RELEASE(listName); } - // Output the text-runs - if (gListTextRuns && mTextRuns) { - IndentBy(out, aIndent); - fputs("text-runs <\n", out); - - ListTextRuns(out, aIndent + 1, mTextRuns); - - IndentBy(out, aIndent); - fputs(">\n", out); - } - aIndent--; IndentBy(out, aIndent); fputs(">\n", out); @@ -1629,7 +1608,6 @@ nsBlockFrame::Reflow(nsIPresContext* aPresContext, if (eReflowReason_Resize != aReflowState.reason) { RenumberLists(aPresContext); - ComputeTextRuns(aPresContext); } nsresult rv = NS_OK; @@ -4157,7 +4135,6 @@ nsBlockFrame::DoReflowInlineFramesMalloc(nsBlockReflowState& aState, return NS_ERROR_OUT_OF_MEMORY; } ll->Init(&aState, aState.mMinLineHeight, aState.mLineNumber); - ll->SetReflowTextRuns(mTextRuns); nsresult rv = DoReflowInlineFrames(aState, *ll, aLine, aKeepReflowGoing, aLineReflowStatus, aUpdateMaximumWidth, aDamageDirtyArea); ll->EndLineReflow(); @@ -4178,7 +4155,6 @@ nsBlockFrame::DoReflowInlineFramesAuto(nsBlockReflowState& aState, &aState.mReflowState, aState.GetFlag(BRS_COMPUTEMAXELEMENTSIZE)); lineLayout.Init(&aState, aState.mMinLineHeight, aState.mLineNumber); - lineLayout.SetReflowTextRuns(mTextRuns); nsresult rv = DoReflowInlineFrames(aState, lineLayout, aLine, aKeepReflowGoing, aLineReflowStatus, aUpdateMaximumWidth, aDamageDirtyArea); @@ -6801,15 +6777,6 @@ nsBlockFrame::SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const line = line->mNext; } - // Add in text-run data - nsTextRun* runs = mTextRuns; - while (runs) { - PRUint32 runSize; - runs->SizeOf(aHandler, &runSize); - aHandler->AddSize(nsLayoutAtoms::textRun, runSize); - runs = runs->GetNext(); - } - *aResult = sum; return NS_OK; } @@ -7161,42 +7128,6 @@ nsBlockFrame::BuildFloaterList() // XXX keep the text-run data in the first-in-flow of the block -// XXX Switch to an interface to pass to child frames -or- do the -// grovelling directly ourselves? -nsresult -nsBlockFrame::ComputeTextRuns(nsIPresContext* aPresContext) -{ - // Destroy old run information first - nsTextRun::DeleteTextRuns(mTextRuns); - mTextRuns = nsnull; - - nsLineLayout textRunThingy(aPresContext); - - // Ask each child to find its text runs - nsLineBox* line = mLines; - while (nsnull != line) { - if (!line->IsBlock()) { - nsIFrame* frame = line->mFirstChild; - PRInt32 n = line->GetChildCount(); - while (--n >= 0) { - frame->FindTextRuns(textRunThingy); - frame->GetNextSibling(&frame); - } - } - else { - // A block frame isn't text therefore it will end an open text - // run. - textRunThingy.EndTextRun(); - } - line = line->mNext; - } - textRunThingy.EndTextRun(); - - // Now take the text-runs away from the line layout engine. - mTextRuns = textRunThingy.TakeTextRuns(); - return NS_OK; -} - #ifdef DEBUG void nsBlockFrame::VerifyLines(PRBool aFinalCheckOK) diff --git a/mozilla/layout/html/base/src/nsBlockReflowState.h b/mozilla/layout/html/base/src/nsBlockReflowState.h index 3956f2e2a74..ff07b406e4d 100644 --- a/mozilla/layout/html/base/src/nsBlockReflowState.h +++ b/mozilla/layout/html/base/src/nsBlockReflowState.h @@ -69,7 +69,6 @@ static PRBool gReallyNoisyReflow; static PRBool gNoisySpaceManager; static PRBool gVerifyLines; static PRBool gDisableResizeOpt; -static PRBool gListTextRuns; struct BlockDebugFlags { const char* name; @@ -86,7 +85,6 @@ static BlockDebugFlags gFlags[] = { { "lame-paint-metrics", &gLamePaintMetrics }, { "lame-reflow-metrics", &gLameReflowMetrics }, { "disable-resize-opt", &gDisableResizeOpt }, - { "list-text-runs", &gListTextRuns }, }; #define NUM_DEBUG_FLAGS (sizeof(gFlags) / sizeof(gFlags[0])) @@ -1200,8 +1198,6 @@ nsBlockFrame::nsBlockFrame() nsBlockFrame::~nsBlockFrame() { - - nsTextRun::DeleteTextRuns(mTextRuns); } NS_IMETHODIMP @@ -1262,20 +1258,14 @@ nsBlockFrame::IsSplittable(nsSplittableType& aIsSplittable) const } #ifdef DEBUG -static void -ListTextRuns(FILE* out, PRInt32 aIndent, nsTextRun* aRuns) -{ - while (nsnull != aRuns) { - aRuns->List(out, aIndent); - aRuns = aRuns->GetNext(); - } -} - NS_METHOD nsBlockFrame::List(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent) const { IndentBy(out, aIndent); ListTag(out); +#ifdef DEBUG_waterson + fprintf(out, " [parent=%p]", mParent); +#endif nsIView* view; GetView(aPresContext, &view); if (nsnull != view) { @@ -1355,17 +1345,6 @@ nsBlockFrame::List(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent) con NS_IF_RELEASE(listName); } - // Output the text-runs - if (gListTextRuns && mTextRuns) { - IndentBy(out, aIndent); - fputs("text-runs <\n", out); - - ListTextRuns(out, aIndent + 1, mTextRuns); - - IndentBy(out, aIndent); - fputs(">\n", out); - } - aIndent--; IndentBy(out, aIndent); fputs(">\n", out); @@ -1629,7 +1608,6 @@ nsBlockFrame::Reflow(nsIPresContext* aPresContext, if (eReflowReason_Resize != aReflowState.reason) { RenumberLists(aPresContext); - ComputeTextRuns(aPresContext); } nsresult rv = NS_OK; @@ -4157,7 +4135,6 @@ nsBlockFrame::DoReflowInlineFramesMalloc(nsBlockReflowState& aState, return NS_ERROR_OUT_OF_MEMORY; } ll->Init(&aState, aState.mMinLineHeight, aState.mLineNumber); - ll->SetReflowTextRuns(mTextRuns); nsresult rv = DoReflowInlineFrames(aState, *ll, aLine, aKeepReflowGoing, aLineReflowStatus, aUpdateMaximumWidth, aDamageDirtyArea); ll->EndLineReflow(); @@ -4178,7 +4155,6 @@ nsBlockFrame::DoReflowInlineFramesAuto(nsBlockReflowState& aState, &aState.mReflowState, aState.GetFlag(BRS_COMPUTEMAXELEMENTSIZE)); lineLayout.Init(&aState, aState.mMinLineHeight, aState.mLineNumber); - lineLayout.SetReflowTextRuns(mTextRuns); nsresult rv = DoReflowInlineFrames(aState, lineLayout, aLine, aKeepReflowGoing, aLineReflowStatus, aUpdateMaximumWidth, aDamageDirtyArea); @@ -6801,15 +6777,6 @@ nsBlockFrame::SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const line = line->mNext; } - // Add in text-run data - nsTextRun* runs = mTextRuns; - while (runs) { - PRUint32 runSize; - runs->SizeOf(aHandler, &runSize); - aHandler->AddSize(nsLayoutAtoms::textRun, runSize); - runs = runs->GetNext(); - } - *aResult = sum; return NS_OK; } @@ -7161,42 +7128,6 @@ nsBlockFrame::BuildFloaterList() // XXX keep the text-run data in the first-in-flow of the block -// XXX Switch to an interface to pass to child frames -or- do the -// grovelling directly ourselves? -nsresult -nsBlockFrame::ComputeTextRuns(nsIPresContext* aPresContext) -{ - // Destroy old run information first - nsTextRun::DeleteTextRuns(mTextRuns); - mTextRuns = nsnull; - - nsLineLayout textRunThingy(aPresContext); - - // Ask each child to find its text runs - nsLineBox* line = mLines; - while (nsnull != line) { - if (!line->IsBlock()) { - nsIFrame* frame = line->mFirstChild; - PRInt32 n = line->GetChildCount(); - while (--n >= 0) { - frame->FindTextRuns(textRunThingy); - frame->GetNextSibling(&frame); - } - } - else { - // A block frame isn't text therefore it will end an open text - // run. - textRunThingy.EndTextRun(); - } - line = line->mNext; - } - textRunThingy.EndTextRun(); - - // Now take the text-runs away from the line layout engine. - mTextRuns = textRunThingy.TakeTextRuns(); - return NS_OK; -} - #ifdef DEBUG void nsBlockFrame::VerifyLines(PRBool aFinalCheckOK) diff --git a/mozilla/layout/html/base/src/nsContainerFrame.cpp b/mozilla/layout/html/base/src/nsContainerFrame.cpp index 2586a8a16e9..6a9ec3d0054 100644 --- a/mozilla/layout/html/base/src/nsContainerFrame.cpp +++ b/mozilla/layout/html/base/src/nsContainerFrame.cpp @@ -1041,6 +1041,9 @@ nsContainerFrame::List(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent) { IndentBy(out, aIndent); ListTag(out); +#ifdef DEBUG_waterson + fprintf(out, " [parent=%p]", mParent); +#endif nsIView* view; GetView(aPresContext, &view); if (nsnull != view) { diff --git a/mozilla/layout/html/base/src/nsFirstLetterFrame.cpp b/mozilla/layout/html/base/src/nsFirstLetterFrame.cpp index 38a6346713f..47ce6558cc2 100644 --- a/mozilla/layout/html/base/src/nsFirstLetterFrame.cpp +++ b/mozilla/layout/html/base/src/nsFirstLetterFrame.cpp @@ -55,7 +55,6 @@ public: NS_IMETHOD SetSelected(nsIPresContext* aPresContext, nsIDOMRange *aRange,PRBool aSelected, nsSpread aSpread); - NS_IMETHOD FindTextRuns(nsLineLayout& aLineLayout); //override of nsFrame method NS_IMETHOD GetChildFrameContainingOffset(PRInt32 inContentOffset, PRBool inHint, @@ -178,17 +177,6 @@ nsFirstLetterFrame::SetSelected(nsIPresContext* aPresContext, nsIDOMRange *aRang return NS_OK; } -NS_IMETHODIMP -nsFirstLetterFrame::FindTextRuns(nsLineLayout& aLineLayout) -{ - nsIFrame* frame = mFrames.FirstChild(); - while (nsnull != frame) { - frame->FindTextRuns(aLineLayout); - frame->GetNextSibling(&frame); - } - return NS_OK; -} - NS_IMETHODIMP nsFirstLetterFrame::GetChildFrameContainingOffset(PRInt32 inContentOffset, PRBool inHint, diff --git a/mozilla/layout/html/base/src/nsFrame.cpp b/mozilla/layout/html/base/src/nsFrame.cpp index 64e8f8d6eeb..4a8854cd8da 100644 --- a/mozilla/layout/html/base/src/nsFrame.cpp +++ b/mozilla/layout/html/base/src/nsFrame.cpp @@ -1684,13 +1684,6 @@ nsFrame::Reflow(nsIPresContext* aPresContext, return NS_OK; } -NS_IMETHODIMP -nsFrame::FindTextRuns(nsLineLayout& aLineLayout) -{ - aLineLayout.EndTextRun(); - return NS_OK; -} - NS_IMETHODIMP nsFrame::AdjustFrameSize(nscoord aExtraSpace, nscoord& aUsedSpace) { @@ -2073,7 +2066,9 @@ nsFrame::List(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent) const { IndentBy(out, aIndent); ListTag(out); - +#ifdef DEBUG_waterson + fprintf(out, " [parent=%p]", mParent); +#endif nsIView* view; GetView(aPresContext, &view); if (view) { diff --git a/mozilla/layout/html/base/src/nsFrame.h b/mozilla/layout/html/base/src/nsFrame.h index 9c69a0cf171..49b727197a2 100644 --- a/mozilla/layout/html/base/src/nsFrame.h +++ b/mozilla/layout/html/base/src/nsFrame.h @@ -279,7 +279,6 @@ public: nsReflowStatus& aStatus); NS_IMETHOD DidReflow(nsIPresContext* aPresContext, nsDidReflowStatus aStatus); - NS_IMETHOD FindTextRuns(nsLineLayout& aLineLayout); NS_IMETHOD AdjustFrameSize(nscoord aExtraSpace, nscoord& aUsedSpace); NS_IMETHOD TrimTrailingWhiteSpace(nsIPresContext* aPresContext, nsIRenderingContext& aRC, diff --git a/mozilla/layout/html/base/src/nsInlineFrame.cpp b/mozilla/layout/html/base/src/nsInlineFrame.cpp index cbf5b9d3895..3842dad40ae 100644 --- a/mozilla/layout/html/base/src/nsInlineFrame.cpp +++ b/mozilla/layout/html/base/src/nsInlineFrame.cpp @@ -328,17 +328,6 @@ nsInlineFrame::Reflow(nsIPresContext* aPresContext, return rv; } -NS_IMETHODIMP -nsInlineFrame::FindTextRuns(nsLineLayout& aLineLayout) -{ - nsIFrame* frame = mFrames.FirstChild(); - while (nsnull != frame) { - frame->FindTextRuns(aLineLayout); - frame->GetNextSibling(&frame); - } - return NS_OK; -} - NS_IMETHODIMP nsInlineFrame::ReflowDirtyChild(nsIPresShell* aPresShell, nsIFrame* aChild) { diff --git a/mozilla/layout/html/base/src/nsInlineFrame.h b/mozilla/layout/html/base/src/nsInlineFrame.h index a9f0989a37e..5b07b0920e7 100644 --- a/mozilla/layout/html/base/src/nsInlineFrame.h +++ b/mozilla/layout/html/base/src/nsInlineFrame.h @@ -78,7 +78,6 @@ public: nsHTMLReflowMetrics& aDesiredSize, const nsHTMLReflowState& aReflowState, nsReflowStatus& aStatus); - NS_IMETHOD FindTextRuns(nsLineLayout& aLineLayout); static nsIID kInlineFrameCID; diff --git a/mozilla/layout/html/base/src/nsLineLayout.cpp b/mozilla/layout/html/base/src/nsLineLayout.cpp index 1568e9ea1a7..57709a4cd8e 100644 --- a/mozilla/layout/html/base/src/nsLineLayout.cpp +++ b/mozilla/layout/html/base/src/nsLineLayout.cpp @@ -61,42 +61,6 @@ #undef REALLY_NOISY_TRIM #endif -MOZ_DECL_CTOR_COUNTER(nsTextRun); - -nsTextRun::nsTextRun() -{ - MOZ_COUNT_CTOR(nsTextRun); - mNext = nsnull; -} - -nsTextRun::~nsTextRun() -{ - MOZ_COUNT_DTOR(nsTextRun); -} - -#ifdef DEBUG -void -nsTextRun::List(FILE* out, PRInt32 aIndent) -{ - PRInt32 i; - for (i = aIndent; --i >= 0; ) fputs(" ", out); - PRInt32 n = mArray.Count(); - fprintf(out, "%p: count=%d <", this, n); - for (i = 0; i < n; i++) { - nsIFrame* text = (nsIFrame*) mArray.ElementAt(i); - nsAutoString tmp; - nsIFrameDebug* frameDebug; - - if (NS_SUCCEEDED(text->QueryInterface(NS_GET_IID(nsIFrameDebug), (void**)&frameDebug))) { - frameDebug->GetFrameName(tmp); - fputs(tmp, out); - } - printf("@%p ", text); - } - fputs(">\n", out); -} -#endif - //---------------------------------------------------------------------- #define PLACED_LEFT 0x1 @@ -128,8 +92,6 @@ nsLineLayout::nsLineLayout(nsIPresContext* aPresContext, mPlacedFloaters = 0; mTotalPlacedFrames = 0; mTopEdge = mBottomEdge = 0; - mReflowTextRuns = nsnull; - mTextRun = nsnull; // Instead of always pre-initializing the free-lists for frames and // spans, we do it on demand so that situations that only use a few @@ -142,9 +104,6 @@ nsLineLayout::nsLineLayout(nsIPresContext* aPresContext, mCurrentSpan = mRootSpan = nsnull; mSpanDepth = 0; - mTextRuns = nsnull; - mTextRunP = &mTextRuns; - mNewTextRun = nsnull; SetFlag(LL_KNOWSTRICTMODE, PR_FALSE); } @@ -153,9 +112,6 @@ nsLineLayout::nsLineLayout(nsIPresContext* aPresContext) { MOZ_COUNT_CTOR(nsLineLayout); - mTextRuns = nsnull; - mTextRunP = &mTextRuns; - mNewTextRun = nsnull; mRootSpan = nsnull; mSpanFreeList = nsnull; mFrameFreeList = nsnull; @@ -166,7 +122,6 @@ nsLineLayout::~nsLineLayout() MOZ_COUNT_DTOR(nsLineLayout); NS_ASSERTION(nsnull == mRootSpan, "bad line-layout user"); - nsTextRun::DeleteTextRuns(mTextRuns); // Free up all of the per-span-data items that were allocated on the heap PerSpanData* psd = mSpanFreeList; @@ -2828,95 +2783,94 @@ nsLineLayout::ForgetWordFrame(nsIFrame* aFrame) } nsIFrame* -nsLineLayout::FindNextText(nsIFrame* aFrame) +nsLineLayout::FindNextText(nsIPresContext* aPresContext, nsIFrame* aFrame) { - // Only the first-in-flows are present in the text run list so - // backup from the argument frame to its first-in-flow. + // Grovel through the frame hierarchy to find a text frame that is + // "adjacent" to aFrame. + + // So this is kind of funky. During reflow, overflow frames will + // have their parent pointers set up lazily. We assume that, on + // entry, aFrame has it's parent pointer set correctly (as do all of + // its ancestors). Starting from that, we need to make sure that as + // we traverse through frames trying to find the next text frame, we + // leave the frames with their parent pointers set correctly, so the + // *next* time we come through here, we're good to go. + + // Build a path from the enclosing block frame down to aFrame. We'll + // use this to walk the frame tree. (XXXwaterson if I was clever, I + // wouldn't need to build this up before hand, and could incorporate + // this logic into the walking code directly.) + nsAutoVoidArray stack; for (;;) { - nsIFrame* prevInFlow; - aFrame->GetPrevInFlow(&prevInFlow); - if (nsnull == prevInFlow) { + stack.InsertElementAt(aFrame, 0); + + aFrame->GetParent(&aFrame); + + NS_ASSERTION(aFrame != nsnull, "wow, no block frame found"); + if (! aFrame) + break; + + nsCOMPtr frameType; + aFrame->GetFrameType(getter_AddRefs(frameType)); + + if (nsLayoutAtoms::blockFrame == frameType.get()) break; - } - aFrame = prevInFlow; } - // Now look for the frame that follows aFrame's first-in-flow - nsTextRun* run = mReflowTextRuns; - while (nsnull != run) { - PRInt32 ix = run->mArray.IndexOf(aFrame); - if (ix >= 0) { - if (ix < run->mArray.Count() - 1) { - return (nsIFrame*) run->mArray[ix + 1]; - } + // Using the path we've built up, walk the frame tree looking for + // the text frame that follows aFrame. + PRInt32 count; + while ((count = stack.Count()) != 0) { + PRInt32 lastIndex = count - 1; + nsIFrame* top = NS_STATIC_CAST(nsIFrame*, stack.ElementAt(lastIndex)); + + nsIFrame* next; + top->GetNextSibling(&next); + + if (! next) { + // No next. Pop the top element. + stack.RemoveElementAt(lastIndex); + continue; } - run = run->mNext; + + // We know top's parent is good, but next's might not be. So let's + // set it to be sure. + nsIFrame* parent; + top->GetParent(&parent); + next->SetParent(parent); + + // Save next at the top of the stack... + stack.ReplaceElementAt(next, lastIndex); + + // ...and prowl down to next's deepest child + for (;;) { + nsIFrame* child; + next->FirstChild(aPresContext, nsnull, &child); + + if (! child) + break; + + stack.AppendElement(child); + next = child; + } + + // Ignore continuing frames + nsIFrame* prevInFlow; + next->GetPrevInFlow(&prevInFlow); + if (prevInFlow) + continue; + + // If this is a text frame, return it. + nsCOMPtr frameType; + next->GetFrameType(getter_AddRefs(frameType)); + if (nsLayoutAtoms::textFrame == frameType.get()) + return next; } + + // If we get here, then there are no more text frames in this block. return nsnull; } -nsresult -nsLineLayout::AddText(nsIFrame* aTextFrame) -{ - if (nsnull == mNewTextRun) { - mNewTextRun = new nsTextRun(); - if (nsnull == mNewTextRun) { - return NS_ERROR_OUT_OF_MEMORY; - } - *mTextRunP = mNewTextRun; - mTextRunP = &mNewTextRun->mNext; - } -#ifdef DEBUG_ADD_TEXT - { - // Check that text-frame is not already there - PRInt32 ix = mNewTextRun->mArray.IndexOf((void*)aTextFrame); - NS_ASSERTION(ix < 0, "text frame already in text run"); - } -#endif - mNewTextRun->mArray.AppendElement(aTextFrame);/* XXX out-of-memory */ - return NS_OK; -} - -void -nsLineLayout::EndTextRun() -{ - if (mNewTextRun) { - PRInt32 numTextInRun = mNewTextRun->mArray.Count(); - if (numTextInRun < 2) { - // Don't bother remembering empty text-runs: reset the array - // back to zero elements. This effectively prepares this - // text-run for the next round. If it turns out there is no next - // round then we will get rid of it later in TakeTextRuns. - mNewTextRun->mArray.Clear(); - } - } - mNewTextRun = nsnull; -} - -nsTextRun* -nsLineLayout::TakeTextRuns() -{ - nsTextRun* result = mTextRuns; - mTextRuns = nsnull; - mTextRunP = &mTextRuns; - mNewTextRun = nsnull; - - // Eliminate any text-runs that are empty - nsTextRun** rp = &result; - nsTextRun* run = *rp; - while (run) { - if (0 == run->mArray.Count()) { - *rp = run->mNext; - delete run; - } - else { - rp = &run->mNext; - } - run = *rp; - } - - return result; -} PRBool nsLineLayout::TreatFrameAsBlock(nsIFrame* aFrame) diff --git a/mozilla/layout/html/base/src/nsLineLayout.h b/mozilla/layout/html/base/src/nsLineLayout.h index 4a2e4c2b100..cc5fc73845c 100644 --- a/mozilla/layout/html/base/src/nsLineLayout.h +++ b/mozilla/layout/html/base/src/nsLineLayout.h @@ -32,7 +32,6 @@ #include "nsFrame.h" #include "nsVoidArray.h" -#include "nsTextRun.h" #include "nsLineBox.h" class nsISpaceManager; @@ -215,7 +214,7 @@ public: mWordFrames.Clear(); } - nsIFrame* FindNextText(nsIFrame* aFrame); + nsIFrame* FindNextText(nsIPresContext* aPresContext, nsIFrame* aFrame); PRBool CanPlaceFloaterNow() const; @@ -253,35 +252,12 @@ public: mFirstLetterFrame = aFrame; } - //---------------------------------------- - // Text run usage methods. These methods are using during reflow to - // track the current text run and to advance through text runs. - - void SetReflowTextRuns(nsTextRun* aTextRuns) { - mReflowTextRuns = aTextRuns; - } - //---------------------------------------- static PRBool TreatFrameAsBlock(nsIFrame* aFrame); //---------------------------------------- - // XXX Move this out of line-layout; make some little interface to - // deal with it... - - // Add another piece of text to a text-run during FindTextRuns. - // Note: continuation frames must NOT add themselves; just the - // first-in-flow - nsresult AddText(nsIFrame* aTextFrame); - - // Close out a text-run during FindTextRuns. - void EndTextRun(); - - // This returns the first nsTextRun found during a FindTextRuns. The - // internal text-run state is reset. - nsTextRun* TakeTextRuns(); - nsIPresContext* mPresContext; protected: @@ -318,9 +294,6 @@ protected: // the block has been called. nscoord mFinalLineHeight; - nsTextRun* mReflowTextRuns; - nsTextRun* mTextRun; - // Per-frame data recorded by the line-layout reflow logic. This // state is the state needed to post-process the line after reflow // has completed (vertical alignment, horizontal alignment, @@ -458,11 +431,6 @@ protected: PRInt32 mFramesAllocated, mFramesFreed; #endif - // XXX These slots are used ONLY during FindTextRuns - nsTextRun* mTextRuns; - nsTextRun** mTextRunP; - nsTextRun* mNewTextRun; - nsresult NewPerFrameData(PerFrameData** aResult); nsresult NewPerSpanData(PerSpanData** aResult); diff --git a/mozilla/layout/html/base/src/nsPlaceholderFrame.cpp b/mozilla/layout/html/base/src/nsPlaceholderFrame.cpp index e3be5a1fad4..bdb583a9ba6 100644 --- a/mozilla/layout/html/base/src/nsPlaceholderFrame.cpp +++ b/mozilla/layout/html/base/src/nsPlaceholderFrame.cpp @@ -104,6 +104,9 @@ nsPlaceholderFrame::List(nsIPresContext* aPresContext, FILE* out, PRInt32 aInden { IndentBy(out, aIndent); ListTag(out); +#ifdef DEBUG_waterson + fprintf(out, " [parent=%p]", mParent); +#endif nsIView* view; GetView(aPresContext, &view); if (nsnull != view) { diff --git a/mozilla/layout/html/base/src/nsTextFrame.cpp b/mozilla/layout/html/base/src/nsTextFrame.cpp index 4498a5d4b3e..1fc88d29287 100644 --- a/mozilla/layout/html/base/src/nsTextFrame.cpp +++ b/mozilla/layout/html/base/src/nsTextFrame.cpp @@ -53,7 +53,6 @@ #include "nsIWordBreaker.h" #include "nsITextContent.h" -#include "nsTextRun.h" #include "nsTextFragment.h" #include "nsTextTransformer.h" #include "nsLayoutAtoms.h" @@ -431,7 +430,6 @@ public: nsIFrame* *outChildFrame); // nsIHTMLReflow - NS_IMETHOD FindTextRuns(nsLineLayout& aLineLayout); NS_IMETHOD Reflow(nsIPresContext* aPresContext, nsHTMLReflowMetrics& aMetrics, const nsHTMLReflowState& aReflowState, @@ -2609,17 +2607,6 @@ nsTextFrame::PaintAsciiText(nsIPresContext* aPresContext, } } -NS_IMETHODIMP -nsTextFrame::FindTextRuns(nsLineLayout& aLineLayout) -{ - nsIFrame* prevInFlow; - GetPrevInFlow(&prevInFlow); - if (nsnull == prevInFlow) { - aLineLayout.AddText(this); - } - return NS_OK; -} - //--------------------------------------------------- // Uses a binary search for find where the cursor falls in the line of text // It also keeps track of the part of the string that has already been measured @@ -3978,7 +3965,7 @@ nsTextFrame::MeasureText(nsIPresContext* aPresContext, // There is room for this word fragment. It's possible that // this word fragment is the end of the text-run. If it's not // then we continue with the look-ahead processing. - nsIFrame* next = lineLayout.FindNextText(this); + nsIFrame* next = lineLayout.FindNextText(aPresContext, this); if (nsnull != next) { #ifdef DEBUG_WORD_WRAPPING nsAutoString tmp(aTx.GetWordBuffer(), lastWordLen); @@ -4503,7 +4490,7 @@ nsTextFrame::ComputeTotalWordWidth(nsIPresContext* aPresContext, } // Move on to the next frame in the text-run - aNextFrame = aLineLayout.FindNextText(aNextFrame); + aNextFrame = aLineLayout.FindNextText(aPresContext, aNextFrame); } done:; @@ -4691,6 +4678,9 @@ nsTextFrame::List(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent) cons // Output the tag IndentBy(out, aIndent); ListTag(out); +#ifdef DEBUG_waterson + fprintf(out, " [parent=%p]", mParent); +#endif nsIView* view; GetView(aPresContext, &view); if (nsnull != view) { diff --git a/mozilla/layout/html/base/src/nsTextRun.h b/mozilla/layout/html/base/src/nsTextRun.h deleted file mode 100644 index 955f0f12346..00000000000 --- a/mozilla/layout/html/base/src/nsTextRun.h +++ /dev/null @@ -1,89 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * - * The contents of this file are subject to the Netscape Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is Mozilla Communicator client code. - * - * The Initial Developer of the Original Code is Netscape Communications - * Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - */ -#ifndef nsTextRun_h___ -#define nsTextRun_h___ - -#include "nslayout.h" -#include "nsIFrame.h" -#include "nsVoidArray.h" - -class nsIContent; -class nsTextFragment; - -// XXX it might be cheaper to have the text-run only contain the -// content pointer instead of the frame pointer - -// A run of text. In mText are the nsIFrame's that are considered text -// frames. -class nsTextRun { -public: - nsTextRun(); - ~nsTextRun(); - - nsIFrame* FindNextText(nsIFrame* aFrame); - - nsTextRun* GetNext() const { - return mNext; - } - - void SetNext(nsTextRun* aNext) { - mNext = aNext; - } - - PRInt32 Count() const { - return mArray.Count(); - } - -#ifdef DEBUG - void SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const { - if (aResult) { - mArray.SizeOf(aHandler, aResult); - *aResult += sizeof(this) - sizeof(mArray); - } - } -#endif - - nsIFrame* operator[](PRInt32 aIndex) const { - return (nsIFrame*) mArray[aIndex]; - } - -#ifdef DEBUG - void List(FILE* out, PRInt32 aIndent); -#endif - - static void DeleteTextRuns(nsTextRun* aRun) { - while (nsnull != aRun) { - nsTextRun* next = aRun->GetNext(); - delete aRun; - aRun = next; - } - } - -protected: - nsVoidArray mArray; - nsTextRun* mNext; - - // XXX get rid of this - friend class nsLineLayout; -}; - -#endif /* nsTextRun_h___ */ diff --git a/mozilla/layout/html/base/src/nsTextTransformer.h b/mozilla/layout/html/base/src/nsTextTransformer.h index 5acc332f2dc..56ad601950d 100644 --- a/mozilla/layout/html/base/src/nsTextTransformer.h +++ b/mozilla/layout/html/base/src/nsTextTransformer.h @@ -27,7 +27,6 @@ class nsIContent; class nsIFrame; -class nsTextRun; class nsILineBreaker; class nsIWordBreaker;