Chromium Code Reviews| 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 static org.chromium.chrome.browser.compositor.layouts.ChromeAnimation.Ani matableAnimation.createAnimation; | 7 import static org.chromium.chrome.browser.compositor.layouts.ChromeAnimation.Ani matableAnimation.createAnimation; |
| 8 | 8 |
| 9 import android.content.Context; | 9 import android.content.Context; |
| 10 import android.graphics.PointF; | 10 import android.graphics.PointF; |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 92 protected TabContentManager mTabContentManager; | 92 protected TabContentManager mTabContentManager; |
| 93 | 93 |
| 94 private ChromeAnimation<Animatable<?>> mLayoutAnimations; | 94 private ChromeAnimation<Animatable<?>> mLayoutAnimations; |
| 95 | 95 |
| 96 // Tablet tab strip managers. | 96 // Tablet tab strip managers. |
| 97 private final List<SceneOverlay> mSceneOverlays = new ArrayList<SceneOverlay >(); | 97 private final List<SceneOverlay> mSceneOverlays = new ArrayList<SceneOverlay >(); |
| 98 | 98 |
| 99 // Helpers | 99 // Helpers |
| 100 private final LayoutUpdateHost mUpdateHost; | 100 private final LayoutUpdateHost mUpdateHost; |
| 101 protected final LayoutRenderHost mRenderHost; | 101 protected final LayoutRenderHost mRenderHost; |
| 102 private EventFilter mEventFilter; | 102 protected EventFilter mEventFilter; |
|
Khushal
2017/03/22 21:20:09
I was thinking about just removing this and adding
mdjones
2017/03/23 17:18:55
I think this is a pretty good idea; it makes the e
David Trainor- moved to gerrit
2017/03/24 17:06:43
getEventFilter makes sense if you want the subclas
Khushal
2017/03/24 22:33:09
Done. StaticLayout returns null because it only ta
| |
| 103 | 103 |
| 104 /** The tabs currently being rendered as part of this layout. The tabs are | 104 /** The tabs currently being rendered as part of this layout. The tabs are |
| 105 * drawn using the same ordering as this array. */ | 105 * drawn using the same ordering as this array. */ |
| 106 protected LayoutTab[] mLayoutTabs; | 106 protected LayoutTab[] mLayoutTabs; |
| 107 | 107 |
| 108 // True means that the layout is going to hide as soon as the animation fini shes. | 108 // True means that the layout is going to hide as soon as the animation fini shes. |
| 109 private boolean mIsHiding; | 109 private boolean mIsHiding; |
| 110 | 110 |
| 111 // The next id to show when the layout is hidden, or TabBase#INVALID_TAB_ID if no change. | 111 // The next id to show when the layout is hidden, or TabBase#INVALID_TAB_ID if no change. |
| 112 private int mNextTabId = Tab.INVALID_TAB_ID; | 112 private int mNextTabId = Tab.INVALID_TAB_ID; |
| 113 | 113 |
| 114 // The ratio of dp to px. | 114 // The ratio of dp to px. |
| 115 private final float mDpToPx; | 115 private final float mDpToPx; |
| 116 | 116 |
| 117 /** | 117 /** |
| 118 * The {@link Layout} is not usable until sizeChanged is called. | 118 * The {@link Layout} is not usable until sizeChanged is called. |
| 119 * This is convenient this way so we can pre-create the layout before the ho st is fully defined. | 119 * This is convenient this way so we can pre-create the layout before the ho st is fully defined. |
| 120 * @param context The current Android's context. | 120 * @param context The current Android's context. |
| 121 * @param updateHost The parent {@link LayoutUpdateHost}. | 121 * @param updateHost The parent {@link LayoutUpdateHost}. |
| 122 * @param renderHost The parent {@link LayoutRenderHost}. | 122 * @param renderHost The parent {@link LayoutRenderHost}. |
| 123 * @param eventFilter The {@link EventFilter} this {@link Layout} is listen ing to. | |
| 124 */ | 123 */ |
| 125 public Layout(Context context, LayoutUpdateHost updateHost, LayoutRenderHost renderHost, | 124 public Layout(Context context, LayoutUpdateHost updateHost, LayoutRenderHost renderHost) { |
| 126 EventFilter eventFilter) { | |
| 127 mContext = context; | 125 mContext = context; |
| 128 mUpdateHost = updateHost; | 126 mUpdateHost = updateHost; |
| 129 mRenderHost = renderHost; | 127 mRenderHost = renderHost; |
| 130 mEventFilter = eventFilter; | |
| 131 | 128 |
| 132 // Invalid sizes | 129 // Invalid sizes |
| 133 mWidthDp = -1; | 130 mWidthDp = -1; |
| 134 mHeightDp = -1; | 131 mHeightDp = -1; |
| 135 mHeightMinusBrowserControlsDp = -1; | 132 mHeightMinusBrowserControlsDp = -1; |
| 136 | 133 |
| 137 mCurrentOrientation = Orientation.UNSET; | 134 mCurrentOrientation = Orientation.UNSET; |
| 138 mDpToPx = context.getResources().getDisplayMetrics().density; | 135 mDpToPx = context.getResources().getDisplayMetrics().density; |
| 139 } | 136 } |
| 140 | 137 |
| (...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 565 */ | 562 */ |
| 566 protected boolean initLayoutTabFromHost(LayoutTab layoutTab) { | 563 protected boolean initLayoutTabFromHost(LayoutTab layoutTab) { |
| 567 if (layoutTab.isInitFromHostNeeded()) { | 564 if (layoutTab.isInitFromHostNeeded()) { |
| 568 mUpdateHost.initLayoutTabFromHost(layoutTab.getId()); | 565 mUpdateHost.initLayoutTabFromHost(layoutTab.getId()); |
| 569 return true; | 566 return true; |
| 570 } | 567 } |
| 571 return false; | 568 return false; |
| 572 } | 569 } |
| 573 | 570 |
| 574 /** | 571 /** |
| 575 * Called on touch drag event. | |
| 576 * @param time The current time of the app in ms. | |
| 577 * @param x The y coordinate of the end of the drag event. | |
| 578 * @param y The y coordinate of the end of the drag event. | |
| 579 * @param deltaX The number of pixels dragged in the x direction. | |
| 580 * @param deltaY The number of pixels dragged in the y direction. | |
| 581 */ | |
| 582 public void drag(long time, float x, float y, float deltaX, float deltaY) { } | |
| 583 | |
| 584 /** | |
| 585 * Called on touch fling event. This is called before the onUpOrCancel event . | |
| 586 * | |
| 587 * @param time The current time of the app in ms. | |
| 588 * @param x The y coordinate of the start of the fling event. | |
| 589 * @param y The y coordinate of the start of the fling event. | |
| 590 * @param velocityX The amount of velocity in the x direction. | |
| 591 * @param velocityY The amount of velocity in the y direction. | |
| 592 */ | |
| 593 public void fling(long time, float x, float y, float velocityX, float veloci tyY) { } | |
| 594 | |
| 595 /** | |
| 596 * Called on onDown event. | |
| 597 * | |
| 598 * @param time The time stamp in millisecond of the event. | |
| 599 * @param x The x position of the event. | |
| 600 * @param y The y position of the event. | |
| 601 */ | |
| 602 public void onDown(long time, float x, float y) { } | |
| 603 | |
| 604 /** | |
| 605 * Called on long press touch event. | |
| 606 * @param time The current time of the app in ms. | |
| 607 * @param x The x coordinate of the position of the press event. | |
| 608 * @param y The y coordinate of the position of the press event. | |
| 609 */ | |
| 610 public void onLongPress(long time, float x, float y) { } | |
| 611 | |
| 612 /** | |
| 613 * Called on click. This is called before the onUpOrCancel event. | |
| 614 * @param time The current time of the app in ms. | |
| 615 * @param x The x coordinate of the position of the click. | |
| 616 * @param y The y coordinate of the position of the click. | |
| 617 */ | |
| 618 public void click(long time, float x, float y) { } | |
| 619 | |
| 620 /** | |
| 621 * Called on up or cancel touch events. This is called after the click and f ling event if any. | |
| 622 * @param time The current time of the app in ms. | |
| 623 */ | |
| 624 public void onUpOrCancel(long time) { } | |
| 625 | |
| 626 /** | |
| 627 * Called when at least 2 touch events are detected. | |
| 628 * @param time The current time of the app in ms. | |
| 629 * @param x0 The x coordinate of the first touch event. | |
| 630 * @param y0 The y coordinate of the first touch event. | |
| 631 * @param x1 The x coordinate of the second touch event. | |
| 632 * @param y1 The y coordinate of the second touch event. | |
| 633 * @param firstEvent The pinch is the first of a sequence of pinch events. | |
| 634 */ | |
| 635 public void onPinch(long time, float x0, float y0, float x1, float y1, boole an firstEvent) { } | |
| 636 | |
| 637 /** | |
| 638 * Called by the LayoutManager when an animation should be killed. | 572 * Called by the LayoutManager when an animation should be killed. |
| 639 */ | 573 */ |
| 640 public void unstallImmediately() { } | 574 public void unstallImmediately() { } |
| 641 | 575 |
| 642 /** | 576 /** |
| 643 * Called by the LayoutManager when an animation should be killed. | 577 * Called by the LayoutManager when an animation should be killed. |
| 644 * @param tabId The tab that the kill signal is associated with | 578 * @param tabId The tab that the kill signal is associated with |
| 645 */ | 579 */ |
| 646 public void unstallImmediately(int tabId) { } | 580 public void unstallImmediately(int tabId) { } |
| 647 | 581 |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1031 } | 965 } |
| 1032 | 966 |
| 1033 /** | 967 /** |
| 1034 * @return True if the currently active content view is shown in the normal interactive mode. | 968 * @return True if the currently active content view is shown in the normal interactive mode. |
| 1035 */ | 969 */ |
| 1036 public boolean isTabInteractive() { | 970 public boolean isTabInteractive() { |
| 1037 return false; | 971 return false; |
| 1038 } | 972 } |
| 1039 | 973 |
| 1040 /** | 974 /** |
| 1041 * Setting this will only take effect the next time this layout is shown. I f it is currently | |
| 1042 * showing the original filter will still be used. | |
| 1043 * @param filter | |
| 1044 */ | |
| 1045 public void setEventFilter(EventFilter filter) { | |
| 1046 mEventFilter = filter; | |
| 1047 } | |
| 1048 | |
| 1049 /** | |
| 1050 * @param e The {@link MotionEvent} to consider. | 975 * @param e The {@link MotionEvent} to consider. |
| 1051 * @param offsets The current touch offsets that should be applied to the | 976 * @param offsets The current touch offsets that should be applied to the |
| 1052 * {@link EventFilter}s. | 977 * {@link EventFilter}s. |
| 1053 * @param isKeyboardShowing Whether or not the keyboard is showing. | 978 * @param isKeyboardShowing Whether or not the keyboard is showing. |
| 1054 * @return The {@link EventFilter} the {@link Layout} is listening to. | 979 * @return The {@link EventFilter} the {@link Layout} is listening to. |
| 1055 */ | 980 */ |
| 1056 public EventFilter findInterceptingEventFilter( | 981 public EventFilter findInterceptingEventFilter( |
| 1057 MotionEvent e, PointF offsets, boolean isKeyboardShowing) { | 982 MotionEvent e, PointF offsets, boolean isKeyboardShowing) { |
| 1058 // The last added overlay will be drawn on top of everything else, there fore the last | 983 // The last added overlay will be drawn on top of everything else, there fore the last |
| 1059 // filter added should have the first chance to intercept any touch even ts. | 984 // filter added should have the first chance to intercept any touch even ts. |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1120 } | 1045 } |
| 1121 | 1046 |
| 1122 /** | 1047 /** |
| 1123 * @return Whether or not the layout should permenantly show the browser con trols. | 1048 * @return Whether or not the layout should permenantly show the browser con trols. |
| 1124 */ | 1049 */ |
| 1125 public boolean forceShowBrowserControlsAndroidView() { | 1050 public boolean forceShowBrowserControlsAndroidView() { |
| 1126 return false; | 1051 return false; |
| 1127 } | 1052 } |
| 1128 | 1053 |
| 1129 /** | 1054 /** |
| 1130 * @return Whether the tabstrip's event filter is enabled. | |
| 1131 */ | |
| 1132 public boolean isTabStripEventFilterEnabled() { | |
|
Khushal
2017/03/22 21:20:09
This would always return true, so not necessary.
mdjones
2017/03/23 17:18:55
Also this had no place in this class and apparentl
| |
| 1133 return true; | |
| 1134 } | |
| 1135 | |
| 1136 /** | |
| 1137 * Get an instance of {@link SceneLayer}. Any class inheriting {@link Layout } | 1055 * Get an instance of {@link SceneLayer}. Any class inheriting {@link Layout } |
| 1138 * should override this function in order for other functions to work. | 1056 * should override this function in order for other functions to work. |
| 1139 * | 1057 * |
| 1140 * @return The scene layer for this {@link Layout}. | 1058 * @return The scene layer for this {@link Layout}. |
| 1141 */ | 1059 */ |
| 1142 protected abstract SceneLayer getSceneLayer(); | 1060 protected abstract SceneLayer getSceneLayer(); |
| 1143 | 1061 |
| 1144 /** | 1062 /** |
| 1145 * Update {@link SceneLayer} instance this layout holds. Any class inheritin g {@link Layout} | 1063 * Update {@link SceneLayer} instance this layout holds. Any class inheritin g {@link Layout} |
| 1146 * should override this function in order for other functions to work. | 1064 * should override this function in order for other functions to work. |
| 1147 */ | 1065 */ |
| 1148 protected void updateSceneLayer(RectF viewport, RectF contentViewport, | 1066 protected void updateSceneLayer(RectF viewport, RectF contentViewport, |
| 1149 LayerTitleCache layerTitleCache, TabContentManager tabContentManager , | 1067 LayerTitleCache layerTitleCache, TabContentManager tabContentManager , |
| 1150 ResourceManager resourceManager, ChromeFullscreenManager fullscreenM anager) { | 1068 ResourceManager resourceManager, ChromeFullscreenManager fullscreenM anager) { |
| 1151 } | 1069 } |
| 1152 } | 1070 } |
| OLD | NEW |