Title: [116632] trunk/Source
Revision
116632
Author
[email protected]
Date
2012-05-10 05:20:04 -0700 (Thu, 10 May 2012)

Log Message

[Qt] Implement fit-to-width behaviour
https://bugs.webkit.org/show_bug.cgi?id=86085

Reviewed by Simon Hausmann.

Source/WebCore:

Add a method to get the minimum scale factor that contains the content
without showing any chrome background.

* dom/ViewportArguments.cpp:
(WebCore::computeMinimumScaleFactorForContentContained):
(WebCore):
* dom/ViewportArguments.h:
(WebCore):

Source/WebKit2:

We don't restrict the minimum scale to the layout viewport anymore,
but instead update the minimum scale when the content size changes.

* UIProcess/API/qt/qquickwebview.cpp:
(QQuickWebViewFlickablePrivate::didChangeViewportProperties):
(QQuickWebViewFlickablePrivate::didChangeContentsSize):
* UIProcess/API/qt/qwebviewportinfo.cpp:
(QWebViewportInfo::minimumScale):
(QWebViewportInfo::maximumScale):
* UIProcess/qt/QtViewportInteractionEngine.h:
(QtViewportInteractionEngine):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (116631 => 116632)


--- trunk/Source/WebCore/ChangeLog	2012-05-10 12:09:30 UTC (rev 116631)
+++ trunk/Source/WebCore/ChangeLog	2012-05-10 12:20:04 UTC (rev 116632)
@@ -1,3 +1,19 @@
+2012-05-10  Kenneth Rohde Christiansen  <[email protected]>
+
+        [Qt] Implement fit-to-width behaviour
+        https://bugs.webkit.org/show_bug.cgi?id=86085
+
+        Reviewed by Simon Hausmann.
+
+        Add a method to get the minimum scale factor that contains the content
+        without showing any chrome background.
+
+        * dom/ViewportArguments.cpp:
+        (WebCore::computeMinimumScaleFactorForContentContained):
+        (WebCore):
+        * dom/ViewportArguments.h:
+        (WebCore):
+
 2012-05-10  MORITA Hajime  <[email protected]>
 
         Remove support for Node::willRemove()

Modified: trunk/Source/WebCore/dom/ViewportArguments.cpp (116631 => 116632)


--- trunk/Source/WebCore/dom/ViewportArguments.cpp	2012-05-10 12:09:30 UTC (rev 116631)
+++ trunk/Source/WebCore/dom/ViewportArguments.cpp	2012-05-10 12:20:04 UTC (rev 116632)
@@ -185,6 +185,19 @@
     return result;
 }
 
+float computeMinimumScaleFactorForContentContained(const ViewportAttributes& result, const IntSize& viewportSize, const IntSize& contentsSize)
+{
+    float availableWidth = viewportSize.width();
+    float availableHeight = viewportSize.height();
+
+    if (result.devicePixelRatio != 1.0) {
+        availableWidth /= result.devicePixelRatio;
+        availableHeight /= result.devicePixelRatio;
+    }
+
+    return max<float>(result.minimumScale, max(availableWidth / contentsSize.width(), availableHeight / contentsSize.height()));
+}
+
 void restrictMinimumScaleFactorToViewportSize(ViewportAttributes& result, IntSize visibleViewport)
 {
     float availableWidth = visibleViewport.width();

Modified: trunk/Source/WebCore/dom/ViewportArguments.h (116631 => 116632)


--- trunk/Source/WebCore/dom/ViewportArguments.h	2012-05-10 12:09:30 UTC (rev 116631)
+++ trunk/Source/WebCore/dom/ViewportArguments.h	2012-05-10 12:20:04 UTC (rev 116632)
@@ -109,6 +109,7 @@
 ViewportAttributes computeViewportAttributes(ViewportArguments args, int desktopWidth, int deviceWidth, int deviceHeight, int deviceDPI, IntSize visibleViewport);
 void restrictMinimumScaleFactorToViewportSize(ViewportAttributes& result, IntSize visibleViewport);
 void restrictScaleFactorToInitialScaleIfNotUserScalable(ViewportAttributes& result);
+float computeMinimumScaleFactorForContentContained(const ViewportAttributes& result, const IntSize& viewportSize, const IntSize& contentSize);
 
 void setViewportFeature(const String& keyString, const String& valueString, Document*, void* data);
 void reportViewportWarning(Document*, ViewportErrorCode, const String& replacement1, const String& replacement2);

Modified: trunk/Source/WebKit2/ChangeLog (116631 => 116632)


--- trunk/Source/WebKit2/ChangeLog	2012-05-10 12:09:30 UTC (rev 116631)
+++ trunk/Source/WebKit2/ChangeLog	2012-05-10 12:20:04 UTC (rev 116632)
@@ -1,3 +1,22 @@
+2012-05-10  Kenneth Rohde Christiansen  <[email protected]>
+
+        [Qt] Implement fit-to-width behaviour
+        https://bugs.webkit.org/show_bug.cgi?id=86085
+
+        Reviewed by Simon Hausmann.
+
+        We don't restrict the minimum scale to the layout viewport anymore,
+        but instead update the minimum scale when the content size changes.
+
+        * UIProcess/API/qt/qquickwebview.cpp:
+        (QQuickWebViewFlickablePrivate::didChangeViewportProperties):
+        (QQuickWebViewFlickablePrivate::didChangeContentsSize):
+        * UIProcess/API/qt/qwebviewportinfo.cpp:
+        (QWebViewportInfo::minimumScale):
+        (QWebViewportInfo::maximumScale):
+        * UIProcess/qt/QtViewportInteractionEngine.h:
+        (QtViewportInteractionEngine):
+
 2012-05-07  Tor Arne Vestbø  <[email protected]>
 
         WebPageProxy::activeURL() should return the pending API request, even when there's no main frame

Modified: trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp (116631 => 116632)


--- trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp	2012-05-10 12:09:30 UTC (rev 116631)
+++ trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp	2012-05-10 12:20:04 UTC (rev 116632)
@@ -857,11 +857,8 @@
 {
     Q_Q(QQuickWebView);
 
-    QSize viewportSize = q->boundingRect().size().toSize();
-
     // FIXME: Revise these when implementing fit-to-width.
     WebCore::ViewportAttributes attr = newAttributes;
-    WebCore::restrictMinimumScaleFactorToViewportSize(attr, viewportSize);
     WebCore::restrictScaleFactorToInitialScaleIfNotUserScalable(attr);
 
     // FIXME: Resetting here can reset more than needed. For instance it will end deferrers.
@@ -949,8 +946,20 @@
 void QQuickWebViewFlickablePrivate::didChangeContentsSize(const QSize& newSize)
 {
     Q_Q(QQuickWebView);
+    QSize viewportSize = q->boundingRect().size().toSize();
+
     pageView->setContentsSize(newSize);
     q->experimental()->viewportInfo()->didUpdateContentsSize();
+
+    float minimumScale = WebCore::computeMinimumScaleFactorForContentContained(attributes, viewportSize, newSize);
+
+    if (!qFuzzyCompare(minimumScale, attributes.minimumScale)) {
+        interactionEngine->setCSSScaleBounds(minimumScale, attributes.maximumScale);
+        q->experimental()->viewportInfo()->didUpdateViewportConstraints();
+
+        if (!interactionEngine->hadUserInteraction() && !pageIsSuspended)
+            interactionEngine->setCSSScale(minimumScale);
+    }
 }
 
 /*!

Modified: trunk/Source/WebKit2/UIProcess/API/qt/qwebviewportinfo.cpp (116631 => 116632)


--- trunk/Source/WebKit2/UIProcess/API/qt/qwebviewportinfo.cpp	2012-05-10 12:09:30 UTC (rev 116631)
+++ trunk/Source/WebKit2/UIProcess/API/qt/qwebviewportinfo.cpp	2012-05-10 12:20:04 UTC (rev 116632)
@@ -62,11 +62,17 @@
 
 QVariant QWebViewportInfo::minimumScale() const
 {
+    if (QtViewportInteractionEngine* interactionEngine = m_webViewPrivate->viewportInteractionEngine())
+        return interactionEngine->m_minimumScale;
+
     return m_webViewPrivate->attributes.minimumScale;
 }
 
 QVariant QWebViewportInfo::maximumScale() const
 {
+    if (QtViewportInteractionEngine* interactionEngine = m_webViewPrivate->viewportInteractionEngine())
+        return interactionEngine->m_maximumScale;
+
     return m_webViewPrivate->attributes.maximumScale;
 }
 

Modified: trunk/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.h (116631 => 116632)


--- trunk/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.h	2012-05-10 12:09:30 UTC (rev 116631)
+++ trunk/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.h	2012-05-10 12:20:04 UTC (rev 116632)
@@ -35,6 +35,8 @@
 class QWheelEvent;
 QT_END_NAMESPACE
 
+class QWebViewportInfo;
+
 namespace WebKit {
 
 class ViewportUpdateDeferrer;
@@ -114,7 +116,7 @@
 
 private:
     friend class ViewportUpdateDeferrer;
-    friend class QWebViewportInfo;
+    friend class ::QWebViewportInfo;
 
     QQuickWebView* const m_viewport;
     QQuickWebPage* const m_content;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to