From 470feacd313e42865ad5cdabdf2c041d0f894f27 Mon Sep 17 00:00:00 2001 From: Masayuki Nakano Date: Wed, 1 Aug 2018 20:16:30 +0900 Subject: [PATCH] Bug 1480055 - part 1: Remove nsIEditor::shouldTxnSetSelection() r=m_kato nsIEditor::ShouldTxnSetSelection() is used only by DeleteRangeTransaction (even if including comm-central and BlueGriffon) and there is a non-virtual method EditorBase::GetShouldTxnSetSelection(). So, we can remove this. MozReview-Commit-ID: JWSCw9k6lI0 --HG-- extra : rebase_source : 2509274216a1493134757a7d106464f06ea0ba57 --- editor/libeditor/DeleteRangeTransaction.cpp | 4 +-- editor/libeditor/EditorBase.cpp | 8 ------ editor/libeditor/EditorBase.h | 2 ++ editor/nsIEditor.idl | 27 +++++++++++++-------- 4 files changed, 20 insertions(+), 21 deletions(-) diff --git a/editor/libeditor/DeleteRangeTransaction.cpp b/editor/libeditor/DeleteRangeTransaction.cpp index 8081b9207fe7..6a6678a6eb2b 100644 --- a/editor/libeditor/DeleteRangeTransaction.cpp +++ b/editor/libeditor/DeleteRangeTransaction.cpp @@ -91,9 +91,7 @@ DeleteRangeTransaction::DoTransaction() } // only set selection to deletion point if editor gives permission - bool bAdjustSelection; - mEditorBase->ShouldTxnSetSelection(&bAdjustSelection); - if (bAdjustSelection) { + if (mEditorBase->GetShouldTxnSetSelection()) { RefPtr selection = mEditorBase->GetSelection(); if (NS_WARN_IF(!selection)) { return NS_ERROR_NULL_POINTER; diff --git a/editor/libeditor/EditorBase.cpp b/editor/libeditor/EditorBase.cpp index 3a173651bc4e..beac70e85863 100644 --- a/editor/libeditor/EditorBase.cpp +++ b/editor/libeditor/EditorBase.cpp @@ -982,14 +982,6 @@ EditorBase::EndPlaceholderTransaction() mPlaceholderBatch--; } -NS_IMETHODIMP -EditorBase::ShouldTxnSetSelection(bool* aResult) -{ - NS_ENSURE_TRUE(aResult, NS_ERROR_NULL_POINTER); - *aResult = mShouldTxnSetSelection; - return NS_OK; -} - NS_IMETHODIMP EditorBase::SetShouldTxnSetSelection(bool aShould) { diff --git a/editor/libeditor/EditorBase.h b/editor/libeditor/EditorBase.h index ccb0abade4b5..8056ac2c68e7 100644 --- a/editor/libeditor/EditorBase.h +++ b/editor/libeditor/EditorBase.h @@ -60,6 +60,7 @@ class CompositionTransaction; class CreateElementTransaction; class CSSEditUtils; class DeleteNodeTransaction; +class DeleteRangeTransaction; class DeleteTextTransaction; class EditAggregateTransaction; class EditorEventListener; @@ -1971,6 +1972,7 @@ protected: friend class CreateElementTransaction; friend class CSSEditUtils; friend class DeleteNodeTransaction; + friend class DeleteRangeTransaction; friend class DeleteTextTransaction; friend class HTMLEditRules; friend class HTMLEditUtils; diff --git a/editor/nsIEditor.idl b/editor/nsIEditor.idl index 85c4aef3967e..0245ecc6fd7d 100644 --- a/editor/nsIEditor.idl +++ b/editor/nsIEditor.idl @@ -216,16 +216,23 @@ interface nsIEditor : nsISupports */ void endTransaction(); - boolean shouldTxnSetSelection(); - - /** Set the flag that prevents insertElementTxn from changing the selection - * @param should Set false to suppress changing the selection; - * i.e., before using InsertElement() to insert - * under element - * WARNING: You must be very careful to reset back to PR_TRUE after - * setting PR_FALSE, else selection/caret is trashed - * for further editing. - */ + /** + * While setting the flag with this method to false, CreateElementTransaction, + * DeleteRangeTransaction, DeleteTextTransaction, InsertNodeTransaction, + * InsertTextTransaction and SplitNodeTransaction won't change Selection + * after modifying the DOM tree. + * Note that calling this with false does not guarantee that Selection won't + * be changed because other transaction may ignore this flag, editor itself + * may change selection, and current selection may become invalid after + * changing the DOM tree, etc. + * After calling this method with true, the caller should guarantee that + * Selection should be positioned where user expects. + * + * @param should false if you don't want above transactions to modify + * Selection automatically after modifying the DOM tree. + * Note that calling this with false does not guarantee + * that Selection is never changed. + */ void setShouldTxnSetSelection(in boolean should); /* ------------ Inline Spell Checking methods -------------- */