Title: [101470] trunk/Source/WebKit2
Revision
101470
Author
[email protected]
Date
2011-11-30 02:55:36 -0800 (Wed, 30 Nov 2011)

Log Message

[Qt] Clean up the Qt viewport interaction engine

Reviewed by Simon Hausmann.

* UIProcess/qt/QtViewportInteractionEngine.cpp:
(WebKit::QtViewportInteractionEngine::reset):

    Make sure reset is not called while suspended.

(WebKit::QtViewportInteractionEngine::applyConstraints):

    We always need to apply the constrains due to initial-scale.

    Now that we only apply the constrains when we are ready to
    paint, it is impossible for the user to have interacted with
    the content in the case the viewport meta tag was declared
    in the <head> tag, and it is thus always applied.

(WebKit::QtViewportInteractionEngine::panGestureStarted):
(WebKit::QtViewportInteractionEngine::pinchGestureActive):

    Fix this method to actually do what it advertises, before
    it would be true even if just animation a bounce back effect.

(WebKit::QtViewportInteractionEngine::pinchGestureStarted):
(WebKit::QtViewportInteractionEngine::pinchGestureEnded):
* UIProcess/qt/QtViewportInteractionEngine.h:

    General, get rid of the interaction flags as we only need to
    know whether the user interacted (panned, pinched, double-tapped).
    Before we would still apply initial-scale if the user had panned
    the content which can be pretty confusing.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (101469 => 101470)


--- trunk/Source/WebKit2/ChangeLog	2011-11-30 10:14:11 UTC (rev 101469)
+++ trunk/Source/WebKit2/ChangeLog	2011-11-30 10:55:36 UTC (rev 101470)
@@ -1,3 +1,38 @@
+2011-11-30  Kenneth Rohde Christiansen  <[email protected]>
+
+        [Qt] Clean up the Qt viewport interaction engine
+
+        Reviewed by Simon Hausmann.
+
+        * UIProcess/qt/QtViewportInteractionEngine.cpp:
+        (WebKit::QtViewportInteractionEngine::reset):
+
+            Make sure reset is not called while suspended.
+
+        (WebKit::QtViewportInteractionEngine::applyConstraints):
+
+            We always need to apply the constrains due to initial-scale.
+
+            Now that we only apply the constrains when we are ready to
+            paint, it is impossible for the user to have interacted with
+            the content in the case the viewport meta tag was declared
+            in the <head> tag, and it is thus always applied.
+
+        (WebKit::QtViewportInteractionEngine::panGestureStarted):
+        (WebKit::QtViewportInteractionEngine::pinchGestureActive):
+
+            Fix this method to actually do what it advertises, before
+            it would be true even if just animation a bounce back effect.
+
+        (WebKit::QtViewportInteractionEngine::pinchGestureStarted):
+        (WebKit::QtViewportInteractionEngine::pinchGestureEnded):
+        * UIProcess/qt/QtViewportInteractionEngine.h:
+
+            General, get rid of the interaction flags as we only need to
+            know whether the user interacted (panned, pinched, double-tapped).
+            Before we would still apply initial-scale if the user had panned
+            the content which can be pretty confusing.
+
 2011-11-30  Simon Hausmann  <[email protected]>
 
         Unreviewed prospective mac build fix after r101450.

Modified: trunk/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.cpp (101469 => 101470)


--- trunk/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.cpp	2011-11-30 10:14:11 UTC (rev 101469)
+++ trunk/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.cpp	2011-11-30 10:55:36 UTC (rev 101470)
@@ -358,23 +358,24 @@
 
 void QtViewportInteractionEngine::reset()
 {
-    m_userInteractionFlags = UserHasNotInteractedWithContent;
+    ASSERT(!m_suspendCount);
 
+    m_hadUserInteraction = false;
+
     scroller()->stop();
     m_scaleAnimation->stop();
 }
 
 void QtViewportInteractionEngine::applyConstraints(const Constraints& constraints)
 {
-    if (m_constraints == constraints)
-        return;
+    // We always have to apply the constrains even if they didn't change, as
+    // the initial scale might need to be applied.
 
     ViewportUpdateGuard guard(this);
 
     m_constraints = constraints;
 
-    bool userHasScaledContent = m_userInteractionFlags & UserHasScaledContent;
-    if (!userHasScaledContent) {
+    if (!m_hadUserInteraction) {
         qreal initialScale = innerBoundedCSSScale(m_constraints.initialScale);
         m_content->setScale(itemScaleFromCSS(initialScale));
     }
@@ -405,8 +406,7 @@
 
 void QtViewportInteractionEngine::panGestureStarted(const QPointF& touchPoint, qint64 eventTimestampMillis)
 {
-    // FIXME: suspend the Web engine (stop animated GIF, etc).
-    m_userInteractionFlags |= UserHasMovedContent;
+    m_hadUserInteraction = true;
     scroller()->handleInput(QScroller::InputPress, m_viewport->mapFromItem(m_content, touchPoint), eventTimestampMillis);
 }
 
@@ -440,7 +440,7 @@
 
 bool QtViewportInteractionEngine::pinchGestureActive() const
 {
-    return !!m_scaleUpdateDeferrer;
+    return m_pinchStartScale > 0;
 }
 
 void QtViewportInteractionEngine::pinchGestureStarted(const QPointF& pinchCenterInContentCoordinates)
@@ -450,11 +450,11 @@
     if (!m_constraints.isUserScalable)
         return;
 
+    m_hadUserInteraction = true;
+
     m_scaleUpdateDeferrer = adoptPtr(new ViewportUpdateGuard(this));
 
     m_lastPinchCenterInViewportCoordinates = m_viewport->mapFromItem(m_content, pinchCenterInContentCoordinates);
-    m_userInteractionFlags |= UserHasScaledContent;
-    m_userInteractionFlags |= UserHasMovedContent;
     m_pinchStartScale = m_content->scale();
 
     // Reset the tiling look-ahead vector so that tiles all around the viewport will be requested on pinch-end.
@@ -491,6 +491,7 @@
     if (!m_constraints.isUserScalable)
         return;
 
+    m_pinchStartScale = -1;
     ensureContentWithinViewportBoundary();
 }
 

Modified: trunk/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.h (101469 => 101470)


--- trunk/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.h	2011-11-30 10:14:11 UTC (rev 101469)
+++ trunk/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.h	2011-11-30 10:55:36 UTC (rev 101470)
@@ -130,14 +130,9 @@
     int m_suspendCount;
     OwnPtr<ViewportUpdateGuard> m_scaleUpdateDeferrer;
     OwnPtr<ViewportUpdateGuard> m_scrollUpdateDeferrer;
-    enum UserInteractionFlag {
-        UserHasNotInteractedWithContent = 0,
-        UserHasMovedContent = 1,
-        UserHasScaledContent = 2,
-    };
-    Q_DECLARE_FLAGS(UserInteractionFlags, UserInteractionFlag);
-    UserInteractionFlags m_userInteractionFlags;
 
+    bool m_hadUserInteraction;
+
     class ScaleAnimation : public QVariantAnimation {
     public:
         ScaleAnimation(QObject* parent = 0)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to