| 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..ada3b5052f2fd1f3cabbd359ab6f6fedcf1a8a8b 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.updateWindowAndroid(null, null);
|
| attachTabContentManager(null);
|
| }
|
|
|
| @@ -1584,7 +1588,11 @@ 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.
|
| + mViewRoot = ViewRoot.create(mWindowAndroid);
|
| + mContentViewCore.updateWindowAndroid(mWindowAndroid, mViewRoot);
|
| + }
|
| }
|
|
|
| /**
|
| @@ -1625,6 +1633,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).
|
| @@ -1717,10 +1732,11 @@ public class Tab implements ViewGroup.OnHierarchyChangeListener,
|
| private ContentViewCore createContentViewCore(WebContents webContents) {
|
| ContentViewCore cvc = new ContentViewCore(mThemedApplicationContext, PRODUCT_VERSION);
|
| ContentView cv = ContentView.createContentView(mThemedApplicationContext, cvc);
|
| + mViewRoot = ViewRoot.create(mWindowAndroid);
|
| cv.setContentDescription(mThemedApplicationContext.getResources().getString(
|
| R.string.accessibility_content_view));
|
| cvc.initialize(ViewAndroidDelegate.createBasicDelegate(cv), cv, webContents,
|
| - getWindowAndroid());
|
| + getWindowAndroid(), mViewRoot);
|
| ChromeActionModeCallback actionModeCallback = new ChromeActionModeCallback(
|
| mThemedApplicationContext, this, cvc.getActionModeCallbackHelper());
|
| cvc.setActionModeCallback(actionModeCallback);
|
| @@ -2459,8 +2475,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(
|
| - bounds.right, bounds.bottom);
|
| + getViewRoot().onPhysicalBackingSizeChanged(bounds.right, bounds.bottom);
|
| }
|
| newContentViewCore.onShow();
|
| setContentViewCore(newContentViewCore);
|
|
|