Bug 1385514 - Part 1: Make SetTextTransaction a selection preserving transaction; r=masayuki
authorEhsan Akhgari <ehsan@mozilla.com>
Fri, 28 Jul 2017 20:31:35 -0400
changeset 420786 91637b17112c15230feaeaae15034f7f5cf3aaab
parent 420785 9360c4975d3652abcae684e4af531fae7eb93789
child 420787 c579ac37ac11a44b9af0c75720f519a40c439b19
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmasayuki
bugs1385514
milestone56.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 1385514 - Part 1: Make SetTextTransaction a selection preserving transaction; r=masayuki This makes the SetTextTransaction transaction behave more similarly to the rest of the editor transactions, by making sure the inner transactions don't manipulate the selections themselves and leave it up to the AfterEdit() method to take care of adjusting the selection when the entire editing operation is finished.
editor/libeditor/TextEditRules.cpp
--- a/editor/libeditor/TextEditRules.cpp
+++ b/editor/libeditor/TextEditRules.cpp
@@ -896,16 +896,19 @@ TextEditRules::WillSetText(Selection& aS
     return NS_OK;
   }
 
   nsINode* curNode = rootElement->GetFirstChild();
   if (NS_WARN_IF(!EditorBase::IsTextNode(curNode))) {
     return NS_OK;
   }
 
+  // don't spaz my selection in subtransactions
+  AutoTransactionsConserveSelection dontSpazMySelection(textEditor);
+
   // Even if empty text, we don't remove text node and set empty text
   // for performance
   nsresult rv = textEditor->SetTextImpl(aSelection, tString,
                                         *curNode->GetAsText());
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }