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

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

Issue 2752113005: Let ImeAdapterAndroid have the same lifecycle as its Java peer (Closed)
Patch Set: comments 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/ContentViewCore.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
index 3fdc4bc25ceb131e2a86e57ce7357343c094a240..66eacf2df6b85fc4b172c55cc3df3ee1c4f47efa 100644
--- a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
+++ b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
@@ -575,18 +575,17 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Displa
mJoystickScrollProvider =
new JoystickScrollProvider(webContents, getContainerView(), windowAndroid);
+ mImeAdapter = createImeAdapter();
mNativeContentViewCore = nativeInit(webContents, mViewAndroidDelegate, windowNativePointer,
- dipScale, mRetainedJavaScriptObjects);
+ mImeAdapter.getNativePointer(), dipScale, mRetainedJavaScriptObjects);
mWebContents = nativeGetWebContentsAndroid(mNativeContentViewCore);
setContainerViewInternals(internalDispatcher);
initPopupZoomer(mContext);
- mImeAdapter = createImeAdapter();
- attachImeAdapter();
mSelectionPopupController = new SelectionPopupController(mContext, windowAndroid,
- webContents, viewDelegate.getContainerView(), mRenderCoordinates, mImeAdapter);
+ webContents, viewDelegate.getContainerView(), mRenderCoordinates);
mSelectionPopupController.setCallback(ActionModeCallbackHelper.EMPTY_CALLBACK);
mSelectionPopupController.setContainerView(getContainerView());
@@ -689,6 +688,7 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Displa
@CalledByNative
private void onNativeContentViewCoreDestroyed(long nativeContentViewCore) {
assert nativeContentViewCore == mNativeContentViewCore;
+ mImeAdapter.destroy();
boliu 2017/03/23 04:17:01 that still doesn't work for webview with gc. by th
boliu 2017/03/23 19:02:02 The other option is to have ime adapter lifetime b
Jinsuk Kim 2017/03/23 23:10:24 I can get the native CVC to own IAA and call Java
Jinsuk Kim 2017/03/24 02:34:23 Done.
mNativeContentViewCore = 0;
}
@@ -784,6 +784,7 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Displa
mWebContentsObserver.destroy();
mWebContentsObserver = null;
mImeAdapter.resetAndHideKeyboard();
+
// TODO(igsolla): address TODO in ContentViewClient because ContentViewClient is not
// currently a real Null Object.
//
@@ -1752,16 +1753,14 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Displa
}
@CalledByNative
- private void updateImeAdapter(long nativeImeAdapterAndroid, int textInputType,
- int textInputFlags, int textInputMode, String text, int selectionStart,
- int selectionEnd, int compositionStart, int compositionEnd, boolean showImeIfNeeded,
- boolean replyToRequest) {
+ private void updateImeAdapter(int textInputType, int textInputFlags, int textInputMode,
+ String text, int selectionStart, int selectionEnd, int compositionStart,
+ int compositionEnd, boolean showImeIfNeeded, boolean replyToRequest) {
try {
TraceEvent.begin("ContentViewCore.updateImeAdapter");
boolean focusedNodeEditable = (textInputType != TextInputType.NONE);
boolean focusedNodeIsPassword = (textInputType == TextInputType.PASSWORD);
- mImeAdapter.attach(nativeImeAdapterAndroid);
mImeAdapter.updateState(textInputType, textInputFlags, textInputMode, showImeIfNeeded,
text, selectionStart, selectionEnd, compositionStart, compositionEnd,
replyToRequest);
@@ -1778,11 +1777,6 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Displa
}
}
- @CalledByNative
- private void forceUpdateImeAdapter(long nativeImeAdapterAndroid) {
- mImeAdapter.attach(nativeImeAdapterAndroid);
- }
-
/**
* Called (from native) when the <select> popup needs to be shown.
* @param anchorView View anchored for popup.
@@ -1897,21 +1891,11 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Displa
@SuppressWarnings("unused")
@CalledByNative
private void onRenderProcessChange() {
- attachImeAdapter();
// Immediately sync closed caption settings to the new render process.
mSystemCaptioningBridge.syncToListener(this);
}
/**
- * Attaches the native ImeAdapter object to the java ImeAdapter to allow communication via JNI.
- */
- public void attachImeAdapter() {
- if (mImeAdapter != null && mNativeContentViewCore != 0) {
- mImeAdapter.attach(nativeGetNativeImeAdapter(mNativeContentViewCore));
- }
- }
-
- /**
* @see View#hasFocus()
*/
@CalledByNative
@@ -2590,7 +2574,8 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Displa
}
private native long nativeInit(WebContents webContents, ViewAndroidDelegate viewAndroidDelegate,
- long windowAndroidPtr, float dipScale, HashSet<Object> retainedObjectSet);
+ long windowAndroidPtr, long imeAdapterPtr, float dipScale,
+ HashSet<Object> retainedObjectSet);
private static native ContentViewCore nativeFromWebContentsAndroid(WebContents webContents);
private native void nativeUpdateWindowAndroid(
@@ -2655,9 +2640,6 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Displa
private native void nativeSelectPopupMenuItems(long nativeContentViewCoreImpl,
long nativeSelectPopupSourceFrame, int[] indices);
-
- private native long nativeGetNativeImeAdapter(long nativeContentViewCoreImpl);
-
private native int nativeGetCurrentRenderProcessId(long nativeContentViewCoreImpl);
private native void nativeSetAllowJavascriptInterfacesInspection(

Powered by Google App Engine
This is Rietveld 408576698