Bug 437142. Be a little more careful with GetPrimaryFrameFor to work around the mess that <area> elements cause. r+sr=roc

This commit is contained in:
Boris Zbarsky 2008-11-25 20:49:14 -05:00
Родитель f727d64ed9
Коммит f3647c87f6
2 изменённых файлов: 24 добавлений и 2 удалений

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

@ -9328,7 +9328,9 @@ nsCSSFrameConstructor::ContentRemoved(nsIContent* aContainer,
nsIFrame* childFrame =
mPresShell->FrameManager()->GetPrimaryFrameFor(aChild, aIndexInContainer);
if (! childFrame) {
if (!childFrame || childFrame->GetContent() != aChild) {
// XXXbz the GetContent() != aChild check is needed due to bug 135040.
// Remove it once that's fixed.
frameManager->ClearUndisplayedContentIn(aChild, aContainer);
}
@ -9413,7 +9415,9 @@ nsCSSFrameConstructor::ContentRemoved(nsIContent* aContainer,
// Recover childFrame and parentFrame
childFrame = mPresShell->GetPrimaryFrameFor(aChild);
if (!childFrame) {
if (!childFrame || childFrame->GetContent() != aChild) {
// XXXbz the GetContent() != aChild check is needed due to bug 135040.
// Remove it once that's fixed.
frameManager->ClearUndisplayedContentIn(aChild, aContainer);
return NS_OK;
}
@ -9834,6 +9838,14 @@ nsCSSFrameConstructor::ProcessRestyledFrames(nsStyleChangeList& aChangeList)
nsIContent* content;
nsChangeHint hint;
aChangeList.ChangeAt(index, frame, content, hint);
if (frame && frame->GetContent() != content) {
// XXXbz this is due to image maps messing with the primary frame map.
// See bug 135040. Remove this block once that's fixed.
frame = nsnull;
if (!(hint & nsChangeHint_ReconstructFrame)) {
continue;
}
}
// skip any frame that has been destroyed due to a ripple effect
if (frame) {
@ -9906,6 +9918,11 @@ nsCSSFrameConstructor::RestyleElement(nsIContent *aContent,
{
NS_ASSERTION(aPrimaryFrame == mPresShell->GetPrimaryFrameFor(aContent),
"frame/content mismatch");
if (aPrimaryFrame && aPrimaryFrame->GetContent() != aContent) {
// XXXbz this is due to image maps messing with the primary frame mapping.
// See bug 135040. We can remove this block once that's fixed.
aPrimaryFrame = nsnull;
}
NS_ASSERTION(!aPrimaryFrame || aPrimaryFrame->GetContent() == aContent,
"frame/content mismatch");

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

@ -893,6 +893,11 @@ nsImageMap::AddArea(nsIContent* aArea)
//Add focus listener to track area focus changes
aArea->AddEventListenerByIID(this, NS_GET_IID(nsIDOMFocusListener));
// This is a nasty hack. It needs to go away: see bug 135040. Once this is
// removed, the code added to nsCSSFrameConstructor::RestyleElement,
// nsCSSFrameConstructor::ContentRemoved (both hacks there), and
// nsCSSFrameConstructor::ProcessRestyledFrames to work around this issue can
// be removed.
mPresShell->FrameManager()->SetPrimaryFrameFor(aArea, mImageFrame);
aArea->SetMayHaveFrame(PR_TRUE);
NS_ASSERTION(aArea->MayHaveFrame(), "SetMayHaveFrame failed?");