Expose more gestures to ContentViewCore.GestureStateListeners

* Let ContentViewCore manage more than one GestureStateListener.
* Change GestureStateListener to be an empty implementation.
* ContentViewCore alerts its GestureStateListeners of any scrolls
  or flings, and alerts it of changes in the vertical scroll offset
  or extent.  That last bit is admittedly a bit strange to put in
  the GestureStateListener, but it's going to be listening to starts
  and stops already anyway...

Downstream CL that uses it: https://chrome-internal-review.googlesource.com/#/c/152640/
BUG=332281

Review URL: https://codereview.chromium.org/145953005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@247825 0039d316-1c4b-4281-b951-d872f2087c98
parent b83aa83d
...@@ -48,6 +48,7 @@ import org.chromium.content.browser.LoadUrlParams; ...@@ -48,6 +48,7 @@ import org.chromium.content.browser.LoadUrlParams;
import org.chromium.content.browser.NavigationHistory; import org.chromium.content.browser.NavigationHistory;
import org.chromium.content.browser.PageTransitionTypes; import org.chromium.content.browser.PageTransitionTypes;
import org.chromium.content.common.CleanupReference; import org.chromium.content.common.CleanupReference;
import org.chromium.content_public.browser.GestureStateListener;
import org.chromium.ui.base.ActivityWindowAndroid; import org.chromium.ui.base.ActivityWindowAndroid;
import org.chromium.ui.base.WindowAndroid; import org.chromium.ui.base.WindowAndroid;
import org.chromium.ui.gfx.DeviceDisplayInfo; import org.chromium.ui.gfx.DeviceDisplayInfo;
...@@ -382,7 +383,7 @@ public class AwContents { ...@@ -382,7 +383,7 @@ public class AwContents {
} }
//-------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------
private class AwGestureStateListener implements ContentViewCore.GestureStateListener { private class AwGestureStateListener extends GestureStateListener {
@Override @Override
public void onPinchGestureStart() { public void onPinchGestureStart() {
// While it's possible to re-layout the view during a pinch gesture, the effect is very // While it's possible to re-layout the view during a pinch gesture, the effect is very
...@@ -400,7 +401,8 @@ public class AwContents { ...@@ -400,7 +401,8 @@ public class AwContents {
} }
@Override @Override
public void onFlingStartGesture(int velocityX, int velocityY) { public void onFlingStartGesture(
int velocityX, int velocityY, int scrollOffsetY, int scrollExtentY) {
mScrollOffsetManager.onFlingStartGesture(velocityX, velocityY); mScrollOffsetManager.onFlingStartGesture(velocityX, velocityY);
} }
...@@ -517,7 +519,7 @@ public class AwContents { ...@@ -517,7 +519,7 @@ public class AwContents {
private static ContentViewCore createAndInitializeContentViewCore(ViewGroup containerView, private static ContentViewCore createAndInitializeContentViewCore(ViewGroup containerView,
InternalAccessDelegate internalDispatcher, int nativeWebContents, InternalAccessDelegate internalDispatcher, int nativeWebContents,
ContentViewCore.GestureStateListener pinchGestureStateListener, GestureStateListener gestureStateListener,
ContentViewClient contentViewClient, ContentViewClient contentViewClient,
ContentViewCore.ZoomControlsDelegate zoomControlsDelegate) { ContentViewCore.ZoomControlsDelegate zoomControlsDelegate) {
Context context = containerView.getContext(); Context context = containerView.getContext();
...@@ -526,7 +528,7 @@ public class AwContents { ...@@ -526,7 +528,7 @@ public class AwContents {
context instanceof Activity ? context instanceof Activity ?
new ActivityWindowAndroid((Activity) context) : new ActivityWindowAndroid((Activity) context) :
new WindowAndroid(context.getApplicationContext())); new WindowAndroid(context.getApplicationContext()));
contentViewCore.setGestureStateListener(pinchGestureStateListener); contentViewCore.addGestureStateListener(gestureStateListener);
contentViewCore.setContentViewClient(contentViewClient); contentViewCore.setContentViewClient(contentViewClient);
contentViewCore.setZoomControlsDelegate(zoomControlsDelegate); contentViewCore.setZoomControlsDelegate(zoomControlsDelegate);
return contentViewCore; return contentViewCore;
......
...@@ -13,8 +13,8 @@ import org.chromium.android_webview.test.util.AwTestTouchUtils; ...@@ -13,8 +13,8 @@ import org.chromium.android_webview.test.util.AwTestTouchUtils;
import org.chromium.android_webview.test.util.CommonResources; import org.chromium.android_webview.test.util.CommonResources;
import org.chromium.android_webview.test.util.JavascriptEventObserver; import org.chromium.android_webview.test.util.JavascriptEventObserver;
import org.chromium.base.test.util.Feature; import org.chromium.base.test.util.Feature;
import org.chromium.content.browser.ContentViewCore;
import org.chromium.content.browser.test.util.CallbackHelper; import org.chromium.content.browser.test.util.CallbackHelper;
import org.chromium.content_public.browser.GestureStateListener;
import org.chromium.ui.gfx.DeviceDisplayInfo; import org.chromium.ui.gfx.DeviceDisplayInfo;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
...@@ -669,7 +669,7 @@ public class AndroidScrollIntegrationTest extends AwTestBase { ...@@ -669,7 +669,7 @@ public class AndroidScrollIntegrationTest extends AwTestBase {
} }
} }
private static class TestGestureStateListener implements ContentViewCore.GestureStateListener { private static class TestGestureStateListener extends GestureStateListener {
private CallbackHelper mOnScrollUpdateGestureConsumedHelper = new CallbackHelper(); private CallbackHelper mOnScrollUpdateGestureConsumedHelper = new CallbackHelper();
public CallbackHelper getOnScrollUpdateGestureConsumedHelper() { public CallbackHelper getOnScrollUpdateGestureConsumedHelper() {
...@@ -685,7 +685,8 @@ public class AndroidScrollIntegrationTest extends AwTestBase { ...@@ -685,7 +685,8 @@ public class AndroidScrollIntegrationTest extends AwTestBase {
} }
@Override @Override
public void onFlingStartGesture(int velocityX, int velocityY) { public void onFlingStartGesture(
int velocityX, int velocityY, int scrollOffsetY, int scrollExtentY) {
} }
@Override @Override
...@@ -726,7 +727,7 @@ public class AndroidScrollIntegrationTest extends AwTestBase { ...@@ -726,7 +727,7 @@ public class AndroidScrollIntegrationTest extends AwTestBase {
getInstrumentation().runOnMainSync(new Runnable() { getInstrumentation().runOnMainSync(new Runnable() {
@Override @Override
public void run() { public void run() {
testContainerView.getContentViewCore().setGestureStateListener( testContainerView.getContentViewCore().addGestureStateListener(
testGestureStateListener); testGestureStateListener);
} }
}); });
......
...@@ -180,35 +180,4 @@ public class ContentViewClient { ...@@ -180,35 +180,4 @@ public class ContentViewClient {
return false; return false;
} }
/**
* Called when a fling start event is sent. Note: onFlingStopped() of the previous
* fling may be called after onFlingStarted() of the current fling, so if the
* client wants to manage the fling status, a counter should be used.
*/
public void onFlingStarted() {
}
/**
* Called when a fling is stopped, or a fling start event didn't trigger a fling.
*/
public void onFlingStopped() {
}
/**
* Called when a scroll gesture has begun.
*/
public void onScrollBeginEvent() {
}
/**
* Called when a scroll gesture has ended.
*/
public void onScrollEndEvent() {
}
/**
* Called when the scroll offsets or viewport dimensions may have changed.
*/
public void onScrollOrViewportChanged() {
}
} }
...@@ -208,12 +208,13 @@ class ContentViewGestureHandler implements LongPressDelegate { ...@@ -208,12 +208,13 @@ class ContentViewGestureHandler implements LongPressDelegate {
static final int GESTURE_SCROLL_END = 8; static final int GESTURE_SCROLL_END = 8;
static final int GESTURE_FLING_START = 9; static final int GESTURE_FLING_START = 9;
static final int GESTURE_FLING_CANCEL = 10; static final int GESTURE_FLING_CANCEL = 10;
static final int GESTURE_PINCH_BEGIN = 11; static final int GESTURE_FLING_END = 11;
static final int GESTURE_PINCH_BY = 12; static final int GESTURE_PINCH_BEGIN = 12;
static final int GESTURE_PINCH_END = 13; static final int GESTURE_PINCH_BY = 13;
static final int GESTURE_TAP_CANCEL = 14; static final int GESTURE_PINCH_END = 14;
static final int GESTURE_LONG_TAP = 15; static final int GESTURE_TAP_CANCEL = 15;
static final int GESTURE_TAP_DOWN = 16; static final int GESTURE_LONG_TAP = 16;
static final int GESTURE_TAP_DOWN = 17;
// These have to be kept in sync with content/port/common/input_event_ack_state.h // These have to be kept in sync with content/port/common/input_event_ack_state.h
static final int INPUT_EVENT_ACK_STATE_UNKNOWN = 0; static final int INPUT_EVENT_ACK_STATE_UNKNOWN = 0;
......
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.content_public.browser;
/**
* A class that is notified of events and state changes related to gesture processing from
* the ContentViewCore.
*/
public class GestureStateListener {
/**
* Called when the pinch gesture starts.
*/
public void onPinchGestureStart() {}
/**
* Called when the pinch gesture ends.
*/
public void onPinchGestureEnd() {}
/**
* Called when the fling gesture is sent.
*/
public void onFlingStartGesture(int vx, int vy, int scrollOffsetY, int scrollExtentY) {}
/**
* Called when the fling cancel gesture is sent.
*/
public void onFlingCancelGesture() {}
/**
* Called when a fling has ended.
*/
public void onFlingEndGesture(int scrollOffsetY, int scrollExtentY) {}
/**
* Called when a fling event was not handled by the renderer.
*/
public void onUnhandledFlingStartEvent() {}
/**
* Called to indicate that a scroll update gesture had been consumed by the page.
* This callback is called whenever any layer is scrolled (like a frame or div). It is
* not called when a JS touch handler consumes the event (preventDefault), it is not called
* for JS-initiated scrolling.
*/
public void onScrollUpdateGestureConsumed() {}
/*
* Called when a scroll gesture has started.
*/
public void onScrollStarted(int scrollOffsetY, int scrollExtentY) {}
/*
* Called when a scroll gesture has stopped.
*/
public void onScrollEnded(int scrollOffsetY, int scrollExtentY) {}
/*
* Called when the scroll offsets or extents may have changed.
*/
public void onScrollOffsetOrExtentChanged(int scrollOffsetY, int scrollExtentY) {}
}
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment