Bug 1370806 - Part 2. Remove selection before calling nsIPlaintextEditor.setText. r=masayuki

nsIPlaintestEditor.setText still use BeginPlaceHolderTransaction and EndPlaceHolderTransaction.  But since input.value setter doesn't create undo transaction, it is unnecessary to save/restore selection via AutoPlaceHolderBatch.  So before calling setText, we should reset selection to reduce saving and restoring selection.

Save/Restore selection is ~7% of input.value setter.

MozReview-Commit-ID: 6yBKCtRmkQt

--HG--
extra : rebase_source : 4df5d0629f083b75615b96b17bc108613fe80c24
This commit is contained in:
Makoto Kato 2017-06-07 15:31:06 +09:00
parent 5644a572f6
commit e1017e8b12

View File

@ -2661,6 +2661,11 @@ nsTextEditorState::SetValue(const nsAString& aValue, uint32_t aFlags)
}
} else {
AutoDisableUndo disableUndo(mEditor);
if (domSel) {
// Since we don't use undo transaction, we don't need to store
// selection state. SetText will set selection to tail.
domSel->RemoveAllRanges();
}
plaintextEditor->SetText(newValue);
}