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

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

Issue 2688113002: Make ViewRoot the top of the ViewAndroid tree (Closed)
Patch Set: comments 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 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 16e8dfbf44b5eb4487f56016bd418792c41a21ea..f23dcec88e0f2c492069a117738072b30a106f01 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,
@@ -260,6 +264,7 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Displa
private InternalAccessDelegate mContainerViewInternals;
private WebContents mWebContents;
private WebContentsObserver mWebContentsObserver;
+ private ViewRoot mViewRoot;
private ContentViewClient mContentViewClient;
@@ -553,10 +558,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;
@@ -568,8 +574,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);
@@ -587,14 +593,16 @@ 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();
+ WindowAndroid windowAndroid = viewRoot == null ? null : viewRoot.getWindowAndroid();
+ 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.
@@ -2705,11 +2713,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);

Powered by Google App Engine
This is Rietveld 408576698