Skip to content

Commit

Permalink
Bug 1556922. Stop using [array] in nsIEditorSpellCheck. r=masayuki
Browse files Browse the repository at this point in the history
  • Loading branch information
bzbarsky committed Jun 5, 2019
1 parent f691a81 commit 127dec0
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 52 deletions.
2 changes: 1 addition & 1 deletion editor/nsIEditorSpellCheck.idl
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ interface nsIEditorSpellCheck : nsISupports
*
* @see mozISpellCheckingEngine::GetDictionaryList
*/
void GetDictionaryList([array, size_is(count)] out wstring dictionaryList, out uint32_t count);
Array<AString> GetDictionaryList();

/**
* @see mozSpellChecker::GetCurrentDictionary
Expand Down
40 changes: 2 additions & 38 deletions editor/spellchecker/EditorSpellCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -501,46 +501,10 @@ EditorSpellCheck::RemoveWordFromDictionary(const nsAString& aWord) {
}

NS_IMETHODIMP
EditorSpellCheck::GetDictionaryList(char16_t*** aDictionaryList,
uint32_t* aCount) {
EditorSpellCheck::GetDictionaryList(nsTArray<nsString>& aList) {
NS_ENSURE_TRUE(mSpellChecker, NS_ERROR_NOT_INITIALIZED);

NS_ENSURE_TRUE(aDictionaryList && aCount, NS_ERROR_NULL_POINTER);

*aDictionaryList = 0;
*aCount = 0;

nsTArray<nsString> 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
Expand Down
7 changes: 3 additions & 4 deletions editor/spellchecker/tests/test_bug338427.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,10 @@
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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 1 addition & 3 deletions toolkit/modules/InlineSpellChecker.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}
Expand Down
5 changes: 2 additions & 3 deletions toolkit/modules/InlineSpellCheckerContent.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -63,7 +62,7 @@ var InlineSpellCheckerContent = {
misspelling: spellChecker.mMisspelling,
spellSuggestions: this._generateSpellSuggestions(),
currentDictionary: spellChecker.mInlineSpellChecker.spellChecker.GetCurrentDictionary(),
dictionaryList: dictionaryList.value };
dictionaryList };
},

uninitContextMenu() {
Expand Down

0 comments on commit 127dec0

Please sign in to comment.