зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1700051: part 8) Change `mozInlineSpellStatus::InitForNavigation` to static factory method. r=smaug
The next part changes its return type to `Result<..., nsresult>`. Differential Revision: https://phabricator.services.mozilla.com/D109743
This commit is contained in:
Родитель
d38cbe5571
Коммит
5dde374aaf
|
@ -206,24 +206,29 @@ mozInlineSpellStatus::CreateForEditorChange(
|
|||
return status;
|
||||
}
|
||||
|
||||
// mozInlineSpellStatus::InitForNavigation
|
||||
// mozInlineSpellStatus::CreateForNavigation
|
||||
//
|
||||
// For navigation events, we just need to store the new and old positions.
|
||||
//
|
||||
// In some cases, we detect that we shouldn't check. If this event should
|
||||
// not be processed, *aContinue will be false.
|
||||
|
||||
nsresult mozInlineSpellStatus::InitForNavigation(
|
||||
bool aForceCheck, int32_t aNewPositionOffset, nsINode* aOldAnchorNode,
|
||||
// static
|
||||
nsresult mozInlineSpellStatus::CreateForNavigation(
|
||||
UniquePtr<mozInlineSpellStatus>& aStatus,
|
||||
mozInlineSpellChecker& aSpellChecker, bool aForceCheck,
|
||||
int32_t aNewPositionOffset, nsINode* aOldAnchorNode,
|
||||
uint32_t aOldAnchorOffset, nsINode* aNewAnchorNode,
|
||||
uint32_t aNewAnchorOffset, bool* aContinue) {
|
||||
mOp = eOpNavigation;
|
||||
aStatus = MakeUnique<mozInlineSpellStatus>(&aSpellChecker);
|
||||
|
||||
mForceNavigationWordCheck = aForceCheck;
|
||||
mNewNavigationPositionOffset = aNewPositionOffset;
|
||||
aStatus->mOp = eOpNavigation;
|
||||
|
||||
aStatus->mForceNavigationWordCheck = aForceCheck;
|
||||
aStatus->mNewNavigationPositionOffset = aNewPositionOffset;
|
||||
|
||||
// get the root node for checking
|
||||
TextEditor* textEditor = mSpellChecker->mTextEditor;
|
||||
TextEditor* textEditor = aStatus->mSpellChecker->mTextEditor;
|
||||
if (NS_WARN_IF(!textEditor)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -238,13 +243,14 @@ nsresult mozInlineSpellStatus::InitForNavigation(
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
mOldNavigationAnchorRange =
|
||||
PositionToCollapsedRange(aOldAnchorNode, aOldAnchorOffset);
|
||||
if (NS_WARN_IF(!mOldNavigationAnchorRange)) {
|
||||
aStatus->mOldNavigationAnchorRange =
|
||||
aStatus->PositionToCollapsedRange(aOldAnchorNode, aOldAnchorOffset);
|
||||
if (NS_WARN_IF(!aStatus->mOldNavigationAnchorRange)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
mAnchorRange = PositionToCollapsedRange(aNewAnchorNode, aNewAnchorOffset);
|
||||
if (NS_WARN_IF(!mAnchorRange)) {
|
||||
aStatus->mAnchorRange =
|
||||
aStatus->PositionToCollapsedRange(aNewAnchorNode, aNewAnchorOffset);
|
||||
if (NS_WARN_IF(!aStatus->mAnchorRange)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -1743,11 +1749,11 @@ nsresult mozInlineSpellChecker::HandleNavigationEvent(
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
bool shouldPost;
|
||||
auto status = MakeUnique<mozInlineSpellStatus>(this);
|
||||
rv = status->InitForNavigation(aForceWordSpellCheck, aNewPositionOffset,
|
||||
currentAnchorNode, currentAnchorOffset,
|
||||
mCurrentSelectionAnchorNode,
|
||||
mCurrentSelectionOffset, &shouldPost);
|
||||
UniquePtr<mozInlineSpellStatus> status;
|
||||
rv = status->CreateForNavigation(
|
||||
status, *this, aForceWordSpellCheck, aNewPositionOffset,
|
||||
currentAnchorNode, currentAnchorOffset, mCurrentSelectionAnchorNode,
|
||||
mCurrentSelectionOffset, &shouldPost);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (shouldPost) {
|
||||
rv = ScheduleSpellCheck(std::move(status));
|
||||
|
|
|
@ -42,10 +42,13 @@ class mozInlineSpellStatus {
|
|||
nsINode* aPreviousNode, uint32_t aPreviousOffset,
|
||||
nsINode* aStartNode, uint32_t aStartOffset,
|
||||
nsINode* aEndNode, uint32_t aEndOffset);
|
||||
nsresult InitForNavigation(bool aForceCheck, int32_t aNewPositionOffset,
|
||||
nsINode* aOldAnchorNode, uint32_t aOldAnchorOffset,
|
||||
nsINode* aNewAnchorNode, uint32_t aNewAnchorOffset,
|
||||
bool* aContinue);
|
||||
|
||||
static nsresult CreateForNavigation(
|
||||
mozilla::UniquePtr<mozInlineSpellStatus>& aStatus,
|
||||
mozInlineSpellChecker& aSpellChecker, bool aForceCheck,
|
||||
int32_t aNewPositionOffset, nsINode* aOldAnchorNode,
|
||||
uint32_t aOldAnchorOffset, nsINode* aNewAnchorNode,
|
||||
uint32_t aNewAnchorOffset, bool* aContinue);
|
||||
nsresult InitForSelection();
|
||||
nsresult InitForRange(nsRange* aRange);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче