diff --git a/mozilla/layout/base/nsCaret.cpp b/mozilla/layout/base/nsCaret.cpp index 93c76d34da8..049bc22acc3 100644 --- a/mozilla/layout/base/nsCaret.cpp +++ b/mozilla/layout/base/nsCaret.cpp @@ -1099,6 +1099,10 @@ void nsCaret::GetCaretRectAndInvert(nsIFrame* aFrame, PRInt32 aFrameOffset) ToggleDrawnStatus(); + if (mDrawn) { + aFrame->AddStateBits(NS_FRAME_EXTERNAL_REFERENCE); + } + #ifdef DONT_REUSE_RENDERING_CONTEXT mRendContext = nsnull; #endif diff --git a/mozilla/layout/base/nsPresShell.cpp b/mozilla/layout/base/nsPresShell.cpp index f21ee756f6e..43860650c92 100644 --- a/mozilla/layout/base/nsPresShell.cpp +++ b/mozilla/layout/base/nsPresShell.cpp @@ -5501,6 +5501,15 @@ PresShell::ContentRemoved(nsIDocument *aDocument, NS_PRECONDITION(!mIsDocumentGone, "Unexpected ContentRemoved"); NS_PRECONDITION(aDocument == mDocument, "Unexpected aDocument"); + // XXX fix for bug 304383. Remove when bug 287813 is fixed? + if (mCaret) { + nsIFrame* frame = nsnull; + GetPrimaryFrameFor(aChild, &frame); + if (frame && (frame->GetStateBits() & NS_FRAME_EXTERNAL_REFERENCE)) { + mCaret->EraseCaret(); + } + } + // Notify the ESM that the content has been removed, so that // it can clean up any state related to the content. mPresContext->EventStateManager()->ContentRemoved(aChild);