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