Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(135)

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/compositor/layouts/LayoutManagerChrome.java

Issue 2784463002: Revert of chrome/android: Push EventFilters into the Layout implementations. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chrome.browser.compositor.layouts; 5 package org.chromium.chrome.browser.compositor.layouts;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 import android.view.ViewGroup; 8 import android.view.ViewGroup;
9 9
10 import org.chromium.base.ObserverList; 10 import org.chromium.base.ObserverList;
11 import org.chromium.base.VisibleForTesting; 11 import org.chromium.base.VisibleForTesting;
12 import org.chromium.chrome.browser.compositor.TitleCache; 12 import org.chromium.chrome.browser.compositor.TitleCache;
13 import org.chromium.chrome.browser.compositor.layouts.components.LayoutTab; 13 import org.chromium.chrome.browser.compositor.layouts.components.LayoutTab;
14 import org.chromium.chrome.browser.compositor.layouts.components.VirtualView; 14 import org.chromium.chrome.browser.compositor.layouts.components.VirtualView;
15 import org.chromium.chrome.browser.compositor.layouts.content.TabContentManager; 15 import org.chromium.chrome.browser.compositor.layouts.content.TabContentManager;
16 import org.chromium.chrome.browser.compositor.layouts.eventfilter.BlackHoleEvent Filter;
16 import org.chromium.chrome.browser.compositor.layouts.eventfilter.EdgeSwipeHandl er; 17 import org.chromium.chrome.browser.compositor.layouts.eventfilter.EdgeSwipeHandl er;
18 import org.chromium.chrome.browser.compositor.layouts.eventfilter.EventFilter;
19 import org.chromium.chrome.browser.compositor.layouts.eventfilter.GestureEventFi lter;
17 import org.chromium.chrome.browser.compositor.layouts.eventfilter.ScrollDirectio n; 20 import org.chromium.chrome.browser.compositor.layouts.eventfilter.ScrollDirectio n;
18 import org.chromium.chrome.browser.compositor.layouts.phone.StackLayout; 21 import org.chromium.chrome.browser.compositor.layouts.phone.StackLayout;
19 import org.chromium.chrome.browser.compositor.overlays.SceneOverlay; 22 import org.chromium.chrome.browser.compositor.overlays.SceneOverlay;
20 import org.chromium.chrome.browser.compositor.overlays.strip.StripLayoutHelperMa nager; 23 import org.chromium.chrome.browser.compositor.overlays.strip.StripLayoutHelperMa nager;
21 import org.chromium.chrome.browser.contextualsearch.ContextualSearchManagementDe legate; 24 import org.chromium.chrome.browser.contextualsearch.ContextualSearchManagementDe legate;
22 import org.chromium.chrome.browser.device.DeviceClassManager; 25 import org.chromium.chrome.browser.device.DeviceClassManager;
23 import org.chromium.chrome.browser.dom_distiller.ReaderModeManagerDelegate; 26 import org.chromium.chrome.browser.dom_distiller.ReaderModeManagerDelegate;
24 import org.chromium.chrome.browser.fullscreen.FullscreenManager; 27 import org.chromium.chrome.browser.fullscreen.FullscreenManager;
25 import org.chromium.chrome.browser.tab.Tab; 28 import org.chromium.chrome.browser.tab.Tab;
26 import org.chromium.chrome.browser.tabmodel.EmptyTabModelObserver; 29 import org.chromium.chrome.browser.tabmodel.EmptyTabModelObserver;
(...skipping 21 matching lines...) Expand all
48 public class LayoutManagerChrome 51 public class LayoutManagerChrome
49 extends LayoutManagerDocument implements OverviewModeBehavior, CloseAllT absDelegate { 52 extends LayoutManagerDocument implements OverviewModeBehavior, CloseAllT absDelegate {
50 // Layouts 53 // Layouts
51 /** An {@link Layout} that should be used as the accessibility tab switcher. */ 54 /** An {@link Layout} that should be used as the accessibility tab switcher. */
52 protected OverviewListLayout mOverviewListLayout; 55 protected OverviewListLayout mOverviewListLayout;
53 /** A {@link Layout} that should be used when the user is swiping sideways o n the toolbar. */ 56 /** A {@link Layout} that should be used when the user is swiping sideways o n the toolbar. */
54 protected ToolbarSwipeLayout mToolbarSwipeLayout; 57 protected ToolbarSwipeLayout mToolbarSwipeLayout;
55 /** A {@link Layout} that should be used when the user is in the tab switche r. */ 58 /** A {@link Layout} that should be used when the user is in the tab switche r. */
56 protected Layout mOverviewLayout; 59 protected Layout mOverviewLayout;
57 60
61 // Event Filters
62 /** A {@link EventFilter} that consumes all touch events. */
63 protected EventFilter mBlackHoleEventFilter;
64 private final GestureEventFilter mGestureEventFilter;
65
58 // Event Filter Handlers 66 // Event Filter Handlers
59 private final EdgeSwipeHandler mToolbarSwipeHandler; 67 private final EdgeSwipeHandler mToolbarSwipeHandler;
60 68
61 // Internal State 69 // Internal State
62 /** A {@link TitleCache} instance that stores all title/favicon bitmaps as C C resources. */ 70 /** A {@link TitleCache} instance that stores all title/favicon bitmaps as C C resources. */
63 protected TitleCache mTitleCache; 71 protected TitleCache mTitleCache;
64 72
65 /** Whether or not animations are enabled. This can disable certain layouts or effects. */ 73 /** Whether or not animations are enabled. This can disable certain layouts or effects. */
66 private boolean mEnableAnimations = true; 74 private boolean mEnableAnimations = true;
67 private boolean mCreatingNtp; 75 private boolean mCreatingNtp;
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 public LayoutManagerChrome(LayoutManagerHost host, boolean createOverviewLay out) { 159 public LayoutManagerChrome(LayoutManagerHost host, boolean createOverviewLay out) {
152 super(host); 160 super(host);
153 Context context = host.getContext(); 161 Context context = host.getContext();
154 LayoutRenderHost renderHost = host.getLayoutRenderHost(); 162 LayoutRenderHost renderHost = host.getLayoutRenderHost();
155 163
156 mOverviewModeObservers = new ObserverList<OverviewModeObserver>(); 164 mOverviewModeObservers = new ObserverList<OverviewModeObserver>();
157 165
158 // Build Event Filter Handlers 166 // Build Event Filter Handlers
159 mToolbarSwipeHandler = createToolbarSwipeHandler(this); 167 mToolbarSwipeHandler = createToolbarSwipeHandler(this);
160 168
169 // Build Event Filters
170 mBlackHoleEventFilter = new BlackHoleEventFilter(context);
171 mGestureEventFilter = new GestureEventFilter(context, mGestureHandler);
172
161 // Build Layouts 173 // Build Layouts
162 mOverviewListLayout = new OverviewListLayout(context, this, renderHost); 174 mOverviewListLayout =
163 mToolbarSwipeLayout = new ToolbarSwipeLayout(context, this, renderHost); 175 new OverviewListLayout(context, this, renderHost, mBlackHoleEven tFilter);
176 mToolbarSwipeLayout =
177 new ToolbarSwipeLayout(context, this, renderHost, mBlackHoleEven tFilter);
164 if (createOverviewLayout) { 178 if (createOverviewLayout) {
165 mOverviewLayout = new StackLayout(context, this, renderHost); 179 mOverviewLayout = new StackLayout(context, this, renderHost, mGestur eEventFilter);
166 } 180 }
167 } 181 }
168 182
169 /** 183 /**
170 * @return The {@link TabModelObserver} instance this class should be using. 184 * @return The {@link TabModelObserver} instance this class should be using.
171 */ 185 */
172 protected LayoutManagerTabModelObserver createTabModelObserver() { 186 protected LayoutManagerTabModelObserver createTabModelObserver() {
173 return new LayoutManagerTabModelObserver(); 187 return new LayoutManagerTabModelObserver();
174 } 188 }
175 189
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 309
296 /** 310 /**
297 * Simulates a click on the view at the specified pixel offset 311 * Simulates a click on the view at the specified pixel offset
298 * from the top left of the view. 312 * from the top left of the view.
299 * This is used by UI tests. 313 * This is used by UI tests.
300 * @param x Coordinate of the click in dp. 314 * @param x Coordinate of the click in dp.
301 * @param y Coordinate of the click in dp. 315 * @param y Coordinate of the click in dp.
302 */ 316 */
303 @VisibleForTesting 317 @VisibleForTesting
304 public void simulateClick(float x, float y) { 318 public void simulateClick(float x, float y) {
305 if (getActiveLayout() instanceof StackLayout) { 319 if (getActiveLayout() != null) getActiveLayout().click(time(), x, y);
306 ((StackLayout) getActiveLayout()).simulateClick(x, y);
307 }
308 } 320 }
309 321
310 /** 322 /**
311 * Simulates a drag and issues Up-event to commit the drag. 323 * Simulates a drag and issues Up-event to commit the drag.
312 * @param x Coordinate to start the Drag from in dp. 324 * @param x Coordinate to start the Drag from in dp.
313 * @param y Coordinate to start the Drag from in dp. 325 * @param y Coordinate to start the Drag from in dp.
314 * @param dX Amount of drag in X direction in dp. 326 * @param dX Amount of drag in X direction in dp.
315 * @param dY Amount of drag in Y direction in dp. 327 * @param dY Amount of drag in Y direction in dp.
316 */ 328 */
317 @VisibleForTesting 329 @VisibleForTesting
318 public void simulateDrag(float x, float y, float dX, float dY) { 330 public void simulateDrag(float x, float y, float dX, float dY) {
319 if (getActiveLayout() instanceof StackLayout) { 331 if (getActiveLayout() != null) {
320 ((StackLayout) getActiveLayout()).simulateDrag(x, y, dX, dY); 332 getActiveLayout().onDown(0, x, y);
333 getActiveLayout().drag(0, x, y, dX, dY);
334 getActiveLayout().onUpOrCancel(time());
321 } 335 }
322 } 336 }
323 337
324 private boolean isOverviewLayout(Layout layout) { 338 private boolean isOverviewLayout(Layout layout) {
325 return layout != null && (layout == mOverviewLayout || layout == mOvervi ewListLayout); 339 return layout != null && (layout == mOverviewLayout || layout == mOvervi ewListLayout);
326 } 340 }
327 341
328 @Override 342 @Override
329 protected void startShowing(Layout layout, boolean animate) { 343 protected void startShowing(Layout layout, boolean animate) {
330 mCreatingNtp = false; 344 mCreatingNtp = false;
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
667 681
668 /** 682 /**
669 * @param id The id of the {@link Tab} to search for. 683 * @param id The id of the {@link Tab} to search for.
670 * @return A {@link Tab} instance or {@code null} if it could be found. 684 * @return A {@link Tab} instance or {@code null} if it could be found.
671 */ 685 */
672 protected Tab getTabById(int id) { 686 protected Tab getTabById(int id) {
673 TabModelSelector selector = getTabModelSelector(); 687 TabModelSelector selector = getTabModelSelector();
674 return selector == null ? null : selector.getTabById(id); 688 return selector == null ? null : selector.getTabById(id);
675 } 689 }
676 } 690 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698