Index: chrome/android/java/src/org/chromium/chrome/browser/compositor/layouts/Layout.java |
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/compositor/layouts/Layout.java b/chrome/android/java/src/org/chromium/chrome/browser/compositor/layouts/Layout.java |
index 67763c3e7adcaa97cd006deb56fcfefd044e7f25..be3cf7b4c8ff4a0fc1129af23eef7b8393925ed4 100644 |
--- a/chrome/android/java/src/org/chromium/chrome/browser/compositor/layouts/Layout.java |
+++ b/chrome/android/java/src/org/chromium/chrome/browser/compositor/layouts/Layout.java |
@@ -99,6 +99,7 @@ |
// Helpers |
private final LayoutUpdateHost mUpdateHost; |
protected final LayoutRenderHost mRenderHost; |
+ private EventFilter mEventFilter; |
/** The tabs currently being rendered as part of this layout. The tabs are |
* drawn using the same ordering as this array. */ |
@@ -119,11 +120,14 @@ |
* @param context The current Android's context. |
* @param updateHost The parent {@link LayoutUpdateHost}. |
* @param renderHost The parent {@link LayoutRenderHost}. |
- */ |
- public Layout(Context context, LayoutUpdateHost updateHost, LayoutRenderHost renderHost) { |
+ * @param eventFilter The {@link EventFilter} this {@link Layout} is listening to. |
+ */ |
+ public Layout(Context context, LayoutUpdateHost updateHost, LayoutRenderHost renderHost, |
+ EventFilter eventFilter) { |
mContext = context; |
mUpdateHost = updateHost; |
mRenderHost = renderHost; |
+ mEventFilter = eventFilter; |
// Invalid sizes |
mWidthDp = -1; |
@@ -566,6 +570,69 @@ |
} |
return false; |
} |
+ |
+ /** |
+ * Called on touch drag event. |
+ * @param time The current time of the app in ms. |
+ * @param x The y coordinate of the end of the drag event. |
+ * @param y The y coordinate of the end of the drag event. |
+ * @param deltaX The number of pixels dragged in the x direction. |
+ * @param deltaY The number of pixels dragged in the y direction. |
+ */ |
+ public void drag(long time, float x, float y, float deltaX, float deltaY) { } |
+ |
+ /** |
+ * Called on touch fling event. This is called before the onUpOrCancel event. |
+ * |
+ * @param time The current time of the app in ms. |
+ * @param x The y coordinate of the start of the fling event. |
+ * @param y The y coordinate of the start of the fling event. |
+ * @param velocityX The amount of velocity in the x direction. |
+ * @param velocityY The amount of velocity in the y direction. |
+ */ |
+ public void fling(long time, float x, float y, float velocityX, float velocityY) { } |
+ |
+ /** |
+ * Called on onDown event. |
+ * |
+ * @param time The time stamp in millisecond of the event. |
+ * @param x The x position of the event. |
+ * @param y The y position of the event. |
+ */ |
+ public void onDown(long time, float x, float y) { } |
+ |
+ /** |
+ * Called on long press touch event. |
+ * @param time The current time of the app in ms. |
+ * @param x The x coordinate of the position of the press event. |
+ * @param y The y coordinate of the position of the press event. |
+ */ |
+ public void onLongPress(long time, float x, float y) { } |
+ |
+ /** |
+ * Called on click. This is called before the onUpOrCancel event. |
+ * @param time The current time of the app in ms. |
+ * @param x The x coordinate of the position of the click. |
+ * @param y The y coordinate of the position of the click. |
+ */ |
+ public void click(long time, float x, float y) { } |
+ |
+ /** |
+ * Called on up or cancel touch events. This is called after the click and fling event if any. |
+ * @param time The current time of the app in ms. |
+ */ |
+ public void onUpOrCancel(long time) { } |
+ |
+ /** |
+ * Called when at least 2 touch events are detected. |
+ * @param time The current time of the app in ms. |
+ * @param x0 The x coordinate of the first touch event. |
+ * @param y0 The y coordinate of the first touch event. |
+ * @param x1 The x coordinate of the second touch event. |
+ * @param y1 The y coordinate of the second touch event. |
+ * @param firstEvent The pinch is the first of a sequence of pinch events. |
+ */ |
+ public void onPinch(long time, float x0, float y0, float x1, float y1, boolean firstEvent) { } |
/** |
* Called by the LayoutManager when an animation should be killed. |
@@ -971,6 +1038,15 @@ |
} |
/** |
+ * Setting this will only take effect the next time this layout is shown. If it is currently |
+ * showing the original filter will still be used. |
+ * @param filter |
+ */ |
+ public void setEventFilter(EventFilter filter) { |
+ mEventFilter = filter; |
+ } |
+ |
+ /** |
* @param e The {@link MotionEvent} to consider. |
* @param offsets The current touch offsets that should be applied to the |
* {@link EventFilter}s. |
@@ -988,14 +1064,9 @@ |
if (eventFilter.onInterceptTouchEvent(e, isKeyboardShowing)) return eventFilter; |
} |
- EventFilter layoutEventFilter = getEventFilter(); |
- if (layoutEventFilter != null) { |
- if (offsets != null) { |
- layoutEventFilter.setCurrentMotionEventOffsets(offsets.x, offsets.y); |
- } |
- if (layoutEventFilter.onInterceptTouchEvent(e, isKeyboardShowing)) { |
- return layoutEventFilter; |
- } |
+ if (mEventFilter != null) { |
+ if (offsets != null) mEventFilter.setCurrentMotionEventOffsets(offsets.x, offsets.y); |
+ if (mEventFilter.onInterceptTouchEvent(e, isKeyboardShowing)) return mEventFilter; |
} |
return null; |
} |
@@ -1056,9 +1127,11 @@ |
} |
/** |
- * @return The EventFilter to use for processing events for this Layout. |
- */ |
- protected abstract EventFilter getEventFilter(); |
+ * @return Whether the tabstrip's event filter is enabled. |
+ */ |
+ public boolean isTabStripEventFilterEnabled() { |
+ return true; |
+ } |
/** |
* Get an instance of {@link SceneLayer}. Any class inheriting {@link Layout} |