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

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

Issue 2121953002: Do not calculate composition bounds until IME requests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove OS_ANDROID from render_widget.cc 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 unified diff | Download patch
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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.content.res.Configuration; 7 import android.content.res.Configuration;
8 import android.os.Build; 8 import android.os.Build;
9 import android.os.ResultReceiver; 9 import android.os.ResultReceiver;
10 import android.os.SystemClock; 10 import android.os.SystemClock;
11 import android.text.SpannableString; 11 import android.text.SpannableString;
12 import android.text.TextUtils; 12 import android.text.TextUtils;
13 import android.text.style.BackgroundColorSpan; 13 import android.text.style.BackgroundColorSpan;
14 import android.text.style.CharacterStyle; 14 import android.text.style.CharacterStyle;
15 import android.text.style.UnderlineSpan; 15 import android.text.style.UnderlineSpan;
16 import android.view.KeyCharacterMap; 16 import android.view.KeyCharacterMap;
17 import android.view.KeyEvent; 17 import android.view.KeyEvent;
18 import android.view.View; 18 import android.view.View;
19 import android.view.inputmethod.BaseInputConnection; 19 import android.view.inputmethod.BaseInputConnection;
20 import android.view.inputmethod.EditorInfo; 20 import android.view.inputmethod.EditorInfo;
21 import android.view.inputmethod.InputConnection;
21 22
22 import org.chromium.base.Log; 23 import org.chromium.base.Log;
23 import org.chromium.base.VisibleForTesting; 24 import org.chromium.base.VisibleForTesting;
24 import org.chromium.base.annotations.CalledByNative; 25 import org.chromium.base.annotations.CalledByNative;
25 import org.chromium.base.annotations.JNINamespace; 26 import org.chromium.base.annotations.JNINamespace;
26 import org.chromium.blink_public.web.WebInputEventModifier; 27 import org.chromium.blink_public.web.WebInputEventModifier;
27 import org.chromium.blink_public.web.WebInputEventType; 28 import org.chromium.blink_public.web.WebInputEventType;
28 import org.chromium.content.browser.RenderCoordinates; 29 import org.chromium.content.browser.RenderCoordinates;
29 import org.chromium.ui.base.ime.TextInputType; 30 import org.chromium.ui.base.ime.TextInputType;
30 import org.chromium.ui.picker.InputDialogContainer; 31 import org.chromium.ui.picker.InputDialogContainer;
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 if (mTextInputType == TextInputType.NONE) { 186 if (mTextInputType == TextInputType.NONE) {
186 setInputConnection(null); 187 setInputConnection(null);
187 if (DEBUG_LOGS) Log.w(TAG, "onCreateInputConnection returns null."); 188 if (DEBUG_LOGS) Log.w(TAG, "onCreateInputConnection returns null.");
188 return null; 189 return null;
189 } 190 }
190 if (mInputConnectionFactory == null) return null; 191 if (mInputConnectionFactory == null) return null;
191 setInputConnection(mInputConnectionFactory.initializeAndGet( 192 setInputConnection(mInputConnectionFactory.initializeAndGet(
192 mViewEmbedder.getAttachedView(), this, mTextInputType, mTextInpu tFlags, 193 mViewEmbedder.getAttachedView(), this, mTextInputType, mTextInpu tFlags,
193 mLastSelectionStart, mLastSelectionEnd, outAttrs)); 194 mLastSelectionStart, mLastSelectionEnd, outAttrs));
194 if (DEBUG_LOGS) Log.w(TAG, "onCreateInputConnection: " + mInputConnectio n); 195 if (DEBUG_LOGS) Log.w(TAG, "onCreateInputConnection: " + mInputConnectio n);
196
195 if (mCursorAnchorInfoController != null) { 197 if (mCursorAnchorInfoController != null) {
196 mCursorAnchorInfoController.resetMonitoringState(); 198 mCursorAnchorInfoController.onRequestCursorUpdates(
199 false /* not an immediate request */, false /* disable monit oring */,
200 mViewEmbedder.getAttachedView());
201 }
202 if (mNativeImeAdapterAndroid != 0) {
203 nativeRequestCursorUpdate(mNativeImeAdapterAndroid,
204 false /* not an immediate request */, false /* disable monit oring */);
197 } 205 }
198 return mInputConnection; 206 return mInputConnection;
199 } 207 }
200 208
201 private void setInputConnection(ChromiumBaseInputConnection inputConnection) { 209 private void setInputConnection(ChromiumBaseInputConnection inputConnection) {
202 if (mInputConnection == inputConnection) return; 210 if (mInputConnection == inputConnection) return;
203 // The previous input connection might be waiting for state update. 211 // The previous input connection might be waiting for state update.
204 if (mInputConnection != null) mInputConnection.unblockOnUiThread(); 212 if (mInputConnection != null) mInputConnection.unblockOnUiThread();
205 mInputConnection = inputConnection; 213 mInputConnection = inputConnection;
206 } 214 }
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 if (mNativeImeAdapterAndroid == 0) return false; 662 if (mNativeImeAdapterAndroid == 0) return false;
655 // You won't get state update anyways. 663 // You won't get state update anyways.
656 if (mInputConnection == null) return false; 664 if (mInputConnection == null) return false;
657 return nativeRequestTextInputStateUpdate(mNativeImeAdapterAndroid); 665 return nativeRequestTextInputStateUpdate(mNativeImeAdapterAndroid);
658 } 666 }
659 667
660 /** 668 /**
661 * Notified when IME requested Chrome to change the cursor update mode. 669 * Notified when IME requested Chrome to change the cursor update mode.
662 */ 670 */
663 public boolean onRequestCursorUpdates(int cursorUpdateMode) { 671 public boolean onRequestCursorUpdates(int cursorUpdateMode) {
672 final boolean immediateRequest =
673 (cursorUpdateMode & InputConnection.CURSOR_UPDATE_IMMEDIATE) != 0;
674 final boolean monitorRequest =
675 (cursorUpdateMode & InputConnection.CURSOR_UPDATE_MONITOR) != 0;
676
677 if (mNativeImeAdapterAndroid != 0) {
678 nativeRequestCursorUpdate(mNativeImeAdapterAndroid, immediateRequest , monitorRequest);
679 }
664 if (mCursorAnchorInfoController == null) return false; 680 if (mCursorAnchorInfoController == null) return false;
665 return mCursorAnchorInfoController.onRequestCursorUpdates(cursorUpdateMo de, 681 return mCursorAnchorInfoController.onRequestCursorUpdates(immediateReque st, monitorRequest,
666 mViewEmbedder.getAttachedView()); 682 mViewEmbedder.getAttachedView());
667 } 683 }
668 684
669 /** 685 /**
670 * Notified when a frame has been produced by the renderer and all the assoc iated metadata. 686 * Notified when a frame has been produced by the renderer and all the assoc iated metadata.
671 * @param renderCoordinates coordinate information to convert CSS (document) coordinates to 687 * @param renderCoordinates coordinate information to convert CSS (document) coordinates to
672 * View-local Physical (screen) coordinates 688 * View-local Physical (screen) coordinates
673 * @param hasInsertionMarker Whether the insertion marker is visible or not. 689 * @param hasInsertionMarker Whether the insertion marker is visible or not.
674 * @param insertionMarkerHorizontal X coordinates (in view-local DIP pixels) of the insertion 690 * @param insertionMarkerHorizontal X coordinates (in view-local DIP pixels) of the insertion
675 * marker if it exists. Will be ignored oth erwise. 691 * marker if it exists. Will be ignored oth erwise.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 727
712 @CalledByNative 728 @CalledByNative
713 private void cancelComposition() { 729 private void cancelComposition() {
714 if (DEBUG_LOGS) Log.w(TAG, "cancelComposition"); 730 if (DEBUG_LOGS) Log.w(TAG, "cancelComposition");
715 if (mInputConnection != null) restartInput(); 731 if (mInputConnection != null) restartInput();
716 } 732 }
717 733
718 @CalledByNative 734 @CalledByNative
719 private void setCharacterBounds(float[] characterBounds) { 735 private void setCharacterBounds(float[] characterBounds) {
720 if (mCursorAnchorInfoController == null) return; 736 if (mCursorAnchorInfoController == null) return;
721 mCursorAnchorInfoController.setCompositionCharacterBounds(characterBound s); 737 mCursorAnchorInfoController.setCompositionCharacterBounds(characterBound s,
738 mViewEmbedder.getAttachedView());
722 } 739 }
723 740
724 @CalledByNative 741 @CalledByNative
725 private void detach() { 742 private void detach() {
726 if (DEBUG_LOGS) Log.w(TAG, "detach"); 743 if (DEBUG_LOGS) Log.w(TAG, "detach");
727 mNativeImeAdapterAndroid = 0; 744 mNativeImeAdapterAndroid = 0;
728 if (mCursorAnchorInfoController != null) { 745 if (mCursorAnchorInfoController != null) {
729 mCursorAnchorInfoController.focusedNodeChanged(false); 746 mCursorAnchorInfoController.focusedNodeChanged(false);
730 } 747 }
731 } 748 }
(...skipping 11 matching lines...) Expand all
743 private native void nativeCommitText(long nativeImeAdapterAndroid, String te xtStr); 760 private native void nativeCommitText(long nativeImeAdapterAndroid, String te xtStr);
744 private native void nativeFinishComposingText(long nativeImeAdapterAndroid); 761 private native void nativeFinishComposingText(long nativeImeAdapterAndroid);
745 private native void nativeAttachImeAdapter(long nativeImeAdapterAndroid); 762 private native void nativeAttachImeAdapter(long nativeImeAdapterAndroid);
746 private native void nativeSetEditableSelectionOffsets(long nativeImeAdapterA ndroid, 763 private native void nativeSetEditableSelectionOffsets(long nativeImeAdapterA ndroid,
747 int start, int end); 764 int start, int end);
748 private native void nativeSetComposingRegion(long nativeImeAdapterAndroid, i nt start, int end); 765 private native void nativeSetComposingRegion(long nativeImeAdapterAndroid, i nt start, int end);
749 private native void nativeDeleteSurroundingText(long nativeImeAdapterAndroid , 766 private native void nativeDeleteSurroundingText(long nativeImeAdapterAndroid ,
750 int before, int after); 767 int before, int after);
751 private native void nativeResetImeAdapter(long nativeImeAdapterAndroid); 768 private native void nativeResetImeAdapter(long nativeImeAdapterAndroid);
752 private native boolean nativeRequestTextInputStateUpdate(long nativeImeAdapt erAndroid); 769 private native boolean nativeRequestTextInputStateUpdate(long nativeImeAdapt erAndroid);
770 private native void nativeRequestCursorUpdate(long nativeImeAdapterAndroid,
771 boolean immediateRequest, boolean monitorRequest);
753 private native boolean nativeIsImeThreadEnabled(long nativeImeAdapterAndroid ); 772 private native boolean nativeIsImeThreadEnabled(long nativeImeAdapterAndroid );
754 } 773 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698