mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-02 18:08:58 +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 "nsIContent.h"
|
||||||
#include "mozilla/unused.h"
|
#include "mozilla/unused.h"
|
||||||
|
|
||||||
|
#ifdef ANDROID
|
||||||
|
#include "AndroidBridge.h"
|
||||||
|
using namespace mozilla;
|
||||||
|
#endif
|
||||||
|
|
||||||
using mozilla::ipc::DocumentRendererParent;
|
using mozilla::ipc::DocumentRendererParent;
|
||||||
using mozilla::ipc::DocumentRendererShmemParent;
|
using mozilla::ipc::DocumentRendererShmemParent;
|
||||||
using mozilla::ipc::DocumentRendererNativeIDParent;
|
using mozilla::ipc::DocumentRendererNativeIDParent;
|
||||||
@ -570,7 +575,27 @@ TabParent::RecvAsyncMessage(const nsString& aMessage,
|
|||||||
bool
|
bool
|
||||||
TabParent::RecvQueryContentResult(const nsQueryContentEvent& event)
|
TabParent::RecvQueryContentResult(const nsQueryContentEvent& event)
|
||||||
{
|
{
|
||||||
|
#ifdef ANDROID
|
||||||
|
if (!event.mSucceeded) {
|
||||||
|
AndroidBridge::Bridge()->ReturnIMEQueryResult(nsnull, 0, 0, 0);
|
||||||
return true;
|
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
|
bool
|
||||||
|
@ -1261,6 +1261,20 @@ public:
|
|||||||
mInput.mLength = aLength;
|
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;
|
PRBool mSucceeded;
|
||||||
PRPackedBool mWasAsync;
|
PRPackedBool mWasAsync;
|
||||||
struct {
|
struct {
|
||||||
|
@ -37,7 +37,10 @@
|
|||||||
|
|
||||||
#include <android/log.h>
|
#include <android/log.h>
|
||||||
|
|
||||||
|
#ifdef MOZ_IPC
|
||||||
#include "mozilla/dom/ContentChild.h"
|
#include "mozilla/dom/ContentChild.h"
|
||||||
|
#include "nsXULAppAPI.h"
|
||||||
|
#endif
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <prthread.h>
|
#include <prthread.h>
|
||||||
#include "nsXPCOMStrings.h"
|
#include "nsXPCOMStrings.h"
|
||||||
@ -192,8 +195,12 @@ AndroidBridge::NotifyIME(int aType, int aState)
|
|||||||
if (sBridge)
|
if (sBridge)
|
||||||
JNI()->CallStaticVoidMethod(sBridge->mGeckoAppShellClass,
|
JNI()->CallStaticVoidMethod(sBridge->mGeckoAppShellClass,
|
||||||
sBridge->jNotifyIME, aType, aState);
|
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);
|
mozilla::dom::ContentChild::GetSingleton()->SendNotifyIME(aType, aState);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -201,9 +208,11 @@ AndroidBridge::NotifyIMEChange(const PRUnichar *aText, PRUint32 aTextLen,
|
|||||||
int aStart, int aEnd, int aNewEnd)
|
int aStart, int aEnd, int aNewEnd)
|
||||||
{
|
{
|
||||||
if (!sBridge) {
|
if (!sBridge) {
|
||||||
|
#ifdef MOZ_IPC
|
||||||
mozilla::dom::ContentChild::GetSingleton()->
|
mozilla::dom::ContentChild::GetSingleton()->
|
||||||
SendNotifyIMEChange(nsAutoString(aText), aTextLen,
|
SendNotifyIMEChange(nsAutoString(aText), aTextLen,
|
||||||
aStart, aEnd, aNewEnd);
|
aStart, aEnd, aNewEnd);
|
||||||
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1365,11 +1365,11 @@ nsWindow::OnIMEEvent(AndroidGeckoEvent *ae)
|
|||||||
AndroidBridge::Bridge()->ReturnIMEQueryResult(
|
AndroidBridge::Bridge()->ReturnIMEQueryResult(
|
||||||
nsnull, 0, 0, 0);
|
nsnull, 0, 0, 0);
|
||||||
return;
|
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());
|
//ALOGIME("IME: -> l=%u", event.mReply.mString.Length());
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -1411,21 +1411,13 @@ nsWindow::OnIMEEvent(AndroidGeckoEvent *ae)
|
|||||||
AndroidBridge::Bridge()->ReturnIMEQueryResult(
|
AndroidBridge::Bridge()->ReturnIMEQueryResult(
|
||||||
nsnull, 0, 0, 0);
|
nsnull, 0, 0, 0);
|
||||||
return;
|
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());
|
//ALOGIME("IME: -> o=%u, l=%u", event.mReply.mOffset, event.mReply.mString.Length());
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -1520,10 +1512,9 @@ NS_IMETHODIMP
|
|||||||
nsWindow::OnIMEFocusChange(PRBool aFocus)
|
nsWindow::OnIMEFocusChange(PRBool aFocus)
|
||||||
{
|
{
|
||||||
ALOGIME("IME: OnIMEFocusChange: f=%d", aFocus);
|
ALOGIME("IME: OnIMEFocusChange: f=%d", aFocus);
|
||||||
|
|
||||||
if (AndroidBridge::Bridge())
|
AndroidBridge::NotifyIME(AndroidBridge::NOTIFY_IME_FOCUSCHANGE,
|
||||||
AndroidBridge::NotifyIME(AndroidBridge::NOTIFY_IME_FOCUSCHANGE,
|
int(aFocus));
|
||||||
int(aFocus));
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user