Bug 814689 - Only use key events for plugins; r=cpeterson

This commit is contained in:
Jim Chen 2012-12-26 10:06:53 -05:00
parent bcb86086ca
commit 852e245734
2 changed files with 21 additions and 3 deletions

View File

@ -532,8 +532,6 @@ final class GeckoEditable
mFocused = false;
} else {
mFocused = true;
LayerView v = GeckoApp.mAppContext.getLayerView();
v.setInputConnectionHandler((InputConnectionHandler)mListener);
// Unmask events on the Gecko side
GeckoAppShell.sendEventToGecko(GeckoEvent.createIMEEvent(
GeckoEvent.IME_ACKNOWLEDGE_FOCUS));
@ -555,6 +553,13 @@ final class GeckoEditable
public void run() {
// Make sure there are no other things going on
mActionQueue.syncWithGecko();
// Set InputConnectionHandler in notifyIMEEnabled because
// GeckoInputConnection.notifyIMEEnabled calls restartInput() which will invoke
// InputConnectionHandler.onCreateInputConnection
LayerView v = GeckoApp.mAppContext.getLayerView();
if (v != null) {
v.setInputConnectionHandler((InputConnectionHandler)mListener);
}
mListener.notifyIMEEnabled(state, typeHint,
modeHint, actionHint);
}

View File

@ -53,6 +53,7 @@ class GeckoInputConnection
private boolean mBatchSelectionChanged;
private boolean mBatchTextChanged;
private Runnable mRestartInputRunnable;
private final InputConnection mPluginInputConnection;
public static GeckoEditableListener create(View targetView,
GeckoEditableClient editable) {
@ -67,6 +68,8 @@ class GeckoInputConnection
super(targetView, true);
mEditableClient = editable;
mIMEState = IME_STATE_DISABLED;
// InputConnection for plugins, which don't have full editors
mPluginInputConnection = new BaseInputConnection(targetView, false);
}
@Override
@ -287,6 +290,8 @@ class GeckoInputConnection
if (mIMEState == IME_STATE_PASSWORD)
outAttrs.inputType |= InputType.TYPE_TEXT_VARIATION_PASSWORD;
else if (mIMEState == IME_STATE_PLUGIN)
outAttrs.inputType = InputType.TYPE_NULL; // "send key events" mode
else if (mIMETypeHint.equalsIgnoreCase("url"))
outAttrs.inputType |= InputType.TYPE_TEXT_VARIATION_URI;
else if (mIMETypeHint.equalsIgnoreCase("email"))
@ -302,7 +307,7 @@ class GeckoInputConnection
| InputType.TYPE_NUMBER_FLAG_DECIMAL;
else if (mIMETypeHint.equalsIgnoreCase("week") ||
mIMETypeHint.equalsIgnoreCase("month"))
outAttrs.inputType = InputType.TYPE_CLASS_DATETIME
outAttrs.inputType = InputType.TYPE_CLASS_DATETIME
| InputType.TYPE_DATETIME_VARIATION_DATE;
else if (mIMEModeHint.equalsIgnoreCase("numeric"))
outAttrs.inputType = InputType.TYPE_CLASS_NUMBER |
@ -360,6 +365,12 @@ class GeckoInputConnection
}
}
if (mIMEState == IME_STATE_PLUGIN) {
// Since we are using a temporary string as the editable, the selection is at 0
outAttrs.initialSelStart = 0;
outAttrs.initialSelEnd = 0;
return mPluginInputConnection;
}
Editable editable = getEditable();
outAttrs.initialSelStart = Selection.getSelectionStart(editable);
outAttrs.initialSelEnd = Selection.getSelectionEnd(editable);
@ -399,6 +410,7 @@ class GeckoInputConnection
// KeyListener returns true if it handled the event for us.
if (mIMEState == IME_STATE_DISABLED ||
mIMEState == IME_STATE_PLUGIN ||
keyCode == KeyEvent.KEYCODE_ENTER ||
keyCode == KeyEvent.KEYCODE_DEL ||
keyCode == KeyEvent.KEYCODE_TAB ||
@ -430,6 +442,7 @@ class GeckoInputConnection
KeyListener keyListener = TextKeyListener.getInstance();
if (mIMEState == IME_STATE_DISABLED ||
mIMEState == IME_STATE_PLUGIN ||
keyCode == KeyEvent.KEYCODE_ENTER ||
keyCode == KeyEvent.KEYCODE_DEL ||
(event.getFlags() & KeyEvent.FLAG_SOFT_KEYBOARD) != 0 ||