diff --git a/mozilla/layout/base/nsCaret.cpp b/mozilla/layout/base/nsCaret.cpp index f23af13ba53..57538b0387b 100644 --- a/mozilla/layout/base/nsCaret.cpp +++ b/mozilla/layout/base/nsCaret.cpp @@ -1104,6 +1104,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 ce4b189698f..8e4a5c3118e 100644 --- a/mozilla/layout/base/nsPresShell.cpp +++ b/mozilla/layout/base/nsPresShell.cpp @@ -5502,6 +5502,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);