Removing line in computeViewportAttributes that enforces a minimum scale factor to...
authorfsamuel@chromium.org <fsamuel@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 3 Nov 2011 15:22:16 +0000 (15:22 +0000)
committerfsamuel@chromium.org <fsamuel@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 3 Nov 2011 15:22:16 +0000 (15:22 +0000)
https://bugs.webkit.org/show_bug.cgi?id=70609

Reviewed by Kenneth Rohde Christiansen.

Source/WebCore:

Operations in computeViewportAttributes that are not a part of the spec:

http://www.w3.org/TR/2011/WD-css-device-adapt-20110915/#constraining-viewport-property-values

were moved into the functions restrictMinimumScaleFactorToViewportSize and
restrictScaleFactorToInitialScaleIfNotUserScalable.

* WebCore.exp.in:
* dom/ViewportArguments.cpp:
(WebCore::computeViewportAttributes):
(WebCore::restrictMinimumScaleFactorToViewportSize):
(WebCore::restrictScaleFactorToInitialScaleIfNotUserScalable):
* dom/ViewportArguments.h:

Source/WebKit/efl:

* ewk/ewk_view.cpp:
(_ewk_view_viewport_attributes_compute):

Source/WebKit/gtk:

* WebCoreSupport/DumpRenderTreeSupportGtk.cpp:
(DumpRenderTreeSupportGtk::dumpConfigurationForViewport):
* webkit/webkitviewportattributes.cpp:
(webkitViewportAttributesRecompute):

Source/WebKit/qt:

* Api/qwebpage.cpp:
(QWebPage::viewportAttributesForSize):
* WebCoreSupport/DumpRenderTreeSupportQt.cpp:
(DumpRenderTreeSupportQt::viewportAsText):

Source/WebKit2:

* UIProcess/API/qt/qtouchwebview.cpp:
(QTouchWebViewPrivate::updateViewportConstraints):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::viewportConfigurationAsText):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@99195 268f45cc-cd09-0410-ab3c-d52691b4dbfc

15 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/dom/ViewportArguments.cpp
Source/WebCore/dom/ViewportArguments.h
Source/WebKit/efl/ChangeLog
Source/WebKit/efl/ewk/ewk_view.cpp
Source/WebKit/gtk/ChangeLog
Source/WebKit/gtk/WebCoreSupport/DumpRenderTreeSupportGtk.cpp
Source/WebKit/gtk/webkit/webkitviewportattributes.cpp
Source/WebKit/qt/Api/qwebpage.cpp
Source/WebKit/qt/ChangeLog
Source/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/qt/qtouchwebview.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.cpp

index 95765e044697347f45167066936ec4f594ecdec6..b9362bb5a34b53b4a5849c3bcf5d1eb6eda37345 100644 (file)
@@ -1,3 +1,24 @@
+2011-11-03  Fady Samuel  <fsamuel@chromium.org>
+
+        Removing line in computeViewportAttributes that enforces a minimum scale factor to never allow zooming out more than viewport
+        https://bugs.webkit.org/show_bug.cgi?id=70609
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Operations in computeViewportAttributes that are not a part of the spec: 
+
+        http://www.w3.org/TR/2011/WD-css-device-adapt-20110915/#constraining-viewport-property-values
+
+        were moved into the functions restrictMinimumScaleFactorToViewportSize and
+        restrictScaleFactorToInitialScaleIfNotUserScalable.
+
+        * WebCore.exp.in:
+        * dom/ViewportArguments.cpp:
+        (WebCore::computeViewportAttributes):
+        (WebCore::restrictMinimumScaleFactorToViewportSize):
+        (WebCore::restrictScaleFactorToInitialScaleIfNotUserScalable):
+        * dom/ViewportArguments.h:
+
 2011-11-03  Andreas Kling  <kling@webkit.org>
 
         Unreviewed build fix, sigh.
index 5ca017c98f9287584819166337b5d71312aae83d..c934d052481c3d4e7de74cb68862e6b864f454d1 100644 (file)
@@ -652,6 +652,8 @@ __ZN7WebCore25PluginMainThreadScheduler16unregisterPluginEP4_NPP
 __ZN7WebCore25PluginMainThreadScheduler9schedulerEv
 __ZN7WebCore25addLanguageChangeObserverEPvPFvS0_E
 __ZN7WebCore25computeViewportAttributesENS_17ViewportArgumentsEiiiiNS_7IntSizeE
+__ZN7WebCore50restrictScaleFactorToInitialScaleIfNotUserScalableERNS_18ViewportAttributesE
+__ZN7WebCore40restrictMinimumScaleFactorToViewportSizeERNS_18ViewportAttributesENS_7IntSizeE
 __ZN7WebCore25contextMenuItemTagOutlineEv
 __ZN7WebCore26CSSMutableStyleDeclarationC1Ev
 __ZN7WebCore26UserTypingGestureIndicator27processingUserTypingGestureEv
index 6ddea07e94ef84aeff517c731592bd9a7ba21a03..939ac5c60a6a8523de815e77cedc729b6cb4f50a 100644 (file)
@@ -180,17 +180,30 @@ ViewportAttributes computeViewportAttributes(ViewportArguments args, int desktop
     result.layoutSize.setWidth(static_cast<int>(roundf(width)));
     result.layoutSize.setHeight(static_cast<int>(roundf(height)));
 
-    // Update minimum scale factor, to never allow zooming out more than viewport
-    result.minimumScale = max<float>(result.minimumScale, max(availableWidth / width, availableHeight / height));
-
     result.userScalable = args.userScalable;
-    // Make maximum and minimum scale equal to the initial scale if user is not allowed to zoom in/out.
-    if (!args.userScalable)
-        result.maximumScale = result.minimumScale = result.initialScale;
 
     return result;
 }
 
+void restrictMinimumScaleFactorToViewportSize(ViewportAttributes& result, IntSize visibleViewport)
+{
+    float availableWidth = visibleViewport.width();
+    float availableHeight = visibleViewport.height();
+
+    if (result.devicePixelRatio != 1.0) {
+        availableWidth /= result.devicePixelRatio;
+        availableHeight /= result.devicePixelRatio;
+    }
+
+    result.minimumScale = max<float>(result.minimumScale, max(availableWidth / result.layoutSize.width(), availableHeight / result.layoutSize.height()));
+}
+
+void restrictScaleFactorToInitialScaleIfNotUserScalable(ViewportAttributes& result)
+{
+    if (!result.userScalable)
+        result.maximumScale = result.minimumScale = result.initialScale;
+}
+
 static float numericPrefix(const String& keyString, const String& valueString, Document* document, bool* ok)
 {
     // If a prefix of property-value can be converted to a number using strtod,
index 7194fe34aedab1237838b41bdc6528429783f497..59b41ded1fd47f627ebba231be7844761b4b7247 100644 (file)
@@ -107,6 +107,8 @@ struct ViewportArguments {
 };
 
 ViewportAttributes computeViewportAttributes(ViewportArguments args, int desktopWidth, int deviceWidth, int deviceHeight, int deviceDPI, IntSize visibleViewport);
+void restrictMinimumScaleFactorToViewportSize(ViewportAttributes& result, IntSize visibleViewport);
+void restrictScaleFactorToInitialScaleIfNotUserScalable(ViewportAttributes& result);
 
 void setViewportFeature(const String& keyString, const String& valueString, Document*, void* data);
 void reportViewportWarning(Document*, ViewportErrorCode, const String& replacement1, const String& replacement2);
index 10eca086fcd0bbb6b80c8d1fa03db13d33a81dd3..1ad1b3d524e14200aac7ef41904905981d52c145 100755 (executable)
@@ -1,3 +1,13 @@
+2011-11-03  Fady Samuel  <fsamuel@chromium.org>
+
+        Removing line in computeViewportAttributes that enforces a minimum scale factor to never allow zooming out more than viewport
+        https://bugs.webkit.org/show_bug.cgi?id=70609
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        * ewk/ewk_view.cpp:
+        (_ewk_view_viewport_attributes_compute):
+
 2011-11-03  Dongwoo Im  <dw.im@samsung.com>
 
         [EFL] Enable the Page Visibility API.
index 1f279396fdcf5b2f89fb9471b4ce1f31970c87d9..baf0af7657bd527895a17d781b408f30234994f4 100644 (file)
@@ -1088,6 +1088,8 @@ static WebCore::ViewportAttributes _ewk_view_viewport_attributes_compute(const E
     WebCore::IntRect deviceRect = enclosingIntRect(priv->page->chrome()->client()->windowRect());
 
     WebCore::ViewportAttributes attributes = WebCore::computeViewportAttributes(priv->viewportArguments, desktopWidth, deviceRect.width(), deviceRect.height(), deviceDPI, availableRect.size());
+    WebCore::restrictMinimumScaleFactorToViewportSize(attributes, availableRect.size());
+    WebCore::restrictScaleFactorToInitialScaleIfNotUserScalable(attributes);
 
     return attributes;
 }
index 487209df962974ff593df0d591b1704587b8e544..b6d28236d3d7616e591eeecd79d85c8afb5c62a2 100644 (file)
@@ -1,3 +1,15 @@
+2011-11-03  Fady Samuel  <fsamuel@chromium.org>
+
+        Removing line in computeViewportAttributes that enforces a minimum scale factor to never allow zooming out more than viewport
+        https://bugs.webkit.org/show_bug.cgi?id=70609
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        * WebCoreSupport/DumpRenderTreeSupportGtk.cpp:
+        (DumpRenderTreeSupportGtk::dumpConfigurationForViewport):
+        * webkit/webkitviewportattributes.cpp:
+        (webkitViewportAttributesRecompute):
+
 2011-11-02  Jon Lee  <jonlee@apple.com>
 
         Expand DragController to provide more information about the dragging session
index 540f53fe5bcebc053db3512c080b2083cb722869..0f68c3a49699fd7b8f15e40382d97f8377b93049 100644 (file)
@@ -711,7 +711,8 @@ void DumpRenderTreeSupportGtk::dumpConfigurationForViewport(WebKitWebView* webVi
 
     ViewportArguments arguments = webView->priv->corePage->mainFrame()->document()->viewportArguments();
     ViewportAttributes attrs = computeViewportAttributes(arguments, /* default layout width for non-mobile pages */ 980, deviceWidth, deviceHeight, deviceDPI, IntSize(availableWidth, availableHeight));
-
+    restrictMinimumScaleFactorToViewportSize(attrs, IntSize(availableWidth, availableHeight));
+    restrictScaleFactorToInitialScaleIfNotUserScalable(attrs);
     fprintf(stdout, "viewport size %dx%d scale %f with limits [%f, %f] and userScalable %f\n", attrs.layoutSize.width(), attrs.layoutSize.height(), attrs.initialScale, attrs.minimumScale, attrs.maximumScale, attrs.userScalable);
 }
 
index 742cddde741ea450d5e5e8d8ca4ab567e57a104e..c08191faedc8abd9ae74a6b3c5ed41b93e226ef1 100644 (file)
@@ -535,6 +535,8 @@ void webkitViewportAttributesRecompute(WebKitViewportAttributes* viewportAttribu
     ViewportArguments arguments = webView->priv->corePage->mainFrame()->document()->viewportArguments();
 
     ViewportAttributes attributes = computeViewportAttributes(arguments, priv->desktopWidth, priv->deviceWidth, priv->deviceHeight, priv->deviceDPI, IntSize(priv->availableWidth, priv->availableHeight));
+    restrictMinimumScaleFactorToViewportSize(attributes, IntSize(priv->availableWidth, priv->availableHeight));
+    restrictScaleFactorToInitialScaleIfNotUserScalable(attributes);
 
     priv->width = attributes.layoutSize.width();
     priv->height = attributes.layoutSize.height();
index 7e696c430f891ce27908b41b46d80585b03d4da0..ef022fe5cfe4742b798cf1458d78b5f40be3adfa 100644 (file)
@@ -2558,6 +2558,8 @@ QWebPage::ViewportAttributes QWebPage::viewportAttributesForSize(const QSize& av
     }
 
     WebCore::ViewportAttributes conf = WebCore::computeViewportAttributes(d->viewportArguments(), desktopWidth, deviceWidth, deviceHeight, qt_defaultDpi(), availableSize);
+    WebCore::restrictMinimumScaleFactorToViewportSize(conf, availableSize);
+    WebCore::restrictScaleFactorToInitialScaleIfNotUserScalable(conf);
 
     result.m_isValid = true;
     result.m_size = conf.layoutSize;
index 5d1d97e286ed6c9cd624794e07743638f6a1652f..d8a706f1de9660cb79b6b69348548c3f92669624 100644 (file)
@@ -1,3 +1,15 @@
+2011-11-03  Fady Samuel  <fsamuel@chromium.org>
+
+        Removing line in computeViewportAttributes that enforces a minimum scale factor to never allow zooming out more than viewport
+        https://bugs.webkit.org/show_bug.cgi?id=70609
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        * Api/qwebpage.cpp:
+        (QWebPage::viewportAttributesForSize):
+        * WebCoreSupport/DumpRenderTreeSupportQt.cpp:
+        (DumpRenderTreeSupportQt::viewportAsText):
+
 2011-11-03  Jesus Sanchez-Palencia  <jesus.palencia@openbossa.org>
 
         [Qt][WK2] Download support and API in UIProcess
index 32134e632bc14b7d232fcd1828366024f5c1b802..f42824c2ee9284b389ec3145afcaa263176a7704 100644 (file)
@@ -765,6 +765,8 @@ QString DumpRenderTreeSupportQt::viewportAsText(QWebPage* page, int deviceDPI, c
         /* device-height */ deviceSize.height(),
         /* device-dpi    */ deviceDPI,
         availableSize);
+    WebCore::restrictMinimumScaleFactorToViewportSize(conf, availableSize);
+    WebCore::restrictScaleFactorToInitialScaleIfNotUserScalable(conf);
 
     QString res;
     res = res.sprintf("viewport size %dx%d scale %f with limits [%f, %f] and userScalable %f\n",
index 7fec488dc4458cc07fb1f1ad69d57bf4e1bc58ad..a079457e45249bad08a1ea46e0e4b10a9c760906 100644 (file)
@@ -1,3 +1,15 @@
+2011-11-03  Fady Samuel  <fsamuel@chromium.org>
+
+        Removing line in computeViewportAttributes that enforces a minimum scale factor to never allow zooming out more than viewport
+        https://bugs.webkit.org/show_bug.cgi?id=70609
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        * UIProcess/API/qt/qtouchwebview.cpp:
+        (QTouchWebViewPrivate::updateViewportConstraints):
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::viewportConfigurationAsText):
+
 2011-11-03  Andras Becsi  <andras.becsi@nokia.com>
 
         [Qt][WK2] Fix the signal signature of the loadFailed API test.
index 1a38b95d0190aa404c7a1755ba32f58e6b101b2b..fc43b8771cebe539b746aa76b1826bd13a9fac4b 100644 (file)
@@ -92,6 +92,8 @@ void QTouchWebViewPrivate::updateViewportConstraints()
     wkPrefs->setDeviceHeight(720);
 
     WebCore::ViewportAttributes attr = WebCore::computeViewportAttributes(viewportArguments, wkPrefs->layoutFallbackWidth(), wkPrefs->deviceWidth(), wkPrefs->deviceHeight(), wkPrefs->deviceDPI(), availableSize);
+    WebCore::restrictMinimumScaleFactorToViewport(attr, availableSize);
+    WebCore::restrictScaleFactorToInitialScaleIfNotUserScalable(attr);
 
     QtViewportInteractionEngine::Constraints newConstraints;
     newConstraints.initialScale = attr.initialScale;
index de48d16bfe71b530c9408ed082f391bc41df4ab8..faf899299e07c34a1fd93ca24f5fe63f53f3110e 100644 (file)
@@ -2618,6 +2618,8 @@ String WebPage::viewportConfigurationAsText(int deviceDPI, int deviceWidth, int
 {
     ViewportArguments arguments = mainFrame()->document()->viewportArguments();
     ViewportAttributes attrs = WebCore::computeViewportAttributes(arguments, /* default layout width for non-mobile pages */ 980, deviceWidth, deviceHeight, deviceDPI, IntSize(availableWidth, availableHeight));
+    WebCore::restrictMinimumScaleFactorToViewportSize(attrs, IntSize(availableWidth, availableHeight));
+    WebCore::restrictScaleFactorToInitialScaleIfNotUserScalable(attrs);
     return String::format("viewport size %dx%d scale %f with limits [%f, %f] and userScalable %f\n", attrs.layoutSize.width(), attrs.layoutSize.height(), attrs.initialScale, attrs.minimumScale, attrs.maximumScale, attrs.userScalable);
 }