From 9b956f652d3a5973ee6c1b056463c99f2734845c Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Wed, 5 Jun 2019 04:07:28 +0000 Subject: [PATCH] Bug 1556922. Stop using [array] in nsIEditorSpellCheck. r=masayuki Differential Revision: https://phabricator.services.mozilla.com/D33742 --HG-- extra : moz-landing-system : lando --- editor/nsIEditorSpellCheck.idl | 2 +- editor/spellchecker/EditorSpellCheck.cpp | 40 +------------------ editor/spellchecker/tests/test_bug338427.html | 7 ++-- .../chrome/test_add_remove_dictionaries.xul | 4 +- toolkit/modules/InlineSpellChecker.jsm | 4 +- toolkit/modules/InlineSpellCheckerContent.jsm | 5 +-- 6 files changed, 10 insertions(+), 52 deletions(-) diff --git a/editor/nsIEditorSpellCheck.idl b/editor/nsIEditorSpellCheck.idl index 13d759c53102..4c5d21a3343e 100644 --- a/editor/nsIEditorSpellCheck.idl +++ b/editor/nsIEditorSpellCheck.idl @@ -109,7 +109,7 @@ interface nsIEditorSpellCheck : nsISupports * * @see mozISpellCheckingEngine::GetDictionaryList */ - void GetDictionaryList([array, size_is(count)] out wstring dictionaryList, out uint32_t count); + Array GetDictionaryList(); /** * @see mozSpellChecker::GetCurrentDictionary diff --git a/editor/spellchecker/EditorSpellCheck.cpp b/editor/spellchecker/EditorSpellCheck.cpp index e6e8d4407f85..838d718b07ca 100644 --- a/editor/spellchecker/EditorSpellCheck.cpp +++ b/editor/spellchecker/EditorSpellCheck.cpp @@ -501,46 +501,10 @@ EditorSpellCheck::RemoveWordFromDictionary(const nsAString& aWord) { } NS_IMETHODIMP -EditorSpellCheck::GetDictionaryList(char16_t*** aDictionaryList, - uint32_t* aCount) { +EditorSpellCheck::GetDictionaryList(nsTArray& aList) { NS_ENSURE_TRUE(mSpellChecker, NS_ERROR_NOT_INITIALIZED); - NS_ENSURE_TRUE(aDictionaryList && aCount, NS_ERROR_NULL_POINTER); - - *aDictionaryList = 0; - *aCount = 0; - - nsTArray dictList; - - nsresult rv = mSpellChecker->GetDictionaryList(&dictList); - - NS_ENSURE_SUCCESS(rv, rv); - - char16_t** tmpPtr = 0; - - if (dictList.IsEmpty()) { - // If there are no dictionaries, return an array containing - // one element and a count of one. - - tmpPtr = (char16_t**)moz_xmalloc(sizeof(char16_t*)); - - *tmpPtr = 0; - *aDictionaryList = tmpPtr; - *aCount = 0; - - return NS_OK; - } - - tmpPtr = (char16_t**)moz_xmalloc(sizeof(char16_t*) * dictList.Length()); - - *aDictionaryList = tmpPtr; - *aCount = dictList.Length(); - - for (uint32_t i = 0; i < *aCount; i++) { - tmpPtr[i] = ToNewUnicode(dictList[i]); - } - - return rv; + return mSpellChecker->GetDictionaryList(&aList); } NS_IMETHODIMP diff --git a/editor/spellchecker/tests/test_bug338427.html b/editor/spellchecker/tests/test_bug338427.html index a3d143a25f71..9c0994437a27 100644 --- a/editor/spellchecker/tests/test_bug338427.html +++ b/editor/spellchecker/tests/test_bug338427.html @@ -31,11 +31,10 @@ function init() { textarea.focus(); onSpellCheck(textarea, function() { - var list = {}, count = {}; - spellchecker.spellChecker.GetDictionaryList(list, count); - ok(count.value > 0, "At least one dictionary should be present"); + var list = spellchecker.spellChecker.GetDictionaryList(); + ok(list.length > 0, "At least one dictionary should be present"); - var lang = list.value[0]; + var lang = list[0]; spellchecker.spellChecker.SetCurrentDictionary(lang); onSpellCheck(textarea, function() { diff --git a/extensions/spellcheck/tests/chrome/test_add_remove_dictionaries.xul b/extensions/spellcheck/tests/chrome/test_add_remove_dictionaries.xul index 0b8b064c4f8b..cc18f79f2786 100644 --- a/extensions/spellcheck/tests/chrome/test_add_remove_dictionaries.xul +++ b/extensions/spellcheck/tests/chrome/test_add_remove_dictionaries.xul @@ -21,9 +21,7 @@ function getMisspelledWords(editor) { function getDictionaryList(editor) { var spellchecker = editor.getInlineSpellChecker(true).spellChecker; - var o1 = {}; - spellchecker.GetDictionaryList(o1, {}); - return o1.value; + return spellchecker.GetDictionaryList(); } function getCurrentDictionary(editor) { diff --git a/toolkit/modules/InlineSpellChecker.jsm b/toolkit/modules/InlineSpellChecker.jsm index 9e3828332ee2..c07ed23de8a7 100644 --- a/toolkit/modules/InlineSpellChecker.jsm +++ b/toolkit/modules/InlineSpellChecker.jsm @@ -193,9 +193,7 @@ InlineSpellChecker.prototype = { curlang = this.mRemote.currentDictionary; } else if (this.mInlineSpellChecker) { var spellchecker = this.mInlineSpellChecker.spellChecker; - var o1 = {}, o2 = {}; - spellchecker.GetDictionaryList(o1, o2); - list = o1.value; + list = spellchecker.GetDictionaryList(); try { curlang = spellchecker.GetCurrentDictionary(); } catch (e) {} diff --git a/toolkit/modules/InlineSpellCheckerContent.jsm b/toolkit/modules/InlineSpellCheckerContent.jsm index 15fe44aaff98..69c9fc818c5a 100644 --- a/toolkit/modules/InlineSpellCheckerContent.jsm +++ b/toolkit/modules/InlineSpellCheckerContent.jsm @@ -52,9 +52,8 @@ var InlineSpellCheckerContent = { enableRealTimeSpell: true }; } - let dictionaryList = {}; let realSpellChecker = spellChecker.mInlineSpellChecker.spellChecker; - realSpellChecker.GetDictionaryList(dictionaryList, {}); + let dictionaryList = realSpellChecker.GetDictionaryList(); return { canSpellCheck: spellChecker.canSpellCheck, initialSpellCheckPending: spellChecker.initialSpellCheckPending, @@ -63,7 +62,7 @@ var InlineSpellCheckerContent = { misspelling: spellChecker.mMisspelling, spellSuggestions: this._generateSpellSuggestions(), currentDictionary: spellChecker.mInlineSpellChecker.spellChecker.GetCurrentDictionary(), - dictionaryList: dictionaryList.value }; + dictionaryList }; }, uninitContextMenu() {