Commit a69c5403 authored by Jinsuk Kim's avatar Jinsuk Kim Committed by Commit Bot

Adds a reference to web contents/container view in Tab class

This is a preparatory CL for upcoming changes that will remove API
getWebContents/getContainerView from ContentViewCore. Tab defines
direct references to WebContents and container view. WebContents is
passed to |initialize| and ContentView is created as the container
view in |createContentViewCore|, so it doesn't need to access them
indirectly through CVC. They are set in |setContentViewCore| and
nulled out in |destroyContentViewCore| to keep their validity in sync.

Accompanying changes for cleanup:

- Deleted |getActiveContentViewCore|. Other method of similar name
  |getContentViewCore| returns null if Tab is showing native view or
  rendered content is already destroyed. So using it instead is
  enough for all the callsites that already have null checks or tests
  that know all the preconditions.

- |getContentView| always returns container view for non-native page.
  In fact it is what it was already doing - just made it clearer by
  removing some dead code in it. Its return type is ViewGroup, and
  will be used as a replacement for CVC.getContainerView() in other classes.

Bug: 598880
Change-Id: I0c5966b69f6871ce53aa5ffadb73a76214ad35b2
Reviewed-on: https://chromium-review.googlesource.com/1018561Reviewed-by: default avatarYash Malik <ymalik@chromium.org>
Reviewed-by: default avatarMaria Khomenko <mariakhomenko@chromium.org>
Commit-Queue: Jinsuk Kim <jinsukkim@chromium.org>
Cr-Commit-Position: refs/heads/master@{#552206}
parent 3947bb6e
...@@ -854,7 +854,7 @@ public abstract class ChromeActivity extends AsyncInitializationActivity ...@@ -854,7 +854,7 @@ public abstract class ChromeActivity extends AsyncInitializationActivity
for (TabModel model : getTabModelSelector().getModels()) { for (TabModel model : getTabModelSelector().getModels()) {
int count = model.getCount(); int count = model.getCount();
for (int i = 0; i < count; ++i) { for (int i = 0; i < count; ++i) {
ContentViewCore cvc = model.getTabAt(i).getActiveContentViewCore(); ContentViewCore cvc = model.getTabAt(i).getContentViewCore();
if (cvc != null) cvc.onResume(); if (cvc != null) cvc.onResume();
} }
} }
...@@ -892,7 +892,7 @@ public abstract class ChromeActivity extends AsyncInitializationActivity ...@@ -892,7 +892,7 @@ public abstract class ChromeActivity extends AsyncInitializationActivity
for (TabModel model : getTabModelSelector().getModels()) { for (TabModel model : getTabModelSelector().getModels()) {
int count = model.getCount(); int count = model.getCount();
for (int i = 0; i < count; ++i) { for (int i = 0; i < count; ++i) {
ContentViewCore cvc = model.getTabAt(i).getActiveContentViewCore(); ContentViewCore cvc = model.getTabAt(i).getContentViewCore();
if (cvc != null) cvc.onPause(); if (cvc != null) cvc.onPause();
} }
} }
......
...@@ -420,7 +420,7 @@ public class CompositorViewHolder extends FrameLayout ...@@ -420,7 +420,7 @@ public class CompositorViewHolder extends FrameLayout
private ContentViewCore getActiveContent() { private ContentViewCore getActiveContent() {
Tab tab = getCurrentTab(); Tab tab = getCurrentTab();
return tab != null ? tab.getActiveContentViewCore() : null; return tab != null ? tab.getContentViewCore() : null;
} }
private WebContents getActiveWebContents() { private WebContents getActiveWebContents() {
...@@ -922,8 +922,7 @@ public class CompositorViewHolder extends FrameLayout ...@@ -922,8 +922,7 @@ public class CompositorViewHolder extends FrameLayout
onPhysicalBackingSizeChanged( onPhysicalBackingSizeChanged(
webContents, mCompositorView.getWidth(), mCompositorView.getHeight()); webContents, mCompositorView.getWidth(), mCompositorView.getHeight());
} }
View view = tab.getContentView(); if (tab.isNativePage() || tab.getView() == null) return;
if (view == null || (tab.isNativePage() && view == tab.getView())) return;
tab.setTopControlsHeight(getTopControlsHeightPixels(), controlsResizeView()); tab.setTopControlsHeight(getTopControlsHeightPixels(), controlsResizeView());
tab.setBottomControlsHeight(getBottomControlsHeightPixels()); tab.setBottomControlsHeight(getBottomControlsHeightPixels());
} }
......
...@@ -88,8 +88,7 @@ public class VrShellControllerInputTest { ...@@ -88,8 +88,7 @@ public class VrShellControllerInputTest {
VrTestFramework.getHtmlTestFile("test_controller_scrolling"), PAGE_LOAD_TIMEOUT_S); VrTestFramework.getHtmlTestFile("test_controller_scrolling"), PAGE_LOAD_TIMEOUT_S);
final WebContents wc = mVrTestRule.getActivity().getActivityTab().getWebContents(); final WebContents wc = mVrTestRule.getActivity().getActivityTab().getWebContents();
Coordinates coord = Coordinates.createFor(wc); Coordinates coord = Coordinates.createFor(wc);
waitForPageToBeScrollable( waitForPageToBeScrollable(mVrTestRule.getActivity().getActivityTab().getContentViewCore());
mVrTestRule.getActivity().getActivityTab().getActiveContentViewCore());
// Test that scrolling down works // Test that scrolling down works
int startScrollPoint = coord.getScrollYPixInt(); int startScrollPoint = coord.getScrollYPixInt();
...@@ -139,8 +138,7 @@ public class VrShellControllerInputTest { ...@@ -139,8 +138,7 @@ public class VrShellControllerInputTest {
VrTestFramework.getHtmlTestFile("test_controller_scrolling"), PAGE_LOAD_TIMEOUT_S); VrTestFramework.getHtmlTestFile("test_controller_scrolling"), PAGE_LOAD_TIMEOUT_S);
final WebContents wc = mVrTestRule.getActivity().getActivityTab().getWebContents(); final WebContents wc = mVrTestRule.getActivity().getActivityTab().getWebContents();
Coordinates coord = Coordinates.createFor(wc); Coordinates coord = Coordinates.createFor(wc);
waitForPageToBeScrollable( waitForPageToBeScrollable(mVrTestRule.getActivity().getActivityTab().getContentViewCore());
mVrTestRule.getActivity().getActivityTab().getActiveContentViewCore());
// Arbitrary, but valid values to trigger fling scrolling // Arbitrary, but valid values to trigger fling scrolling
int scrollSteps = 2; int scrollSteps = 2;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment