зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1499429 - 2. Set default GeckoEditableChild from native code; r=esawin
Set the default GeckoEditableChild from C++, so we can keep the same GeckoEditableChild instance across session transfers, and only have a different GeckoEditableParent instance after each transfer. Differential Revision: https://phabricator.services.mozilla.com/D8995
This commit is contained in:
Родитель
e0b3022b2c
Коммит
2944534e33
|
@ -11,6 +11,9 @@ import org.mozilla.gecko.IGeckoEditableChild;
|
|||
|
||||
// Interface for GeckoEditable calls from child to parent
|
||||
interface IGeckoEditableParent {
|
||||
// Set the default child to forward events to, when there is no focused child.
|
||||
void setDefaultChild(IGeckoEditableChild child);
|
||||
|
||||
// Notify an IME event of a type defined in GeckoEditableListener.
|
||||
void notifyIME(IGeckoEditableChild child, int type);
|
||||
|
||||
|
|
|
@ -72,11 +72,14 @@ public final class GeckoEditableChild extends JNIObject implements IGeckoEditabl
|
|||
|
||||
private final IGeckoEditableParent mEditableParent;
|
||||
private final IGeckoEditableChild mEditableChild;
|
||||
private final boolean mIsDefault;
|
||||
|
||||
private int mCurrentTextLength; // Used by Gecko thread
|
||||
|
||||
@WrapForJNI(calledFrom = "gecko")
|
||||
public GeckoEditableChild(final IGeckoEditableParent editableParent) {
|
||||
private GeckoEditableChild(final IGeckoEditableParent editableParent,
|
||||
final boolean isDefault) {
|
||||
mIsDefault = isDefault;
|
||||
mEditableParent = editableParent;
|
||||
|
||||
final IBinder binder = editableParent.asBinder();
|
||||
|
@ -87,6 +90,15 @@ public final class GeckoEditableChild extends JNIObject implements IGeckoEditabl
|
|||
// IGeckoEditableParent is remote; i.e. we're in a content process.
|
||||
mEditableChild = new RemoteChild();
|
||||
}
|
||||
|
||||
if (mIsDefault) {
|
||||
// Tell the parent we're the default child.
|
||||
try {
|
||||
editableParent.setDefaultChild(mEditableChild);
|
||||
} catch (final RemoteException e) {
|
||||
Log.e(LOGTAG, "Failed to set default child", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@WrapForJNI(dispatchTo = "proxy") @Override // IGeckoEditableChild
|
||||
|
|
|
@ -658,10 +658,10 @@ import android.view.inputmethod.EditorInfo;
|
|||
mIcRunHandler = mIcPostHandler = ThreadUtils.getUiHandler();
|
||||
}
|
||||
|
||||
public void setDefaultEditableChild(final IGeckoEditableChild child) {
|
||||
@Override // IGeckoEditableParent
|
||||
public void setDefaultChild(final IGeckoEditableChild child) {
|
||||
if (DEBUG) {
|
||||
// Called by SessionTextInput.
|
||||
ThreadUtils.assertOnUiThread();
|
||||
// On Gecko or binder thread.
|
||||
Log.d(LOGTAG, "setDefaultEditableChild " + child);
|
||||
}
|
||||
mDefaultChild = child;
|
||||
|
|
|
@ -730,8 +730,7 @@ public class GeckoSession extends LayerSession
|
|||
GeckoBundle initData);
|
||||
|
||||
@WrapForJNI(dispatchTo = "proxy")
|
||||
public native void attachEditable(IGeckoEditableParent parent,
|
||||
GeckoEditableChild child);
|
||||
public native void attachEditable(IGeckoEditableParent parent);
|
||||
|
||||
@WrapForJNI(dispatchTo = "proxy")
|
||||
public native void attachAccessibility(SessionAccessibility.NativeProvider sessionAccessibility);
|
||||
|
|
|
@ -275,7 +275,6 @@ public final class SessionTextInput {
|
|||
private final GeckoSession mSession;
|
||||
private final NativeQueue mQueue;
|
||||
private final GeckoEditable mEditable;
|
||||
private final GeckoEditableChild mEditableChild;
|
||||
private InputConnectionClient mInputConnection;
|
||||
private GeckoSession.TextInputDelegate mDelegate;
|
||||
// Auto-fill nodes.
|
||||
|
@ -289,8 +288,6 @@ public final class SessionTextInput {
|
|||
mSession = session;
|
||||
mQueue = queue;
|
||||
mEditable = new GeckoEditable(session);
|
||||
mEditableChild = new GeckoEditableChild(mEditable);
|
||||
mEditable.setDefaultEditableChild(mEditableChild);
|
||||
|
||||
session.getEventDispatcher().registerUiThreadListener(
|
||||
new BundleEventListener() {
|
||||
|
@ -314,11 +311,10 @@ public final class SessionTextInput {
|
|||
|
||||
/* package */ void onWindowChanged(final GeckoSession.Window window) {
|
||||
if (mQueue.isReady()) {
|
||||
window.attachEditable(mEditable, mEditableChild);
|
||||
window.attachEditable(mEditable);
|
||||
} else {
|
||||
mQueue.queueUntilReady(window, "attachEditable",
|
||||
IGeckoEditableParent.class, mEditable,
|
||||
GeckoEditableChild.class, mEditableChild);
|
||||
IGeckoEditableParent.class, mEditable);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -702,7 +702,8 @@ nsAppShell::Observe(nsISupports* aSubject,
|
|||
contentId, tabId);
|
||||
NS_ENSURE_TRUE(editableParent, NS_OK);
|
||||
|
||||
auto editableChild = java::GeckoEditableChild::New(editableParent);
|
||||
auto editableChild = java::GeckoEditableChild::New(editableParent,
|
||||
/* default */ false);
|
||||
NS_ENSURE_TRUE(editableChild, NS_OK);
|
||||
|
||||
RefPtr<widget::GeckoEditableSupport> editableSupport =
|
||||
|
|
|
@ -361,8 +361,7 @@ public:
|
|||
jni::Object::Param aInitData);
|
||||
|
||||
void AttachEditable(const GeckoSession::Window::LocalRef& inst,
|
||||
jni::Object::Param aEditableParent,
|
||||
jni::Object::Param aEditableChild);
|
||||
jni::Object::Param aEditableParent);
|
||||
|
||||
void AttachAccessibility(const GeckoSession::Window::LocalRef& inst,
|
||||
jni::Object::Param aSessionAccessibility);
|
||||
|
@ -1362,11 +1361,10 @@ nsWindow::GeckoViewSupport::Transfer(const GeckoSession::Window::LocalRef& inst,
|
|||
|
||||
void
|
||||
nsWindow::GeckoViewSupport::AttachEditable(const GeckoSession::Window::LocalRef& inst,
|
||||
jni::Object::Param aEditableParent,
|
||||
jni::Object::Param aEditableChild)
|
||||
jni::Object::Param aEditableParent)
|
||||
{
|
||||
java::GeckoEditableChild::LocalRef editableChild(inst.Env());
|
||||
editableChild = java::GeckoEditableChild::Ref::From(aEditableChild);
|
||||
auto editableChild = java::GeckoEditableChild::New(aEditableParent,
|
||||
/* default */ true);
|
||||
|
||||
if (window.mEditableSupport) {
|
||||
window.mEditableSupport.Detach(
|
||||
|
|
Загрузка…
Ссылка в новой задаче