Bug 1768317 - Make `InsertTextTransaction::GetData()` returns reference of its `mStringToInsert` r=m_kato

Differential Revision: https://phabricator.services.mozilla.com/D179521
This commit is contained in:
Masayuki Nakano 2023-06-12 00:08:02 +00:00
Родитель a062f85860
Коммит 9f3eb23029
2 изменённых файлов: 4 добавлений и 10 удалений

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

@ -157,9 +157,7 @@ NS_IMETHODIMP InsertTextTransaction::Merge(nsITransaction* aOtherTransaction,
return NS_OK;
}
nsAutoString otherData;
otherInsertTextTransaction->GetData(otherData);
mStringToInsert += otherData;
mStringToInsert += otherInsertTextTransaction->GetData();
*aDidMerge = true;
MOZ_LOG(GetLogModule(), LogLevel::Debug,
("%p InsertTextTransaction::%s(aOtherTransaction=%p) returned true",
@ -169,12 +167,8 @@ NS_IMETHODIMP InsertTextTransaction::Merge(nsITransaction* aOtherTransaction,
/* ============ private methods ================== */
void InsertTextTransaction::GetData(nsString& aResult) {
aResult = mStringToInsert;
}
bool InsertTextTransaction::IsSequentialInsert(
InsertTextTransaction& aOtherTransaction) {
InsertTextTransaction& aOtherTransaction) const {
return aOtherTransaction.mTextNode == mTextNode &&
aOtherTransaction.mOffset == mOffset + mStringToInsert.Length();
}

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

@ -56,7 +56,7 @@ class InsertTextTransaction final : public EditTransactionBase {
/**
* Return the string data associated with this transaction.
*/
void GetData(nsString& aResult);
const nsString& GetData() const { return mStringToInsert; }
template <typename EditorDOMPointType>
EditorDOMPointType SuggestPointToPutCaret() const {
@ -73,7 +73,7 @@ class InsertTextTransaction final : public EditTransactionBase {
virtual ~InsertTextTransaction() = default;
// Return true if aOtherTransaction immediately follows this transaction.
bool IsSequentialInsert(InsertTextTransaction& aOtherTrasaction);
bool IsSequentialInsert(InsertTextTransaction& aOtherTransaction) const;
// The Text node to operate upon.
RefPtr<dom::Text> mTextNode;