Changeset 93358 in webkit
- Timestamp:
- Aug 18, 2011 3:19:23 PM (13 years ago)
- Location:
- trunk/Source
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r93356 r93358 1 2011-08-18 Sadrul Habib Chowdhury <sadrul@chromium.org> 2 3 GestureRecognizer: Update how gesture-scroll works. 4 5 Instead of just sending a series of 'GestureUpdate' events, send a 6 single 'GestureBegin' event, followed by a series of 'GestureUpdate' events, 7 and end with a 'GestureEnd' event. 8 https://bugs.webkit.org/show_bug.cgi?id=66267 9 10 Reviewed by Adam Barth. 11 12 * page/EventHandler.cpp: 13 (WebCore::EventHandler::handleGestureEvent): 14 * platform/chromium/GestureRecognizerChromium.cpp: 15 (WebCore::InnerGestureRecognizer::InnerGestureRecognizer): 16 (WebCore::InnerGestureRecognizer::appendScrollGestureBegin): 17 (WebCore::InnerGestureRecognizer::appendScrollGestureEnd): 18 (WebCore::InnerGestureRecognizer::appendScrollGestureUpdate): 19 (WebCore::scrollEnd): 20 (WebCore::isClickOrScroll): 21 (WebCore::inScroll): 22 * platform/chromium/GestureRecognizerChromium.h: 23 (WebCore::InnerGestureRecognizer::firstTouchPosition): 24 1 25 2011-08-18 Sailesh Agrawal <sail@chromium.org> 2 26 -
trunk/Source/WebCore/page/EventHandler.cpp
r93134 r93358 2223 2223 const float tickDivisor = (float)WheelEvent::tickMultiplier; 2224 2224 // FIXME: Replace this interim implementation once the above fixme has been addressed. 2225 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()); 2225 IntPoint point(gestureEvent.position().x() + gestureEvent.deltaX(), gestureEvent.position().y() + gestureEvent.deltaY()); 2226 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()); 2226 2227 handleWheelEvent(syntheticWheelEvent); 2227 2228 return true; -
trunk/Source/WebCore/platform/chromium/GestureRecognizerChromium.cpp
r92234 r93358 41 41 static bool isClickOrScroll(InnerGestureRecognizer*, const PlatformTouchPoint&, InnerGestureRecognizer::Gestures); 42 42 static bool inScroll(InnerGestureRecognizer*, const PlatformTouchPoint&, InnerGestureRecognizer::Gestures); 43 static bool scrollEnd(InnerGestureRecognizer*, const PlatformTouchPoint&, InnerGestureRecognizer::Gestures); 43 44 static bool noGesture(InnerGestureRecognizer*, const PlatformTouchPoint&, InnerGestureRecognizer::Gestures); 44 45 static bool touchDown(InnerGestureRecognizer*, const PlatformTouchPoint&, InnerGestureRecognizer::Gestures); … … 71 72 addEdgeFunction(PendingSyntheticClick, FirstFinger, Stationary, false, isClickOrScroll); 72 73 addEdgeFunction(Scroll, FirstFinger, Moved, false, inScroll); 73 addEdgeFunction(Scroll, FirstFinger, Released, false, noGesture);74 addEdgeFunction(Scroll, FirstFinger, Cancelled, false, noGesture);74 addEdgeFunction(Scroll, FirstFinger, Released, false, scrollEnd); 75 addEdgeFunction(Scroll, FirstFinger, Cancelled, false, scrollEnd); 75 76 } 76 77 … … 127 128 } 128 129 129 void InnerGestureRecognizer::appendScrollGesture(const PlatformTouchPoint& touchPoint, Gestures gestures) 130 { 131 float deltaX(touchPoint.pos().x() - m_firstTouchPosition.x()); 132 float deltaY(touchPoint.pos().y() - m_firstTouchPosition.y()); 133 134 gestures->append(PlatformGestureEvent(PlatformGestureEvent::ScrollUpdateType, touchPoint.pos(), touchPoint.screenPos(), m_lastTouchTime, deltaX, deltaY, m_shiftKey, m_ctrlKey, m_altKey, m_metaKey)); 135 m_firstTouchPosition = touchPoint.pos(); 130 void InnerGestureRecognizer::appendScrollGestureBegin(const IntPoint& touchPoint, Gestures gestures) 131 { 132 gestures->append(PlatformGestureEvent(PlatformGestureEvent::ScrollBeginType, touchPoint, touchPoint, m_lastTouchTime, 0.0f, 0.0f, m_shiftKey, m_ctrlKey, m_altKey, m_metaKey)); 133 m_firstTouchPosition = touchPoint; 134 m_lastTouchPosition = m_firstTouchPosition; 135 } 136 137 void InnerGestureRecognizer::appendScrollGestureEnd(const IntPoint& touchPoint, Gestures gestures) 138 { 139 gestures->append(PlatformGestureEvent(PlatformGestureEvent::ScrollEndType, m_firstTouchPosition, m_firstTouchPosition, m_lastTouchTime, 0.0f, 0.0f, m_shiftKey, m_ctrlKey, m_altKey, m_metaKey)); 140 } 141 142 void InnerGestureRecognizer::appendScrollGestureUpdate(const IntPoint& touchPoint, Gestures gestures) 143 { 144 float deltaX(touchPoint.x() - m_lastTouchPosition.x()); 145 float deltaY(touchPoint.y() - m_lastTouchPosition.y()); 146 147 gestures->append(PlatformGestureEvent(PlatformGestureEvent::ScrollUpdateType, m_firstTouchPosition, m_firstTouchPosition, m_lastTouchTime, deltaX, deltaY, m_shiftKey, m_ctrlKey, m_altKey, m_metaKey)); 148 m_lastTouchPosition = touchPoint; 136 149 } 137 150 … … 163 176 } 164 177 178 static bool scrollEnd(InnerGestureRecognizer* gestureRecognizer, const PlatformTouchPoint& point, InnerGestureRecognizer::Gestures gestures) 179 { 180 gestureRecognizer->appendScrollGestureEnd(point.pos(), gestures); 181 gestureRecognizer->setState(InnerGestureRecognizer::NoGesture); 182 return false; 183 } 184 165 185 static bool noGesture(InnerGestureRecognizer* gestureRecognizer, const PlatformTouchPoint&, InnerGestureRecognizer::Gestures gestures) 166 186 { … … 187 207 188 208 if (point.state() == PlatformTouchPoint::TouchMoved && !gestureRecognizer->isInsideManhattanSquare(point)) { 189 gestureRecognizer->appendScrollGesture(point, gestures); 209 gestureRecognizer->appendScrollGestureBegin(gestureRecognizer->firstTouchPosition(), gestures); 210 gestureRecognizer->appendScrollGestureUpdate(point.pos(), gestures); 190 211 gestureRecognizer->setState(InnerGestureRecognizer::Scroll); 191 212 return true; … … 196 217 static bool inScroll(InnerGestureRecognizer* gestureRecognizer, const PlatformTouchPoint& point, InnerGestureRecognizer::Gestures gestures) 197 218 { 198 gestureRecognizer->appendScrollGesture (point, gestures);219 gestureRecognizer->appendScrollGestureUpdate(point.pos(), gestures); 199 220 return true; 200 221 } -
trunk/Source/WebCore/platform/chromium/GestureRecognizerChromium.h
r92234 r93358 60 60 bool isInsideManhattanSquare(const PlatformTouchPoint&); 61 61 virtual PlatformGestureRecognizer::PassGestures processTouchEventForGestures(const PlatformTouchEvent&, bool defaultPrevented); 62 void appendScrollGesture(const PlatformTouchPoint&, Gestures); 62 void appendScrollGestureBegin(const IntPoint&, Gestures); 63 void appendScrollGestureEnd(const IntPoint&, Gestures); 64 void appendScrollGestureUpdate(const IntPoint&, Gestures); 63 65 void setState(State value) { m_state = value; } 64 66 State state() { return m_state; } 67 68 IntPoint firstTouchPosition() { return m_firstTouchPosition; } 65 69 protected: 66 70 InnerGestureRecognizer(); … … 75 79 double m_firstTouchTime; 76 80 State m_state; 81 IntPoint m_lastTouchPosition; 77 82 double m_lastTouchTime; 78 83 -
trunk/Source/WebKit/chromium/ChangeLog
r93350 r93358 1 2011-08-18 Sadrul Habib Chowdhury <sadrul@chromium.org> 2 3 GestureRecognizer: Update how gesture-scroll works. 4 5 Add a unit-test to make sure the correct gesture events are being 6 generated. 7 https://bugs.webkit.org/show_bug.cgi?id=66267 8 9 Reviewed by Adam Barth. 10 11 * tests/InnerGestureRecognizerTest.cpp: 12 (WebCore::BuildablePlatformTouchPoint::BuildablePlatformTouchPoint): 13 (WebCore::BuildablePlatformTouchEvent::BuildablePlatformTouchEvent): 14 (WebCore::TEST_F): 15 1 16 2011-08-18 Sheriff Bot <webkit.review.bot@gmail.com> 2 17 -
trunk/Source/WebKit/chromium/tests/InnerGestureRecognizerTest.cpp
r88307 r93358 79 79 BuildablePlatformTouchPoint(); 80 80 BuildablePlatformTouchPoint(int x, int y); 81 BuildablePlatformTouchPoint(int x, int y, PlatformTouchPoint::State); 81 82 82 83 void setX(int x) … … 109 110 }; 110 111 112 BuildablePlatformTouchPoint::BuildablePlatformTouchPoint(int x, int y, PlatformTouchPoint::State state) 113 { 114 m_id = 0; 115 m_state = state; 116 m_pos = IntPoint(x, y); 117 m_screenPos = IntPoint(x, y); 118 } 119 120 class BuildablePlatformTouchEvent : public WebCore::PlatformTouchEvent { 121 public: 122 BuildablePlatformTouchEvent(WebCore::TouchEventType type, PlatformTouchPoint& point) 123 { 124 m_type = type; 125 m_touchPoints.append(point); 126 } 127 }; 111 128 112 129 class TestGestureRecognizer : public testing::Test { … … 244 261 } 245 262 263 TEST_F(TestGestureRecognizer, gestureScrollEvents) 264 { 265 InspectableInnerGestureRecognizer gm; 266 267 ASSERT_EQ(InnerGestureRecognizer::NoGesture, gm.state()); 268 269 BuildablePlatformTouchPoint press(10, 15, PlatformTouchPoint::TouchPressed); 270 BuildablePlatformTouchEvent pressEvent(WebCore::TouchStart, press); 271 gm.processTouchEventForGestures(pressEvent, false); 272 273 ASSERT_EQ(InnerGestureRecognizer::PendingSyntheticClick, gm.state()); 274 275 BuildablePlatformTouchPoint move(10, 50, PlatformTouchPoint::TouchMoved); 276 BuildablePlatformTouchEvent moveEvent(WebCore::TouchMove, move); 277 OwnPtr<Vector<WebCore::PlatformGestureEvent> > gestureStart(gm.processTouchEventForGestures(moveEvent, false)); 278 bool scrollStarted = false, scrollUpdated = false; 279 for (unsigned int i = 0; i < gestureStart->size(); i++) { 280 switch ((*gestureStart)[i].type()) { 281 case PlatformGestureEvent::ScrollBeginType: 282 scrollStarted = true; 283 break; 284 case PlatformGestureEvent::ScrollUpdateType: 285 scrollUpdated = true; 286 break; 287 default: 288 ASSERT_TRUE(false); 289 } 290 } 291 292 ASSERT_TRUE(scrollStarted); 293 ASSERT_TRUE(scrollUpdated); 294 ASSERT_EQ(InnerGestureRecognizer::Scroll, gm.state()); 295 296 BuildablePlatformTouchPoint release(10, 50, PlatformTouchPoint::TouchReleased); 297 BuildablePlatformTouchEvent releaseEvent(WebCore::TouchEnd, release); 298 bool scrollEnd = false; 299 OwnPtr<Vector<WebCore::PlatformGestureEvent> > gestureEnd(gm.processTouchEventForGestures(releaseEvent, false)); 300 for (unsigned int i = 0; i < gestureEnd->size(); i++) { 301 switch ((*gestureEnd)[i].type()) { 302 case PlatformGestureEvent::ScrollEndType: 303 scrollEnd = true; 304 break; 305 default: 306 ASSERT_TRUE(false); 307 } 308 } 309 ASSERT_TRUE(scrollEnd); 310 ASSERT_EQ(InnerGestureRecognizer::NoGesture, gm.state()); 311 } 312 246 313 } // namespace
Note: See TracChangeset
for help on using the changeset viewer.