From 96dcfbdcd066dce479ab5452ef1507d89ff79542 Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Wed, 6 Aug 2014 17:19:23 +1200 Subject: [PATCH] Bug 1048752. Part 2: Remove InvalidateOutsideCaret and MaybeInvalidateCaretPosition. r=tn I'm quite sure DLBI means we don't need these anymore. --HG-- extra : rebase_source : 6cb6cd7c160a46688793c6ab1cdded333aecdd61 --- editor/libeditor/text/nsPlaintextEditor.cpp | 6 --- layout/base/nsCaret.cpp | 10 ----- layout/base/nsCaret.h | 7 ---- layout/base/nsIPresShell.h | 12 +----- layout/base/nsPresShell.cpp | 44 --------------------- layout/base/nsPresShell.h | 2 - 6 files changed, 2 insertions(+), 79 deletions(-) diff --git a/editor/libeditor/text/nsPlaintextEditor.cpp b/editor/libeditor/text/nsPlaintextEditor.cpp index ed113b55532..0365649b81f 100644 --- a/editor/libeditor/text/nsPlaintextEditor.cpp +++ b/editor/libeditor/text/nsPlaintextEditor.cpp @@ -762,12 +762,6 @@ NS_IMETHODIMP nsPlaintextEditor::InsertLineBreak() nsRefPtr selection = GetSelection(); NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER); - // Batching the selection and moving nodes out from under the caret causes - // caret turds. Ask the shell to invalidate the caret now to avoid the turds. - nsCOMPtr shell = GetPresShell(); - NS_ENSURE_TRUE(shell, NS_ERROR_NOT_INITIALIZED); - shell->MaybeInvalidateCaretPosition(); - nsTextRulesInfo ruleInfo(EditAction::insertBreak); ruleInfo.maxLength = mMaxTextLength; bool cancel, handled; diff --git a/layout/base/nsCaret.cpp b/layout/base/nsCaret.cpp index 24e8d53bb57..24fa95edc7e 100644 --- a/layout/base/nsCaret.cpp +++ b/layout/base/nsCaret.cpp @@ -457,16 +457,6 @@ nsIFrame * nsCaret::GetCaretFrame(int32_t *aOffset) return frame; } -void nsCaret::InvalidateOutsideCaret() -{ - nsIFrame *frame = GetCaretFrame(); - - // Only invalidate if we are not fully contained by our frame's rect. - if (frame && !frame->GetVisualOverflowRect().Contains(GetCaretRect())) { - frame->SchedulePaint(); - } -} - void nsCaret::UpdateCaretPosition() { // We'll recalculate anyway if we're not drawn right now. diff --git a/layout/base/nsCaret.h b/layout/base/nsCaret.h index e08fb9f8cb7..8d9c59bd864 100644 --- a/layout/base/nsCaret.h +++ b/layout/base/nsCaret.h @@ -111,13 +111,6 @@ class nsCaret : public nsISelectionListener return r; } - /** InvalidateOutsideCaret - * Invalidate the area that the caret currently occupies if the caret is - * outside of its frame's overflow area. This is used when the content that - * the caret is currently drawn is is being deleted or reflowed. - */ - void InvalidateOutsideCaret(); - /** UpdateCaretPosition * Update the caret's current frame and rect, but don't draw yet. This is * useful for flickerless moving of the caret (e.g., when the frame the diff --git a/layout/base/nsIPresShell.h b/layout/base/nsIPresShell.h index 10df929885f..23fc0a818dc 100644 --- a/layout/base/nsIPresShell.h +++ b/layout/base/nsIPresShell.h @@ -137,10 +137,9 @@ typedef struct CapturingContentInfo { nsIContent* mContent; } CapturingContentInfo; -//a4e5ff3a-dc5c-4b3a-a625-d164a9e50619 #define NS_IPRESSHELL_IID \ -{ 0xa4e5ff3a, 0xdc5c, 0x4b3a, \ - {0xa6, 0x25, 0xd1, 0x64, 0xa9, 0xe5, 0x06, 0x19}} + { 0x42e9a352, 0x76f3, 0x4ba3, \ + { 0x94, 0x0b, 0x78, 0x9e, 0x58, 0x38, 0x73, 0x4f } } // debug VerifyReflow flags #define VERIFY_REFLOW_ON 0x01 @@ -789,13 +788,6 @@ public: */ virtual already_AddRefed GetCaret() const = 0; - /** - * Invalidate the caret's current position if it's outside of its frame's - * boundaries. This function is useful if you're batching selection - * notifications and might remove the caret's frame out from under it. - */ - virtual void MaybeInvalidateCaretPosition() = 0; - /** * Set the current caret to a new caret. To undo this, call RestoreCaret. */ diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index 03610aad425..d5eb5043edb 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -2209,13 +2209,6 @@ already_AddRefed PresShell::GetSelectionCarets() const return selectionCaret.forget(); } -void PresShell::MaybeInvalidateCaretPosition() -{ - if (mCaret) { - mCaret->InvalidateOutsideCaret(); - } -} - void PresShell::SetCaret(nsCaret *aNewCaret) { mCaret = aNewCaret; @@ -4287,29 +4280,6 @@ PresShell::FlushPendingNotifications(mozilla::ChangesToFlush aFlush) } } -void -PresShell::CharacterDataWillChange(nsIDocument *aDocument, - nsIContent* aContent, - CharacterDataChangeInfo* aInfo) -{ - NS_PRECONDITION(!mIsDocumentGone, "Unexpected CharacterDataChanged"); - NS_PRECONDITION(aDocument == mDocument, "Unexpected aDocument"); - - if (mCaret) { - // Invalidate the caret's current location before we call into the frame - // constructor. It is important to do this now, and not wait until the - // resulting reflow, because this call causes continuation frames of the - // text frame the caret is in to forget what part of the content they - // refer to, making it hard for them to return the correct continuation - // frame to the caret. - // - // It's also important to do this before the content actually changes, since - // in bidi text the caret needs to look at the content to determine its - // position and shape. - mCaret->InvalidateOutsideCaret(); - } -} - void PresShell::CharacterDataChanged(nsIDocument *aDocument, nsIContent* aContent, @@ -4504,11 +4474,6 @@ PresShell::ContentRemoved(nsIDocument *aDocument, NS_PRECONDITION(!mIsDocumentGone, "Unexpected ContentRemoved"); NS_PRECONDITION(aDocument == mDocument, "Unexpected aDocument"); - // Make sure that the caret doesn't leave a turd where the child used to be. - if (mCaret) { - mCaret->InvalidateOutsideCaret(); - } - // Notify the ESM that the content has been removed, so that // it can clean up any state related to the content. @@ -8633,12 +8598,6 @@ PresShell::DidCauseReflow() void PresShell::WillDoReflow() { - // We just reflowed, tell the caret that its frame might have moved. - // XXXbz that comment makes no sense - if (mCaret) { - mCaret->InvalidateOutsideCaret(); - } - mPresContext->FlushUserFontSet(); mPresContext->FlushCounterStyles(); @@ -8666,9 +8625,6 @@ PresShell::DidDoReflow(bool aInterruptible, bool aWasInterrupted) } if (mCaret) { - // Update the caret's position now to account for any changes created by - // the reflow. - mCaret->InvalidateOutsideCaret(); mCaret->UpdateCaretPosition(); } diff --git a/layout/base/nsPresShell.h b/layout/base/nsPresShell.h index 87cd5a537a1..d73339bd4de 100644 --- a/layout/base/nsPresShell.h +++ b/layout/base/nsPresShell.h @@ -229,7 +229,6 @@ public: virtual mozilla::dom::Element* GetSelectionCaretsEndElement() const MOZ_OVERRIDE; // caret handling virtual already_AddRefed GetCaret() const MOZ_OVERRIDE; - virtual void MaybeInvalidateCaretPosition() MOZ_OVERRIDE; NS_IMETHOD SetCaretEnabled(bool aInEnable) MOZ_OVERRIDE; NS_IMETHOD SetCaretReadOnly(bool aReadOnly) MOZ_OVERRIDE; NS_IMETHOD GetCaretEnabled(bool *aOutEnabled) MOZ_OVERRIDE; @@ -276,7 +275,6 @@ public: NS_DECL_NSIDOCUMENTOBSERVER_STYLERULEREMOVED // nsIMutationObserver - NS_DECL_NSIMUTATIONOBSERVER_CHARACTERDATAWILLCHANGE NS_DECL_NSIMUTATIONOBSERVER_CHARACTERDATACHANGED NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTEWILLCHANGE NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED