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

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

Issue 2121953002: Do not calculate composition bounds until IME requests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix test failures Created 4 years, 4 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/CursorAnchorInfoController.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/input/CursorAnchorInfoController.java b/content/public/android/java/src/org/chromium/content/browser/input/CursorAnchorInfoController.java
index 443e7d25a4c660083b3906c8b44f6f471bfc4050..718db1632ed332fb1d255499929383050720e4aa 100644
--- a/content/public/android/java/src/org/chromium/content/browser/input/CursorAnchorInfoController.java
+++ b/content/public/android/java/src/org/chromium/content/browser/input/CursorAnchorInfoController.java
@@ -9,7 +9,6 @@ import android.graphics.Matrix;
import android.os.Build;
import android.view.View;
import android.view.inputmethod.CursorAnchorInfo;
-import android.view.inputmethod.InputConnection;
import org.chromium.base.VisibleForTesting;
import org.chromium.base.annotations.SuppressFBWarnings;
@@ -129,13 +128,17 @@ final class CursorAnchorInfoController {
/**
* Sets positional information of composing text as an array of character bounds.
* @param compositionCharacterBounds Array of character bounds in local coordinates.
+ * @param view The attached view.
*/
- public void setCompositionCharacterBounds(float[] compositionCharacterBounds) {
+ public void setCompositionCharacterBounds(float[] compositionCharacterBounds, View view) {
if (!mIsEditable) return;
if (!Arrays.equals(compositionCharacterBounds, mCompositionCharacterBounds)) {
mLastCursorAnchorInfo = null;
mCompositionCharacterBounds = compositionCharacterBounds;
+ if (mHasCoordinateInfo) {
+ updateCursorAnchorInfo(view);
+ }
}
}
@@ -198,14 +201,6 @@ final class CursorAnchorInfoController {
}
}
- /**
- * Resets the current state on update monitoring mode to the default (= do nothing.)
- */
- public void resetMonitoringState() {
- mMonitorModeEnabled = false;
- mHasPendingImmediateRequest = false;
- }
-
public void focusedNodeChanged(boolean isEditable) {
mIsEditable = isEditable;
mCompositionCharacterBounds = null;
@@ -213,11 +208,18 @@ final class CursorAnchorInfoController {
mLastCursorAnchorInfo = null;
}
- public boolean onRequestCursorUpdates(int cursorUpdateMode, View view) {
+ public boolean onRequestCursorUpdates(boolean immediateRequest, boolean monitorRequest,
+ View view) {
if (!mIsEditable) return false;
- mMonitorModeEnabled = (cursorUpdateMode & InputConnection.CURSOR_UPDATE_MONITOR) != 0;
- if ((cursorUpdateMode & InputConnection.CURSOR_UPDATE_IMMEDIATE) != 0) {
+ if (mMonitorModeEnabled && !monitorRequest) {
+ // Invalidate saved cursor anchor info if monitor request is cancelled since no longer
+ // new values will be arrived from renderer and immediate request may return too old
+ // position.
+ invalidateLastCursorAnchorInfo();
+ }
+ mMonitorModeEnabled = monitorRequest;
+ if (immediateRequest) {
mHasPendingImmediateRequest = true;
updateCursorAnchorInfo(view);
}
« no previous file with comments | « content/common/input_messages.h ('k') | content/public/android/java/src/org/chromium/content/browser/input/ImeAdapter.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698