mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 15:52:07 +00:00
Bug 1416918 - 3. Use TextInputController in GeckoView; r=esawin
Use the new TextInputController API in GeckoView to process key events and input method interactions. MozReview-Commit-ID: H0oyCDkGHul --HG-- extra : rebase_source : a0ab70e77aa05b7d3aa05982c47299a0222f3ee5
This commit is contained in:
parent
9ba6dc8991
commit
96ffac273d
@ -329,9 +329,6 @@ public class GeckoSession extends LayerSession
|
||||
}
|
||||
}
|
||||
|
||||
@WrapForJNI(dispatchTo = "proxy")
|
||||
public native void attach(GeckoView view);
|
||||
|
||||
@WrapForJNI(dispatchTo = "proxy")
|
||||
public native void attachEditable(IGeckoEditableParent parent,
|
||||
GeckoEditableChild child);
|
||||
@ -517,20 +514,6 @@ public class GeckoSession extends LayerSession
|
||||
}
|
||||
}
|
||||
|
||||
public void attachView(final GeckoView view) {
|
||||
if (view == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (GeckoThread.isStateAtLeast(GeckoThread.State.PROFILE_READY)) {
|
||||
mWindow.attach(view);
|
||||
} else {
|
||||
GeckoThread.queueNativeCallUntil(GeckoThread.State.PROFILE_READY,
|
||||
mWindow, "attach",
|
||||
GeckoView.class, view);
|
||||
}
|
||||
}
|
||||
|
||||
public void closeWindow() {
|
||||
if (GeckoThread.isStateAtLeast(GeckoThread.State.PROFILE_READY)) {
|
||||
mWindow.close();
|
||||
|
@ -46,7 +46,6 @@ public class GeckoView extends FrameLayout {
|
||||
|
||||
protected SurfaceView mSurfaceView;
|
||||
|
||||
private InputConnectionListener mInputConnectionListener;
|
||||
private boolean mIsResettingFocus;
|
||||
|
||||
private static class SavedState extends BaseSavedState {
|
||||
@ -265,7 +264,8 @@ public class GeckoView extends FrameLayout {
|
||||
if (!mSession.isOpen()) {
|
||||
mSession.openWindow(getContext().getApplicationContext());
|
||||
}
|
||||
mSession.attachView(this);
|
||||
|
||||
mSession.getTextInputController().setView(this);
|
||||
|
||||
super.onAttachedToWindow();
|
||||
}
|
||||
@ -274,6 +274,8 @@ public class GeckoView extends FrameLayout {
|
||||
public void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
|
||||
mSession.getTextInputController().setView(this);
|
||||
|
||||
if (mStateSaved) {
|
||||
// If we saved state earlier, we don't want to close the window.
|
||||
return;
|
||||
@ -320,10 +322,6 @@ public class GeckoView extends FrameLayout {
|
||||
}
|
||||
}
|
||||
|
||||
/* package */ void setInputConnectionListener(final InputConnectionListener icl) {
|
||||
mInputConnectionListener = icl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFocusChanged(boolean gainFocus, int direction, Rect previouslyFocusedRect) {
|
||||
super.onFocusChanged(gainFocus, direction, previouslyFocusedRect);
|
||||
@ -368,18 +366,18 @@ public class GeckoView extends FrameLayout {
|
||||
|
||||
@Override
|
||||
public Handler getHandler() {
|
||||
if (mInputConnectionListener != null) {
|
||||
return mInputConnectionListener.getHandler(super.getHandler());
|
||||
if (Build.VERSION.SDK_INT >= 24 || mSession == null) {
|
||||
return super.getHandler();
|
||||
}
|
||||
return super.getHandler();
|
||||
return mSession.getTextInputController().getHandler(super.getHandler());
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
|
||||
if (mInputConnectionListener != null) {
|
||||
return mInputConnectionListener.onCreateInputConnection(outAttrs);
|
||||
public InputConnection onCreateInputConnection(final EditorInfo outAttrs) {
|
||||
if (mSession == null) {
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
return mSession.getTextInputController().onCreateInputConnection(outAttrs);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -387,8 +385,8 @@ public class GeckoView extends FrameLayout {
|
||||
if (super.onKeyPreIme(keyCode, event)) {
|
||||
return true;
|
||||
}
|
||||
return mInputConnectionListener != null &&
|
||||
mInputConnectionListener.onKeyPreIme(keyCode, event);
|
||||
return mSession != null &&
|
||||
mSession.getTextInputController().onKeyPreIme(keyCode, event);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -396,8 +394,8 @@ public class GeckoView extends FrameLayout {
|
||||
if (super.onKeyUp(keyCode, event)) {
|
||||
return true;
|
||||
}
|
||||
return mInputConnectionListener != null &&
|
||||
mInputConnectionListener.onKeyUp(keyCode, event);
|
||||
return mSession != null &&
|
||||
mSession.getTextInputController().onKeyUp(keyCode, event);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -405,8 +403,8 @@ public class GeckoView extends FrameLayout {
|
||||
if (super.onKeyDown(keyCode, event)) {
|
||||
return true;
|
||||
}
|
||||
return mInputConnectionListener != null &&
|
||||
mInputConnectionListener.onKeyDown(keyCode, event);
|
||||
return mSession != null &&
|
||||
mSession.getTextInputController().onKeyDown(keyCode, event);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -414,8 +412,8 @@ public class GeckoView extends FrameLayout {
|
||||
if (super.onKeyLongPress(keyCode, event)) {
|
||||
return true;
|
||||
}
|
||||
return mInputConnectionListener != null &&
|
||||
mInputConnectionListener.onKeyLongPress(keyCode, event);
|
||||
return mSession != null &&
|
||||
mSession.getTextInputController().onKeyLongPress(keyCode, event);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -423,8 +421,8 @@ public class GeckoView extends FrameLayout {
|
||||
if (super.onKeyMultiple(keyCode, repeatCount, event)) {
|
||||
return true;
|
||||
}
|
||||
return mInputConnectionListener != null &&
|
||||
mInputConnectionListener.onKeyMultiple(keyCode, repeatCount, event);
|
||||
return mSession != null &&
|
||||
mSession.getTextInputController().onKeyMultiple(keyCode, repeatCount, event);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -297,10 +297,6 @@ public:
|
||||
jni::Object::Param aDispatcher,
|
||||
jni::Object::Param aSettings);
|
||||
|
||||
// Reattach this nsWindow to a new GeckoView.
|
||||
void Attach(const GeckoSession::Window::LocalRef& inst,
|
||||
jni::Object::Param aView);
|
||||
|
||||
void AttachEditable(const GeckoSession::Window::LocalRef& inst,
|
||||
jni::Object::Param aEditableParent,
|
||||
jni::Object::Param aEditableChild);
|
||||
@ -1371,12 +1367,6 @@ nsWindow::GeckoViewSupport::Transfer(const GeckoSession::Window::LocalRef& inst,
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsWindow::GeckoViewSupport::Attach(const GeckoSession::Window::LocalRef& inst,
|
||||
jni::Object::Param aView)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
nsWindow::GeckoViewSupport::AttachEditable(const GeckoSession::Window::LocalRef& inst,
|
||||
jni::Object::Param aEditableParent,
|
||||
|
Loading…
Reference in New Issue
Block a user