Changeset 99065 in webkit
- Timestamp:
- Nov 2, 2011, 9:14:20 AM (14 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r99058 r99065 1 2011-11-02 Kenneth Rohde Christiansen <kenneth@webkit.org> 2 3 [Qt] Handle interruption of page interaction better 4 https://bugs.webkit.org/show_bug.cgi?id=71366 5 6 Reviewed by Simon Hausmann. 7 8 Touching the screen when a kinetic scrolling animation is running or 9 it is bouncing back because it was out of bounds, the animation is 10 immediately stopped and the content is immediately put into valid 11 bounds. 12 13 Touching the screen when the contents is bouncing back from a pinch 14 zoom which was out of bounds, we do not stop the animation, but 15 instead ignored the touch events while the animation lasts. 16 17 In the future we want to queue the events instead. 18 19 This also fixes some issues which was present before: As the bounce 20 back animation from pinch zoom centers the content using the contents 21 point which was in the center of the viewport, this animation could 22 not be used when stopping a pan animation, as it wouldn't position the 23 content at the place it was when the pan animation was interrupted. 24 25 * UIProcess/qt/QtPanGestureRecognizer.cpp: 26 (WebKit::QtPanGestureRecognizer::recognize): 27 * UIProcess/qt/QtPinchGestureRecognizer.cpp: 28 (WebKit::QtPinchGestureRecognizer::recognize): 29 * UIProcess/qt/QtViewportInteractionEngine.cpp: 30 (WebKit::QtViewportInteractionEngine::animateContentIntoBoundariesIfNeeded): 31 (WebKit::QtViewportInteractionEngine::reset): 32 (WebKit::QtViewportInteractionEngine::setConstraints): 33 (WebKit::QtViewportInteractionEngine::panAnimationActive): 34 (WebKit::QtViewportInteractionEngine::panGestureStarted): 35 (WebKit::QtViewportInteractionEngine::panGestureCancelled): 36 (WebKit::QtViewportInteractionEngine::pinchAnimationActive): 37 * UIProcess/qt/QtViewportInteractionEngine.h: 38 1 39 2011-11-02 Zalan Bujtas <zbujtas@gmail.com> 2 40 -
trunk/Source/WebKit2/UIProcess/qt/QtPanGestureRecognizer.cpp
r98460 r99065 40 40 bool QtPanGestureRecognizer::recognize(const QTouchEvent* event, qint64 eventTimestampMillis) 41 41 { 42 // Pan gesture always starts on TouchBegin unless the engine is suspended. 42 // Pan gesture always starts on TouchBegin unless the engine is suspended, or 43 // we ignored the event. 43 44 if (m_state == NoGesture && event->type() != QEvent::TouchBegin) 44 45 return false; … … 57 58 case QEvent::TouchBegin: 58 59 ASSERT(m_state == NoGesture); 60 // The pan gesture might still be animating kinetic scrolling/bounce back effect. 61 if (m_viewportInteractionEngine->panAnimationActive()) 62 m_viewportInteractionEngine->panGestureCancelled(); 63 64 // We do not stop bounce back effects for pinch zoom, but instead ignore the touch event. 65 // FIXME: We should queue the events instead and repost then when done with the animation. 66 if (m_viewportInteractionEngine->pinchAnimationActive()) 67 return false; 68 59 69 m_state = GestureRecognitionStarted; 60 70 m_firstPosition = touchPoint.screenPos(); 61 m_viewportInteractionEngine->stopAnimations();62 71 return false; 63 72 case QEvent::TouchUpdate: { -
trunk/Source/WebKit2/UIProcess/qt/QtPinchGestureRecognizer.cpp
r98474 r99065 65 65 return false; 66 66 } 67 68 // The pan gesture might still be animating kinetic scrolling/bounce back effect. 69 if (m_viewportInteractionEngine->panAnimationActive()) 70 m_viewportInteractionEngine->panGestureCancelled(); 71 72 // We do not stop bounce back effects for pinch zoom, but instead ignore the touch event. 73 // FIXME: We should queue the events instead and repost then when done with the animation. 74 if (m_viewportInteractionEngine->pinchAnimationActive()) 75 return false; 67 76 68 77 switch (event->type()) { -
trunk/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.cpp
r98965 r99065 196 196 } 197 197 198 void QtViewportInteractionEngine::stopAnimations()199 {200 m_scaleAnimation->stop();201 scroller()->stop();202 203 // If the animations were stopped we need to scale and reposition the content into valid boundaries immediately.204 m_userInteractionFlags |= UserHasStoppedAnimations;205 animateContentIntoBoundariesIfNeeded();206 m_userInteractionFlags &= ~UserHasStoppedAnimations;207 }208 209 198 QRectF QtViewportInteractionEngine::computePosRangeForItemScale(qreal itemScale) const 210 199 { … … 220 209 void QtViewportInteractionEngine::animateContentIntoBoundariesIfNeeded() 221 210 { 222 m_scaleAnimation->stop(); 211 if (panAnimationActive() || pinchAnimationActive()) 212 return; 223 213 224 214 qreal currentCSSScale = cssScaleFromItem(m_content->scale()); 225 215 bool userHasScaledContent = m_userInteractionFlags & UserHasScaledContent; 226 bool userHasStoppedAnimations = m_userInteractionFlags & UserHasStoppedAnimations;227 216 228 217 if (!userHasScaledContent) … … 243 232 endPosition.setY(qBound(minValue.y(), endPosition.y(), maxValue.y())); 244 233 245 QRectF startVisibleContentRect (m_viewport->mapRectToItem(m_content, viewportRect));234 QRectF startVisibleContentRect = m_content->mapRectFromItem(m_viewport, viewportRect); 246 235 QRectF endVisibleContentRect(endPosition, viewportRect.size() / endItemScale); 247 236 … … 249 238 return; 250 239 251 if (userHasScaledContent && !userHasStoppedAnimations) {240 if (userHasScaledContent) { 252 241 m_scaleAnimation->setDuration(kScaleAnimationDurationMillis); 253 242 m_scaleAnimation->setEasingCurve(QEasingCurve::OutCubic); … … 264 253 m_userInteractionFlags = UserHasNotInteractedWithContent; 265 254 266 stopAnimations(); 255 scroller()->stop(); 256 m_scaleAnimation->stop(); 267 257 268 258 QScrollerProperties properties = scroller()->scrollerProperties(); … … 291 281 ViewportUpdateGuard guard(this); 292 282 m_constraints = constraints; 283 293 284 animateContentIntoBoundariesIfNeeded(); 294 285 } 295 286 287 bool QtViewportInteractionEngine::panAnimationActive() const 288 { 289 QScroller* scroller = const_cast<QtViewportInteractionEngine*>(this)->scroller(); 290 291 return scroller->state() != QScroller::Inactive; 292 } 293 296 294 void QtViewportInteractionEngine::panGestureStarted(const QPointF& touchPoint, qint64 eventTimestampMillis) 297 295 { 296 Q_ASSERT(!panGestureActive); 297 298 298 // FIXME: suspend the Web engine (stop animated GIF, etc). 299 299 m_userInteractionFlags |= UserHasMovedContent; … … 309 309 void QtViewportInteractionEngine::panGestureCancelled() 310 310 { 311 ViewportUpdateGuard guard(this); 312 stopAnimations(); 311 // Stopping the scroller immediately stops kinetic scrolling and if the view is out of bounds it 312 // is moved inside valid bounds immediately as well. This is the behavior that we want. 313 scroller()->stop(); 313 314 } 314 315 … … 317 318 ViewportUpdateGuard guard(this); 318 319 scroller()->handleInput(QScroller::InputRelease, m_viewport->mapFromItem(m_content, touchPoint), eventTimestampMillis); 320 } 321 322 bool QtViewportInteractionEngine::pinchAnimationActive() const 323 { 324 return m_scaleAnimation->state() == QAbstractAnimation::Running; 319 325 } 320 326 -
trunk/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.h
r98965 r99065 67 67 void setConstraints(const Constraints&); 68 68 69 bool panAnimationActive() const; 69 70 void panGestureStarted(const QPointF& touchPoint, qint64 eventTimestampMillis); 70 71 void panGestureRequestUpdate(const QPointF& touchPoint, qint64 eventTimestampMillis); … … 72 73 void panGestureEnded(const QPointF& touchPoint, qint64 eventTimestampMillis); 73 74 75 bool pinchAnimationActive() const; 74 76 void pinchGestureStarted(const QPointF& pinchCenterInContentCoordinates); 75 77 void pinchGestureRequestUpdate(const QPointF& pinchCenterInContentCoordinates, qreal totalScaleFactor); 76 78 void pinchGestureEnded(); 77 void stopAnimations();78 79 79 80 Q_SIGNALS: … … 113 114 UserHasMovedContent = 1, 114 115 UserHasScaledContent = 2, 115 UserHasStoppedAnimations = 4116 116 }; 117 117 Q_DECLARE_FLAGS(UserInteractionFlags, UserInteractionFlag);
Note:
See TracChangeset
for help on using the changeset viewer.