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
--- 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();