diff --git a/extensions/spellcheck/src/mozInlineSpellChecker.cpp b/extensions/spellcheck/src/mozInlineSpellChecker.cpp index 8b270c43bb01..1469698ddf42 100644 --- a/extensions/spellcheck/src/mozInlineSpellChecker.cpp +++ b/extensions/spellcheck/src/mozInlineSpellChecker.cpp @@ -115,8 +115,9 @@ mozInlineSpellStatus::CreateForEditorChange( return Err(NS_ERROR_FAILURE); } - UniquePtr status = - MakeUnique(&aSpellChecker); + UniquePtr status{ + /* The constructor is `private`, hence the explicit allocation. */ + new mozInlineSpellStatus{&aSpellChecker}}; // save the anchor point as a range so we can find the current word later status->mAnchorRange = @@ -220,8 +221,9 @@ mozInlineSpellStatus::CreateForNavigation( int32_t aNewPositionOffset, nsINode* aOldAnchorNode, uint32_t aOldAnchorOffset, nsINode* aNewAnchorNode, uint32_t aNewAnchorOffset, bool* aContinue) { - UniquePtr status = - MakeUnique(&aSpellChecker); + UniquePtr status{ + /* The constructor is `private`, hence the explicit allocation. */ + new mozInlineSpellStatus{&aSpellChecker}}; status->mOp = eOpNavigation; @@ -267,8 +269,9 @@ mozInlineSpellStatus::CreateForNavigation( // static UniquePtr mozInlineSpellStatus::CreateForSelection( mozInlineSpellChecker& aSpellChecker) { - UniquePtr status = - MakeUnique(&aSpellChecker); + UniquePtr status{ + /* The constructor is `private`, hence the explicit allocation. */ + new mozInlineSpellStatus{&aSpellChecker}}; status->mOp = eOpSelection; return status; } @@ -284,8 +287,9 @@ UniquePtr mozInlineSpellStatus::CreateForRange( MOZ_LOG(sInlineSpellCheckerLog, LogLevel::Debug, ("%s: range=%p", __FUNCTION__, aRange)); - UniquePtr status = - MakeUnique(&aSpellChecker); + UniquePtr status{ + /* The constructor is `private`, hence the explicit allocation. */ + new mozInlineSpellStatus{&aSpellChecker}}; status->mOp = eOpChange; status->mRange = aRange; diff --git a/extensions/spellcheck/src/mozInlineSpellChecker.h b/extensions/spellcheck/src/mozInlineSpellChecker.h index b043226f4ecc..31218b1f0af9 100644 --- a/extensions/spellcheck/src/mozInlineSpellChecker.h +++ b/extensions/spellcheck/src/mozInlineSpellChecker.h @@ -32,9 +32,6 @@ class Event; class mozInlineSpellStatus { public: - // @param aSpellChecker must be non-nullptr. - explicit mozInlineSpellStatus(mozInlineSpellChecker* aSpellChecker); - static mozilla::Result, nsresult> CreateForEditorChange(mozInlineSpellChecker& aSpellChecker, mozilla::EditSubAction aEditSubAction, @@ -86,6 +83,9 @@ class mozInlineSpellStatus { const nsRange* GetNoCheckRange() const { return mNoCheckRange; } private: + // @param aSpellChecker must be non-nullptr. + explicit mozInlineSpellStatus(mozInlineSpellChecker* aSpellChecker); + // For resuming a previously started check. Operation mOp;