зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1502661 - Part 1. Add async IPC to check word by spellchecker. r=masayuki
Actually we have no async IPC for spellchecker, so I would like to add async IPC to check word. When using full check, spellchecker requests a lot of words to check word. New async IPC should allow multiple words per IPC to reduce IPC call. Differential Revision: https://phabricator.services.mozilla.com/D14835 --HG-- extra : rebase_source : e54177c1779dc7e2e48c189a65cbc212b4aa519a
This commit is contained in:
Родитель
dac799c9f4
Коммит
65e177f953
|
@ -13,6 +13,7 @@ parent:
|
|||
async __delete__();
|
||||
|
||||
sync Check(nsString aWord) returns (bool aIsMisspelled);
|
||||
async CheckAsync(nsString[] aWord) returns (bool[] aIsMisspelled);
|
||||
|
||||
sync CheckAndSuggest(nsString aWord) returns (bool aIsMisspelled, nsString[] aSuggestions);
|
||||
|
||||
|
|
|
@ -45,6 +45,23 @@ mozilla::ipc::IPCResult RemoteSpellcheckEngineParent::RecvCheck(
|
|||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult RemoteSpellcheckEngineParent::RecvCheckAsync(
|
||||
nsTArray<nsString>&& aWords, CheckAsyncResolver&& aResolve) {
|
||||
nsTArray<bool> misspells;
|
||||
misspells.SetCapacity(aWords.Length());
|
||||
for (auto& word : aWords) {
|
||||
bool misspelled;
|
||||
nsresult rv = mSpellChecker->CheckWord(word, &misspelled, nullptr);
|
||||
// If CheckWord failed, we can't tell whether the word is correctly spelled
|
||||
if (NS_FAILED(rv)) {
|
||||
misspelled = false;
|
||||
}
|
||||
misspells.AppendElement(misspelled);
|
||||
}
|
||||
aResolve(std::move(misspells));
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult RemoteSpellcheckEngineParent::RecvCheckAndSuggest(
|
||||
const nsString& aWord, bool* aIsMisspelled,
|
||||
InfallibleTArray<nsString>* aSuggestions) {
|
||||
|
|
|
@ -30,6 +30,9 @@ class RemoteSpellcheckEngineParent : public PRemoteSpellcheckEngineParent {
|
|||
virtual mozilla::ipc::IPCResult RecvCheck(const nsString& aWord,
|
||||
bool* aIsMisspelled) override;
|
||||
|
||||
virtual mozilla::ipc::IPCResult RecvCheckAsync(
|
||||
nsTArray<nsString>&& aWord, CheckAsyncResolver&& aResolve) override;
|
||||
|
||||
virtual mozilla::ipc::IPCResult RecvCheckAndSuggest(
|
||||
const nsString& aWord, bool* aIsMisspelled,
|
||||
InfallibleTArray<nsString>* aSuggestions) override;
|
||||
|
|
Загрузка…
Ссылка в новой задаче