Bug 1480055 - part 3: Create non-virtual method to set EditorBase::mAllowsTransactionsToChangeSelection r=m_kato
authorMasayuki Nakano <masayuki@d-toybox.com>
Wed, 01 Aug 2018 21:11:44 +0900
changeset 487713 702671b11b7c6fe20898f2ef464d2088a14c60f1
parent 487712 a3ee99eced65c73a8c3ba0b5d1ee5a47235aa362
child 487714 e0fa16503d340f35a9dd5ef2c1771bee457d9c87
push id1815
push userffxbld-merge
push dateMon, 15 Oct 2018 10:40:45 +0000
treeherdermozilla-release@18d4c09e9378 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersm_kato
bugs1480055
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1480055 - part 3: Create non-virtual method to set EditorBase::mAllowsTransactionsToChangeSelection r=m_kato There is no non-virtual method to modify EditorBase::mAllowsTransactionsToChangeSelection. Therefore, AutoTransactionsConserveSelection calls virtual method, nsIEditor::SetShouldTxnSetSelection() twice (from both constructor and destructor). So, we should save this unnecessary cost. MozReview-Commit-ID: B7TYGnGtuLB
editor/libeditor/EditorBase.cpp
editor/libeditor/EditorBase.h
editor/libeditor/EditorUtils.h
--- a/editor/libeditor/EditorBase.cpp
+++ b/editor/libeditor/EditorBase.cpp
@@ -980,17 +980,17 @@ EditorBase::EndPlaceholderTransaction()
     }
   }
   mPlaceholderBatch--;
 }
 
 NS_IMETHODIMP
 EditorBase::SetShouldTxnSetSelection(bool aShould)
 {
-  mAllowsTransactionsToChangeSelection = aShould;
+  MakeThisAllowTransactionsToChangeSelection(aShould);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 EditorBase::GetDocumentIsEmpty(bool* aDocumentIsEmpty)
 {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
--- a/editor/libeditor/EditorBase.h
+++ b/editor/libeditor/EditorBase.h
@@ -1551,16 +1551,26 @@ protected: // May be called by friends.
    * transactions to change Selection.  Otherwise, transactions shouldn't
    * change Selection.
    */
   inline bool AllowsTransactionsToChangeSelection() const
   {
     return mAllowsTransactionsToChangeSelection;
   }
 
+  /**
+   * MakeThisAllowTransactionsToChangeSelection() with true makes this editor
+   * allow transactions to change Selection.  Otherwise, i.e., with false,
+   * makes this editor not allow transactions to change Selection.
+   */
+  inline void MakeThisAllowTransactionsToChangeSelection(bool aAllow)
+  {
+    mAllowsTransactionsToChangeSelection = aAllow;
+  }
+
   nsresult HandleInlineSpellCheck(EditSubAction aEditSubAction,
                                   Selection& aSelection,
                                   nsINode* previousSelectedNode,
                                   uint32_t previousSelectedOffset,
                                   nsINode* aStartContainer,
                                   uint32_t aStartOffset,
                                   nsINode* aEndContainer,
                                   uint32_t aEndOffset);
--- a/editor/libeditor/EditorUtils.h
+++ b/editor/libeditor/EditorUtils.h
@@ -576,24 +576,24 @@ public:
                                              MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
     : mEditorBase(aEditorBase)
     , mAllowedTransactionsToChangeSelection(true)
   {
     MOZ_GUARD_OBJECT_NOTIFIER_INIT;
     if (mEditorBase) {
       mAllowedTransactionsToChangeSelection =
         mEditorBase->AllowsTransactionsToChangeSelection();
-      mEditorBase->SetShouldTxnSetSelection(false);
+      mEditorBase->MakeThisAllowTransactionsToChangeSelection(false);
     }
   }
 
   ~AutoTransactionsConserveSelection()
   {
     if (mEditorBase) {
-      mEditorBase->SetShouldTxnSetSelection(
+      mEditorBase->MakeThisAllowTransactionsToChangeSelection(
                      mAllowedTransactionsToChangeSelection);
     }
   }
 
 protected:
   EditorBase* mEditorBase;
   bool mAllowedTransactionsToChangeSelection;
   MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER