[webkit-qt] API for viewport meta tag support

steve.lewontin at nokia.com steve.lewontin at nokia.com
Fri Jun 4 08:52:55 PDT 2010


This is exactly what browser needs to cleanly implement tiling! When do you think this could be done?


-----Original Message-----
From: webkit-qt-bounces at lists.webkit.org [mailto:webkit-qt-bounces at lists.webkit.org] On Behalf Of Hausmann Simon (Nokia-D-Qt/Oslo)
Sent: Friday, June 04, 2010 8:54 AM
To: webkit-qt at lists.webkit.org
Subject: [webkit-qt] API for viewport meta tag support


WebCore itself has support for Apple's viewport meta tag:


which can look like this in HTML:

	<meta name = "viewport" content = "width = 320,
           initial-scale = 2.3, user-scalable = no">

The tag allows the web page to influence the sacl and geometry of the viewport on mobile browsers. WebCore has support for parsing all these attributes and passing them to the ChromeClient layer as soon as they're available. It is then the job of the WebKit API layer to propagate the information to the mobile browser application.

Jesus has been working on that in bug


and has come up with a nice API where QWebPage emits a signal as soon as WebCore processes this tag:

+    \since 4.7
+    \fn void QWebPage::viewportChangeRequested(const ViewportHints& 
+ hints)
+    This signal is emitted before any layout of the contents, giving you the viewport \a arguments
+    the web page would like you to use when laying out its contents, including elements fixed to the
+    viewport. This viewport might be larger that your actual viewport, meaning that a initialScale
+    should be applied. When no scale is given (-1.0), it is assumed that the contents should be scaled
+    such that the width of the scaled contents fits within the actual viewport.
+    The minimum and maximum allowed scale represents the min and max values that the page
+    allows for scaling, and thus, affects the ability to zoom in on the page.
+    Invalid values are supplied for the values not explicitly set by the web author; thus an
+    invalid viewport size, and values equal to -1.0 for scale factor and limits. The boolean
+    ViewportHints::isUserScalable is set to true.
+    Page authors can provide the supplied values by using the viewport meta tag. More information
+    about this can be found at 
+ \l{http://developer.apple.com/safari/library/documentation/appleapplic
+ ations/reference/safariwebcontent/usingtheviewport/usingtheviewport.ht
+ ml}{Safari Reference Library: Using the
Viewport Meta Tag}.
+    \sa QWebPage::ViewportHints, setPreferredContentsSize(), 
+QGraphicsWebView::setScale() */

In order to avoid having a signal in the API that has lots of arguments, the parameters are instead collected in a structure:

+    struct ViewportHints {
+        ViewportHints()
+            : initialScale(-1.0)
+            , minAllowedScale(-1.0)
+            , maxAllowedScale(-1.0)
+            , isUserScalable(true)
+        {
+        }
+        QSize size;
+        qreal initialScale;
+        qreal minAllowedScale;
+        qreal maxAllowedScale;
+        bool isUserScalable;
+    };

What do you guys think about this API?

Please give feedback on https://bugs.webkit.org/show_bug.cgi?id=39902 :-)


More information about the webkit-qt mailing list