зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1030451-Update spellchecker context menu suggestions for multiprocess.r=billm
This commit is contained in:
Родитель
feca7cd8ff
Коммит
2bf5772323
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче