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

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

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