| Index: chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java
|
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java b/chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java
|
| index 699d62ed8f1c24ab7666633e9e6b27b154d95428..44efdba735ca4cca40e0ac4b1927d6dfd26d95d7 100644
|
| --- a/chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java
|
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java
|
| @@ -107,6 +107,7 @@ import org.chromium.printing.PrintingControllerImpl;
|
| import org.chromium.ui.base.LocalizationUtils;
|
| import org.chromium.ui.base.PageTransition;
|
| import org.chromium.ui.base.ViewAndroidDelegate;
|
| +import org.chromium.ui.base.ViewRoot;
|
| import org.chromium.ui.base.WindowAndroid;
|
| import org.chromium.ui.mojom.WindowOpenDisposition;
|
|
|
| @@ -187,6 +188,9 @@ public class Tab implements ViewGroup.OnHierarchyChangeListener,
|
| /** {@link ContentViewCore} showing the current page, or {@code null} if the tab is frozen. */
|
| private ContentViewCore mContentViewCore;
|
|
|
| + /** {@link ViewRoot} used to forward input/view events down to native. */
|
| + private ViewRoot mViewRoot;
|
| +
|
| /** Listens to gesture events fired by the ContentViewCore. */
|
| private GestureStateListener mGestureStateListener;
|
|
|
| @@ -1523,7 +1527,7 @@ public class Tab implements ViewGroup.OnHierarchyChangeListener,
|
| // TODO(yusufo): We can't call updateWindowAndroid here and set mWindowAndroid to null
|
| // because many code paths (including navigation) expect the tab to always be associated
|
| // with an activity, and will crash. crbug.com/657007
|
| - if (mContentViewCore != null) mContentViewCore.updateWindowAndroid(null);
|
| + if (mContentViewCore != null) mContentViewCore.updateViewRoot(null);
|
| attachTabContentManager(null);
|
| }
|
|
|
| @@ -1584,7 +1588,13 @@ public class Tab implements ViewGroup.OnHierarchyChangeListener,
|
| // TODO(yusufo): mWindowAndroid can never be null until crbug.com/657007 is fixed.
|
| assert windowAndroid != null;
|
| mWindowAndroid = windowAndroid;
|
| - if (mContentViewCore != null) mContentViewCore.updateWindowAndroid(mWindowAndroid);
|
| + if (mContentViewCore != null) {
|
| + // Create a new ViewRoot for the updated WindowAndroid.
|
| + ViewRoot viewRoot = ViewRoot.create(mWindowAndroid);
|
| + mContentViewCore.updateViewRoot(viewRoot);
|
| + mViewRoot.destroy();
|
| + mViewRoot = viewRoot;
|
| + }
|
| }
|
|
|
| /**
|
| @@ -1625,6 +1635,13 @@ public class Tab implements ViewGroup.OnHierarchyChangeListener,
|
| }
|
|
|
| /**
|
| + * @return {@link ViewRoot} instance used to forward view/input events.
|
| + */
|
| + public ViewRoot getViewRoot() {
|
| + return mViewRoot;
|
| + }
|
| +
|
| + /**
|
| * Called when a navigation begins and no navigation was in progress
|
| * @param toDifferentDocument Whether this navigation will transition between
|
| * documents (i.e., not a fragment navigation or JS History API call).
|
| @@ -1720,7 +1737,7 @@ public class Tab implements ViewGroup.OnHierarchyChangeListener,
|
| cv.setContentDescription(mThemedApplicationContext.getResources().getString(
|
| R.string.accessibility_content_view));
|
| cvc.initialize(ViewAndroidDelegate.createBasicDelegate(cv), cv, webContents,
|
| - getWindowAndroid());
|
| + ViewRoot.create(mWindowAndroid));
|
| ChromeActionModeCallback actionModeCallback = new ChromeActionModeCallback(
|
| mThemedApplicationContext, this, cvc.getActionModeCallbackHelper());
|
| cvc.setActionModeCallback(actionModeCallback);
|
| @@ -1749,6 +1766,7 @@ public class Tab implements ViewGroup.OnHierarchyChangeListener,
|
| }
|
|
|
| mContentViewCore = cvc;
|
| + mViewRoot = cvc.getViewRoot();
|
| cvc.getContainerView().setOnHierarchyChangeListener(this);
|
| cvc.getContainerView().setOnSystemUiVisibilityChangeListener(this);
|
|
|
| @@ -2343,6 +2361,9 @@ public class Tab implements ViewGroup.OnHierarchyChangeListener,
|
| mContentViewCore.destroy();
|
| mContentViewCore = null;
|
|
|
| + mViewRoot.destroy();
|
| + mViewRoot = null;
|
| +
|
| mWebContentsDelegate = null;
|
|
|
| if (mWebContentsObserver != null) {
|
| @@ -2459,7 +2480,7 @@ public class Tab implements ViewGroup.OnHierarchyChangeListener,
|
| // (see http://crbug.com/340987).
|
| newContentViewCore.onSizeChanged(originalWidth, originalHeight, 0, 0);
|
| if (!bounds.isEmpty()) {
|
| - newContentViewCore.getWindowAndroid().getViewRoot().onPhysicalBackingSizeChanged(
|
| + newContentViewCore.getViewRoot().onPhysicalBackingSizeChanged(
|
| bounds.right, bounds.bottom);
|
| }
|
| newContentViewCore.onShow();
|
|
|