Bug 1310912 - Part 3. The selection into PlaceholderTransaction should be updated via RangeUpdater. r?masayuki draft
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Thu, 10 Nov 2016 21:10:50 +0900
changeset 437524 9e1a71a7f497181171209ac05edcbddae227ab93
parent 437523 e7be1cb9e5c7c0fb4283f81541fc7441f52a1101
child 437525 02a8bebe6c89ceb023bd598b77b40c5817cd4007
push id35433
push userm_kato@ga2.so-net.ne.jp
push dateFri, 11 Nov 2016 01:31:07 +0000
reviewersmasayuki
bugs1310912
milestone52.0a1
Bug 1310912 - Part 3. The selection into PlaceholderTransaction should be updated via RangeUpdater. r?masayuki Since the selection into PlaceholderTransaction isn't updated via RangeUpdater, UndoTransaction may return error when selection/caret position is changed. Then, redo is failed. So we should add selection into PlaceholderTrancation to RangeUpdater. MozReview-Commit-ID: LcUIiUExNhx
editor/libeditor/EditorBase.cpp
--- a/editor/libeditor/EditorBase.cpp
+++ b/editor/libeditor/EditorBase.cpp
@@ -922,16 +922,17 @@ EditorBase::BeginPlaceHolderTransaction(
     // time to turn on the batch
     BeginUpdateViewBatch();
     mPlaceHolderTxn = nullptr;
     mPlaceHolderName = aName;
     RefPtr<Selection> selection = GetSelection();
     if (selection) {
       mSelState = new SelectionState();
       mSelState->SaveSelection(selection);
+      mRangeUpdater.RegisterSelectionState(*mSelState);
     }
   }
   mPlaceHolderBatch++;
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
@@ -973,16 +974,17 @@ EditorBase::EndPlaceHolderTransaction()
     // cached for frame offset are Not available now
     if (selection) {
       selection->SetCanCacheFrameOffset(false);
     }
 
     if (mSelState) {
       // we saved the selection state, but never got to hand it to placeholder
       // (else we ould have nulled out this pointer), so destroy it to prevent leaks.
+      mRangeUpdater.DropSelectionState(*mSelState);
       delete mSelState;
       mSelState = nullptr;
     }
     // We might have never made a placeholder if no action took place.
     if (mPlaceHolderTxn) {
       nsCOMPtr<nsIAbsorbingTransaction> plcTxn = do_QueryReferent(mPlaceHolderTxn);
       if (plcTxn) {
         plcTxn->EndPlaceHolderBatch();