Title: [92851] trunk/Source/WebKit2
Revision
92851
Author
[email protected]
Date
2011-08-11 08:33:25 -0700 (Thu, 11 Aug 2011)

Log Message

[Qt/WK2] Add initial support for viewport meta tag
https://bugs.webkit.org/show_bug.cgi?id=65975

Reviewed by Benjamin Poulain.

Redirect the viewport arguments through to the view.

* UIProcess/API/qt/qdesktopwebview.cpp:
(QDesktopWebViewPrivate::didReceiveViewportArguments):
* UIProcess/API/qt/qdesktopwebview_p.h:
* UIProcess/API/qt/qtouchwebview.cpp:
(QTouchWebView::geometryChanged):
* UIProcess/qt/QtWebPageProxy.cpp:
(QtWebPageProxy::setViewportArguments):
* UIProcess/qt/QtWebPageProxy.h:
* UIProcess/qt/TouchViewInterface.cpp:
(WebKit::TouchViewInterface::updateViewportState):
(WebKit::TouchViewInterface::didReceiveViewportArguments):
* UIProcess/qt/TouchViewInterface.h:
(WebKit::TouchViewInterface::ViewportState::ViewportState):
* UIProcess/qt/ViewInterface.h:
* UIProcess/qt/qtouchwebpageproxy.cpp:
(QTouchWebPageProxy::QTouchWebPageProxy):
* UIProcess/qt/qtouchwebpageproxy.h:

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (92850 => 92851)


--- trunk/Source/WebKit2/ChangeLog	2011-08-11 15:24:30 UTC (rev 92850)
+++ trunk/Source/WebKit2/ChangeLog	2011-08-11 15:33:25 UTC (rev 92851)
@@ -1,3 +1,30 @@
+2011-08-11  Kenneth Rohde Christiansen  <[email protected]>
+
+        [Qt/WK2] Add initial support for viewport meta tag
+        https://bugs.webkit.org/show_bug.cgi?id=65975
+
+        Reviewed by Benjamin Poulain.
+
+        Redirect the viewport arguments through to the view.
+
+        * UIProcess/API/qt/qdesktopwebview.cpp:
+        (QDesktopWebViewPrivate::didReceiveViewportArguments):
+        * UIProcess/API/qt/qdesktopwebview_p.h:
+        * UIProcess/API/qt/qtouchwebview.cpp:
+        (QTouchWebView::geometryChanged):
+        * UIProcess/qt/QtWebPageProxy.cpp:
+        (QtWebPageProxy::setViewportArguments):
+        * UIProcess/qt/QtWebPageProxy.h:
+        * UIProcess/qt/TouchViewInterface.cpp:
+        (WebKit::TouchViewInterface::updateViewportState):
+        (WebKit::TouchViewInterface::didReceiveViewportArguments):
+        * UIProcess/qt/TouchViewInterface.h:
+        (WebKit::TouchViewInterface::ViewportState::ViewportState):
+        * UIProcess/qt/ViewInterface.h:
+        * UIProcess/qt/qtouchwebpageproxy.cpp:
+        (QTouchWebPageProxy::QTouchWebPageProxy):
+        * UIProcess/qt/qtouchwebpageproxy.h:
+
 2011-08-10  David Hyatt  <[email protected]>
 
         https://bugs.webkit.org/show_bug.cgi?id=66004

Modified: trunk/Source/WebKit2/UIProcess/API/qt/qdesktopwebview.cpp (92850 => 92851)


--- trunk/Source/WebKit2/UIProcess/API/qt/qdesktopwebview.cpp	2011-08-11 15:24:30 UTC (rev 92850)
+++ trunk/Source/WebKit2/UIProcess/API/qt/qdesktopwebview.cpp	2011-08-11 15:33:25 UTC (rev 92851)
@@ -89,6 +89,11 @@
     *clientPosition = widget->mapFromGlobal(*globalPosition);
 }
 
+void QDesktopWebViewPrivate::didReceiveViewportArguments(const WebCore::ViewportArguments&)
+{
+    // This feature is only used by QTouchWebView.
+}
+
 void QDesktopWebViewPrivate::didFindZoomableArea(const QPoint&, const QRect&)
 {
     // This feature is only used by QTouchWebView.

Modified: trunk/Source/WebKit2/UIProcess/API/qt/qdesktopwebview_p.h (92850 => 92851)


--- trunk/Source/WebKit2/UIProcess/API/qt/qdesktopwebview_p.h	2011-08-11 15:24:30 UTC (rev 92850)
+++ trunk/Source/WebKit2/UIProcess/API/qt/qdesktopwebview_p.h	2011-08-11 15:33:25 UTC (rev 92851)
@@ -52,6 +52,7 @@
     virtual bool isVisible();
 
     virtual void startDrag(Qt::DropActions supportedDropActions, const QImage& dragImage, QMimeData*, QPoint* clientPosition, QPoint* globalPosition, Qt::DropAction* dropAction);
+    virtual void didReceiveViewportArguments(const WebCore::ViewportArguments&);
     virtual void didFindZoomableArea(const QPoint&, const QRect&);
 
     virtual void didChangeUrl(const QUrl&);

Modified: trunk/Source/WebKit2/UIProcess/API/qt/qtouchwebview.cpp (92850 => 92851)


--- trunk/Source/WebKit2/UIProcess/API/qt/qtouchwebview.cpp	2011-08-11 15:24:30 UTC (rev 92850)
+++ trunk/Source/WebKit2/UIProcess/API/qt/qtouchwebview.cpp	2011-08-11 15:33:25 UTC (rev 92851)
@@ -25,6 +25,8 @@
 #include "TouchViewInterface.h"
 #include "qtouchwebpage_p.h"
 #include "QtWebPageProxy.h"
+#include "WebPageGroup.h"
+#include "WebPreferences.h"
 #include <qgraphicssceneevent.h>
 
 QTouchWebViewPrivate::QTouchWebViewPrivate(QTouchWebView* q)
@@ -51,6 +53,35 @@
     pageViewPrivate->setViewportRect(viewportRectInPageViewCoordinate);
 }
 
+void QTouchWebViewPrivate::updateViewportState()
+{
+    QSize availableSize = q->boundingRect().size().toSize();
+
+    WebPageProxy* wkPage = toImpl(page.pageRef());
+    WebPreferences* wkPrefs = wkPage->pageGroup()->preferences();
+
+    WebCore::ViewportAttributes attr = WebCore::computeViewportAttributes(viewportArguments, wkPrefs->layoutFallbackWidth(), wkPrefs->deviceWidth(), wkPrefs->deviceHeight(), wkPrefs->deviceDPI(), availableSize);
+
+    viewport.initialScale = attr.initialScale;
+    viewport.minimumScale = attr.minimumScale;
+    viewport.maximumScale = attr.maximumScale;
+    viewport.pixelRatio = attr.devicePixelRatio;
+    viewport.isUserScalable = !!attr.userScalable;
+
+    // Overwrite minimum scale value with fit-to-view value, unless the the content author
+    // explicitly says no. NB: We can only do this when we know we have a valid size, ie.
+    // after initial layout has completed.
+
+    // FIXME: Do this on the web process side.
+    wkPage->setResizesToContentsUsingLayoutSize(attr.layoutSize);
+}
+
+void QTouchWebViewPrivate::setViewportArguments(const WebCore::ViewportArguments& args)
+{
+    viewportArguments = args;
+    updateViewportState();
+}
+
 QTouchWebView::QTouchWebView(QSGItem* parent)
     : QSGItem(parent)
     , d(new QTouchWebViewPrivate(this))
@@ -71,8 +102,10 @@
 void QTouchWebView::geometryChanged(const QRectF& newGeometry, const QRectF& oldGeometry)
 {
     QSGItem::geometryChanged(newGeometry, oldGeometry);
-    if (newGeometry.size() != oldGeometry.size())
+    if (newGeometry.size() != oldGeometry.size()) {
+        d->updateViewportState();
         d->viewportRectUpdated();
+    }
 }
 
 #include "moc_qtouchwebview.cpp"

Modified: trunk/Source/WebKit2/UIProcess/API/qt/qtouchwebview_p.h (92850 => 92851)


--- trunk/Source/WebKit2/UIProcess/API/qt/qtouchwebview_p.h	2011-08-11 15:24:30 UTC (rev 92850)
+++ trunk/Source/WebKit2/UIProcess/API/qt/qtouchwebview_p.h	2011-08-11 15:33:25 UTC (rev 92851)
@@ -32,13 +32,35 @@
 {
 public:
     QTouchWebViewPrivate(QTouchWebView* q);
+
     void scroll(qreal deltaX, qreal deltaY);
     void viewportRectUpdated();
+    void updateViewportState();
 
+    void setViewportArguments(const WebCore::ViewportArguments& args);
+
+    struct ViewportState {
+        ViewportState()
+            : initialScale(1.0)
+            , minimumScale(0.25)
+            , maximumScale(1.8)
+            , pixelRatio(1.0)
+            , isUserScalable(true)
+        { }
+
+        qreal initialScale;
+        qreal minimumScale;
+        qreal maximumScale;
+        qreal pixelRatio;
+        bool isUserScalable;
+    } viewport;
+
     QTouchWebView* const q;
     QScopedPointer<QTouchWebPage> pageView;
     WebKit::TouchViewInterface viewInterface;
     QTouchWebPageProxy page;
+
+    WebCore::ViewportArguments viewportArguments;
 };
 
 #endif /* qtouchwebview_p_h */

Modified: trunk/Source/WebKit2/UIProcess/qt/QtWebPageProxy.cpp (92850 => 92851)


--- trunk/Source/WebKit2/UIProcess/qt/QtWebPageProxy.cpp	2011-08-11 15:24:30 UTC (rev 92850)
+++ trunk/Source/WebKit2/UIProcess/qt/QtWebPageProxy.cpp	2011-08-11 15:33:25 UTC (rev 92851)
@@ -705,6 +705,11 @@
     m_webPageProxy->dragEnded(clientPosition, globalPosition, dropActionToDragOperation(actualDropAction));
 }
 
+void QtWebPageProxy::setViewportArguments(const WebCore::ViewportArguments& args)
+{
+    m_viewInterface->didReceiveViewportArguments(args);
+}
+
 void QtWebPageProxy::setPageIsVisible(bool isVisible)
 {
     m_webPageProxy->drawingArea()->setPageIsVisible(isVisible);

Modified: trunk/Source/WebKit2/UIProcess/qt/QtWebPageProxy.h (92850 => 92851)


--- trunk/Source/WebKit2/UIProcess/qt/QtWebPageProxy.h	2011-08-11 15:24:30 UTC (rev 92850)
+++ trunk/Source/WebKit2/UIProcess/qt/QtWebPageProxy.h	2011-08-11 15:33:25 UTC (rev 92851)
@@ -97,6 +97,7 @@
     virtual void didChangeContentsSize(const WebCore::IntSize&);
 
     virtual void startDrag(const WebCore::DragData&, PassRefPtr<ShareableBitmap> dragImage);
+    virtual void setViewportArguments(const WebCore::ViewportArguments&);
     virtual void setCursor(const WebCore::Cursor&);
     virtual void setCursorHiddenUntilMouseMoves(bool hiddenUntilMouseMoves);
     virtual void toolTipChanged(const WTF::String&, const WTF::String&);

Modified: trunk/Source/WebKit2/UIProcess/qt/TouchViewInterface.cpp (92850 => 92851)


--- trunk/Source/WebKit2/UIProcess/qt/TouchViewInterface.cpp	2011-08-11 15:24:30 UTC (rev 92850)
+++ trunk/Source/WebKit2/UIProcess/qt/TouchViewInterface.cpp	2011-08-11 15:33:25 UTC (rev 92851)
@@ -143,6 +143,11 @@
     Q_ASSERT(false);
 }
 
+void TouchViewInterface::didReceiveViewportArguments(const WebCore::ViewportArguments& args)
+{
+    m_viewportView->d->setViewportArguments(args);
+}
+
 void TouchViewInterface::didChangeUrl(const QUrl& url)
 {
     emit m_pageView->urlChanged(url);

Modified: trunk/Source/WebKit2/UIProcess/qt/TouchViewInterface.h (92850 => 92851)


--- trunk/Source/WebKit2/UIProcess/qt/TouchViewInterface.h	2011-08-11 15:24:30 UTC (rev 92850)
+++ trunk/Source/WebKit2/UIProcess/qt/TouchViewInterface.h	2011-08-11 15:33:25 UTC (rev 92851)
@@ -27,6 +27,10 @@
 class QTouchWebPage;
 class QTouchWebView;
 
+namespace WebCore {
+class ViewportArguments;
+}
+
 namespace WebKit {
 
 class SGAgent;
@@ -59,6 +63,8 @@
     virtual bool isVisible();
 
     virtual void startDrag(Qt::DropActions supportedDropActions, const QImage& dragImage, QMimeData* data, QPoint* clientPosition, QPoint* globalPosition, Qt::DropAction* dropAction);
+    virtual void didReceiveViewportArguments(const WebCore::ViewportArguments&);
+
     virtual void didFindZoomableArea(const QPoint&, const QRect&);
 
     virtual void didChangeUrl(const QUrl&);

Modified: trunk/Source/WebKit2/UIProcess/qt/ViewInterface.h (92850 => 92851)


--- trunk/Source/WebKit2/UIProcess/qt/ViewInterface.h	2011-08-11 15:24:30 UTC (rev 92850)
+++ trunk/Source/WebKit2/UIProcess/qt/ViewInterface.h	2011-08-11 15:33:25 UTC (rev 92851)
@@ -38,6 +38,10 @@
 class QWidget;
 QT_END_NAMESPACE
 
+namespace WebCore {
+class ViewportArguments;
+}
+
 namespace WebKit {
 
 class ViewInterface
@@ -53,6 +57,8 @@
     virtual bool isVisible() = 0;
 
     virtual void startDrag(Qt::DropActions supportedDropActions, const QImage& dragImage, QMimeData* data, QPoint* clientPosition, QPoint* globalPosition, Qt::DropAction* dropAction) = 0;
+    virtual void didReceiveViewportArguments(const WebCore::ViewportArguments&) = 0;
+
     virtual void didFindZoomableArea(const QPoint&, const QRect&) = 0;
 
     virtual void didChangeUrl(const QUrl&) = 0;

Modified: trunk/Source/WebKit2/UIProcess/qt/qtouchwebpageproxy.cpp (92850 => 92851)


--- trunk/Source/WebKit2/UIProcess/qt/qtouchwebpageproxy.cpp	2011-08-11 15:24:30 UTC (rev 92850)
+++ trunk/Source/WebKit2/UIProcess/qt/qtouchwebpageproxy.cpp	2011-08-11 15:33:25 UTC (rev 92851)
@@ -33,8 +33,6 @@
     , m_pinchGestureRecognizer(viewInterface)
 {
     init();
-    // FIXME: add proper handling of viewport.
-    setResizesToContentsUsingLayoutSize(QSize(980, 980));
 }
 
 PassOwnPtr<DrawingAreaProxy> QTouchWebPageProxy::createDrawingAreaProxy()
@@ -54,12 +52,6 @@
     m_webPageProxy->drawingArea()->paint(IntRect(area), painter);
 }
 
-void QTouchWebPageProxy::setViewportArguments(const WebCore::ViewportArguments& args)
-{
-    m_viewportArguments = args;
-    // FIXME: we must tell our Views to react to the new viewport parameters.
-}
-
 #if ENABLE(TOUCH_EVENTS)
 void QTouchWebPageProxy::doneWithTouchEvent(const NativeWebTouchEvent& event, bool wasEventHandled)
 {

Modified: trunk/Source/WebKit2/UIProcess/qt/qtouchwebpageproxy.h (92850 => 92851)


--- trunk/Source/WebKit2/UIProcess/qt/qtouchwebpageproxy.h	2011-08-11 15:24:30 UTC (rev 92850)
+++ trunk/Source/WebKit2/UIProcess/qt/qtouchwebpageproxy.h	2011-08-11 15:33:25 UTC (rev 92851)
@@ -50,7 +50,6 @@
 private:
     virtual PassOwnPtr<DrawingAreaProxy> createDrawingAreaProxy();
     virtual void processDidCrash();
-    virtual void setViewportArguments(const WebCore::ViewportArguments&);
 #if ENABLE(TOUCH_EVENTS)
     virtual void doneWithTouchEvent(const NativeWebTouchEvent&, bool wasEventHandled);
 #endif
@@ -62,7 +61,6 @@
 
     QtPanGestureRecognizer m_panGestureRecognizer;
     QtPinchGestureRecognizer m_pinchGestureRecognizer;
-    WebCore::ViewportArguments m_viewportArguments;
 };
 
 #endif /* qtouchwebpageproxy_h */
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to