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.)
This commit is contained in:
hyatt%netscape.com 1999-06-28 08:35:10 +00:00
Родитель b365542c28
Коммит 9a161d923f
6 изменённых файлов: 96 добавлений и 30 удалений

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

@ -6005,8 +6005,10 @@ nsCSSFrameConstructor::WrapTextFrame(nsIPresContext* aPresContext,
NS_IMETHODIMP NS_IMETHODIMP
nsCSSFrameConstructor::CreateTreeWidgetContent(nsIPresContext* aPresContext, nsCSSFrameConstructor::CreateTreeWidgetContent(nsIPresContext* aPresContext,
nsIFrame* aParentFrame, nsIFrame* aParentFrame,
nsIFrame* aPrevFrame,
nsIContent* aChild, nsIContent* aChild,
nsIFrame** aNewFrame) nsIFrame** aNewFrame,
PRBool aIsAppend)
{ {
nsCOMPtr<nsIPresShell> shell; nsCOMPtr<nsIPresShell> shell;
aPresContext->GetShell(getter_AddRefs(shell)); aPresContext->GetShell(getter_AddRefs(shell));
@ -6026,8 +6028,11 @@ nsCSSFrameConstructor::CreateTreeWidgetContent(nsIPresContext* aPresContext,
if (NS_SUCCEEDED(rv) && (nsnull != newFrame)) { if (NS_SUCCEEDED(rv) && (nsnull != newFrame)) {
// Notify the parent frame // 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 // If there are new absolutely positioned child frames, then notify
// the parent // the parent
// XXX We can't just assume these frames are being appended, we need to // XXX We can't just assume these frames are being appended, we need to

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

@ -114,8 +114,10 @@ public:
NS_IMETHODIMP CreateTreeWidgetContent(nsIPresContext* aPresContext, NS_IMETHODIMP CreateTreeWidgetContent(nsIPresContext* aPresContext,
nsIFrame* aParentFrame, nsIFrame* aParentFrame,
nsIFrame* aPrevFrame,
nsIContent* aChild, nsIContent* aChild,
nsIFrame** aResult); nsIFrame** aResult,
PRBool aIsAppend);
protected: protected:

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

@ -6005,8 +6005,10 @@ nsCSSFrameConstructor::WrapTextFrame(nsIPresContext* aPresContext,
NS_IMETHODIMP NS_IMETHODIMP
nsCSSFrameConstructor::CreateTreeWidgetContent(nsIPresContext* aPresContext, nsCSSFrameConstructor::CreateTreeWidgetContent(nsIPresContext* aPresContext,
nsIFrame* aParentFrame, nsIFrame* aParentFrame,
nsIFrame* aPrevFrame,
nsIContent* aChild, nsIContent* aChild,
nsIFrame** aNewFrame) nsIFrame** aNewFrame,
PRBool aIsAppend)
{ {
nsCOMPtr<nsIPresShell> shell; nsCOMPtr<nsIPresShell> shell;
aPresContext->GetShell(getter_AddRefs(shell)); aPresContext->GetShell(getter_AddRefs(shell));
@ -6026,8 +6028,11 @@ nsCSSFrameConstructor::CreateTreeWidgetContent(nsIPresContext* aPresContext,
if (NS_SUCCEEDED(rv) && (nsnull != newFrame)) { if (NS_SUCCEEDED(rv) && (nsnull != newFrame)) {
// Notify the parent frame // 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 // If there are new absolutely positioned child frames, then notify
// the parent // the parent
// XXX We can't just assume these frames are being appended, we need to // XXX We can't just assume these frames are being appended, we need to

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

@ -114,8 +114,10 @@ public:
NS_IMETHODIMP CreateTreeWidgetContent(nsIPresContext* aPresContext, NS_IMETHODIMP CreateTreeWidgetContent(nsIPresContext* aPresContext,
nsIFrame* aParentFrame, nsIFrame* aParentFrame,
nsIFrame* aPrevFrame,
nsIContent* aChild, nsIContent* aChild,
nsIFrame** aResult); nsIFrame** aResult,
PRBool aIsAppend);
protected: protected:

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

@ -63,7 +63,8 @@ NS_NewTreeRowGroupFrame (nsIFrame** aNewFrame)
// Constructor // Constructor
nsTreeRowGroupFrame::nsTreeRowGroupFrame() nsTreeRowGroupFrame::nsTreeRowGroupFrame()
:nsTableRowGroupFrame(), mScrollbar(nsnull), mFrameConstructor(nsnull), :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 // Destructor
@ -534,6 +535,7 @@ nsIFrame*
nsTreeRowGroupFrame::GetFirstFrameForReflow(nsIPresContext& aPresContext) nsTreeRowGroupFrame::GetFirstFrameForReflow(nsIPresContext& aPresContext)
{ {
// Clear ourselves out. // Clear ourselves out.
mLinkupFrame = nsnull;
mBottomFrame = mTopFrame; mBottomFrame = mTopFrame;
mIsFull = PR_FALSE; mIsFull = PR_FALSE;
@ -567,26 +569,21 @@ nsTreeRowGroupFrame::GetFirstFrameForReflow(nsIPresContext& aPresContext)
// The two content nodes are the same. Our content chain has // The two content nodes are the same. Our content chain has
// been synched up, and we can now remove our element and // been synched up, and we can now remove our element and
// pass the content chain inwards. // pass the content chain inwards.
mContentChain->RemoveElementAt(0); InitSubContentChain((nsTreeRowGroupFrame*)mTopFrame);
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;
} }
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; startContent = chainContent;
} }
// We don't have a top frame instantiated. Let's // We don't have a top frame instantiated. Let's
// try to make one. // try to make one.
// If we have a content chain, use that content node to make our frame, // If startContent is initialized, we have a content chain, and
// and prepare a sub-content chain for the new child frame that we make. // we're using that content node to make our frame.
// Otherwise just grab the first child. // Otherwise we have nothing, and we should just try to grab the first child.
if (!startContent) { if (!startContent) {
PRInt32 childCount; PRInt32 childCount;
mContent->ChildCount(childCount); mContent->ChildCount(childCount);
@ -598,8 +595,10 @@ nsTreeRowGroupFrame::GetFirstFrameForReflow(nsIPresContext& aPresContext)
} }
if (startContent) { if (startContent) {
mFrameConstructor->CreateTreeWidgetContent(&aPresContext, this, startContent, PRBool isAppend = (mLinkupFrame == nsnull);
&mTopFrame);
mFrameConstructor->CreateTreeWidgetContent(&aPresContext, this, nsnull, startContent,
&mTopFrame, isAppend);
printf("Created a frame\n"); printf("Created a frame\n");
mBottomFrame = mTopFrame; mBottomFrame = mTopFrame;
const nsStyleDisplay *rowDisplay; const nsStyleDisplay *rowDisplay;
@ -607,6 +606,14 @@ nsTreeRowGroupFrame::GetFirstFrameForReflow(nsIPresContext& aPresContext)
if (NS_STYLE_DISPLAY_TABLE_ROW==rowDisplay->mDisplay) { if (NS_STYLE_DISPLAY_TABLE_ROW==rowDisplay->mDisplay) {
((nsTableRowFrame *)mTopFrame)->InitChildren(); ((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; return mTopFrame;
} }
@ -619,6 +626,27 @@ nsTreeRowGroupFrame::GetNextFrameForReflow(nsIPresContext& aPresContext, nsIFram
if (mIsLazy) { if (mIsLazy) {
// We're ultra-cool. We build our frames on the fly. // We're ultra-cool. We build our frames on the fly.
LocateFrame(aFrame, aResult); 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<nsIContent> prevContent;
aFrame->GetContent(getter_AddRefs(prevContent));
nsCOMPtr<nsIContent> 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) { if (!*aResult) {
// No result found. See if there's a content node that wants a frame. // No result found. See if there's a content node that wants a frame.
PRInt32 i, childCount; PRInt32 i, childCount;
@ -631,23 +659,31 @@ nsTreeRowGroupFrame::GetNextFrameForReflow(nsIPresContext& aPresContext, nsIFram
// There is a content node that wants a frame. // There is a content node that wants a frame.
nsCOMPtr<nsIContent> nextContent; nsCOMPtr<nsIContent> nextContent;
mContent->ChildAt(i+1, *getter_AddRefs(nextContent)); mContent->ChildAt(i+1, *getter_AddRefs(nextContent));
mFrameConstructor->CreateTreeWidgetContent(&aPresContext, this, nextContent, nsIFrame* prevFrame = nsnull; // Default is to append
aResult); PRBool isAppend = PR_TRUE;
mBottomFrame = *aResult; 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"); printf("Created a frame\n");
const nsStyleDisplay *rowDisplay; 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) { if (NS_STYLE_DISPLAY_TABLE_ROW==rowDisplay->mDisplay) {
((nsTableRowFrame *)mBottomFrame)->InitChildren(); ((nsTableRowFrame *)(*aResult))->InitChildren();
} }
} }
} }
mBottomFrame = *aResult;
return; return;
} }
// Ho-hum. Move along, nothing to see here. // Ho-hum. Move along, nothing to see here.
aFrame->GetNextSibling(aResult); aFrame->GetNextSibling(aResult);
} }
NS_IMETHODIMP NS_IMETHODIMP
nsTreeRowGroupFrame::TreeInsertFrames(nsIFrame* aPrevFrame, nsIFrame* aFrameList) nsTreeRowGroupFrame::TreeInsertFrames(nsIFrame* aPrevFrame, nsIFrame* aFrameList)
@ -704,4 +740,18 @@ void nsTreeRowGroupFrame::SetContentChain(nsISupportsArray* aContentChain)
NS_IF_RELEASE(mContentChain); NS_IF_RELEASE(mContentChain);
mContentChain = aContentChain; mContentChain = aContentChain;
NS_IF_ADDREF(mContentChain); 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);
}
} }

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

@ -88,6 +88,7 @@ protected:
void LocateFrame(nsIFrame* aStartFrame, nsIFrame** aResult); void LocateFrame(nsIFrame* aStartFrame, nsIFrame** aResult);
void SetContentChain(nsISupportsArray* aContentChain); void SetContentChain(nsISupportsArray* aContentChain);
void InitSubContentChain(nsTreeRowGroupFrame* aRowGroupFrame);
void ConstructContentChain(nsIContent* aRowContent); void ConstructContentChain(nsIContent* aRowContent);
void FindPreviousRowContent(PRInt32& aDelta, nsIContent* aUpwardHint, void FindPreviousRowContent(PRInt32& aDelta, nsIContent* aUpwardHint,
@ -97,6 +98,7 @@ protected:
protected: // Data Members protected: // Data Members
nsIFrame* mTopFrame; // The current topmost frame in the view. nsIFrame* mTopFrame; // The current topmost frame in the view.
nsIFrame* mBottomFrame; // The current bottom 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 mIsLazy; // Whether or not we're a lazily instantiated beast
PRBool mIsFull; // Whether or not we have any more room. PRBool mIsFull; // Whether or not we have any more room.