Bug 508927. In list box body frame don't return a frame for an item that is not in its child list, and don't destory a frame if it is not in the childlist. r=bzbarsky

This commit is contained in:
Timothy Nikkel 2009-08-25 08:37:07 -04:00
parent 8204627bef
commit a468df22eb

View File

@ -1228,6 +1228,9 @@ nsListBoxBodyFrame::GetNextItemBox(nsIBox* aBox, PRInt32 aOffset,
nsIFrame* existingFrame =
presContext->GetPresShell()->GetPrimaryFrameFor(nextContent);
if (existingFrame && existingFrame->GetParent() != this)
return GetNextItemBox(aBox, ++aOffset, aCreated);
if (!existingFrame) {
// Either append the new frame, or insert it after the current frame
PRBool isAppend = result != mLinkupFrame && mRowsToPrepend <= 0;
@ -1506,6 +1509,11 @@ void
nsListBoxBodyFrame::RemoveChildFrame(nsBoxLayoutState &aState,
nsIFrame *aFrame)
{
if (!mFrames.ContainsFrame(aFrame)) {
NS_ERROR("tried to remove a child frame which isn't our child");
return;
}
if (aFrame == GetContentInsertionFrame()) {
// Don't touch that one
return;
@ -1515,12 +1523,7 @@ nsListBoxBodyFrame::RemoveChildFrame(nsBoxLayoutState &aState,
nsCSSFrameConstructor* fc = presContext->PresShell()->FrameConstructor();
fc->RemoveMappingsForFrameSubtree(aFrame);
#ifdef DEBUG
PRBool removed =
#endif
mFrames.RemoveFrame(aFrame);
NS_ASSERTION(removed,
"Going to destroy a frame we didn't remove. Prepare to crash");
mFrames.RemoveFrame(aFrame);
if (mLayoutManager)
mLayoutManager->ChildrenRemoved(this, aState, aFrame);
aFrame->Destroy();