Bug 1030451-Update spellchecker context menu suggestions for multiprocess.r=billm

This commit is contained in:
Allison Naaktgeboren 2014-08-11 13:07:54 -07:00
Родитель feca7cd8ff
Коммит 2bf5772323
6 изменённых файлов: 51 добавлений и 14 удалений

Просмотреть файл

@ -75,7 +75,7 @@ addEventListener("blur", function(event) {
if (Services.appinfo.processType == Services.appinfo.PROCESS_TYPE_CONTENT) {
addEventListener("contextmenu", function (event) {
sendAsyncMessage("contextmenu", {}, { event: event });
sendSyncMessage("contextmenu", {}, { event: event });
}, false);
} else {
addEventListener("mozUITour", function(event) {

Просмотреть файл

@ -504,6 +504,8 @@ nsContextMenu.prototype = {
if (gContextMenuContentData) {
this.isRemote = true;
aNode = gContextMenuContentData.event.target;
aRangeParent = gContextMenuContentData.event.rangeParent;
aRangeOffset = gContextMenuContentData.event.rangeOffset;
} else {
this.isRemote = false;
}

Просмотреть файл

@ -6,15 +6,17 @@ include protocol PContent;
namespace mozilla {
sync protocol PRemoteSpellcheckEngine {
rpc protocol PRemoteSpellcheckEngine {
manager PContent;
parent:
__delete__();
sync CheckForMisspelling(nsString aWord) returns (bool isMisspelled);
rpc Check(nsString aWord) returns (bool aIsMisspelled);
sync SetDictionary(nsString aDictionary) returns (bool success);
rpc CheckAndSuggest(nsString aWord) returns (bool aIsMisspelled, nsString[] aSuggestions);
rpc SetDictionary(nsString aDictionary) returns (bool success);
};
} // namespace mozilla

Просмотреть файл

@ -20,7 +20,7 @@ RemoteSpellcheckEngineParent::~RemoteSpellcheckEngineParent()
}
bool
RemoteSpellcheckEngineParent::RecvSetDictionary(
RemoteSpellcheckEngineParent::AnswerSetDictionary(
const nsString& aDictionary,
bool* success)
{
@ -30,13 +30,34 @@ RemoteSpellcheckEngineParent::RecvSetDictionary(
}
bool
RemoteSpellcheckEngineParent::RecvCheckForMisspelling(
RemoteSpellcheckEngineParent::AnswerCheck(
const nsString& aWord,
bool* isMisspelled)
bool* aIsMisspelled)
{
bool isCorrect = false;
bool isCorrect = true;
mEngine->Check(aWord.get(), &isCorrect);
*isMisspelled = !isCorrect;
*aIsMisspelled = !isCorrect;
return true;
}
bool
RemoteSpellcheckEngineParent::AnswerCheckAndSuggest(
const nsString& aWord,
bool* aIsMisspelled,
InfallibleTArray<nsString>* aSuggestions)
{
bool isCorrect = true;
mEngine->Check(aWord.get(), &isCorrect);
*aIsMisspelled = !isCorrect;
if (!isCorrect) {
char16_t **suggestions;
uint32_t count = 0;
mEngine->Suggest(aWord.get(), &suggestions, &count);
for (uint32_t i=0; i<count; i++) {
aSuggestions->AppendElement(nsDependentString(suggestions[i]));
}
}
return true;
}

Просмотреть файл

@ -19,9 +19,16 @@ public:
virtual void ActorDestroy(ActorDestroyReason aWhy);
bool RecvSetDictionary(const nsString& aDictionary, bool* success);
bool AnswerSetDictionary(const nsString& aDictionary, bool* success);
bool AnswerCheck( const nsString& aWord, bool* aIsMisspelled);
bool AnswerCheckAndSuggest(
const nsString& aWord,
bool* aIsMisspelled,
InfallibleTArray<nsString>* aSuggestions);
bool RecvCheckForMisspelling( const nsString& aWord, bool* isMisspelled);
private:
nsCOMPtr<mozISpellCheckingEngine> mEngine;

Просмотреть файл

@ -128,7 +128,12 @@ mozSpellChecker::CheckWord(const nsAString &aWord, bool *aIsMisspelled, nsTArray
if (XRE_GetProcessType() == GeckoProcessType_Content) {
nsString wordwrapped = nsString(aWord);
bool rv = mEngine->SendCheckForMisspelling(wordwrapped, aIsMisspelled);
bool rv;
if (aSuggestions) {
rv = mEngine->CallCheckAndSuggest(wordwrapped, aIsMisspelled, aSuggestions);
} else {
rv = mEngine->CallCheck(wordwrapped, aIsMisspelled);
}
return rv ? NS_OK : NS_ERROR_NOT_AVAILABLE;
}
@ -359,7 +364,7 @@ mozSpellChecker::SetCurrentDictionary(const nsAString &aDictionary)
if (XRE_GetProcessType() == GeckoProcessType_Content) {
nsString wrappedDict = nsString(aDictionary);
bool isSuccess;
mEngine->SendSetDictionary(wrappedDict, &isSuccess);
mEngine->CallSetDictionary(wrappedDict, &isSuccess);
return isSuccess ? NS_OK : NS_ERROR_NOT_AVAILABLE;
}
@ -562,4 +567,4 @@ mozSpellChecker::GetEngineList(nsCOMArray<mozISpellCheckingEngine>* aSpellChecki
void mozSpellChecker::DeleteRemoteEngine() {
mEngine = nullptr;
}
}