зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1388269 - part4: Make mozInlineSpellChecker::GetSpellCheckSelection() return Selection instead of nsISelection r=m_kato
Although, this is not necessary for bug 1388269, we should fix this here since this change is really similar to what bug 1388269 tries to fix and enough simple and safe. MozReview-Commit-ID: H68pYTBmurf --HG-- extra : rebase_source : dfa47370232ad44e1523c94929cf50e5539b787d
This commit is contained in:
Родитель
310515ea06
Коммит
1f7edc42ce
|
@ -602,11 +602,12 @@ mozInlineSpellChecker::Init(nsIEditor* aEditor)
|
|||
nsresult mozInlineSpellChecker::Cleanup(bool aDestroyingFrames)
|
||||
{
|
||||
mNumWordsInSpellSelection = 0;
|
||||
nsCOMPtr<nsISelection> spellCheckSelection;
|
||||
nsresult rv = GetSpellCheckSelection(getter_AddRefs(spellCheckSelection));
|
||||
if (NS_FAILED(rv)) {
|
||||
RefPtr<Selection> spellCheckSelection = GetSpellCheckSelection();
|
||||
nsresult rv = NS_OK;
|
||||
if (!spellCheckSelection) {
|
||||
// Ensure we still unregister event listeners (but return a failure code)
|
||||
UnregisterEventListeners();
|
||||
rv = NS_ERROR_FAILURE;
|
||||
} else {
|
||||
if (!aDestroyingFrames) {
|
||||
spellCheckSelection->RemoveAllRanges();
|
||||
|
@ -936,11 +937,13 @@ NS_IMETHODIMP
|
|||
mozInlineSpellChecker::GetMisspelledWord(nsIDOMNode *aNode, int32_t aOffset,
|
||||
nsIDOMRange **newword)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aNode);
|
||||
nsCOMPtr<nsISelection> spellCheckSelection;
|
||||
nsresult res = GetSpellCheckSelection(getter_AddRefs(spellCheckSelection));
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
|
||||
if (NS_WARN_IF(!aNode)) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
RefPtr<Selection> spellCheckSelection = GetSpellCheckSelection();
|
||||
if (NS_WARN_IF(!spellCheckSelection)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
return IsPointInSelection(spellCheckSelection, aNode, aOffset, newword);
|
||||
}
|
||||
|
||||
|
@ -1658,12 +1661,10 @@ mozInlineSpellChecker::ResumeCheck(UniquePtr<mozInlineSpellStatus>&& aStatus)
|
|||
if (NS_FAILED(rv))
|
||||
return NS_OK; // editor doesn't like us, don't assert
|
||||
|
||||
nsCOMPtr<nsISelection> spellCheckSelectionRef;
|
||||
rv = GetSpellCheckSelection(getter_AddRefs(spellCheckSelectionRef));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
auto spellCheckSelection =
|
||||
static_cast<Selection *>(spellCheckSelectionRef.get());
|
||||
RefPtr<Selection> spellCheckSelection = GetSpellCheckSelection();
|
||||
if (NS_WARN_IF(!spellCheckSelection)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsAutoString currentDictionary;
|
||||
rv = mSpellCheck->GetCurrentDictionary(currentDictionary);
|
||||
|
@ -1807,20 +1808,18 @@ mozInlineSpellChecker::AddRange(nsISelection* aSpellCheckSelection,
|
|||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
mozInlineSpellChecker::GetSpellCheckSelection(
|
||||
nsISelection** aSpellCheckSelection)
|
||||
already_AddRefed<Selection>
|
||||
mozInlineSpellChecker::GetSpellCheckSelection()
|
||||
{
|
||||
if (NS_WARN_IF(!mTextEditor)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
return nullptr;
|
||||
}
|
||||
RefPtr<Selection> selection =
|
||||
mTextEditor->GetSelection(SelectionType::eSpellCheck);
|
||||
if (!selection) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
return nullptr;
|
||||
}
|
||||
selection.forget(aSpellCheckSelection);
|
||||
return NS_OK;
|
||||
return selection.forget();
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
|
|
@ -247,7 +247,7 @@ public:
|
|||
nsresult UnregisterEventListeners();
|
||||
nsresult HandleNavigationEvent(bool aForceWordSpellCheck, int32_t aNewPositionOffset = 0);
|
||||
|
||||
nsresult GetSpellCheckSelection(nsISelection ** aSpellCheckSelection);
|
||||
already_AddRefed<mozilla::dom::Selection> GetSpellCheckSelection();
|
||||
nsresult SaveCurrentSelectionPosition();
|
||||
|
||||
nsresult ResumeCheck(mozilla::UniquePtr<mozInlineSpellStatus>&& aStatus);
|
||||
|
|
Загрузка…
Ссылка в новой задаче