| 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 d51e32f303eb6f4bf2248e4e6e07fc28bd275303..b075d2aee7b476ded346cbb3770f0516606c09ba 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
|
| @@ -70,6 +70,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;
|
| @@ -282,6 +283,7 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Displa
|
| private InternalAccessDelegate mContainerViewInternals;
|
| private WebContents mWebContents;
|
| private WebContentsObserver mWebContentsObserver;
|
| + private ViewRoot mViewRoot;
|
|
|
| private ContentViewClient mContentViewClient;
|
|
|
| @@ -456,6 +458,13 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Displa
|
| }
|
|
|
| /**
|
| + * @return The ViewRoot associated with this ContentViewCore.
|
| + */
|
| + public ViewRoot getViewRoot() {
|
| + return mViewRoot;
|
| + }
|
| +
|
| + /**
|
| * @return The SelectionPopupController that handles select action mode on web contents.
|
| */
|
| @VisibleForTesting
|
| @@ -582,10 +591,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;
|
|
|
| @@ -597,8 +607,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, dipScale,
|
| + mRetainedJavaScriptObjects);
|
| mWebContents = nativeGetWebContentsAndroid(mNativeContentViewCore);
|
|
|
| setContainerViewInternals(internalDispatcher);
|
| @@ -616,14 +626,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 attached 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.
|
| @@ -632,6 +643,7 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Displa
|
|
|
| addDisplayAndroidObserverIfNeeded();
|
|
|
| + WindowAndroid windowAndroid = viewRoot == null ? null : viewRoot.getWindowAndroid();
|
| mJoystickScrollProvider.updateWindowAndroid(windowAndroid);
|
|
|
| for (WindowAndroidChangedObserver observer : mWindowAndroidChangedObservers) {
|
| @@ -2784,11 +2796,10 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Displa
|
| }
|
|
|
| private native long nativeInit(WebContents webContents, ViewAndroidDelegate viewAndroidDelegate,
|
| - long windowAndroidPtr, float dipScale, HashSet<Object> retainedObjectSet);
|
| + ViewRoot viewRoot, 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);
|
|
|
|
|