зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1209574 - Move GeckoEditable management to nsWindow; r=esawin
This patch removes the GeckoEditable code in GeckoAppShell, and make nsWindow create a GeckoEditable for itself when opening a window. Instead of calling GeckoAppShell, nsWindow can now call GeckoEditable methods directly.
This commit is contained in:
Родитель
4204ec39a0
Коммит
42c7f8215a
|
@ -132,8 +132,6 @@ public class GeckoAppShell
|
|||
// We have static members only.
|
||||
private GeckoAppShell() { }
|
||||
|
||||
private static GeckoEditableListener editableListener;
|
||||
|
||||
private static final CrashHandler CRASH_HANDLER = new CrashHandler() {
|
||||
@Override
|
||||
protected String getAppPackageName() {
|
||||
|
@ -324,17 +322,6 @@ public class GeckoAppShell
|
|||
return;
|
||||
}
|
||||
sLayerView = lv;
|
||||
|
||||
// We should have a unique GeckoEditable instance per nsWindow instance,
|
||||
// so even though we have a new view here, the underlying nsWindow is the same,
|
||||
// and we don't create a new GeckoEditable.
|
||||
if (editableListener == null) {
|
||||
// Starting up; istall new Gecko-to-Java editable listener.
|
||||
editableListener = new GeckoEditable();
|
||||
} else {
|
||||
// Bind the existing GeckoEditable instance to the new LayerView
|
||||
GeckoAppShell.notifyIMEContext(GeckoEditableListener.IME_STATE_DISABLED, "", "", "");
|
||||
}
|
||||
}
|
||||
|
||||
@RobocopTarget
|
||||
|
@ -419,31 +406,6 @@ public class GeckoAppShell
|
|||
CRASH_HANDLER.uncaughtException(thread, e);
|
||||
}
|
||||
|
||||
@WrapForJNI
|
||||
public static void notifyIME(int type) {
|
||||
if (editableListener != null) {
|
||||
editableListener.notifyIME(type);
|
||||
}
|
||||
}
|
||||
|
||||
@WrapForJNI
|
||||
public static void notifyIMEContext(int state, String typeHint,
|
||||
String modeHint, String actionHint) {
|
||||
if (editableListener != null) {
|
||||
editableListener.notifyIMEContext(state, typeHint,
|
||||
modeHint, actionHint);
|
||||
}
|
||||
}
|
||||
|
||||
@WrapForJNI
|
||||
public static void notifyIMEChange(String text, int start, int end, int newEnd) {
|
||||
if (newEnd < 0) { // Selection change
|
||||
editableListener.onSelectionChange(start, end);
|
||||
} else { // Text change
|
||||
editableListener.onTextChange(text, start, end, newEnd);
|
||||
}
|
||||
}
|
||||
|
||||
private static final Object sEventAckLock = new Object();
|
||||
private static boolean sWaitingForEventAck;
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ import java.util.concurrent.Semaphore;
|
|||
|
||||
import org.json.JSONObject;
|
||||
import org.mozilla.gecko.AppConstants.Versions;
|
||||
import org.mozilla.gecko.annotation.WrapForJNI;
|
||||
import org.mozilla.gecko.gfx.LayerView;
|
||||
import org.mozilla.gecko.util.GeckoEventListener;
|
||||
import org.mozilla.gecko.util.ThreadUtils;
|
||||
|
@ -347,7 +348,12 @@ final class GeckoEditable
|
|||
}
|
||||
}
|
||||
|
||||
@WrapForJNI
|
||||
GeckoEditable() {
|
||||
if (DEBUG) {
|
||||
// Called by nsWindow.
|
||||
ThreadUtils.assertOnGeckoThread();
|
||||
}
|
||||
mActionQueue = new ActionQueue();
|
||||
mSavedSelectionStart = -1;
|
||||
mUpdateGecko = true;
|
||||
|
@ -768,7 +774,7 @@ final class GeckoEditable
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@WrapForJNI @Override
|
||||
public void notifyIME(final int type) {
|
||||
if (DEBUG) {
|
||||
// GeckoEditableListener methods should all be called from the Gecko thread
|
||||
|
@ -844,12 +850,12 @@ final class GeckoEditable
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@WrapForJNI @Override
|
||||
public void notifyIMEContext(final int state, final String typeHint,
|
||||
final String modeHint, final String actionHint) {
|
||||
// Because we want to be able to bind GeckoEditable to the newest LayerView instance,
|
||||
// this can be called from the Java IC thread in addition to the Gecko thread.
|
||||
final String modeHint, final String actionHint) {
|
||||
if (DEBUG) {
|
||||
// GeckoEditableListener methods should all be called from the Gecko thread
|
||||
ThreadUtils.assertOnGeckoThread();
|
||||
Log.d(LOGTAG, "notifyIMEContext(" +
|
||||
getConstantName(GeckoEditableListener.class, "IME_STATE_", state) +
|
||||
", \"" + typeHint + "\", \"" + modeHint + "\", \"" + actionHint + "\")");
|
||||
|
@ -872,7 +878,7 @@ final class GeckoEditable
|
|||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@WrapForJNI @Override
|
||||
public void onSelectionChange(final int start, final int end) {
|
||||
if (DEBUG) {
|
||||
// GeckoEditableListener methods should all be called from the Gecko thread
|
||||
|
@ -928,9 +934,9 @@ final class GeckoEditable
|
|||
TextUtils.regionMatches(mText, start, newText, 0, oldEnd - start);
|
||||
}
|
||||
|
||||
@Override
|
||||
@WrapForJNI @Override
|
||||
public void onTextChange(final CharSequence text, final int start,
|
||||
final int unboundedOldEnd, final int unboundedNewEnd) {
|
||||
final int unboundedOldEnd, final int unboundedNewEnd) {
|
||||
if (DEBUG) {
|
||||
// GeckoEditableListener methods should all be called from the Gecko thread
|
||||
ThreadUtils.assertOnGeckoThread();
|
||||
|
|
|
@ -5,13 +5,17 @@
|
|||
|
||||
package org.mozilla.gecko;
|
||||
|
||||
import org.mozilla.gecko.annotation.WrapForJNI;
|
||||
|
||||
/**
|
||||
* Interface for the Editable to listen on the Gecko thread, as well as for the IC thread to listen
|
||||
* to the Editable.
|
||||
*/
|
||||
interface GeckoEditableListener {
|
||||
// IME notification type for notifyIME(), corresponding to NotificationToIME enum in Gecko
|
||||
@WrapForJNI
|
||||
int NOTIFY_IME_OPEN_VKB = -2;
|
||||
@WrapForJNI
|
||||
int NOTIFY_IME_REPLY_EVENT = -1;
|
||||
int NOTIFY_IME_OF_FOCUS = 1;
|
||||
int NOTIFY_IME_OF_BLUR = 2;
|
||||
|
|
|
@ -542,30 +542,6 @@ auto GeckoAppShell::NotifyDefaultPrevented(bool a0) -> void
|
|||
return mozilla::jni::Method<NotifyDefaultPrevented_t>::Call(nullptr, nullptr, a0);
|
||||
}
|
||||
|
||||
constexpr char GeckoAppShell::NotifyIME_t::name[];
|
||||
constexpr char GeckoAppShell::NotifyIME_t::signature[];
|
||||
|
||||
auto GeckoAppShell::NotifyIME(int32_t a0) -> void
|
||||
{
|
||||
return mozilla::jni::Method<NotifyIME_t>::Call(nullptr, nullptr, a0);
|
||||
}
|
||||
|
||||
constexpr char GeckoAppShell::NotifyIMEChange_t::name[];
|
||||
constexpr char GeckoAppShell::NotifyIMEChange_t::signature[];
|
||||
|
||||
auto GeckoAppShell::NotifyIMEChange(mozilla::jni::String::Param a0, int32_t a1, int32_t a2, int32_t a3) -> void
|
||||
{
|
||||
return mozilla::jni::Method<NotifyIMEChange_t>::Call(nullptr, nullptr, a0, a1, a2, a3);
|
||||
}
|
||||
|
||||
constexpr char GeckoAppShell::NotifyIMEContext_t::name[];
|
||||
constexpr char GeckoAppShell::NotifyIMEContext_t::signature[];
|
||||
|
||||
auto GeckoAppShell::NotifyIMEContext(int32_t a0, mozilla::jni::String::Param a1, mozilla::jni::String::Param a2, mozilla::jni::String::Param a3) -> void
|
||||
{
|
||||
return mozilla::jni::Method<NotifyIMEContext_t>::Call(nullptr, nullptr, a0, a1, a2, a3);
|
||||
}
|
||||
|
||||
constexpr char GeckoAppShell::NotifyWakeLockChanged_t::name[];
|
||||
constexpr char GeckoAppShell::NotifyWakeLockChanged_t::signature[];
|
||||
|
||||
|
@ -734,6 +710,50 @@ auto GeckoAppShell::VibrateA(mozilla::jni::LongArray::Param a0, int32_t a1) -> v
|
|||
return mozilla::jni::Method<VibrateA_t>::Call(nullptr, nullptr, a0, a1);
|
||||
}
|
||||
|
||||
constexpr char GeckoEditable::name[];
|
||||
|
||||
constexpr char GeckoEditable::New_t::name[];
|
||||
constexpr char GeckoEditable::New_t::signature[];
|
||||
|
||||
auto GeckoEditable::New() -> GeckoEditable::LocalRef
|
||||
{
|
||||
return mozilla::jni::Constructor<New_t>::Call(nullptr, nullptr);
|
||||
}
|
||||
|
||||
constexpr char GeckoEditable::NotifyIME_t::name[];
|
||||
constexpr char GeckoEditable::NotifyIME_t::signature[];
|
||||
|
||||
auto GeckoEditable::NotifyIME(int32_t a0) const -> void
|
||||
{
|
||||
return mozilla::jni::Method<NotifyIME_t>::Call(this, nullptr, a0);
|
||||
}
|
||||
|
||||
constexpr char GeckoEditable::NotifyIMEContext_t::name[];
|
||||
constexpr char GeckoEditable::NotifyIMEContext_t::signature[];
|
||||
|
||||
auto GeckoEditable::NotifyIMEContext(int32_t a0, mozilla::jni::String::Param a1, mozilla::jni::String::Param a2, mozilla::jni::String::Param a3) const -> void
|
||||
{
|
||||
return mozilla::jni::Method<NotifyIMEContext_t>::Call(this, nullptr, a0, a1, a2, a3);
|
||||
}
|
||||
|
||||
constexpr char GeckoEditable::OnSelectionChange_t::name[];
|
||||
constexpr char GeckoEditable::OnSelectionChange_t::signature[];
|
||||
|
||||
auto GeckoEditable::OnSelectionChange(int32_t a0, int32_t a1) const -> void
|
||||
{
|
||||
return mozilla::jni::Method<OnSelectionChange_t>::Call(this, nullptr, a0, a1);
|
||||
}
|
||||
|
||||
constexpr char GeckoEditable::OnTextChange_t::name[];
|
||||
constexpr char GeckoEditable::OnTextChange_t::signature[];
|
||||
|
||||
auto GeckoEditable::OnTextChange(mozilla::jni::String::Param a0, int32_t a1, int32_t a2, int32_t a3) const -> void
|
||||
{
|
||||
return mozilla::jni::Method<OnTextChange_t>::Call(this, nullptr, a0, a1, a2, a3);
|
||||
}
|
||||
|
||||
constexpr char GeckoEditableListener::name[];
|
||||
|
||||
constexpr char GeckoJavaSampler::name[];
|
||||
|
||||
constexpr char GeckoJavaSampler::GetFrameNameJavaProfilingWrapper_t::name[];
|
||||
|
|
|
@ -1295,66 +1295,6 @@ public:
|
|||
|
||||
static auto NotifyDefaultPrevented(bool) -> void;
|
||||
|
||||
public:
|
||||
struct NotifyIME_t {
|
||||
typedef GeckoAppShell Owner;
|
||||
typedef void ReturnType;
|
||||
typedef void SetterType;
|
||||
typedef mozilla::jni::Args<
|
||||
int32_t> Args;
|
||||
static constexpr char name[] = "notifyIME";
|
||||
static constexpr char signature[] =
|
||||
"(I)V";
|
||||
static const bool isStatic = true;
|
||||
static const bool isMultithreaded = false;
|
||||
static const mozilla::jni::ExceptionMode exceptionMode =
|
||||
mozilla::jni::ExceptionMode::ABORT;
|
||||
};
|
||||
|
||||
static auto NotifyIME(int32_t) -> void;
|
||||
|
||||
public:
|
||||
struct NotifyIMEChange_t {
|
||||
typedef GeckoAppShell Owner;
|
||||
typedef void ReturnType;
|
||||
typedef void SetterType;
|
||||
typedef mozilla::jni::Args<
|
||||
mozilla::jni::String::Param,
|
||||
int32_t,
|
||||
int32_t,
|
||||
int32_t> Args;
|
||||
static constexpr char name[] = "notifyIMEChange";
|
||||
static constexpr char signature[] =
|
||||
"(Ljava/lang/String;III)V";
|
||||
static const bool isStatic = true;
|
||||
static const bool isMultithreaded = false;
|
||||
static const mozilla::jni::ExceptionMode exceptionMode =
|
||||
mozilla::jni::ExceptionMode::ABORT;
|
||||
};
|
||||
|
||||
static auto NotifyIMEChange(mozilla::jni::String::Param, int32_t, int32_t, int32_t) -> void;
|
||||
|
||||
public:
|
||||
struct NotifyIMEContext_t {
|
||||
typedef GeckoAppShell Owner;
|
||||
typedef void ReturnType;
|
||||
typedef void SetterType;
|
||||
typedef mozilla::jni::Args<
|
||||
int32_t,
|
||||
mozilla::jni::String::Param,
|
||||
mozilla::jni::String::Param,
|
||||
mozilla::jni::String::Param> Args;
|
||||
static constexpr char name[] = "notifyIMEContext";
|
||||
static constexpr char signature[] =
|
||||
"(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V";
|
||||
static const bool isStatic = true;
|
||||
static const bool isMultithreaded = false;
|
||||
static const mozilla::jni::ExceptionMode exceptionMode =
|
||||
mozilla::jni::ExceptionMode::ABORT;
|
||||
};
|
||||
|
||||
static auto NotifyIMEContext(int32_t, mozilla::jni::String::Param, mozilla::jni::String::Param, mozilla::jni::String::Param) -> void;
|
||||
|
||||
public:
|
||||
struct NotifyWakeLockChanged_t {
|
||||
typedef GeckoAppShell Owner;
|
||||
|
@ -1746,6 +1686,140 @@ public:
|
|||
|
||||
};
|
||||
|
||||
class GeckoEditable : public mozilla::jni::Class<GeckoEditable>
|
||||
{
|
||||
public:
|
||||
typedef mozilla::jni::Ref<GeckoEditable> Ref;
|
||||
typedef mozilla::jni::LocalRef<GeckoEditable> LocalRef;
|
||||
typedef mozilla::jni::GlobalRef<GeckoEditable> GlobalRef;
|
||||
typedef const mozilla::jni::Param<GeckoEditable>& Param;
|
||||
|
||||
static constexpr char name[] =
|
||||
"org/mozilla/gecko/GeckoEditable";
|
||||
|
||||
protected:
|
||||
GeckoEditable(jobject instance) : Class(instance) {}
|
||||
|
||||
public:
|
||||
struct New_t {
|
||||
typedef GeckoEditable Owner;
|
||||
typedef GeckoEditable::LocalRef ReturnType;
|
||||
typedef GeckoEditable::Param SetterType;
|
||||
typedef mozilla::jni::Args<> Args;
|
||||
static constexpr char name[] = "<init>";
|
||||
static constexpr char signature[] =
|
||||
"()V";
|
||||
static const bool isStatic = false;
|
||||
static const bool isMultithreaded = false;
|
||||
static const mozilla::jni::ExceptionMode exceptionMode =
|
||||
mozilla::jni::ExceptionMode::ABORT;
|
||||
};
|
||||
|
||||
static auto New() -> GeckoEditable::LocalRef;
|
||||
|
||||
public:
|
||||
struct NotifyIME_t {
|
||||
typedef GeckoEditable Owner;
|
||||
typedef void ReturnType;
|
||||
typedef void SetterType;
|
||||
typedef mozilla::jni::Args<
|
||||
int32_t> Args;
|
||||
static constexpr char name[] = "notifyIME";
|
||||
static constexpr char signature[] =
|
||||
"(I)V";
|
||||
static const bool isStatic = false;
|
||||
static const bool isMultithreaded = false;
|
||||
static const mozilla::jni::ExceptionMode exceptionMode =
|
||||
mozilla::jni::ExceptionMode::ABORT;
|
||||
};
|
||||
|
||||
auto NotifyIME(int32_t) const -> void;
|
||||
|
||||
public:
|
||||
struct NotifyIMEContext_t {
|
||||
typedef GeckoEditable Owner;
|
||||
typedef void ReturnType;
|
||||
typedef void SetterType;
|
||||
typedef mozilla::jni::Args<
|
||||
int32_t,
|
||||
mozilla::jni::String::Param,
|
||||
mozilla::jni::String::Param,
|
||||
mozilla::jni::String::Param> Args;
|
||||
static constexpr char name[] = "notifyIMEContext";
|
||||
static constexpr char signature[] =
|
||||
"(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V";
|
||||
static const bool isStatic = false;
|
||||
static const bool isMultithreaded = false;
|
||||
static const mozilla::jni::ExceptionMode exceptionMode =
|
||||
mozilla::jni::ExceptionMode::ABORT;
|
||||
};
|
||||
|
||||
auto NotifyIMEContext(int32_t, mozilla::jni::String::Param, mozilla::jni::String::Param, mozilla::jni::String::Param) const -> void;
|
||||
|
||||
public:
|
||||
struct OnSelectionChange_t {
|
||||
typedef GeckoEditable Owner;
|
||||
typedef void ReturnType;
|
||||
typedef void SetterType;
|
||||
typedef mozilla::jni::Args<
|
||||
int32_t,
|
||||
int32_t> Args;
|
||||
static constexpr char name[] = "onSelectionChange";
|
||||
static constexpr char signature[] =
|
||||
"(II)V";
|
||||
static const bool isStatic = false;
|
||||
static const bool isMultithreaded = false;
|
||||
static const mozilla::jni::ExceptionMode exceptionMode =
|
||||
mozilla::jni::ExceptionMode::ABORT;
|
||||
};
|
||||
|
||||
auto OnSelectionChange(int32_t, int32_t) const -> void;
|
||||
|
||||
public:
|
||||
struct OnTextChange_t {
|
||||
typedef GeckoEditable Owner;
|
||||
typedef void ReturnType;
|
||||
typedef void SetterType;
|
||||
typedef mozilla::jni::Args<
|
||||
mozilla::jni::String::Param,
|
||||
int32_t,
|
||||
int32_t,
|
||||
int32_t> Args;
|
||||
static constexpr char name[] = "onTextChange";
|
||||
static constexpr char signature[] =
|
||||
"(Ljava/lang/CharSequence;III)V";
|
||||
static const bool isStatic = false;
|
||||
static const bool isMultithreaded = false;
|
||||
static const mozilla::jni::ExceptionMode exceptionMode =
|
||||
mozilla::jni::ExceptionMode::ABORT;
|
||||
};
|
||||
|
||||
auto OnTextChange(mozilla::jni::String::Param, int32_t, int32_t, int32_t) const -> void;
|
||||
|
||||
};
|
||||
|
||||
class GeckoEditableListener : public mozilla::jni::Class<GeckoEditableListener>
|
||||
{
|
||||
public:
|
||||
typedef mozilla::jni::Ref<GeckoEditableListener> Ref;
|
||||
typedef mozilla::jni::LocalRef<GeckoEditableListener> LocalRef;
|
||||
typedef mozilla::jni::GlobalRef<GeckoEditableListener> GlobalRef;
|
||||
typedef const mozilla::jni::Param<GeckoEditableListener>& Param;
|
||||
|
||||
static constexpr char name[] =
|
||||
"org/mozilla/gecko/GeckoEditableListener";
|
||||
|
||||
protected:
|
||||
GeckoEditableListener(jobject instance) : Class(instance) {}
|
||||
|
||||
public:
|
||||
static const int32_t NOTIFY_IME_OPEN_VKB = -2;
|
||||
|
||||
public:
|
||||
static const int32_t NOTIFY_IME_REPLY_EVENT = -1;
|
||||
|
||||
};
|
||||
|
||||
class GeckoJavaSampler : public mozilla::jni::Class<GeckoJavaSampler>
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -249,6 +249,10 @@ nsWindow::Natives::Open(const jni::ClassObject::LocalRef& cls,
|
|||
|
||||
gGeckoViewWindow = static_cast<nsWindow*>(widget.get());
|
||||
gGeckoViewWindow->mNatives = mozilla::MakeUnique<Natives>(gGeckoViewWindow);
|
||||
|
||||
// Create GeckoEditable for the new nsWindow/GeckoView pair.
|
||||
gGeckoViewWindow->mEditable = GeckoEditable::New();
|
||||
|
||||
AttachNative(GeckoView::Window::LocalRef(cls.Env(), gvWindow),
|
||||
gGeckoViewWindow->mNatives.get());
|
||||
}
|
||||
|
@ -1011,8 +1015,8 @@ nsWindow::OnGlobalAndroidEvent(AndroidGeckoEvent *ae)
|
|||
break;
|
||||
|
||||
case AndroidGeckoEvent::IME_EVENT:
|
||||
win->UserActivity();
|
||||
win->OnIMEEvent(ae);
|
||||
gGeckoViewWindow->UserActivity();
|
||||
gGeckoViewWindow->OnIMEEvent(ae);
|
||||
break;
|
||||
|
||||
case AndroidGeckoEvent::IME_KEY_EVENT:
|
||||
|
@ -1808,7 +1812,7 @@ public:
|
|||
nsRefPtr<mozilla::TextComposition>
|
||||
nsWindow::GetIMEComposition()
|
||||
{
|
||||
MOZ_ASSERT(this == TopWindow());
|
||||
MOZ_ASSERT(this == FindTopLevel());
|
||||
return mozilla::IMEStateManager::GetTextCompositionFor(this);
|
||||
}
|
||||
|
||||
|
@ -1884,14 +1888,14 @@ nsWindow::OnIMEEvent(AndroidGeckoEvent *ae)
|
|||
NotifyIMEOfTextChange(notification);
|
||||
FlushIMEChanges();
|
||||
}
|
||||
GeckoAppShell::NotifyIME(AndroidBridge::NOTIFY_IME_REPLY_EVENT);
|
||||
mEditable->NotifyIME(GeckoEditableListener::NOTIFY_IME_REPLY_EVENT);
|
||||
return;
|
||||
|
||||
} else if (ae->Action() == AndroidGeckoEvent::IME_UPDATE_CONTEXT) {
|
||||
GeckoAppShell::NotifyIMEContext(mInputContext.mIMEState.mEnabled,
|
||||
mInputContext.mHTMLInputType,
|
||||
mInputContext.mHTMLInputInputmode,
|
||||
mInputContext.mActionHint);
|
||||
mEditable->NotifyIMEContext(mInputContext.mIMEState.mEnabled,
|
||||
mInputContext.mHTMLInputType,
|
||||
mInputContext.mHTMLInputInputmode,
|
||||
mInputContext.mActionHint);
|
||||
mIMEUpdatingContext = false;
|
||||
return;
|
||||
}
|
||||
|
@ -1901,7 +1905,7 @@ nsWindow::OnIMEEvent(AndroidGeckoEvent *ae)
|
|||
if (ae->Action() == AndroidGeckoEvent::IME_SYNCHRONIZE ||
|
||||
ae->Action() == AndroidGeckoEvent::IME_COMPOSE_TEXT ||
|
||||
ae->Action() == AndroidGeckoEvent::IME_REPLACE_TEXT) {
|
||||
GeckoAppShell::NotifyIME(AndroidBridge::NOTIFY_IME_REPLY_EVENT);
|
||||
mEditable->NotifyIME(GeckoEditableListener::NOTIFY_IME_REPLY_EVENT);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -1916,7 +1920,7 @@ nsWindow::OnIMEEvent(AndroidGeckoEvent *ae)
|
|||
case AndroidGeckoEvent::IME_SYNCHRONIZE:
|
||||
{
|
||||
FlushIMEChanges();
|
||||
GeckoAppShell::NotifyIME(AndroidBridge::NOTIFY_IME_REPLY_EVENT);
|
||||
mEditable->NotifyIME(GeckoEditableListener::NOTIFY_IME_REPLY_EVENT);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -1961,7 +1965,8 @@ nsWindow::OnIMEEvent(AndroidGeckoEvent *ae)
|
|||
}
|
||||
mIMEKeyEvents.Clear();
|
||||
FlushIMEChanges();
|
||||
GeckoAppShell::NotifyIME(AndroidBridge::NOTIFY_IME_REPLY_EVENT);
|
||||
mEditable->NotifyIME(
|
||||
GeckoEditableListener::NOTIFY_IME_REPLY_EVENT);
|
||||
// Break out of the switch block
|
||||
break;
|
||||
}
|
||||
|
@ -2012,7 +2017,7 @@ nsWindow::OnIMEEvent(AndroidGeckoEvent *ae)
|
|||
}
|
||||
|
||||
FlushIMEChanges();
|
||||
GeckoAppShell::NotifyIME(AndroidBridge::NOTIFY_IME_REPLY_EVENT);
|
||||
mEditable->NotifyIME(GeckoEditableListener::NOTIFY_IME_REPLY_EVENT);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -2176,13 +2181,17 @@ nsWindow::UserActivity()
|
|||
nsresult
|
||||
nsWindow::NotifyIMEInternal(const IMENotification& aIMENotification)
|
||||
{
|
||||
MOZ_ASSERT(this == TopWindow());
|
||||
MOZ_ASSERT(this == FindTopLevel());
|
||||
|
||||
if (!mEditable) {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
switch (aIMENotification.mMessage) {
|
||||
case REQUEST_TO_COMMIT_COMPOSITION:
|
||||
//ALOGIME("IME: REQUEST_TO_COMMIT_COMPOSITION: s=%d", aState);
|
||||
RemoveIMEComposition();
|
||||
GeckoAppShell::NotifyIME(REQUEST_TO_COMMIT_COMPOSITION);
|
||||
mEditable->NotifyIME(REQUEST_TO_COMMIT_COMPOSITION);
|
||||
return NS_OK;
|
||||
|
||||
case REQUEST_TO_CANCEL_COMPOSITION:
|
||||
|
@ -2200,12 +2209,12 @@ nsWindow::NotifyIMEInternal(const IMENotification& aIMENotification)
|
|||
DispatchEvent(&compositionCommitEvent);
|
||||
}
|
||||
|
||||
GeckoAppShell::NotifyIME(REQUEST_TO_CANCEL_COMPOSITION);
|
||||
mEditable->NotifyIME(REQUEST_TO_CANCEL_COMPOSITION);
|
||||
return NS_OK;
|
||||
|
||||
case NOTIFY_IME_OF_FOCUS:
|
||||
ALOGIME("IME: NOTIFY_IME_OF_FOCUS");
|
||||
GeckoAppShell::NotifyIME(NOTIFY_IME_OF_FOCUS);
|
||||
mEditable->NotifyIME(NOTIFY_IME_OF_FOCUS);
|
||||
return NS_OK;
|
||||
|
||||
case NOTIFY_IME_OF_BLUR:
|
||||
|
@ -2216,7 +2225,7 @@ nsWindow::NotifyIMEInternal(const IMENotification& aIMENotification)
|
|||
// event back to Gecko. That is where we unmask event handling
|
||||
mIMEMaskEventsCount++;
|
||||
|
||||
GeckoAppShell::NotifyIME(NOTIFY_IME_OF_BLUR);
|
||||
mEditable->NotifyIME(NOTIFY_IME_OF_BLUR);
|
||||
return NS_OK;
|
||||
|
||||
case NOTIFY_IME_OF_SELECTION_CHANGE:
|
||||
|
@ -2246,7 +2255,7 @@ nsWindow::SetInputContext(const InputContext& aContext,
|
|||
// Disable the Android keyboard on b2gdroid.
|
||||
return;
|
||||
#endif
|
||||
nsWindow *top = TopWindow();
|
||||
nsWindow *top = FindTopLevel();
|
||||
if (top && this != top) {
|
||||
// We are using an IME event later to notify Java, and the IME event
|
||||
// will be processed by the top window. Therefore, to ensure the
|
||||
|
@ -2256,6 +2265,10 @@ nsWindow::SetInputContext(const InputContext& aContext,
|
|||
return;
|
||||
}
|
||||
|
||||
if (!mEditable) {
|
||||
return;
|
||||
}
|
||||
|
||||
ALOGIME("IME: SetInputContext: s=0x%X, 0x%X, action=0x%X, 0x%X",
|
||||
aContext.mIMEState.mEnabled, aContext.mIMEState.mOpen,
|
||||
aAction.mCause, aAction.mFocusChange);
|
||||
|
@ -2284,7 +2297,7 @@ nsWindow::SetInputContext(const InputContext& aContext,
|
|||
|
||||
if (enabled == IMEState::ENABLED && aAction.UserMightRequestOpenVKB()) {
|
||||
// Don't reset keyboard when we should simply open the vkb
|
||||
GeckoAppShell::NotifyIME(AndroidBridge::NOTIFY_IME_OPEN_VKB);
|
||||
mEditable->NotifyIME(GeckoEditableListener::NOTIFY_IME_OPEN_VKB);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2300,7 +2313,7 @@ nsWindow::SetInputContext(const InputContext& aContext,
|
|||
NS_IMETHODIMP_(InputContext)
|
||||
nsWindow::GetInputContext()
|
||||
{
|
||||
nsWindow *top = TopWindow();
|
||||
nsWindow *top = FindTopLevel();
|
||||
if (top && this != top) {
|
||||
// We let the top window process SetInputContext,
|
||||
// so we should let it process GetInputContext as well.
|
||||
|
@ -2360,8 +2373,8 @@ nsWindow::FlushIMEChanges()
|
|||
NS_ENSURE_TRUE_VOID(event.mReply.mContentsRoot == imeRoot.get());
|
||||
}
|
||||
|
||||
GeckoAppShell::NotifyIMEChange(event.mReply.mString, change.mStart,
|
||||
change.mOldEnd, change.mNewEnd);
|
||||
mEditable->OnTextChange(event.mReply.mString, change.mStart,
|
||||
change.mOldEnd, change.mNewEnd);
|
||||
}
|
||||
mIMETextChanges.Clear();
|
||||
|
||||
|
@ -2373,9 +2386,8 @@ nsWindow::FlushIMEChanges()
|
|||
NS_ENSURE_TRUE_VOID(event.mSucceeded);
|
||||
NS_ENSURE_TRUE_VOID(event.mReply.mContentsRoot == imeRoot.get());
|
||||
|
||||
GeckoAppShell::NotifyIMEChange(EmptyString(),
|
||||
int32_t(event.GetSelectionStart()),
|
||||
int32_t(event.GetSelectionEnd()), -1);
|
||||
mEditable->OnSelectionChange(int32_t(event.GetSelectionStart()),
|
||||
int32_t(event.GetSelectionEnd()));
|
||||
mIMESelectionChanged = false;
|
||||
}
|
||||
}
|
||||
|
@ -2383,6 +2395,8 @@ nsWindow::FlushIMEChanges()
|
|||
nsresult
|
||||
nsWindow::NotifyIMEOfTextChange(const IMENotification& aIMENotification)
|
||||
{
|
||||
MOZ_ASSERT(this == FindTopLevel());
|
||||
|
||||
MOZ_ASSERT(aIMENotification.mMessage == NOTIFY_IME_OF_TEXT_CHANGE,
|
||||
"NotifyIMEOfTextChange() is called with invaild notification");
|
||||
|
||||
|
|
|
@ -49,6 +49,9 @@ public:
|
|||
// Object that implements native GeckoView calls;
|
||||
// nullptr for nsWindows that were not opened from GeckoView.
|
||||
mozilla::UniquePtr<Natives> mNatives;
|
||||
// GeckoEditable instance used by this nsWindow;
|
||||
// nullptr for nsWindows that are not GeckoViews.
|
||||
mozilla::widget::GeckoEditable::GlobalRef mEditable;
|
||||
|
||||
static void OnGlobalAndroidEvent(mozilla::AndroidGeckoEvent *ae);
|
||||
static mozilla::gfx::IntSize GetAndroidScreenBounds();
|
||||
|
|
Загрузка…
Ссылка в новой задаче