OLD | NEW |
---|---|
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; |
11 import android.view.inputmethod.CursorAnchorInfo; | 11 import android.view.inputmethod.CursorAnchorInfo; |
12 import android.view.inputmethod.InputConnection; | |
13 | 12 |
14 import org.chromium.base.VisibleForTesting; | 13 import org.chromium.base.VisibleForTesting; |
15 import org.chromium.base.annotations.SuppressFBWarnings; | 14 import org.chromium.base.annotations.SuppressFBWarnings; |
16 import org.chromium.content.browser.RenderCoordinates; | 15 import org.chromium.content.browser.RenderCoordinates; |
17 | 16 |
18 import java.util.Arrays; | 17 import java.util.Arrays; |
19 | 18 |
20 import javax.annotation.Nonnull; | 19 import javax.annotation.Nonnull; |
21 import javax.annotation.Nullable; | 20 import javax.annotation.Nullable; |
22 | 21 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
122 */ | 121 */ |
123 public void invalidateLastCursorAnchorInfo() { | 122 public void invalidateLastCursorAnchorInfo() { |
124 if (!mIsEditable) return; | 123 if (!mIsEditable) return; |
125 | 124 |
126 mLastCursorAnchorInfo = null; | 125 mLastCursorAnchorInfo = null; |
127 } | 126 } |
128 | 127 |
129 /** | 128 /** |
130 * Sets positional information of composing text as an array of character bo unds. | 129 * Sets positional information of composing text as an array of character bo unds. |
131 * @param compositionCharacterBounds Array of character bounds in local coor dinates. | 130 * @param compositionCharacterBounds Array of character bounds in local coor dinates. |
131 * @param view The attached view. | |
132 */ | 132 */ |
133 public void setCompositionCharacterBounds(float[] compositionCharacterBounds ) { | 133 public void setCompositionCharacterBounds(float[] compositionCharacterBounds , View view) { |
134 if (!mIsEditable) return; | 134 if (!mIsEditable) return; |
135 | 135 |
136 if (!Arrays.equals(compositionCharacterBounds, mCompositionCharacterBoun ds)) { | 136 if (!Arrays.equals(compositionCharacterBounds, mCompositionCharacterBoun ds)) { |
137 mLastCursorAnchorInfo = null; | 137 mLastCursorAnchorInfo = null; |
138 mCompositionCharacterBounds = compositionCharacterBounds; | 138 mCompositionCharacterBounds = compositionCharacterBounds; |
139 } | 139 } |
140 updateCursorAnchorInfo(view); | |
140 } | 141 } |
141 | 142 |
142 /** | 143 /** |
143 * Sets coordinates system parameters and selection marker information. | 144 * Sets coordinates system parameters and selection marker information. |
144 * @param hasInsertionMarker {@code true} if the insertion marker exists. | 145 * @param hasInsertionMarker {@code true} if the insertion marker exists. |
145 * @param isInsertionMarkerVisible {@code true} if the insertion insertion m arker is visible. | 146 * @param isInsertionMarkerVisible {@code true} if the insertion insertion m arker is visible. |
146 * @param insertionMarkerHorizontal X coordinate of the top of the first sel ection marker. | 147 * @param insertionMarkerHorizontal X coordinate of the top of the first sel ection marker. |
147 * @param insertionMarkerTop Y coordinate of the top of the first selection marker. | 148 * @param insertionMarkerTop Y coordinate of the top of the first selection marker. |
148 * @param insertionMarkerBottom Y coordinate of the bottom of the first sele ction marker. | 149 * @param insertionMarkerBottom Y coordinate of the bottom of the first sele ction marker. |
149 * @param view The attached view. | 150 * @param view The attached view. |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
191 } | 192 } |
192 | 193 |
193 // Notify to IME if there is a pending request, or if it is in monitor m ode and we have | 194 // Notify to IME if there is a pending request, or if it is in monitor m ode and we have |
194 // some change in the state. | 195 // some change in the state. |
195 if (mHasPendingImmediateRequest | 196 if (mHasPendingImmediateRequest |
196 || (mMonitorModeEnabled && mLastCursorAnchorInfo == null)) { | 197 || (mMonitorModeEnabled && mLastCursorAnchorInfo == null)) { |
197 updateCursorAnchorInfo(view); | 198 updateCursorAnchorInfo(view); |
198 } | 199 } |
199 } | 200 } |
200 | 201 |
201 /** | |
202 * Resets the current state on update monitoring mode to the default (= do n othing.) | |
203 */ | |
204 public void resetMonitoringState() { | |
205 mMonitorModeEnabled = false; | |
aelias_OOO_until_Jul13
2016/07/07 00:13:35
These two booleans mHasPendingImmediateRequest and
Seigo Nonaka
2016/07/07 13:38:26
I think we still need the both two members since w
| |
206 mHasPendingImmediateRequest = false; | |
207 } | |
208 | |
209 public void focusedNodeChanged(boolean isEditable) { | 202 public void focusedNodeChanged(boolean isEditable) { |
210 mIsEditable = isEditable; | 203 mIsEditable = isEditable; |
211 mCompositionCharacterBounds = null; | 204 mCompositionCharacterBounds = null; |
212 mHasCoordinateInfo = false; | 205 mHasCoordinateInfo = false; |
213 mLastCursorAnchorInfo = null; | 206 mLastCursorAnchorInfo = null; |
214 } | 207 } |
215 | 208 |
216 public boolean onRequestCursorUpdates(int cursorUpdateMode, View view) { | 209 public boolean onRequestCursorUpdates(boolean immediateRequest, boolean moni torRequest, |
210 View view) { | |
217 if (!mIsEditable) return false; | 211 if (!mIsEditable) return false; |
218 | 212 |
219 mMonitorModeEnabled = (cursorUpdateMode & InputConnection.CURSOR_UPDATE_ MONITOR) != 0; | 213 mMonitorModeEnabled = monitorRequest; |
220 if ((cursorUpdateMode & InputConnection.CURSOR_UPDATE_IMMEDIATE) != 0) { | 214 if (immediateRequest) { |
221 mHasPendingImmediateRequest = true; | 215 mHasPendingImmediateRequest = true; |
222 updateCursorAnchorInfo(view); | 216 updateCursorAnchorInfo(view); |
223 } | 217 } |
224 return true; | 218 return true; |
225 } | 219 } |
226 | 220 |
227 /** | 221 /** |
228 * Computes the CursorAnchorInfo instance and notify to InputMethodManager i f needed. | 222 * Computes the CursorAnchorInfo instance and notify to InputMethodManager i f needed. |
229 */ | 223 */ |
230 private void updateCursorAnchorInfo(View view) { | 224 private void updateCursorAnchorInfo(View view) { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
271 } | 265 } |
272 mLastCursorAnchorInfo = mCursorAnchorInfoBuilder.build(); | 266 mLastCursorAnchorInfo = mCursorAnchorInfoBuilder.build(); |
273 } | 267 } |
274 | 268 |
275 if (mInputMethodManagerWrapper != null) { | 269 if (mInputMethodManagerWrapper != null) { |
276 mInputMethodManagerWrapper.updateCursorAnchorInfo(view, mLastCursorA nchorInfo); | 270 mInputMethodManagerWrapper.updateCursorAnchorInfo(view, mLastCursorA nchorInfo); |
277 } | 271 } |
278 mHasPendingImmediateRequest = false; | 272 mHasPendingImmediateRequest = false; |
279 } | 273 } |
280 } | 274 } |
OLD | NEW |