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 6d4807151870a877bedb575ad17594476883b98d..5e20430563beb2b39688fa1ff6430ca2ae227f09 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 |
@@ -68,6 +68,7 @@ import org.chromium.content_public.browser.WebContentsObserver; |
import org.chromium.device.gamepad.GamepadList; |
import org.chromium.ui.base.DeviceFormFactor; |
import org.chromium.ui.base.ViewAndroidDelegate; |
+import org.chromium.ui.base.ViewRoot; |
import org.chromium.ui.base.WindowAndroid; |
import org.chromium.ui.base.ime.TextInputType; |
import org.chromium.ui.display.DisplayAndroid; |
@@ -85,6 +86,9 @@ import java.util.Map; |
* Provides a Java-side 'wrapper' around a WebContent (native) instance. |
* Contains all the major functionality necessary to manage the lifecycle of a ContentView without |
* being tied to the view system. |
+ * |
+ * WARNING: ContentViewCore is in the process of being broken up. Please do not add new stuff. |
+ * See https://crbug.com/598880. |
*/ |
@JNINamespace("content") |
public class ContentViewCore implements AccessibilityStateChangeListener, DisplayAndroidObserver, |
@@ -269,6 +273,7 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Displa |
private InternalAccessDelegate mContainerViewInternals; |
private WebContents mWebContents; |
private WebContentsObserver mWebContentsObserver; |
+ private ViewRoot mViewRoot; |
private ContentViewClient mContentViewClient; |
@@ -562,10 +567,11 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Displa |
// Note that the caller remains the owner of the nativeWebContents and is responsible for |
// deleting it after destroying the ContentViewCore. |
public void initialize(ViewAndroidDelegate viewDelegate, |
- InternalAccessDelegate internalDispatcher, WebContents webContents, |
- WindowAndroid windowAndroid) { |
+ InternalAccessDelegate internalDispatcher, WebContents webContents, ViewRoot viewRoot) { |
mViewAndroidDelegate = viewDelegate; |
setContainerView(viewDelegate.getContainerView()); |
+ mViewRoot = viewRoot; |
+ WindowAndroid windowAndroid = viewRoot.getWindowAndroid(); |
long windowNativePointer = windowAndroid.getNativePointer(); |
assert windowNativePointer != 0; |
@@ -577,8 +583,8 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Displa |
mJoystickScrollProvider = |
new JoystickScrollProvider(webContents, getContainerView(), windowAndroid); |
- mNativeContentViewCore = nativeInit(webContents, mViewAndroidDelegate, windowNativePointer, |
- dipScale, mRetainedJavaScriptObjects); |
+ mNativeContentViewCore = nativeInit(webContents, mViewAndroidDelegate, |
+ viewRoot.getNativePointer(), dipScale, mRetainedJavaScriptObjects); |
mWebContents = nativeGetWebContentsAndroid(mNativeContentViewCore); |
setContainerViewInternals(internalDispatcher); |
@@ -596,20 +602,22 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Displa |
} |
/** |
- * Updates the native {@link ContentViewCore} with a new window. This moves the NativeView and |
- * attached it to the new NativeWindow linked with the given {@link WindowAndroid}. |
- * @param windowAndroid The new {@link WindowAndroid} for this {@link ContentViewCore}. |
+ * Updates the native {@link ContentViewCore} with a new window and view root. |
+ * This moves the NativeView and attaches it to the new ViewRoot. |
+ * @param viewRoot The new {@link ViewRoot} for this {@link ContentViewCore}. |
*/ |
- public void updateWindowAndroid(WindowAndroid windowAndroid) { |
+ public void updateViewRoot(ViewRoot viewRoot) { |
removeDisplayAndroidObserver(); |
- long windowNativePointer = windowAndroid == null ? 0 : windowAndroid.getNativePointer(); |
- nativeUpdateWindowAndroid(mNativeContentViewCore, windowNativePointer); |
+ long viewRootPointer = viewRoot == null ? 0 : viewRoot.getNativePointer(); |
+ nativeUpdateViewRoot(mNativeContentViewCore, viewRootPointer); |
+ mViewRoot = viewRoot; |
// TODO(yusufo): Rename this call to be general for tab reparenting. |
// Clean up cached popups that may have been created with an old activity. |
mSelectPopup = null; |
destroyPastePopup(); |
+ WindowAndroid windowAndroid = viewRoot == null ? null : viewRoot.getWindowAndroid(); |
boliu
2017/02/13 22:58:08
nit: move this next to where viewRootPointer is de
Jinsuk Kim
2017/02/14 05:09:59
Done.
|
addDisplayAndroidObserverIfNeeded(); |
mJoystickScrollProvider.updateWindowAndroid(windowAndroid); |
@@ -2714,11 +2722,10 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Displa |
} |
private native long nativeInit(WebContents webContents, ViewAndroidDelegate viewAndroidDelegate, |
- long windowAndroidPtr, float dipScale, HashSet<Object> retainedObjectSet); |
+ long viewRootPtr, float dipScale, HashSet<Object> retainedObjectSet); |
private static native ContentViewCore nativeFromWebContentsAndroid(WebContents webContents); |
- private native void nativeUpdateWindowAndroid( |
- long nativeContentViewCoreImpl, long windowAndroidPtr); |
+ private native void nativeUpdateViewRoot(long nativeContentViewCoreImpl, long viewRootPtr); |
private native WebContents nativeGetWebContentsAndroid(long nativeContentViewCoreImpl); |
private native WindowAndroid nativeGetJavaWindowAndroid(long nativeContentViewCoreImpl); |