From 27508743966db1503b3e861ba163b45e7c666f6b Mon Sep 17 00:00:00 2001 From: "mats.palmgren%bredband.net" Date: Mon, 22 Aug 2005 00:25:20 +0000 Subject: [PATCH] Erase caret if needed when content is removed. b=304383 r=mrbkap sr=bzbarsky git-svn-id: svn://10.0.0.236/trunk@178577 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 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);