Modified: trunk/Source/WebCore/page/EventHandler.cpp (93357 => 93358)
--- trunk/Source/WebCore/page/EventHandler.cpp 2011-08-18 22:16:21 UTC (rev 93357)
+++ trunk/Source/WebCore/page/EventHandler.cpp 2011-08-18 22:19:23 UTC (rev 93358)
@@ -2222,7 +2222,8 @@
case PlatformGestureEvent::ScrollUpdateType: {
const float tickDivisor = (float)WheelEvent::tickMultiplier;
// FIXME: Replace this interim implementation once the above fixme has been addressed.
- PlatformWheelEvent syntheticWheelEvent(gestureEvent.position(), gestureEvent.globalPosition(), gestureEvent.deltaX(), gestureEvent.deltaY(), gestureEvent.deltaX() / tickDivisor, gestureEvent.deltaY() / tickDivisor, ScrollByPixelWheelEvent, /* isAccepted */ false, gestureEvent.shiftKey(), gestureEvent.ctrlKey(), gestureEvent.altKey(), gestureEvent.metaKey());
+ IntPoint point(gestureEvent.position().x() + gestureEvent.deltaX(), gestureEvent.position().y() + gestureEvent.deltaY());
+ PlatformWheelEvent syntheticWheelEvent(point, point, gestureEvent.deltaX(), gestureEvent.deltaY(), gestureEvent.deltaX() / tickDivisor, gestureEvent.deltaY() / tickDivisor, ScrollByPixelWheelEvent, /* isAccepted */ false, gestureEvent.shiftKey(), gestureEvent.ctrlKey(), gestureEvent.altKey(), gestureEvent.metaKey());
handleWheelEvent(syntheticWheelEvent);
return true;
}
Modified: trunk/Source/WebCore/platform/chromium/GestureRecognizerChromium.cpp (93357 => 93358)
--- trunk/Source/WebCore/platform/chromium/GestureRecognizerChromium.cpp 2011-08-18 22:16:21 UTC (rev 93357)
+++ trunk/Source/WebCore/platform/chromium/GestureRecognizerChromium.cpp 2011-08-18 22:19:23 UTC (rev 93358)
@@ -40,6 +40,7 @@
static bool click(InnerGestureRecognizer*, const PlatformTouchPoint&, InnerGestureRecognizer::Gestures);
static bool isClickOrScroll(InnerGestureRecognizer*, const PlatformTouchPoint&, InnerGestureRecognizer::Gestures);
static bool inScroll(InnerGestureRecognizer*, const PlatformTouchPoint&, InnerGestureRecognizer::Gestures);
+static bool scrollEnd(InnerGestureRecognizer*, const PlatformTouchPoint&, InnerGestureRecognizer::Gestures);
static bool noGesture(InnerGestureRecognizer*, const PlatformTouchPoint&, InnerGestureRecognizer::Gestures);
static bool touchDown(InnerGestureRecognizer*, const PlatformTouchPoint&, InnerGestureRecognizer::Gestures);
@@ -70,8 +71,8 @@
addEdgeFunction(PendingSyntheticClick, FirstFinger, Moved, false, isClickOrScroll);
addEdgeFunction(PendingSyntheticClick, FirstFinger, Stationary, false, isClickOrScroll);
addEdgeFunction(Scroll, FirstFinger, Moved, false, inScroll);
- addEdgeFunction(Scroll, FirstFinger, Released, false, noGesture);
- addEdgeFunction(Scroll, FirstFinger, Cancelled, false, noGesture);
+ addEdgeFunction(Scroll, FirstFinger, Released, false, scrollEnd);
+ addEdgeFunction(Scroll, FirstFinger, Cancelled, false, scrollEnd);
}
void InnerGestureRecognizer::reset()
@@ -126,15 +127,27 @@
return gestures.release();
}
-void InnerGestureRecognizer::appendScrollGesture(const PlatformTouchPoint& touchPoint, Gestures gestures)
+void InnerGestureRecognizer::appendScrollGestureBegin(const IntPoint& touchPoint, Gestures gestures)
{
- float deltaX(touchPoint.pos().x() - m_firstTouchPosition.x());
- float deltaY(touchPoint.pos().y() - m_firstTouchPosition.y());
+ gestures->append(PlatformGestureEvent(PlatformGestureEvent::ScrollBeginType, touchPoint, touchPoint, m_lastTouchTime, 0.0f, 0.0f, m_shiftKey, m_ctrlKey, m_altKey, m_metaKey));
+ m_firstTouchPosition = touchPoint;
+ m_lastTouchPosition = m_firstTouchPosition;
+}
- gestures->append(PlatformGestureEvent(PlatformGestureEvent::ScrollUpdateType, touchPoint.pos(), touchPoint.screenPos(), m_lastTouchTime, deltaX, deltaY, m_shiftKey, m_ctrlKey, m_altKey, m_metaKey));
- m_firstTouchPosition = touchPoint.pos();
+void InnerGestureRecognizer::appendScrollGestureEnd(const IntPoint& touchPoint, Gestures gestures)
+{
+ gestures->append(PlatformGestureEvent(PlatformGestureEvent::ScrollEndType, m_firstTouchPosition, m_firstTouchPosition, m_lastTouchTime, 0.0f, 0.0f, m_shiftKey, m_ctrlKey, m_altKey, m_metaKey));
}
+void InnerGestureRecognizer::appendScrollGestureUpdate(const IntPoint& touchPoint, Gestures gestures)
+{
+ float deltaX(touchPoint.x() - m_lastTouchPosition.x());
+ float deltaY(touchPoint.y() - m_lastTouchPosition.y());
+
+ gestures->append(PlatformGestureEvent(PlatformGestureEvent::ScrollUpdateType, m_firstTouchPosition, m_firstTouchPosition, m_lastTouchTime, deltaX, deltaY, m_shiftKey, m_ctrlKey, m_altKey, m_metaKey));
+ m_lastTouchPosition = touchPoint;
+}
+
void InnerGestureRecognizer::updateValues(const double touchTime, const PlatformTouchPoint& touchPoint)
{
m_lastTouchTime = touchTime;
@@ -162,6 +175,13 @@
return false;
}
+static bool scrollEnd(InnerGestureRecognizer* gestureRecognizer, const PlatformTouchPoint& point, InnerGestureRecognizer::Gestures gestures)
+{
+ gestureRecognizer->appendScrollGestureEnd(point.pos(), gestures);
+ gestureRecognizer->setState(InnerGestureRecognizer::NoGesture);
+ return false;
+}
+
static bool noGesture(InnerGestureRecognizer* gestureRecognizer, const PlatformTouchPoint&, InnerGestureRecognizer::Gestures gestures)
{
gestureRecognizer->reset();
@@ -186,7 +206,8 @@
}
if (point.state() == PlatformTouchPoint::TouchMoved && !gestureRecognizer->isInsideManhattanSquare(point)) {
- gestureRecognizer->appendScrollGesture(point, gestures);
+ gestureRecognizer->appendScrollGestureBegin(gestureRecognizer->firstTouchPosition(), gestures);
+ gestureRecognizer->appendScrollGestureUpdate(point.pos(), gestures);
gestureRecognizer->setState(InnerGestureRecognizer::Scroll);
return true;
}
@@ -195,7 +216,7 @@
static bool inScroll(InnerGestureRecognizer* gestureRecognizer, const PlatformTouchPoint& point, InnerGestureRecognizer::Gestures gestures)
{
- gestureRecognizer->appendScrollGesture(point, gestures);
+ gestureRecognizer->appendScrollGestureUpdate(point.pos(), gestures);
return true;
}
Modified: trunk/Source/WebCore/platform/chromium/GestureRecognizerChromium.h (93357 => 93358)
--- trunk/Source/WebCore/platform/chromium/GestureRecognizerChromium.h 2011-08-18 22:16:21 UTC (rev 93357)
+++ trunk/Source/WebCore/platform/chromium/GestureRecognizerChromium.h 2011-08-18 22:19:23 UTC (rev 93358)
@@ -59,9 +59,13 @@
bool isInClickTimeWindow();
bool isInsideManhattanSquare(const PlatformTouchPoint&);
virtual PlatformGestureRecognizer::PassGestures processTouchEventForGestures(const PlatformTouchEvent&, bool defaultPrevented);
- void appendScrollGesture(const PlatformTouchPoint&, Gestures);
+ void appendScrollGestureBegin(const IntPoint&, Gestures);
+ void appendScrollGestureEnd(const IntPoint&, Gestures);
+ void appendScrollGestureUpdate(const IntPoint&, Gestures);
void setState(State value) { m_state = value; }
State state() { return m_state; }
+
+ IntPoint firstTouchPosition() { return m_firstTouchPosition; }
protected:
InnerGestureRecognizer();
void addEdgeFunction(State, unsigned finger, PlatformTouchPoint::State, bool touchHandledByJavaScript, GestureTransitionFunction);
@@ -74,6 +78,7 @@
IntPoint m_firstTouchPosition;
double m_firstTouchTime;
State m_state;
+ IntPoint m_lastTouchPosition;
double m_lastTouchTime;
bool m_ctrlKey;
Modified: trunk/Source/WebKit/chromium/tests/InnerGestureRecognizerTest.cpp (93357 => 93358)
--- trunk/Source/WebKit/chromium/tests/InnerGestureRecognizerTest.cpp 2011-08-18 22:16:21 UTC (rev 93357)
+++ trunk/Source/WebKit/chromium/tests/InnerGestureRecognizerTest.cpp 2011-08-18 22:19:23 UTC (rev 93358)
@@ -78,6 +78,7 @@
public:
BuildablePlatformTouchPoint();
BuildablePlatformTouchPoint(int x, int y);
+ BuildablePlatformTouchPoint(int x, int y, PlatformTouchPoint::State);
void setX(int x)
{
@@ -108,7 +109,23 @@
m_screenPos = IntPoint(x, y);
};
+BuildablePlatformTouchPoint::BuildablePlatformTouchPoint(int x, int y, PlatformTouchPoint::State state)
+{
+ m_id = 0;
+ m_state = state;
+ m_pos = IntPoint(x, y);
+ m_screenPos = IntPoint(x, y);
+}
+class BuildablePlatformTouchEvent : public WebCore::PlatformTouchEvent {
+public:
+ BuildablePlatformTouchEvent(WebCore::TouchEventType type, PlatformTouchPoint& point)
+ {
+ m_type = type;
+ m_touchPoints.append(point);
+ }
+};
+
class TestGestureRecognizer : public testing::Test {
public:
TestGestureRecognizer() { }
@@ -243,4 +260,54 @@
ASSERT_EQ(0.0, gm.lastTouchTime() - gm.firstTouchTime());
}
+TEST_F(TestGestureRecognizer, gestureScrollEvents)
+{
+ InspectableInnerGestureRecognizer gm;
+
+ ASSERT_EQ(InnerGestureRecognizer::NoGesture, gm.state());
+
+ BuildablePlatformTouchPoint press(10, 15, PlatformTouchPoint::TouchPressed);
+ BuildablePlatformTouchEvent pressEvent(WebCore::TouchStart, press);
+ gm.processTouchEventForGestures(pressEvent, false);
+
+ ASSERT_EQ(InnerGestureRecognizer::PendingSyntheticClick, gm.state());
+
+ BuildablePlatformTouchPoint move(10, 50, PlatformTouchPoint::TouchMoved);
+ BuildablePlatformTouchEvent moveEvent(WebCore::TouchMove, move);
+ OwnPtr<Vector<WebCore::PlatformGestureEvent> > gestureStart(gm.processTouchEventForGestures(moveEvent, false));
+ bool scrollStarted = false, scrollUpdated = false;
+ for (unsigned int i = 0; i < gestureStart->size(); i++) {
+ switch ((*gestureStart)[i].type()) {
+ case PlatformGestureEvent::ScrollBeginType:
+ scrollStarted = true;
+ break;
+ case PlatformGestureEvent::ScrollUpdateType:
+ scrollUpdated = true;
+ break;
+ default:
+ ASSERT_TRUE(false);
+ }
+ }
+
+ ASSERT_TRUE(scrollStarted);
+ ASSERT_TRUE(scrollUpdated);
+ ASSERT_EQ(InnerGestureRecognizer::Scroll, gm.state());
+
+ BuildablePlatformTouchPoint release(10, 50, PlatformTouchPoint::TouchReleased);
+ BuildablePlatformTouchEvent releaseEvent(WebCore::TouchEnd, release);
+ bool scrollEnd = false;
+ OwnPtr<Vector<WebCore::PlatformGestureEvent> > gestureEnd(gm.processTouchEventForGestures(releaseEvent, false));
+ for (unsigned int i = 0; i < gestureEnd->size(); i++) {
+ switch ((*gestureEnd)[i].type()) {
+ case PlatformGestureEvent::ScrollEndType:
+ scrollEnd = true;
+ break;
+ default:
+ ASSERT_TRUE(false);
+ }
+ }
+ ASSERT_TRUE(scrollEnd);
+ ASSERT_EQ(InnerGestureRecognizer::NoGesture, gm.state());
+}
+
} // namespace