Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Unified Diff: content/public/android/java/src/org/chromium/content/browser/input/ImeAdapter.java

Issue 2741993003: Revert restartInput change off the M57 release branch. (Closed)
Patch Set: Rebase Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/public/android/java/src/org/chromium/content/browser/input/ImeAdapter.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/input/ImeAdapter.java b/content/public/android/java/src/org/chromium/content/browser/input/ImeAdapter.java
index 930afc0edbdb982daf9482aacb1c705ab2e3c5f3..df58b85a1caa6589cebf562a34cb16f6ee454732 100644
--- a/content/public/android/java/src/org/chromium/content/browser/input/ImeAdapter.java
+++ b/content/public/android/java/src/org/chromium/content/browser/input/ImeAdapter.java
@@ -116,7 +116,6 @@ public class ImeAdapter {
private String mLastText;
private int mLastCompositionStart;
private int mLastCompositionEnd;
- private boolean mRestartInputOnNextStateUpdate;
/**
* @param wrapper InputMethodManagerWrapper that should receive all the call directed to
@@ -256,13 +255,46 @@ public class ImeAdapter {
}
/**
- * Updates internal representation of the text being edited and its selection and composition
- * properties.
- *
+ * Shows or hides the keyboard based on passed parameters.
* @param textInputType Text input type for the currently focused field in renderer.
* @param textInputFlags Text input flags.
* @param textInputMode Text input mode.
* @param showIfNeeded Whether the keyboard should be shown if it is currently hidden.
+ */
+ public void updateKeyboardVisibility(
+ int textInputType, int textInputFlags, int textInputMode, boolean showIfNeeded) {
+ if (DEBUG_LOGS) {
+ Log.w(TAG, "updateKeyboardVisibility: type [%d->%d], flags [%d], show [%b], ",
+ mTextInputType, textInputType, textInputFlags, showIfNeeded);
+ }
+ boolean needsRestart = false;
+ mTextInputFlags = textInputFlags;
+ if (mTextInputMode != textInputMode) {
+ mTextInputMode = textInputMode;
+ needsRestart = true;
+ }
+
+ if (mTextInputType != textInputType) {
+ mTextInputType = textInputType;
+ // No need to restart if we are going to hide anyways.
+ if (textInputType != TextInputType.NONE) needsRestart = true;
+ }
+
+ if (needsRestart) restartInput();
+
+ // There is no API for us to get notified of user's dismissal of keyboard.
+ // Therefore, we should try to show keyboard even when text input type hasn't changed.
+ if (textInputType != TextInputType.NONE) {
+ if (showIfNeeded) showSoftKeyboard();
+ } else {
+ hideKeyboard();
+ }
+ }
+
+ /**
+ * Updates internal representation of the text being edited and its selection and composition
+ * properties.
+ *
* @param text The String contents of the field being edited.
* @param selectionStart The character offset of the selection start, or the caret position if
* there is no selection.
@@ -274,26 +306,8 @@ public class ImeAdapter {
* selection.
* @param replyToRequest True when the update was requested by IME.
*/
- public void updateState(int textInputType, int textInputFlags, int textInputMode,
- boolean showIfNeeded, String text, int selectionStart, int selectionEnd,
- int compositionStart, int compositionEnd, boolean replyToRequest) {
- Log.w(TAG, "updateState: type [%d->%d], flags [%d], show [%b], ", mTextInputType,
- textInputType, textInputFlags, showIfNeeded);
- boolean needsRestart = false;
- if (mRestartInputOnNextStateUpdate) {
- needsRestart = true;
- mRestartInputOnNextStateUpdate = false;
- }
-
- mTextInputFlags = textInputFlags;
- if (mTextInputMode != textInputMode) {
- mTextInputMode = textInputMode;
- needsRestart = true;
- }
- if (mTextInputType != textInputType) {
- mTextInputType = textInputType;
- needsRestart = true;
- }
+ public void updateState(String text, int selectionStart, int selectionEnd, int compositionStart,
+ int compositionEnd, boolean replyToRequest) {
if (mCursorAnchorInfoController != null && (!TextUtils.equals(mLastText, text)
|| mLastSelectionStart != selectionStart || mLastSelectionEnd != selectionEnd
|| mLastCompositionStart != compositionStart
@@ -306,15 +320,6 @@ public class ImeAdapter {
mLastCompositionStart = compositionStart;
mLastCompositionEnd = compositionEnd;
- if (textInputType == TextInputType.NONE) {
- hideKeyboard();
- } else {
- if (needsRestart) restartInput();
- // There is no API for us to get notified of user's dismissal of keyboard.
- // Therefore, we should try to show keyboard even when text input type hasn't changed.
- if (showIfNeeded) showSoftKeyboard();
- }
-
if (mInputConnection == null) return;
boolean singleLine = mTextInputType != TextInputType.TEXT_AREA
&& mTextInputType != TextInputType.CONTENT_EDITABLE;
@@ -486,7 +491,6 @@ public class ImeAdapter {
mTextInputType = TextInputType.NONE;
mTextInputFlags = 0;
mTextInputMode = WebTextInputMode.kDefault;
- mRestartInputOnNextStateUpdate = false;
// This will trigger unblocking if necessary.
hideKeyboard();
}
@@ -668,7 +672,7 @@ public class ImeAdapter {
}
if (mTextInputType != TextInputType.NONE && mInputConnection != null && isEditable) {
- mRestartInputOnNextStateUpdate = true;
+ restartInput();
}
}

Powered by Google App Engine
This is Rietveld 408576698