Title: [135399] trunk/Source/WebKit2
Revision
135399
Author
abe...@webkit.org
Date
2012-11-21 07:08:02 -0800 (Wed, 21 Nov 2012)

Log Message

[WK2] Viewport meta tag broken after r134801
https://bugs.webkit.org/show_bug.cgi?id=102801

Reviewed by Kenneth Rohde Christiansen.

If the initial-scale attribute is not explicitly specified it is left -1 by the
viewport meta algorithm and if the content is not scalable the min and max scales
are restricted by restrictScaleFactorToInitialScaleIfNotUserScalable() which resulted
in negative scales on the UI side.
Make sure that the minimum scale to fit the viewport is calculated before restricting
the scales and use this scale as the initial scale if no explicit initial scale was set.

* UIProcess/PageViewportController.cpp:
(WebKit::PageViewportController::PageViewportController):
(WebKit::PageViewportController::pageTransitionViewportReady):
(WebKit::PageViewportController::didChangeViewportAttributes):
(WebKit::PageViewportController::updateMinimumScaleToFit):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (135398 => 135399)


--- trunk/Source/WebKit2/ChangeLog	2012-11-21 15:07:55 UTC (rev 135398)
+++ trunk/Source/WebKit2/ChangeLog	2012-11-21 15:08:02 UTC (rev 135399)
@@ -1,3 +1,23 @@
+2012-11-21  Andras Becsi  <andras.be...@digia.com>
+
+        [WK2] Viewport meta tag broken after r134801
+        https://bugs.webkit.org/show_bug.cgi?id=102801
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        If the initial-scale attribute is not explicitly specified it is left -1 by the
+        viewport meta algorithm and if the content is not scalable the min and max scales
+        are restricted by restrictScaleFactorToInitialScaleIfNotUserScalable() which resulted
+        in negative scales on the UI side.
+        Make sure that the minimum scale to fit the viewport is calculated before restricting
+        the scales and use this scale as the initial scale if no explicit initial scale was set.
+
+        * UIProcess/PageViewportController.cpp:
+        (WebKit::PageViewportController::PageViewportController):
+        (WebKit::PageViewportController::pageTransitionViewportReady):
+        (WebKit::PageViewportController::didChangeViewportAttributes):
+        (WebKit::PageViewportController::updateMinimumScaleToFit):
+
 2012-11-21  Gyuyoung Kim  <gyuyoung....@samsung.com>
 
         [EFL][WK2] Support Context Menu

Modified: trunk/Source/WebKit2/UIProcess/PageViewportController.cpp (135398 => 135399)


--- trunk/Source/WebKit2/UIProcess/PageViewportController.cpp	2012-11-21 15:07:55 UTC (rev 135398)
+++ trunk/Source/WebKit2/UIProcess/PageViewportController.cpp	2012-11-21 15:08:02 UTC (rev 135399)
@@ -52,11 +52,15 @@
 {
     // Initializing Viewport Raw Attributes to avoid random negative or infinity scale factors
     // if there is a race condition between the first layout and setting the viewport attributes for the first time.
-    m_rawAttributes.initialScale = 1;
     m_rawAttributes.minimumScale = 1;
     m_rawAttributes.maximumScale = 1;
     m_rawAttributes.userScalable = m_allowsUserScaling;
 
+    // The initial scale might be implicit and set to -1, in this case we have to infer it
+    // using the viewport size and the final layout size.
+    // To be able to assert for valid scale we initialize it to -1.
+    m_rawAttributes.initialScale = -1;
+
     ASSERT(m_client);
     m_client->setController(this);
 }
@@ -145,8 +149,8 @@
 {
     if (!m_rawAttributes.layoutSize.isEmpty()) {
         m_hadUserInteraction = false;
-        float initialScale = (m_rawAttributes.initialScale < 0) ? m_minimumScaleToFit : m_rawAttributes.initialScale;
-        applyScaleAfterRenderingContents(innerBoundedViewportScale(toViewportScale(initialScale)));
+        ASSERT(m_rawAttributes.initialScale > 0);
+        applyScaleAfterRenderingContents(innerBoundedViewportScale(toViewportScale(m_rawAttributes.initialScale)));
     }
 
     // At this point we should already have received the first viewport arguments and the requested scroll
@@ -213,11 +217,19 @@
         return;
 
     m_rawAttributes = newAttributes;
+    m_allowsUserScaling = !!m_rawAttributes.userScalable;
+
+    if (!updateMinimumScaleToFit())
+        return;
+
+    ASSERT(m_minimumScaleToFit > 0);
+
+    // Set the initial scale if it was not specified in the viewport meta tag.
+    if (m_rawAttributes.initialScale < 0)
+        m_rawAttributes.initialScale = m_minimumScaleToFit;
+
     WebCore::restrictScaleFactorToInitialScaleIfNotUserScalable(m_rawAttributes);
 
-    m_allowsUserScaling = !!m_rawAttributes.userScalable;
-    updateMinimumScaleToFit();
-
     m_client->didChangeViewportAttributes();
 }
 
@@ -262,11 +274,14 @@
 
 bool PageViewportController::updateMinimumScaleToFit()
 {
-    if (m_viewportSize.isEmpty())
+    if (m_viewportSize.isEmpty() || m_contentsSize.isEmpty())
         return false;
 
     float minimumScale = WebCore::computeMinimumScaleFactorForContentContained(m_rawAttributes, WebCore::roundedIntSize(m_viewportSize), WebCore::roundedIntSize(m_contentsSize), devicePixelRatio());
 
+    if (minimumScale <= 0)
+        return false;
+
     if (!fuzzyCompare(minimumScale, m_minimumScaleToFit, 0.001)) {
         m_minimumScaleToFit = minimumScale;
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to