Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/compositor/layouts/LayoutManagerDocument.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/compositor/layouts/LayoutManagerDocument.java b/chrome/android/java/src/org/chromium/chrome/browser/compositor/layouts/LayoutManagerDocument.java |
| index ee07e5639bc11476f462a55b684ae569df667457..d6548123c840745b5ef77cb352b649df11b1c455 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/compositor/layouts/LayoutManagerDocument.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/compositor/layouts/LayoutManagerDocument.java |
| @@ -14,7 +14,6 @@ import android.view.ViewGroup; |
| import org.chromium.chrome.browser.ChromeApplication; |
| import org.chromium.chrome.browser.UrlConstants; |
| -import org.chromium.chrome.browser.compositor.bottombar.OverlayPanel; |
| import org.chromium.chrome.browser.compositor.bottombar.OverlayPanelContentViewDelegate; |
| import org.chromium.chrome.browser.compositor.bottombar.OverlayPanelManager; |
| import org.chromium.chrome.browser.compositor.bottombar.contextualsearch.ContextualSearchPanel; |
| @@ -22,19 +21,13 @@ import org.chromium.chrome.browser.compositor.bottombar.readermode.ReaderModePan |
| import org.chromium.chrome.browser.compositor.layouts.components.LayoutTab; |
| import org.chromium.chrome.browser.compositor.layouts.components.VirtualView; |
| import org.chromium.chrome.browser.compositor.layouts.content.TabContentManager; |
| -import org.chromium.chrome.browser.compositor.layouts.eventfilter.CascadeEventFilter; |
| -import org.chromium.chrome.browser.compositor.layouts.eventfilter.ContextualSearchEventFilter; |
| import org.chromium.chrome.browser.compositor.layouts.eventfilter.EdgeSwipeEventFilter; |
| import org.chromium.chrome.browser.compositor.layouts.eventfilter.EdgeSwipeEventFilter.ScrollDirection; |
| import org.chromium.chrome.browser.compositor.layouts.eventfilter.EdgeSwipeHandler; |
| import org.chromium.chrome.browser.compositor.layouts.eventfilter.EmptyEdgeSwipeHandler; |
| -import org.chromium.chrome.browser.compositor.layouts.eventfilter.EventFilter; |
| import org.chromium.chrome.browser.compositor.layouts.eventfilter.GestureHandler; |
| -import org.chromium.chrome.browser.compositor.layouts.phone.ContextualSearchLayout; |
| import org.chromium.chrome.browser.compositor.overlays.SceneOverlay; |
| import org.chromium.chrome.browser.contextualsearch.ContextualSearchManagementDelegate; |
| -import org.chromium.chrome.browser.contextualsearch.ContextualSearchStaticEventFilter; |
| -import org.chromium.chrome.browser.contextualsearch.ContextualSearchStaticEventFilter.ContextualSearchTapHandler; |
| import org.chromium.chrome.browser.device.DeviceClassManager; |
| import org.chromium.chrome.browser.dom_distiller.ReaderModeManagerDelegate; |
| import org.chromium.chrome.browser.fullscreen.FullscreenManager; |
| @@ -57,22 +50,18 @@ import java.util.List; |
| * driving all {@link Layout}s that get shown via the {@link LayoutManager}. |
| */ |
| public class LayoutManagerDocument extends LayoutManager |
| - implements ContextualSearchTapHandler, OverlayPanelContentViewDelegate { |
|
Theresa
2016/04/21 21:22:39
Happy to see some of the CS specific stuff disappe
mdjones
2016/04/22 17:03:42
\o/
|
| + implements OverlayPanelContentViewDelegate { |
| // Layouts |
| /** A {@link Layout} used for showing a normal web page. */ |
| protected final StaticLayout mStaticLayout; |
| - /** A {@link Layout} used for when the contextual search panel is up. */ |
| - protected final ContextualSearchLayout mContextualSearchLayout; |
| // Event Filters |
| private final EdgeSwipeEventFilter mStaticEdgeEventFilter; |
| - private final ContextualSearchEventFilter mContextualSearchEventFilter; |
| private final EdgeSwipeHandler mToolbarSwipeHandler; |
| // Event Filter Handlers |
| /** A {@link GestureHandler} that will delegate all events to {@link #getActiveLayout()}. */ |
| protected final GestureHandler mGestureHandler; |
| - private final EdgeSwipeHandler mOverlayPanelEdgeSwipeHandler; |
| // Internal State |
| private final SparseArray<LayoutTab> mTabCache = new SparseArray<LayoutTab>(); |
| @@ -93,30 +82,26 @@ public class LayoutManagerDocument extends LayoutManager |
| Context context = host.getContext(); |
| LayoutRenderHost renderHost = host.getLayoutRenderHost(); |
| - mOverlayPanelManager = new OverlayPanelManager(); |
| - mContextualSearchPanel = new ContextualSearchPanel(context, this, mOverlayPanelManager); |
| - mReaderModePanel = new ReaderModePanel(context, this, mOverlayPanelManager, this); |
| - |
| // Build Event Filter Handlers |
| - mOverlayPanelEdgeSwipeHandler = new OverlayPanelEdgeSwipeHandler(this); |
| mGestureHandler = new GestureHandlerLayoutDelegate(this); |
| mToolbarSwipeHandler = new ToolbarSwipeHandler(this); |
| // Build Event Filters |
| mStaticEdgeEventFilter = |
| new EdgeSwipeEventFilter(context, this, new StaticEdgeSwipeHandler()); |
| - mContextualSearchEventFilter = new ContextualSearchEventFilter( |
| - context, this, mGestureHandler, mOverlayPanelManager); |
| - EventFilter contextualSearchStaticEventFilter = new ContextualSearchStaticEventFilter( |
| - context, this, mOverlayPanelManager, mOverlayPanelEdgeSwipeHandler, this); |
| - EventFilter staticCascadeEventFilter = new CascadeEventFilter(context, this, |
| - new EventFilter[] {contextualSearchStaticEventFilter, mStaticEdgeEventFilter}); |
| + |
| + mOverlayPanelManager = new OverlayPanelManager(); |
| // Build Layouts |
| mStaticLayout = new StaticLayout( |
| - context, this, renderHost, staticCascadeEventFilter, mOverlayPanelManager); |
| - mContextualSearchLayout = new ContextualSearchLayout( |
| - context, this, renderHost, mContextualSearchEventFilter, mOverlayPanelManager); |
| + context, this, renderHost, mStaticEdgeEventFilter, mOverlayPanelManager); |
| + |
| + // Contextual Search scene overlay. |
| + mContextualSearchPanel = new ContextualSearchPanel(context, this, this, |
| + mOverlayPanelManager); |
| + |
| + // Reader Mode scene overlay. |
| + mReaderModePanel = new ReaderModePanel(context, this, this, mOverlayPanelManager, this); |
| // Set up layout parameters |
| mStaticLayout.setLayoutHandlesTabLifecycles(true); |
| @@ -130,6 +115,9 @@ public class LayoutManagerDocument extends LayoutManager |
| ContextualSearchManagementDelegate contextualSearchDelegate, |
| ReaderModeManagerDelegate readerModeDelegate, |
| DynamicResourceLoader dynamicResourceLoader) { |
| + // Add any SceneOverlays to a layout. |
| + addAllSceneOverlays(); |
| + |
| // Save state |
| mContextualSearchDelegate = contextualSearchDelegate; |
| @@ -138,7 +126,6 @@ public class LayoutManagerDocument extends LayoutManager |
| // Initialize Layouts |
| mStaticLayout.setTabModelSelector(selector, content); |
| - mContextualSearchLayout.setTabModelSelector(selector, content); |
| // Initialize Contextual Search Panel |
| mContextualSearchPanel.setManagementDelegate(contextualSearchDelegate); |
| @@ -155,6 +142,7 @@ public class LayoutManagerDocument extends LayoutManager |
| // Set the dynamic resource loader for all overlay panels. |
| mOverlayPanelManager.setDynamicResourceLoader(dynamicResourceLoader); |
| + mOverlayPanelManager.setContainerView(androidContentContainer); |
| mTabModelSelectorTabObserver = new TabModelSelectorTabObserver(selector) { |
| @Override |
| @@ -182,7 +170,6 @@ public class LayoutManagerDocument extends LayoutManager |
| super.destroy(); |
| if (mStaticLayout != null) mStaticLayout.destroy(); |
| - if (mContextualSearchLayout != null) mContextualSearchLayout.destroy(); |
| if (mOverlayPanelManager != null) mOverlayPanelManager.destroy(); |
| if (mTabModelSelectorTabObserver != null) mTabModelSelectorTabObserver.destroy(); |
| } |
| @@ -225,7 +212,15 @@ public class LayoutManagerDocument extends LayoutManager |
| */ |
| protected void addGlobalSceneOverlay(SceneOverlay helper) { |
| mStaticLayout.addSceneOverlay(helper); |
| - mContextualSearchLayout.addSceneOverlay(helper); |
| + } |
| + |
| + /** |
| + * Add any {@link SceneOverlay}s to the layout. This can be used to add the overlays in a |
| + * particular order. |
| + */ |
| + protected void addAllSceneOverlays() { |
| + mStaticLayout.addSceneOverlay(mContextualSearchPanel); |
| + mStaticLayout.addSceneOverlay(mReaderModePanel); |
| } |
| /** |
| @@ -304,27 +299,6 @@ public class LayoutManagerDocument extends LayoutManager |
| } |
| @Override |
| - public void handleTapContextualSearchBar(long time, float x, float y) { |
| - if (getActiveLayout() == mContextualSearchLayout) return; |
| - |
| - OverlayPanel panel = mOverlayPanelManager.getActivePanel(); |
| - if (panel == null) return; |
| - |
| - // When not in compatibility mode, tapping on the Search Bar will expand the Panel, |
| - // therefore we must start showing the ContextualSearchLayout. |
| - // TODO(pedrosimonetti): once we implement the close button, a tap in the Panel might |
| - // trigger the Panel to close, not expand, so in that case we don't want to show the |
| - // ContextualSearchLayout. Coordinate with dtrainor@ to solve this. It might be |
| - // necessary for the ContextualSearchPanel to be able to trigger the display of the |
| - // ContextualSearchLayout. |
| - if (panel.supportsContextualSearchLayout()) { |
| - showContextualSearchLayout(true); |
| - } |
| - |
| - panel.handleClick(time, x, y); |
| - } |
| - |
| - @Override |
| public void setOverlayPanelContentViewCore(ContentViewCore contentViewCore) { |
| mHost.onContentViewCoreAdded(contentViewCore); |
| } |
| @@ -336,14 +310,6 @@ public class LayoutManagerDocument extends LayoutManager |
| if (tab != null) tab.updateFullscreenEnabledState(); |
| } |
| - private void showContextualSearchLayout(boolean animate) { |
| - ContentViewCore cvc = getCurrentTabContentViewCore(); |
| - if (cvc != null) { |
| - cvc.preserveSelectionOnNextLossOfFocus(); |
| - } |
| - startShowing(mContextualSearchLayout, animate); |
| - } |
| - |
| private ContentViewCore getCurrentTabContentViewCore() { |
| if (getTabModelSelector() == null) return null; |
| Tab tab = getTabModelSelector().getCurrentTab(); |
| @@ -365,31 +331,6 @@ public class LayoutManagerDocument extends LayoutManager |
| } |
| } |
| - private class OverlayPanelEdgeSwipeHandler extends EdgeSwipeHandlerLayoutDelegate { |
| - public OverlayPanelEdgeSwipeHandler(LayoutProvider provider) { |
| - super(provider); |
| - } |
| - |
| - @Override |
| - public void swipeStarted(ScrollDirection direction, float x, float y) { |
| - OverlayPanel panel = mOverlayPanelManager.getActivePanel(); |
| - if (getActiveLayout() != mContextualSearchLayout && panel != null |
| - && panel.supportsContextualSearchLayout()) { |
| - showContextualSearchLayout(false); |
| - } |
| - |
| - if (panel != null && !panel.onInterceptBarSwipe()) { |
| - super.swipeStarted(direction, x, y); |
| - } |
| - } |
| - |
| - @Override |
| - public boolean isSwipeEnabled(ScrollDirection direction) { |
| - OverlayPanel panel = mOverlayPanelManager.getActivePanel(); |
| - return direction == ScrollDirection.UP && panel != null && panel.isShowing(); |
| - } |
| - } |
| - |
| /** |
| * A {@link EdgeSwipeHandler} meant to respond to edge events for the toolbar. |
| */ |