Bug 1480055 - part 3: Create non-virtual method to set EditorBase::mAllowsTransactionsToChangeSelection r=m_kato

There is no non-virtual method to modify
EditorBase::mAllowsTransactionsToChangeSelection.  Therefore,
AutoTransactionsConserveSelection calls virtual method,
nsIEditor::SetShouldTxnSetSelection() twice (from both constructor and
destructor).  So, we should save this unnecessary cost.

MozReview-Commit-ID: B7TYGnGtuLB

--HG--
extra : rebase_source : 26ce77fb63a1967cca88b002cd65e1105477a63d
This commit is contained in:
Masayuki Nakano 2018-08-01 21:11:44 +09:00
Родитель a9559a1d82
Коммит 4292293e8c
3 изменённых файлов: 13 добавлений и 3 удалений

Просмотреть файл

@ -985,7 +985,7 @@ EditorBase::EndPlaceholderTransaction()
NS_IMETHODIMP
EditorBase::SetShouldTxnSetSelection(bool aShould)
{
mAllowsTransactionsToChangeSelection = aShould;
MakeThisAllowTransactionsToChangeSelection(aShould);
return NS_OK;
}

Просмотреть файл

@ -1556,6 +1556,16 @@ protected: // May be called by friends.
return mAllowsTransactionsToChangeSelection;
}
/**
* MakeThisAllowTransactionsToChangeSelection() with true makes this editor
* allow transactions to change Selection. Otherwise, i.e., with false,
* makes this editor not allow transactions to change Selection.
*/
inline void MakeThisAllowTransactionsToChangeSelection(bool aAllow)
{
mAllowsTransactionsToChangeSelection = aAllow;
}
nsresult HandleInlineSpellCheck(EditSubAction aEditSubAction,
Selection& aSelection,
nsINode* previousSelectedNode,

Просмотреть файл

@ -581,14 +581,14 @@ public:
if (mEditorBase) {
mAllowedTransactionsToChangeSelection =
mEditorBase->AllowsTransactionsToChangeSelection();
mEditorBase->SetShouldTxnSetSelection(false);
mEditorBase->MakeThisAllowTransactionsToChangeSelection(false);
}
}
~AutoTransactionsConserveSelection()
{
if (mEditorBase) {
mEditorBase->SetShouldTxnSetSelection(
mEditorBase->MakeThisAllowTransactionsToChangeSelection(
mAllowedTransactionsToChangeSelection);
}
}