| 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 ce2ee82caafa55761070ad421262d5b01aad5c7a..9855058d8330a95b0b206e4642783e4adfe9cde4 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,
|
| @@ -277,6 +281,7 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Displa
|
| private InternalAccessDelegate mContainerViewInternals;
|
| private WebContents mWebContents;
|
| private WebContentsObserver mWebContentsObserver;
|
| + private ViewRoot mViewRoot;
|
|
|
| private ContentViewClient mContentViewClient;
|
|
|
| @@ -576,10 +581,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;
|
|
|
| @@ -591,8 +597,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.getNativePtr(), dipScale, mRetainedJavaScriptObjects);
|
| mWebContents = nativeGetWebContentsAndroid(mNativeContentViewCore);
|
|
|
| setContainerViewInternals(internalDispatcher);
|
| @@ -610,14 +616,15 @@ 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 {@link ViewRoot} used to forward events to native.
|
| */
|
| - 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.getNativePtr();
|
| + 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.
|
| @@ -626,6 +633,7 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Displa
|
|
|
| addDisplayAndroidObserverIfNeeded();
|
|
|
| + WindowAndroid windowAndroid = viewRoot == null ? null : viewRoot.getWindowAndroid();
|
| mJoystickScrollProvider.updateWindowAndroid(windowAndroid);
|
|
|
| for (WindowAndroidChangedObserver observer : mWindowAndroidChangedObservers) {
|
| @@ -660,6 +668,14 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Displa
|
| }
|
|
|
| /**
|
| + * Update the order of corresponding native view in the view hierarchy.
|
| + * Moves the view to the front to make it a first responder of events.
|
| + */
|
| + public void moveToFrontInViewHierarchy() {
|
| + nativeMoveToFrontInViewHierarchy(mNativeContentViewCore);
|
| + }
|
| +
|
| + /**
|
| * Sets a new container view for this {@link ContentViewCore}.
|
| *
|
| * <p>WARNING: This method can also be used to replace the existing container view,
|
| @@ -1424,6 +1440,10 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Displa
|
| updateAfterSizeChanged();
|
| }
|
|
|
| + public void updateViewBounds(int x, int y, int width, int height) {
|
| + nativeUpdateViewBounds(mNativeContentViewCore, x, y, width, height);
|
| + }
|
| +
|
| /**
|
| * Called when the underlying surface the compositor draws to changes size.
|
| * This may be larger than the viewport size.
|
| @@ -2784,11 +2804,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);
|
|
|
| @@ -2899,4 +2918,7 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Displa
|
| private native boolean nativeIsTouchDragDropEnabled(long nativeContentViewCoreImpl);
|
| private native void nativeOnDragEvent(long nativeContentViewCoreImpl, int action, int x, int y,
|
| int screenX, int screenY, String[] mimeTypes, String content);
|
| + private native void nativeMoveToFrontInViewHierarchy(long nativeContentViewCoreImpl);
|
| + private native void nativeUpdateViewBounds(long nativeContentViewCoreImpl, int x, int y,
|
| + int width, int height);
|
| }
|
|
|