From 55deb4d67325dbcad335764eb92291b625e9290b Mon Sep 17 00:00:00 2001 From: "mats.palmgren%bredband.net" Date: Mon, 29 Aug 2005 05:22:54 +0000 Subject: [PATCH] Erase caret if needed when content is removed. b=304383 r=mrbkap sr=bzbarsky a=asa git-svn-id: svn://10.0.0.236/branches/MOZILLA_1_8_BRANCH@179186 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/base/nsCaret.cpp | 4 ++++ mozilla/layout/base/nsPresShell.cpp | 9 +++++++++ 2 files changed, 13 insertions(+) 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);