Bug 1700051: part 13) Reduce accessibility of `mozInlineSpellStatus`'s constructor to `private`. r=smaug

Prevents users of `mozInlineSpellStatus` forgetting to initialize it.

Differential Revision: https://phabricator.services.mozilla.com/D109748
This commit is contained in:
Mirko Brodesser 2021-03-26 09:21:13 +00:00
Родитель 14313e8270
Коммит 17b3805751
2 изменённых файлов: 15 добавлений и 11 удалений

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

@ -115,8 +115,9 @@ mozInlineSpellStatus::CreateForEditorChange(
return Err(NS_ERROR_FAILURE);
}
UniquePtr<mozInlineSpellStatus> status =
MakeUnique<mozInlineSpellStatus>(&aSpellChecker);
UniquePtr<mozInlineSpellStatus> 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<mozInlineSpellStatus> status =
MakeUnique<mozInlineSpellStatus>(&aSpellChecker);
UniquePtr<mozInlineSpellStatus> status{
/* The constructor is `private`, hence the explicit allocation. */
new mozInlineSpellStatus{&aSpellChecker}};
status->mOp = eOpNavigation;
@ -267,8 +269,9 @@ mozInlineSpellStatus::CreateForNavigation(
// static
UniquePtr<mozInlineSpellStatus> mozInlineSpellStatus::CreateForSelection(
mozInlineSpellChecker& aSpellChecker) {
UniquePtr<mozInlineSpellStatus> status =
MakeUnique<mozInlineSpellStatus>(&aSpellChecker);
UniquePtr<mozInlineSpellStatus> status{
/* The constructor is `private`, hence the explicit allocation. */
new mozInlineSpellStatus{&aSpellChecker}};
status->mOp = eOpSelection;
return status;
}
@ -284,8 +287,9 @@ UniquePtr<mozInlineSpellStatus> mozInlineSpellStatus::CreateForRange(
MOZ_LOG(sInlineSpellCheckerLog, LogLevel::Debug,
("%s: range=%p", __FUNCTION__, aRange));
UniquePtr<mozInlineSpellStatus> status =
MakeUnique<mozInlineSpellStatus>(&aSpellChecker);
UniquePtr<mozInlineSpellStatus> status{
/* The constructor is `private`, hence the explicit allocation. */
new mozInlineSpellStatus{&aSpellChecker}};
status->mOp = eOpChange;
status->mRange = aRange;

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

@ -32,9 +32,6 @@ class Event;
class mozInlineSpellStatus {
public:
// @param aSpellChecker must be non-nullptr.
explicit mozInlineSpellStatus(mozInlineSpellChecker* aSpellChecker);
static mozilla::Result<mozilla::UniquePtr<mozInlineSpellStatus>, 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;