fix for #18420 - scrolling screws up when selection changes

fix oncontentinserted and oncontentremoved so that mTopFrame is set correctly, and don't be over-zealous about destroying frames.
r=hyatt (well, really written mostly by hyatt and digested by me)
This commit is contained in:
alecf%netscape.com 1999-12-08 07:20:25 +00:00
Родитель 19b1ae7b34
Коммит ebaab71049
4 изменённых файлов: 27 добавлений и 10 удалений

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

@ -5907,7 +5907,7 @@ nsCSSFrameConstructor::ContentInserted(nsIPresContext* aPresContext,
nsIFrame* frame = GetFrameFor(shell, aPresContext, aContainer); nsIFrame* frame = GetFrameFor(shell, aPresContext, aContainer);
nsTreeRowGroupFrame* frameTreeRowGroup = (nsTreeRowGroupFrame*)frame; nsTreeRowGroupFrame* frameTreeRowGroup = (nsTreeRowGroupFrame*)frame;
if(frameTreeRowGroup) if(frameTreeRowGroup)
frameTreeRowGroup->OnContentInserted(aPresContext, nextSibling); frameTreeRowGroup->OnContentInserted(aPresContext, nextSibling, aIndexInContainer);
} }
return NS_OK; return NS_OK;
} }

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

@ -5907,7 +5907,7 @@ nsCSSFrameConstructor::ContentInserted(nsIPresContext* aPresContext,
nsIFrame* frame = GetFrameFor(shell, aPresContext, aContainer); nsIFrame* frame = GetFrameFor(shell, aPresContext, aContainer);
nsTreeRowGroupFrame* frameTreeRowGroup = (nsTreeRowGroupFrame*)frame; nsTreeRowGroupFrame* frameTreeRowGroup = (nsTreeRowGroupFrame*)frame;
if(frameTreeRowGroup) if(frameTreeRowGroup)
frameTreeRowGroup->OnContentInserted(aPresContext, nextSibling); frameTreeRowGroup->OnContentInserted(aPresContext, nextSibling, aIndexInContainer);
} }
return NS_OK; return NS_OK;
} }

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

@ -1339,12 +1339,28 @@ void nsTreeRowGroupFrame::OnContentAdded(nsIPresContext* aPresContext)
MarkTreeAsDirty(aPresContext, treeFrame); MarkTreeAsDirty(aPresContext, treeFrame);
} }
void nsTreeRowGroupFrame::OnContentInserted(nsIPresContext* aPresContext, nsIFrame* aNextSibling) void nsTreeRowGroupFrame::OnContentInserted(nsIPresContext* aPresContext, nsIFrame* aNextSibling, PRInt32 aIndex)
{ {
nsIFrame* currFrame = aNextSibling; nsIFrame* currFrame = aNextSibling;
if(aNextSibling == mTopFrame) // this will probably never happen -
mTopFrame = nsnull; // if we haven't created the topframe, it doesn't matter if
// content was inserted
if (mTopFrame == nsnull) return;
// if we're inserting content at the top of visible content,
// then ignore it because it would go off-screen
// except of course in the case of the first row, where we're
// actually adding visible content
if(aNextSibling == mTopFrame) {
if (aIndex == 0)
// it's the first row, blow away mTopFrame so it can be
// crecreated later
mTopFrame = nsnull;
else
// it's not visible, nothing to do
return;
}
while (currFrame) { while (currFrame) {
nsIFrame* nextFrame; nsIFrame* nextFrame;
@ -1362,10 +1378,11 @@ void nsTreeRowGroupFrame::OnContentInserted(nsIPresContext* aPresContext, nsIFra
void nsTreeRowGroupFrame::OnContentRemoved(nsIPresContext* aPresContext, void nsTreeRowGroupFrame::OnContentRemoved(nsIPresContext* aPresContext,
nsIFrame* aChildFrame) nsIFrame* aChildFrame)
{ {
// We need to make sure we update things when content gets removed.
// Clear out our top and bottom frames. // if we're removing the top row, the new top row is the next row
mTopFrame = mBottomFrame = nsnull; if (mTopFrame == aChildFrame)
mTopFrame->GetNextSibling(&mTopFrame);
nsTableFrame* tableFrame; nsTableFrame* tableFrame;
nsTableFrame::GetTableFrame(this, tableFrame); nsTableFrame::GetTableFrame(this, tableFrame);

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

@ -74,7 +74,7 @@ public:
// Responses to changes // Responses to changes
void OnContentAdded(nsIPresContext* aPresContext); void OnContentAdded(nsIPresContext* aPresContext);
void OnContentInserted(nsIPresContext* aPresContext, nsIFrame* aNextSibling); void OnContentInserted(nsIPresContext* aPresContext, nsIFrame* aNextSibling, PRInt32 aIndex);
void OnContentRemoved(nsIPresContext* aPresContext, nsIFrame* aChildFrame); void OnContentRemoved(nsIPresContext* aPresContext, nsIFrame* aChildFrame);
NS_IMETHOD AttributeChanged(nsIPresContext* aPresContext, nsIContent* aChild, NS_IMETHOD AttributeChanged(nsIPresContext* aPresContext, nsIContent* aChild,