Title: [120075] trunk/Source/WebKit2
Revision
120075
Author
kenn...@webkit.org
Date
2012-06-12 07:55:14 -0700 (Tue, 12 Jun 2012)

Log Message

[Qt] Do not move/scale content while the user is interacting with it
https://bugs.webkit.org/show_bug.cgi?id=88872

Reviewed by Simon Hausmann.

Don't try moving content into valid bounds when the content
size changes and the user is interacting with the content.

Only apply the viewport initial scale after user interaction
has ended.

* UIProcess/qt/QtViewportHandler.cpp:
(WebKit::ViewportUpdateDeferrer::~ViewportUpdateDeferrer):
(WebKit::QtViewportHandler::setInitialScaleIfNeeded):
(WebKit::QtViewportHandler::viewportAttributesChanged):
(WebKit::QtViewportHandler::pageContentsSizeChanged):
(WebKit::QtViewportHandler::initialRect):
(WebKit):
* UIProcess/qt/QtViewportHandler.h:
(QtViewportHandler):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (120074 => 120075)


--- trunk/Source/WebKit2/ChangeLog	2012-06-12 14:51:18 UTC (rev 120074)
+++ trunk/Source/WebKit2/ChangeLog	2012-06-12 14:55:14 UTC (rev 120075)
@@ -1,3 +1,26 @@
+2012-06-12  Kenneth Rohde Christiansen  <kenn...@webkit.org>
+
+        [Qt] Do not move/scale content while the user is interacting with it
+        https://bugs.webkit.org/show_bug.cgi?id=88872
+
+        Reviewed by Simon Hausmann.
+
+        Don't try moving content into valid bounds when the content
+        size changes and the user is interacting with the content.
+
+        Only apply the viewport initial scale after user interaction
+        has ended.
+
+        * UIProcess/qt/QtViewportHandler.cpp:
+        (WebKit::ViewportUpdateDeferrer::~ViewportUpdateDeferrer):
+        (WebKit::QtViewportHandler::setInitialScaleIfNeeded):
+        (WebKit::QtViewportHandler::viewportAttributesChanged):
+        (WebKit::QtViewportHandler::pageContentsSizeChanged):
+        (WebKit::QtViewportHandler::initialRect):
+        (WebKit):
+        * UIProcess/qt/QtViewportHandler.h:
+        (QtViewportHandler):
+
 2012-06-11  Kaustubh Atrawalkar  <kaust...@motorola.com>
 
         [DRT] LTC:: counterValueForElementById() could be moved to Internals.

Modified: trunk/Source/WebKit2/UIProcess/qt/QtViewportHandler.cpp (120074 => 120075)


--- trunk/Source/WebKit2/UIProcess/qt/QtViewportHandler.cpp	2012-06-12 14:51:18 UTC (rev 120074)
+++ trunk/Source/WebKit2/UIProcess/qt/QtViewportHandler.cpp	2012-06-12 14:55:14 UTC (rev 120075)
@@ -78,6 +78,11 @@
 
     ~ViewportUpdateDeferrer()
     {
+        // We are calling setInitialScaleIfNeeded() here as it requires a
+        // possitive m_suspendCount due to the assert in setPageItemRectVisible().
+        if (handler->m_suspendCount == 1)
+            handler->setInitialScaleIfNeeded();
+
         if (--(handler->m_suspendCount))
             return;
 
@@ -195,51 +200,37 @@
     return innerBoundedCSSScale(cssScale);
 }
 
-void QtViewportHandler::viewportAttributesChanged(const WebCore::ViewportAttributes& newAttributes)
+void QtViewportHandler::setInitialScaleIfNeeded()
 {
-    m_rawAttributes = newAttributes;
-    WebCore::restrictScaleFactorToInitialScaleIfNotUserScalable(m_rawAttributes);
+    if (m_rawAttributes.initialScale < 0)
+        return;
 
-    {
-        // FIXME: Resetting here is wrong, it should happen only for the first
-        // viewport change for a given page and first when we paint the page for
-        // the first time.
+    m_zoomOutScale = 0.0;
+    m_scaleStack.clear();
 
-        m_hadUserInteraction = false;
+    m_hadUserInteraction = false;
 
-        m_zoomOutScale = 0.0;
-        m_scaleStack.clear();
+    // We must not animate here as the new contents size might be very different
+    // than the current one.
+    setPageItemRectVisible(initialRect());
 
-        // This part below should go fully away when the above plan is implemented.
+    m_rawAttributes.initialScale = -1; // Mark used.
+}
 
-        m_viewportItem->cancelFlick();
-        m_scaleAnimation->stop();
+void QtViewportHandler::viewportAttributesChanged(const WebCore::ViewportAttributes& newAttributes)
+{
+    m_rawAttributes = newAttributes;
+    WebCore::restrictScaleFactorToInitialScaleIfNotUserScalable(m_rawAttributes);
 
-        m_scaleUpdateDeferrer.clear();
-        m_scrollUpdateDeferrer.clear();
-        m_touchUpdateDeferrer.clear();
-        m_animationUpdateDeferrer.clear();
-        ASSERT(!m_suspendCount);
-        ASSERT(!m_hasSuspendedContent);
-    }
-
     m_devicePixelRatio = m_rawAttributes.devicePixelRatio; // Should return value from the webPageProxy.
     m_allowsUserScaling = !!m_rawAttributes.userScalable;
     m_minimumScale = m_rawAttributes.minimumScale;
     m_maximumScale = m_rawAttributes.maximumScale;
 
-    if (!m_hadUserInteraction && !m_hasSuspendedContent) {
-        ASSERT(m_pinchStartScale == -1);
-        // Emits contentsScaleChanged();
-        setCSSScale(m_rawAttributes.initialScale);
-    }
+    // Make sure we apply the new initial scale when deferring ends.
+    ViewportUpdateDeferrer guard(this);
 
     emit m_viewportItem->experimental()->test()->viewportChanged();
-
-    // If the web app successively changes the viewport on purpose
-    // it wants to be in control and we should disable animations.
-    ViewportUpdateDeferrer guard(this);
-    setPageItemRectVisible(nearestValidBounds());
 }
 
 void QtViewportHandler::pageContentsSizeChanged(const QSize& newSize, const QSize& viewportSize)
@@ -260,8 +251,10 @@
     // we didn't do scale adjustment.
     emit m_viewportItem->experimental()->test()->contentsScaleCommitted();
 
-    ViewportUpdateDeferrer guard(this);
-    setPageItemRectVisible(nearestValidBounds());
+    if (!m_hasSuspendedContent) {
+        ViewportUpdateDeferrer guard(this);
+        setPageItemRectVisible(nearestValidBounds());
+    }
 }
 
 void QtViewportHandler::setPageItemRectVisible(const QRectF& itemRect)
@@ -522,6 +515,16 @@
     animatePageItemRectVisible(endVisibleContentRect);
 }
 
+QRectF QtViewportHandler::initialRect() const
+{
+    ASSERT(m_rawAttributes.initialScale > 0);
+
+    qreal endItemScale = itemScaleFromCSS(innerBoundedCSSScale(m_rawAttributes.initialScale));
+    QRectF endVisibleContentRect(QPointF(0, 0), viewportRect.size() / endItemScale);
+
+    return endVisibleContentRect;
+}
+
 QRectF QtViewportHandler::nearestValidBounds() const
 {
     qreal endItemScale = itemScaleFromCSS(innerBoundedCSSScale(currentCSSScale()));

Modified: trunk/Source/WebKit2/UIProcess/qt/QtViewportHandler.h (120074 => 120075)


--- trunk/Source/WebKit2/UIProcess/qt/QtViewportHandler.h	2012-06-12 14:51:18 UTC (rev 120074)
+++ trunk/Source/WebKit2/UIProcess/qt/QtViewportHandler.h	2012-06-12 14:55:14 UTC (rev 120075)
@@ -107,6 +107,8 @@
     qreal innerBoundedCSSScale(qreal) const;
     qreal outerBoundedCSSScale(qreal) const;
 
+    void setInitialScaleIfNeeded();
+
     void setCSSScale(qreal);
     qreal currentCSSScale() const;
 
@@ -114,6 +116,7 @@
     void animatePageItemRectVisible(const QRectF&);
 
     QRect visibleContentsRect() const;
+    QRectF initialRect() const;
     QRectF nearestValidBounds() const;
 
     QRectF computePosRangeForPageItemAtScale(qreal itemScale) const;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to