Bug 1170484 - Use {Begin,End}PlaceHolderTransaction from mozInlineSpellCheck::ReplaceWord. r=ehsan
authorBobby Holley <bobbyholley@gmail.com>
Wed, 19 Aug 2015 16:48:42 -0700
changeset 259054 d528e1ac009c720f294168279cb79ca4969f07f9
parent 259053 697f5d72aebe8d661e31424f328ffb1539d8e904
child 259055 a94b60f1a7a73e45af867e9c9b1329ae251ae4a6
push id29268
push userryanvm@gmail.com
push dateTue, 25 Aug 2015 00:37:23 +0000
treeherdermozilla-central@08015770c9d6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs1170484
milestone43.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 1170484 - Use {Begin,End}PlaceHolderTransaction from mozInlineSpellCheck::ReplaceWord. r=ehsan Both InsertText and DeleteSelection do a placeholder transaction. When the placeholder transaction depth drops to zero, we fire input events (which in turn does a microtask checkpoint). So we can prevent that from happening mid-operation by scoping a larger placeholder transaction around both calls.
extensions/spellcheck/src/mozInlineSpellChecker.cpp
--- a/extensions/spellcheck/src/mozInlineSpellChecker.cpp
+++ b/extensions/spellcheck/src/mozInlineSpellChecker.cpp
@@ -59,16 +59,17 @@
 #include "nsITextServicesFilter.h"
 #include "nsString.h"
 #include "nsThreadUtils.h"
 #include "nsUnicharUtils.h"
 #include "nsIContent.h"
 #include "nsRange.h"
 #include "nsContentUtils.h"
 #include "nsEditor.h"
+#include "nsEditorUtils.h"
 #include "mozilla/Services.h"
 #include "nsIObserverService.h"
 #include "nsITextControlElement.h"
 #include "prtime.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
@@ -940,30 +941,28 @@ mozInlineSpellChecker::ReplaceWord(nsIDO
   NS_ENSURE_TRUE(newword.Length() != 0, NS_ERROR_FAILURE);
 
   nsCOMPtr<nsIDOMRange> range;
   nsresult res = GetMisspelledWord(aNode, aOffset, getter_AddRefs(range));
   NS_ENSURE_SUCCESS(res, res); 
 
   if (range)
   {
-    editor->BeginTransaction();
+    nsAutoPlaceHolderBatch(editor, nullptr);
   
     nsCOMPtr<nsISelection> selection;
     res = editor->GetSelection(getter_AddRefs(selection));
     NS_ENSURE_SUCCESS(res, res);
     selection->RemoveAllRanges();
     selection->AddRange(range);
     editor->DeleteSelection(nsIEditor::eNone, nsIEditor::eStrip);
 
     nsCOMPtr<nsIPlaintextEditor> textEditor(do_QueryReferent(mEditor));
     if (textEditor)
       textEditor->InsertText(newword);
-
-    editor->EndTransaction();
   }
 
   return NS_OK;
 }
 
 // mozInlineSpellChecker::AddWordToDictionary
 
 NS_IMETHODIMP