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

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

Issue 2650113004: [WIP] Add support for Android SuggestionSpans when editing text (Closed)
Patch Set: Created 3 years, 10 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.content.browser.input; 5 package org.chromium.content.browser.input;
6 6
7 import android.annotation.TargetApi; 7 import android.annotation.TargetApi;
8 import android.graphics.Matrix; 8 import android.graphics.Matrix;
9 import android.os.Build; 9 import android.os.Build;
10 import android.view.View; 10 import android.view.View;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 @Nonnull 74 @Nonnull
75 private final CursorAnchorInfo.Builder mCursorAnchorInfoBuilder = 75 private final CursorAnchorInfo.Builder mCursorAnchorInfoBuilder =
76 new CursorAnchorInfo.Builder(); 76 new CursorAnchorInfo.Builder();
77 77
78 @Nullable 78 @Nullable
79 private InputMethodManagerWrapper mInputMethodManagerWrapper; 79 private InputMethodManagerWrapper mInputMethodManagerWrapper;
80 @Nullable 80 @Nullable
81 private final ComposingTextDelegate mComposingTextDelegate; 81 private final ComposingTextDelegate mComposingTextDelegate;
82 @Nonnull 82 @Nonnull
83 private final ViewDelegate mViewDelegate; 83 private final ViewDelegate mViewDelegate;
84 @Nullable
85 private final ImeAdapter mImeAdapter;
84 86
85 private CursorAnchorInfoController(InputMethodManagerWrapper inputMethodMana gerWrapper, 87 private CursorAnchorInfoController(InputMethodManagerWrapper inputMethodMana gerWrapper,
86 ComposingTextDelegate composingTextDelegate, ViewDelegate viewDelega te) { 88 ComposingTextDelegate composingTextDelegate, ViewDelegate viewDelega te,
89 ImeAdapter imeAdapter) {
87 mInputMethodManagerWrapper = inputMethodManagerWrapper; 90 mInputMethodManagerWrapper = inputMethodManagerWrapper;
88 mComposingTextDelegate = composingTextDelegate; 91 mComposingTextDelegate = composingTextDelegate;
89 mViewDelegate = viewDelegate; 92 mViewDelegate = viewDelegate;
93 mImeAdapter = imeAdapter;
90 } 94 }
91 95
92 public static CursorAnchorInfoController create( 96 public static CursorAnchorInfoController create(
93 InputMethodManagerWrapper inputMethodManagerWrapper, 97 InputMethodManagerWrapper inputMethodManagerWrapper,
94 ComposingTextDelegate composingTextDelegate) { 98 ComposingTextDelegate composingTextDelegate, ImeAdapter imeAdapter) {
95 return new CursorAnchorInfoController(inputMethodManagerWrapper, 99 return new CursorAnchorInfoController(
96 composingTextDelegate, new ViewDelegate() { 100 inputMethodManagerWrapper, composingTextDelegate, new ViewDelega te() {
97 @Override 101 @Override
98 public void getLocationOnScreen(View view, int[] location) { 102 public void getLocationOnScreen(View view, int[] location) {
99 view.getLocationOnScreen(location); 103 view.getLocationOnScreen(location);
100 } 104 }
101 }); 105 }, imeAdapter);
102 } 106 }
103 107
104 @VisibleForTesting 108 @VisibleForTesting
105 public void setInputMethodManagerWrapperForTest( 109 public void setInputMethodManagerWrapperForTest(
106 InputMethodManagerWrapper inputMethodManagerWrapper) { 110 InputMethodManagerWrapper inputMethodManagerWrapper) {
107 mInputMethodManagerWrapper = inputMethodManagerWrapper; 111 mInputMethodManagerWrapper = inputMethodManagerWrapper;
108 } 112 }
109 113
110 @VisibleForTesting 114 @VisibleForTesting
111 public static CursorAnchorInfoController createForTest( 115 public static CursorAnchorInfoController createForTest(
112 InputMethodManagerWrapper inputMethodManagerWrapper, 116 InputMethodManagerWrapper inputMethodManagerWrapper,
113 ComposingTextDelegate composingTextDelegate, 117 ComposingTextDelegate composingTextDelegate, ViewDelegate viewDelega te,
114 ViewDelegate viewDelegate) { 118 ImeAdapter imeAdapter) {
115 return new CursorAnchorInfoController(inputMethodManagerWrapper, composi ngTextDelegate, 119 return new CursorAnchorInfoController(
116 viewDelegate); 120 inputMethodManagerWrapper, composingTextDelegate, viewDelegate, imeAdapter);
117 } 121 }
118 122
119 /** 123 /**
120 * Called by ImeAdapter when a IME related web content state is changed. 124 * Called by ImeAdapter when a IME related web content state is changed.
121 */ 125 */
122 public void invalidateLastCursorAnchorInfo() { 126 public void invalidateLastCursorAnchorInfo() {
123 if (!mIsEditable) return; 127 if (!mIsEditable) return;
124 128
125 mLastCursorAnchorInfo = null; 129 mLastCursorAnchorInfo = null;
126 } 130 }
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 mScale = scale; 190 mScale = scale;
187 mTranslationX = translationX; 191 mTranslationX = translationX;
188 mTranslationY = translationY; 192 mTranslationY = translationY;
189 mHasInsertionMarker = hasInsertionMarker; 193 mHasInsertionMarker = hasInsertionMarker;
190 mIsInsertionMarkerVisible = isInsertionMarkerVisible; 194 mIsInsertionMarkerVisible = isInsertionMarkerVisible;
191 mInsertionMarkerHorizontal = insertionMarkerHorizontal; 195 mInsertionMarkerHorizontal = insertionMarkerHorizontal;
192 mInsertionMarkerTop = insertionMarkerTop; 196 mInsertionMarkerTop = insertionMarkerTop;
193 mInsertionMarkerBottom = insertionMarkerBottom; 197 mInsertionMarkerBottom = insertionMarkerBottom;
194 } 198 }
195 199
196 // Notify to IME if there is a pending request, or if it is in monitor m ode and we have 200 // Notify ImeAdapter
197 // some change in the state. 201 updateCursorAnchorInfo(view);
198 if (mHasPendingImmediateRequest
aelias_OOO_until_Jul13 2017/01/25 03:34:26 These conditions are important to preserve for per
rlanday 2017/01/25 19:21:56 I think we probably want to turn on "monitor mode"
199 || (mMonitorModeEnabled && mLastCursorAnchorInfo == null)) {
200 updateCursorAnchorInfo(view);
201 }
202 } 202 }
203 203
204 public void focusedNodeChanged(boolean isEditable) { 204 public void focusedNodeChanged(boolean isEditable) {
205 mIsEditable = isEditable; 205 mIsEditable = isEditable;
206 mCompositionCharacterBounds = null; 206 mCompositionCharacterBounds = null;
207 mHasCoordinateInfo = false; 207 mHasCoordinateInfo = false;
208 mLastCursorAnchorInfo = null; 208 mLastCursorAnchorInfo = null;
209 } 209 }
210 210
211 public boolean onRequestCursorUpdates(boolean immediateRequest, boolean moni torRequest, 211 public boolean onRequestCursorUpdates(boolean immediateRequest, boolean moni torRequest,
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 mInsertionMarkerBottom, 270 mInsertionMarkerBottom,
271 mIsInsertionMarkerVisible ? CursorAnchorInfo.FLAG_HAS_VI SIBLE_REGION : 271 mIsInsertionMarkerVisible ? CursorAnchorInfo.FLAG_HAS_VI SIBLE_REGION :
272 CursorAnchorInfo.FLAG_HAS_INVISIBLE_REGION); 272 CursorAnchorInfo.FLAG_HAS_INVISIBLE_REGION);
273 } 273 }
274 mLastCursorAnchorInfo = mCursorAnchorInfoBuilder.build(); 274 mLastCursorAnchorInfo = mCursorAnchorInfoBuilder.build();
275 } 275 }
276 276
277 if (mInputMethodManagerWrapper != null) { 277 if (mInputMethodManagerWrapper != null) {
278 mInputMethodManagerWrapper.updateCursorAnchorInfo(view, mLastCursorA nchorInfo); 278 mInputMethodManagerWrapper.updateCursorAnchorInfo(view, mLastCursorA nchorInfo);
279 } 279 }
280 if (mImeAdapter != null) {
281 mImeAdapter.updateCursorAnchorInfo(view, mLastCursorAnchorInfo);
282 }
280 mHasPendingImmediateRequest = false; 283 mHasPendingImmediateRequest = false;
281 } 284 }
282 } 285 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698