mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-02 10:00:54 +00:00
bug 582644 - IME event remoting, patch for android r=blassey blocking-fennec=2.0a1+
This commit is contained in:
parent
a60ca48289
commit
3d4ef5adca
@ -71,6 +71,11 @@
|
||||
#include "nsIContent.h"
|
||||
#include "mozilla/unused.h"
|
||||
|
||||
#ifdef ANDROID
|
||||
#include "AndroidBridge.h"
|
||||
using namespace mozilla;
|
||||
#endif
|
||||
|
||||
using mozilla::ipc::DocumentRendererParent;
|
||||
using mozilla::ipc::DocumentRendererShmemParent;
|
||||
using mozilla::ipc::DocumentRendererNativeIDParent;
|
||||
@ -570,7 +575,27 @@ TabParent::RecvAsyncMessage(const nsString& aMessage,
|
||||
bool
|
||||
TabParent::RecvQueryContentResult(const nsQueryContentEvent& event)
|
||||
{
|
||||
#ifdef ANDROID
|
||||
if (!event.mSucceeded) {
|
||||
AndroidBridge::Bridge()->ReturnIMEQueryResult(nsnull, 0, 0, 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (event.message) {
|
||||
case NS_QUERY_TEXT_CONTENT:
|
||||
AndroidBridge::Bridge()->ReturnIMEQueryResult(
|
||||
event.mReply.mString.get(), event.mReply.mString.Length(), 0, 0);
|
||||
break;
|
||||
case NS_QUERY_SELECTED_TEXT:
|
||||
AndroidBridge::Bridge()->ReturnIMEQueryResult(
|
||||
event.mReply.mString.get(),
|
||||
event.mReply.mString.Length(),
|
||||
event.GetSelectionStart(),
|
||||
event.GetSelectionEnd() - event.GetSelectionStart());
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -1261,6 +1261,20 @@ public:
|
||||
mInput.mLength = aLength;
|
||||
}
|
||||
|
||||
PRUint32 GetSelectionStart(void) const
|
||||
{
|
||||
NS_ASSERTION(message == NS_QUERY_SELECTED_TEXT,
|
||||
"not querying selection");
|
||||
return mReply.mOffset + (mReply.mReversed ? mReply.mString.Length() : 0);
|
||||
}
|
||||
|
||||
PRUint32 GetSelectionEnd(void) const
|
||||
{
|
||||
NS_ASSERTION(message == NS_QUERY_SELECTED_TEXT,
|
||||
"not querying selection");
|
||||
return mReply.mOffset + (mReply.mReversed ? 0 : mReply.mString.Length());
|
||||
}
|
||||
|
||||
PRBool mSucceeded;
|
||||
PRPackedBool mWasAsync;
|
||||
struct {
|
||||
|
@ -37,7 +37,10 @@
|
||||
|
||||
#include <android/log.h>
|
||||
|
||||
#ifdef MOZ_IPC
|
||||
#include "mozilla/dom/ContentChild.h"
|
||||
#include "nsXULAppAPI.h"
|
||||
#endif
|
||||
#include <pthread.h>
|
||||
#include <prthread.h>
|
||||
#include "nsXPCOMStrings.h"
|
||||
@ -192,8 +195,12 @@ AndroidBridge::NotifyIME(int aType, int aState)
|
||||
if (sBridge)
|
||||
JNI()->CallStaticVoidMethod(sBridge->mGeckoAppShellClass,
|
||||
sBridge->jNotifyIME, aType, aState);
|
||||
else
|
||||
#ifdef MOZ_IPC
|
||||
// It's possible that we are in chrome process
|
||||
// but sBridge is not initialized yet
|
||||
else if (XRE_GetProcessType() == GeckoProcessType_Content)
|
||||
mozilla::dom::ContentChild::GetSingleton()->SendNotifyIME(aType, aState);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
@ -201,9 +208,11 @@ AndroidBridge::NotifyIMEChange(const PRUnichar *aText, PRUint32 aTextLen,
|
||||
int aStart, int aEnd, int aNewEnd)
|
||||
{
|
||||
if (!sBridge) {
|
||||
#ifdef MOZ_IPC
|
||||
mozilla::dom::ContentChild::GetSingleton()->
|
||||
SendNotifyIMEChange(nsAutoString(aText), aTextLen,
|
||||
aStart, aEnd, aNewEnd);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1365,11 +1365,11 @@ nsWindow::OnIMEEvent(AndroidGeckoEvent *ae)
|
||||
AndroidBridge::Bridge()->ReturnIMEQueryResult(
|
||||
nsnull, 0, 0, 0);
|
||||
return;
|
||||
} else if (!event.mWasAsync) {
|
||||
AndroidBridge::Bridge()->ReturnIMEQueryResult(
|
||||
event.mReply.mString.get(),
|
||||
event.mReply.mString.Length(), 0, 0);
|
||||
}
|
||||
|
||||
AndroidBridge::Bridge()->ReturnIMEQueryResult(
|
||||
event.mReply.mString.get(),
|
||||
event.mReply.mString.Length(), 0, 0);
|
||||
//ALOGIME("IME: -> l=%u", event.mReply.mString.Length());
|
||||
}
|
||||
return;
|
||||
@ -1411,21 +1411,13 @@ nsWindow::OnIMEEvent(AndroidGeckoEvent *ae)
|
||||
AndroidBridge::Bridge()->ReturnIMEQueryResult(
|
||||
nsnull, 0, 0, 0);
|
||||
return;
|
||||
} else if (!event.mWasAsync) {
|
||||
AndroidBridge::Bridge()->ReturnIMEQueryResult(
|
||||
event.mReply.mString.get(),
|
||||
event.mReply.mString.Length(),
|
||||
event.GetSelectionStart(),
|
||||
event.GetSelectionEnd() - event.GetSelectionStart());
|
||||
}
|
||||
|
||||
int selStart = int(event.mReply.mOffset +
|
||||
(event.mReply.mReversed ?
|
||||
event.mReply.mString.Length() : 0));
|
||||
|
||||
int selLength = event.mReply.mReversed ?
|
||||
int(event.mReply.mString.Length()) :
|
||||
-int(event.mReply.mString.Length());
|
||||
|
||||
AndroidBridge::Bridge()->ReturnIMEQueryResult(
|
||||
event.mReply.mString.get(),
|
||||
event.mReply.mString.Length(),
|
||||
selStart, selLength);
|
||||
|
||||
//ALOGIME("IME: -> o=%u, l=%u", event.mReply.mOffset, event.mReply.mString.Length());
|
||||
}
|
||||
return;
|
||||
@ -1520,10 +1512,9 @@ NS_IMETHODIMP
|
||||
nsWindow::OnIMEFocusChange(PRBool aFocus)
|
||||
{
|
||||
ALOGIME("IME: OnIMEFocusChange: f=%d", aFocus);
|
||||
|
||||
if (AndroidBridge::Bridge())
|
||||
AndroidBridge::NotifyIME(AndroidBridge::NOTIFY_IME_FOCUSCHANGE,
|
||||
int(aFocus));
|
||||
|
||||
AndroidBridge::NotifyIME(AndroidBridge::NOTIFY_IME_FOCUSCHANGE,
|
||||
int(aFocus));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user