зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1385392 - Avoid needlessly looking up the selection twice when DoTransaction() is called from TextEditRules::WillSetText(); r=masayuki
This commit is contained in:
Родитель
423b388329
Коммит
1eb17afc4f
|
@ -689,6 +689,12 @@ EditorBase::GetSelection(SelectionType aSelectionType)
|
|||
|
||||
NS_IMETHODIMP
|
||||
EditorBase::DoTransaction(nsITransaction* aTxn)
|
||||
{
|
||||
return DoTransaction(nullptr, aTxn);
|
||||
}
|
||||
|
||||
nsresult
|
||||
EditorBase::DoTransaction(Selection* aSelection, nsITransaction* aTxn)
|
||||
{
|
||||
if (mPlaceholderBatch && !mPlaceholderTransaction) {
|
||||
mPlaceholderTransaction =
|
||||
|
@ -736,7 +742,7 @@ EditorBase::DoTransaction(nsITransaction* aTxn)
|
|||
// XXX: re-entry during initial reflow. - kin
|
||||
|
||||
// get the selection and start a batch change
|
||||
RefPtr<Selection> selection = GetSelection();
|
||||
RefPtr<Selection> selection = aSelection ? aSelection : GetSelection();
|
||||
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
|
||||
|
||||
selection->StartBatchChanges();
|
||||
|
@ -2714,7 +2720,8 @@ EditorBase::NotifyDocumentListeners(
|
|||
}
|
||||
|
||||
nsresult
|
||||
EditorBase::SetTextImpl(const nsAString& aString, Text& aCharData)
|
||||
EditorBase::SetTextImpl(Selection& aSelection, const nsAString& aString,
|
||||
Text& aCharData)
|
||||
{
|
||||
RefPtr<SetTextTransaction> transaction =
|
||||
CreateTxnForSetText(aString, aCharData);
|
||||
|
@ -2744,7 +2751,7 @@ EditorBase::SetTextImpl(const nsAString& aString, Text& aCharData)
|
|||
}
|
||||
}
|
||||
|
||||
nsresult rv = DoTransaction(transaction);
|
||||
nsresult rv = DoTransaction(&aSelection, transaction);
|
||||
|
||||
// Let listeners know what happened
|
||||
{
|
||||
|
|
|
@ -279,7 +279,8 @@ public:
|
|||
Text& aTextNode, int32_t aOffset,
|
||||
bool aSuppressIME = false);
|
||||
|
||||
nsresult SetTextImpl(const nsAString& aString,
|
||||
nsresult SetTextImpl(Selection& aSelection,
|
||||
const nsAString& aString,
|
||||
Text& aTextNode);
|
||||
|
||||
NS_IMETHOD DeleteSelectionImpl(EDirection aAction,
|
||||
|
@ -495,6 +496,10 @@ protected:
|
|||
*/
|
||||
void DoAfterRedoTransaction();
|
||||
|
||||
// Note that aSelection is optional and can be nullptr.
|
||||
nsresult DoTransaction(Selection* aSelection,
|
||||
nsITransaction* aTxn);
|
||||
|
||||
enum TDocumentListenerNotification
|
||||
{
|
||||
eDocumentCreated,
|
||||
|
|
|
@ -903,7 +903,8 @@ TextEditRules::WillSetText(Selection& aSelection,
|
|||
|
||||
// Even if empty text, we don't remove text node and set empty text
|
||||
// for performance
|
||||
nsresult rv = textEditor->SetTextImpl(tString, *curNode->GetAsText());
|
||||
nsresult rv = textEditor->SetTextImpl(aSelection, tString,
|
||||
*curNode->GetAsText());
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче