From 2214b0dc002fbf9ff9f8eb228a3113e137b61ce3 Mon Sep 17 00:00:00 2001 From: Masayuki Nakano Date: Thu, 9 Dec 2021 07:44:09 +0000 Subject: [PATCH] Bug 1735446 - part 5: Make `nsIInlineSpellChecker` use `unsigned long` as offset in node r=m_kato It has two methods which take (signed) `long` argument to specify offset in a DOM node, but it's declared as "unsigned long" in the standards. And now, they work with rewritten Selection API which take `uint32_t` so that they should use `unsigned long` for making the handling simpler and safer. Differential Revision: https://phabricator.services.mozilla.com/D131034 --- editor/spellchecker/nsIInlineSpellChecker.idl | 6 ++++-- extensions/spellcheck/src/mozInlineSpellChecker.cpp | 11 +++++------ extensions/spellcheck/src/mozInlineSpellChecker.h | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/editor/spellchecker/nsIInlineSpellChecker.idl b/editor/spellchecker/nsIInlineSpellChecker.idl index b95bb954b4ae..d6f66a793d90 100644 --- a/editor/spellchecker/nsIInlineSpellChecker.idl +++ b/editor/spellchecker/nsIInlineSpellChecker.idl @@ -24,9 +24,11 @@ interface nsIInlineSpellChecker : nsISupports void spellCheckRange(in Range aSelection); - Range getMisspelledWord(in Node aNode, in long aOffset); + Range getMisspelledWord(in Node aNode, in unsigned long aOffset); [can_run_script] - void replaceWord(in Node aNode, in long aOffset, in AString aNewword); + void replaceWord(in Node aNode, + in unsigned long aOffset, + in AString aNewword); void addWordToDictionary(in AString aWord); void removeWordFromDictionary(in AString aWord); diff --git a/extensions/spellcheck/src/mozInlineSpellChecker.cpp b/extensions/spellcheck/src/mozInlineSpellChecker.cpp index e84035ecc1b2..4ca8b69183a3 100644 --- a/extensions/spellcheck/src/mozInlineSpellChecker.cpp +++ b/extensions/spellcheck/src/mozInlineSpellChecker.cpp @@ -906,7 +906,7 @@ nsresult mozInlineSpellChecker::SpellCheckRange(nsRange* aRange) { // mozInlineSpellChecker::GetMisspelledWord NS_IMETHODIMP -mozInlineSpellChecker::GetMisspelledWord(nsINode* aNode, int32_t aOffset, +mozInlineSpellChecker::GetMisspelledWord(nsINode* aNode, uint32_t aOffset, nsRange** newword) { if (NS_WARN_IF(!aNode)) { return NS_ERROR_INVALID_ARG; @@ -921,7 +921,7 @@ mozInlineSpellChecker::GetMisspelledWord(nsINode* aNode, int32_t aOffset, // mozInlineSpellChecker::ReplaceWord NS_IMETHODIMP -mozInlineSpellChecker::ReplaceWord(nsINode* aNode, int32_t aOffset, +mozInlineSpellChecker::ReplaceWord(nsINode* aNode, uint32_t aOffset, const nsAString& aNewWord) { if (NS_WARN_IF(!mEditorBase) || NS_WARN_IF(aNewWord.IsEmpty())) { return NS_ERROR_FAILURE; @@ -1715,14 +1715,13 @@ nsresult mozInlineSpellChecker::ResumeCheck( // static nsresult mozInlineSpellChecker::IsPointInSelection(Selection& aSelection, nsINode* aNode, - int32_t aOffset, + uint32_t aOffset, nsRange** aRange) { *aRange = nullptr; nsTArray ranges; - nsresult rv = aSelection.GetRangesForIntervalArray( - aNode, AssertedCast(aOffset), aNode, - static_cast(aOffset), true, &ranges); + nsresult rv = aSelection.GetRangesForIntervalArray(aNode, aOffset, aNode, + aOffset, true, &ranges); NS_ENSURE_SUCCESS(rv, rv); if (ranges.Length() == 0) return NS_OK; // no matches diff --git a/extensions/spellcheck/src/mozInlineSpellChecker.h b/extensions/spellcheck/src/mozInlineSpellChecker.h index e3d0648cd5dd..0e304c93a2c7 100644 --- a/extensions/spellcheck/src/mozInlineSpellChecker.h +++ b/extensions/spellcheck/src/mozInlineSpellChecker.h @@ -251,7 +251,7 @@ class mozInlineSpellChecker final : public nsIInlineSpellChecker, // helper routine to determine if a point is inside of the passed in // selection. static nsresult IsPointInSelection(mozilla::dom::Selection& aSelection, - nsINode* aNode, int32_t aOffset, + nsINode* aNode, uint32_t aOffset, nsRange** aRange); nsresult CleanupRangesInSelection(mozilla::dom::Selection* aSelection);