From ab20bcc3c9ff0fc37991bb361b26fb0d88b4f153 Mon Sep 17 00:00:00 2001 From: "hyatt%netscape.com" Date: Mon, 28 Jun 1999 08:35:10 +0000 Subject: [PATCH] Number Two: Mail/news performance continued to decline. We thought the situation with the tree widget was hopeless. And so we cloned it. This new tree widget is exactly like the original in every way... only 1/8 its size. Dr. Evil: I shall call it... MINI-TREE. (Translation: Backward scrolling now works in the lazy tree widget.) git-svn-id: svn://10.0.0.236/trunk@37168 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/base/nsCSSFrameConstructor.cpp | 11 ++- mozilla/layout/base/nsCSSFrameConstructor.h | 4 +- .../html/style/src/nsCSSFrameConstructor.cpp | 11 ++- .../html/style/src/nsCSSFrameConstructor.h | 4 +- .../xul/base/src/nsTreeRowGroupFrame.cpp | 94 ++++++++++++++----- .../layout/xul/base/src/nsTreeRowGroupFrame.h | 2 + 6 files changed, 96 insertions(+), 30 deletions(-) diff --git a/mozilla/layout/base/nsCSSFrameConstructor.cpp b/mozilla/layout/base/nsCSSFrameConstructor.cpp index 9522bba416d..acb964f4663 100644 --- a/mozilla/layout/base/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/base/nsCSSFrameConstructor.cpp @@ -6005,8 +6005,10 @@ nsCSSFrameConstructor::WrapTextFrame(nsIPresContext* aPresContext, NS_IMETHODIMP nsCSSFrameConstructor::CreateTreeWidgetContent(nsIPresContext* aPresContext, nsIFrame* aParentFrame, + nsIFrame* aPrevFrame, nsIContent* aChild, - nsIFrame** aNewFrame) + nsIFrame** aNewFrame, + PRBool aIsAppend) { nsCOMPtr shell; aPresContext->GetShell(getter_AddRefs(shell)); @@ -6026,8 +6028,11 @@ nsCSSFrameConstructor::CreateTreeWidgetContent(nsIPresContext* aPresContext, if (NS_SUCCEEDED(rv) && (nsnull != newFrame)) { // Notify the parent frame - rv = ((nsTreeRowGroupFrame*)aParentFrame)->TreeAppendFrames(newFrame); - + if (aIsAppend) + rv = ((nsTreeRowGroupFrame*)aParentFrame)->TreeAppendFrames(newFrame); + else + rv = ((nsTreeRowGroupFrame*)aParentFrame)->TreeInsertFrames(aPrevFrame, newFrame); + // If there are new absolutely positioned child frames, then notify // the parent // XXX We can't just assume these frames are being appended, we need to diff --git a/mozilla/layout/base/nsCSSFrameConstructor.h b/mozilla/layout/base/nsCSSFrameConstructor.h index 412b3f2c4cf..ae4624ca452 100644 --- a/mozilla/layout/base/nsCSSFrameConstructor.h +++ b/mozilla/layout/base/nsCSSFrameConstructor.h @@ -114,8 +114,10 @@ public: NS_IMETHODIMP CreateTreeWidgetContent(nsIPresContext* aPresContext, nsIFrame* aParentFrame, + nsIFrame* aPrevFrame, nsIContent* aChild, - nsIFrame** aResult); + nsIFrame** aResult, + PRBool aIsAppend); protected: diff --git a/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp b/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp index 9522bba416d..acb964f4663 100644 --- a/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp @@ -6005,8 +6005,10 @@ nsCSSFrameConstructor::WrapTextFrame(nsIPresContext* aPresContext, NS_IMETHODIMP nsCSSFrameConstructor::CreateTreeWidgetContent(nsIPresContext* aPresContext, nsIFrame* aParentFrame, + nsIFrame* aPrevFrame, nsIContent* aChild, - nsIFrame** aNewFrame) + nsIFrame** aNewFrame, + PRBool aIsAppend) { nsCOMPtr shell; aPresContext->GetShell(getter_AddRefs(shell)); @@ -6026,8 +6028,11 @@ nsCSSFrameConstructor::CreateTreeWidgetContent(nsIPresContext* aPresContext, if (NS_SUCCEEDED(rv) && (nsnull != newFrame)) { // Notify the parent frame - rv = ((nsTreeRowGroupFrame*)aParentFrame)->TreeAppendFrames(newFrame); - + if (aIsAppend) + rv = ((nsTreeRowGroupFrame*)aParentFrame)->TreeAppendFrames(newFrame); + else + rv = ((nsTreeRowGroupFrame*)aParentFrame)->TreeInsertFrames(aPrevFrame, newFrame); + // If there are new absolutely positioned child frames, then notify // the parent // XXX We can't just assume these frames are being appended, we need to diff --git a/mozilla/layout/html/style/src/nsCSSFrameConstructor.h b/mozilla/layout/html/style/src/nsCSSFrameConstructor.h index 412b3f2c4cf..ae4624ca452 100644 --- a/mozilla/layout/html/style/src/nsCSSFrameConstructor.h +++ b/mozilla/layout/html/style/src/nsCSSFrameConstructor.h @@ -114,8 +114,10 @@ public: NS_IMETHODIMP CreateTreeWidgetContent(nsIPresContext* aPresContext, nsIFrame* aParentFrame, + nsIFrame* aPrevFrame, nsIContent* aChild, - nsIFrame** aResult); + nsIFrame** aResult, + PRBool aIsAppend); protected: diff --git a/mozilla/layout/xul/base/src/nsTreeRowGroupFrame.cpp b/mozilla/layout/xul/base/src/nsTreeRowGroupFrame.cpp index 4ea7e136536..110dc66ab1e 100644 --- a/mozilla/layout/xul/base/src/nsTreeRowGroupFrame.cpp +++ b/mozilla/layout/xul/base/src/nsTreeRowGroupFrame.cpp @@ -63,7 +63,8 @@ NS_NewTreeRowGroupFrame (nsIFrame** aNewFrame) // Constructor nsTreeRowGroupFrame::nsTreeRowGroupFrame() :nsTableRowGroupFrame(), mScrollbar(nsnull), mFrameConstructor(nsnull), - mTopFrame(nsnull), mBottomFrame(nsnull), mIsLazy(PR_FALSE), mIsFull(PR_FALSE), mContentChain(nsnull) + mTopFrame(nsnull), mBottomFrame(nsnull), mIsLazy(PR_FALSE), mIsFull(PR_FALSE), + mContentChain(nsnull), mLinkupFrame(nsnull) { } // Destructor @@ -534,6 +535,7 @@ nsIFrame* nsTreeRowGroupFrame::GetFirstFrameForReflow(nsIPresContext& aPresContext) { // Clear ourselves out. + mLinkupFrame = nsnull; mBottomFrame = mTopFrame; mIsFull = PR_FALSE; @@ -567,26 +569,21 @@ nsTreeRowGroupFrame::GetFirstFrameForReflow(nsIPresContext& aPresContext) // The two content nodes are the same. Our content chain has // been synched up, and we can now remove our element and // pass the content chain inwards. - mContentChain->RemoveElementAt(0); - PRUint32 chainSize; - mContentChain->Count(&chainSize); - if (chainSize > 0) { - ((nsTreeRowGroupFrame*)mTopFrame)->SetContentChain(mContentChain); - } - - // The chain is dead. Long live the chain. - NS_RELEASE(mContentChain); - mContentChain = nsnull; + InitSubContentChain((nsTreeRowGroupFrame*)mTopFrame); } + else mLinkupFrame = mTopFrame; // We have some frames that we'll eventually catch up with. + // Cache the pointer to the first of these frames, so + // we'll know it when we hit it. + startContent = chainContent; } // We don't have a top frame instantiated. Let's // try to make one. - // If we have a content chain, use that content node to make our frame, - // and prepare a sub-content chain for the new child frame that we make. - // Otherwise just grab the first child. + // If startContent is initialized, we have a content chain, and + // we're using that content node to make our frame. + // Otherwise we have nothing, and we should just try to grab the first child. if (!startContent) { PRInt32 childCount; mContent->ChildCount(childCount); @@ -598,8 +595,10 @@ nsTreeRowGroupFrame::GetFirstFrameForReflow(nsIPresContext& aPresContext) } if (startContent) { - mFrameConstructor->CreateTreeWidgetContent(&aPresContext, this, startContent, - &mTopFrame); + PRBool isAppend = (mLinkupFrame == nsnull); + + mFrameConstructor->CreateTreeWidgetContent(&aPresContext, this, nsnull, startContent, + &mTopFrame, isAppend); printf("Created a frame\n"); mBottomFrame = mTopFrame; const nsStyleDisplay *rowDisplay; @@ -607,6 +606,14 @@ nsTreeRowGroupFrame::GetFirstFrameForReflow(nsIPresContext& aPresContext) if (NS_STYLE_DISPLAY_TABLE_ROW==rowDisplay->mDisplay) { ((nsTableRowFrame *)mTopFrame)->InitChildren(); } + else if (NS_STYLE_DISPLAY_TABLE_ROW_GROUP==rowDisplay->mDisplay && mContentChain) { + // We have just instantiated a row group, and we have a content chain. This + // means we need to potentially pass a sub-content chain to the instantiated + // frame, so that it can also sync up with its children. + InitSubContentChain((nsTreeRowGroupFrame*)mTopFrame); + } + + SetContentChain(nsnull); return mTopFrame; } @@ -619,6 +626,27 @@ nsTreeRowGroupFrame::GetNextFrameForReflow(nsIPresContext& aPresContext, nsIFram if (mIsLazy) { // We're ultra-cool. We build our frames on the fly. LocateFrame(aFrame, aResult); + if (*aResult && (*aResult == mLinkupFrame)) { + // We haven't really found a result. We've only found a result if + // the linkup frame is really the next frame following the + // previous frame. + nsCOMPtr prevContent; + aFrame->GetContent(getter_AddRefs(prevContent)); + nsCOMPtr linkupContent; + mLinkupFrame->GetContent(getter_AddRefs(linkupContent)); + PRInt32 i, j; + mContent->IndexOf(prevContent, i); + mContent->IndexOf(linkupContent, j); + if (i+1==j) { + // We have found a match and successfully linked back up with our + // old frame. + mBottomFrame = mLinkupFrame; + mLinkupFrame = nsnull; + return; + } + else *aResult = nsnull; // No true linkup. We need to make a frame. + } + if (!*aResult) { // No result found. See if there's a content node that wants a frame. PRInt32 i, childCount; @@ -631,23 +659,31 @@ nsTreeRowGroupFrame::GetNextFrameForReflow(nsIPresContext& aPresContext, nsIFram // There is a content node that wants a frame. nsCOMPtr nextContent; mContent->ChildAt(i+1, *getter_AddRefs(nextContent)); - mFrameConstructor->CreateTreeWidgetContent(&aPresContext, this, nextContent, - aResult); - mBottomFrame = *aResult; + nsIFrame* prevFrame = nsnull; // Default is to append + PRBool isAppend = PR_TRUE; + if (mLinkupFrame) { + // This will be an insertion, since we have frames on the end. + prevFrame = aFrame; + isAppend = PR_FALSE; + } + mFrameConstructor->CreateTreeWidgetContent(&aPresContext, this, prevFrame, nextContent, + aResult, isAppend); printf("Created a frame\n"); const nsStyleDisplay *rowDisplay; - mBottomFrame->GetStyleData(eStyleStruct_Display, (const nsStyleStruct *&)rowDisplay); + (*aResult)->GetStyleData(eStyleStruct_Display, (const nsStyleStruct *&)rowDisplay); if (NS_STYLE_DISPLAY_TABLE_ROW==rowDisplay->mDisplay) { - ((nsTableRowFrame *)mBottomFrame)->InitChildren(); + ((nsTableRowFrame *)(*aResult))->InitChildren(); } } } + + mBottomFrame = *aResult; return; } // Ho-hum. Move along, nothing to see here. aFrame->GetNextSibling(aResult); -} +} NS_IMETHODIMP nsTreeRowGroupFrame::TreeInsertFrames(nsIFrame* aPrevFrame, nsIFrame* aFrameList) @@ -704,4 +740,18 @@ void nsTreeRowGroupFrame::SetContentChain(nsISupportsArray* aContentChain) NS_IF_RELEASE(mContentChain); mContentChain = aContentChain; NS_IF_ADDREF(mContentChain); +} + +void nsTreeRowGroupFrame::InitSubContentChain(nsTreeRowGroupFrame* aRowGroupFrame) +{ + if (mContentChain) { + mContentChain->RemoveElementAt(0); + PRUint32 chainSize; + mContentChain->Count(&chainSize); + if (chainSize > 0 && aRowGroupFrame) { + aRowGroupFrame->SetContentChain(mContentChain); + } + // The chain is dead. Long live the chain. + SetContentChain(nsnull); + } } \ No newline at end of file diff --git a/mozilla/layout/xul/base/src/nsTreeRowGroupFrame.h b/mozilla/layout/xul/base/src/nsTreeRowGroupFrame.h index 03fda7ad139..ef267afd87a 100644 --- a/mozilla/layout/xul/base/src/nsTreeRowGroupFrame.h +++ b/mozilla/layout/xul/base/src/nsTreeRowGroupFrame.h @@ -88,6 +88,7 @@ protected: void LocateFrame(nsIFrame* aStartFrame, nsIFrame** aResult); void SetContentChain(nsISupportsArray* aContentChain); + void InitSubContentChain(nsTreeRowGroupFrame* aRowGroupFrame); void ConstructContentChain(nsIContent* aRowContent); void FindPreviousRowContent(PRInt32& aDelta, nsIContent* aUpwardHint, @@ -97,6 +98,7 @@ protected: protected: // Data Members nsIFrame* mTopFrame; // The current topmost frame in the view. nsIFrame* mBottomFrame; // The current bottom frame in the view. + nsIFrame* mLinkupFrame; // An old top frame that we're trying to link up with. PRBool mIsLazy; // Whether or not we're a lazily instantiated beast PRBool mIsFull; // Whether or not we have any more room.