[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

andreas.kling at nokia.com andreas.kling at nokia.com
Wed Dec 22 16:32:26 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit e3dea026a00f31c0ea18b630afe479cb13fc0ca6
Author: andreas.kling at nokia.com <andreas.kling at nokia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Nov 25 13:40:18 2010 +0000

    2010-11-25  Kenneth Rohde Christiansen  <kenneth at webkit.org>
    
            Reviewed by Andreas Kling and Simon Hausmann.
    
            [Qt] Calculate the -webkit-pixel-radio using the device DPI.
            http://webkit.org/b/50059
    
            Also, update the documentation on what a DIP is and how to override
            the device DPI in the case the system reports the wrong one (which
            unfortunately is common on X11).
    
            * Api/qwebpage.cpp:
            (QWebPagePrivate::QWebPagePrivate):
            (QWebPage::viewportAttributesForSize):
            * Api/qwebpage_p.h:
            * WebCoreSupport/ChromeClientQt.cpp:
            (WebCore::ChromeClientQt::scaleFactor):
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@72726 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit/qt/Api/qwebpage.cpp b/WebKit/qt/Api/qwebpage.cpp
index 94ed62a..030923f 100644
--- a/WebKit/qt/Api/qwebpage.cpp
+++ b/WebKit/qt/Api/qwebpage.cpp
@@ -141,6 +141,11 @@
 
 using namespace WebCore;
 
+// from text/qfont.cpp
+QT_BEGIN_NAMESPACE
+extern Q_GUI_EXPORT int qt_defaultDpi();
+QT_END_NAMESPACE
+
 bool QWebPagePrivate::drtRun = false;
 
 // Lookup table mapping QWebPage::WebActions to the associated Editor commands
@@ -286,6 +291,7 @@ QWebPagePrivate::QWebPagePrivate(QWebPage *qq)
     , selectTrailingWhitespaceEnabled(false)
     , linkPolicy(QWebPage::DontDelegateLinks)
     , viewportSize(QSize(0, 0))
+    , pixelRatio(1)
 #ifndef QT_NO_CONTEXTMENU
     , currentContextMenu(0)
 #endif
@@ -2451,14 +2457,30 @@ static QSize queryDeviceSizeForScreenContainingWidget(const QWidget* widget)
     environment variables QTWEBKIT_DEVICE_WIDTH and QTWEBKIT_DEVICE_HEIGHT, which
     both needs to be set.
 
+    The ViewportAttributes includes a pixel density ratio, which will also be exposed to
+    the web author though the -webkit-pixel-ratio media feature. This is the ratio
+    between 1 density-independent pixel (DPI) and physical pixels.
+
+    A density-independent pixel is equivalent to one physical pixel on a 160 DPI screen,
+    so on our platform assumes that as the baseline density.
+
+    The conversion of DIP units to screen pixels is quite simple:
+
+    pixels = DIPs * (density / 160).
+
+    Thus, on a 240 DPI screen, 1 DIPs would equal 1.5 physical pixels.
+
     An invalid instance will be returned in the case an empty size is passed to the
     method.
+
+    \note The density is automatically obtained from the DPI of the screen where the page
+    is being shown, but as many X11 servers are reporting wrong DPI, it is possible to
+    override it using QX11Info::setAppDpiY().
 */
 
 QWebPage::ViewportAttributes QWebPage::viewportAttributesForSize(const QSize& availableSize) const
 {
     static int desktopWidth = 980;
-    static int deviceDPI = 160;
 
     ViewportAttributes result;
 
@@ -2475,7 +2497,7 @@ QWebPage::ViewportAttributes QWebPage::viewportAttributesForSize(const QSize& av
         deviceHeight = size.height();
     }
 
-    WebCore::ViewportAttributes conf = WebCore::computeViewportAttributes(d->viewportArguments(), desktopWidth, deviceWidth, deviceHeight, deviceDPI, availableSize);
+    WebCore::ViewportAttributes conf = WebCore::computeViewportAttributes(d->viewportArguments(), desktopWidth, deviceWidth, deviceHeight, qt_defaultDpi(), availableSize);
 
     result.m_isValid = true;
     result.m_size = conf.layoutSize;
@@ -2485,6 +2507,8 @@ QWebPage::ViewportAttributes QWebPage::viewportAttributesForSize(const QSize& av
     result.m_devicePixelRatio = conf.devicePixelRatio;
     result.m_isUserScalable = conf.userScalable;
 
+    d->pixelRatio = conf.devicePixelRatio;
+
     return result;
 }
 
diff --git a/WebKit/qt/Api/qwebpage_p.h b/WebKit/qt/Api/qwebpage_p.h
index 1b9cd66..624ff99 100644
--- a/WebKit/qt/Api/qwebpage_p.h
+++ b/WebKit/qt/Api/qwebpage_p.h
@@ -188,6 +188,8 @@ public:
 
     QSize viewportSize;
     QSize fixedLayoutSize;
+    qreal pixelRatio;
+
     QWebHistory history;
     QWebHitTestResult hitTestResult;
 #ifndef QT_NO_CONTEXTMENU
diff --git a/WebKit/qt/ChangeLog b/WebKit/qt/ChangeLog
index 42faf2e..0f1d926 100644
--- a/WebKit/qt/ChangeLog
+++ b/WebKit/qt/ChangeLog
@@ -1,3 +1,21 @@
+2010-11-25  Kenneth Rohde Christiansen  <kenneth at webkit.org>
+
+        Reviewed by Andreas Kling and Simon Hausmann.
+
+        [Qt] Calculate the -webkit-pixel-radio using the device DPI.
+        http://webkit.org/b/50059
+
+        Also, update the documentation on what a DIP is and how to override
+        the device DPI in the case the system reports the wrong one (which
+        unfortunately is common on X11).
+
+        * Api/qwebpage.cpp:
+        (QWebPagePrivate::QWebPagePrivate):
+        (QWebPage::viewportAttributesForSize):
+        * Api/qwebpage_p.h:
+        * WebCoreSupport/ChromeClientQt.cpp:
+        (WebCore::ChromeClientQt::scaleFactor):
+
 2010-11-24  Kristian Amlie  <kristian.amlie at nokia.com>
 
         Reviewed by Andreas Kling.
diff --git a/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp b/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp
index 3fec1d3..d4875a8 100644
--- a/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp
+++ b/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp
@@ -118,14 +118,13 @@ FloatRect ChromeClientQt::pageRect()
     return FloatRect(QRectF(QPointF(0, 0), m_webPage->viewportSize()));
 }
 
-
 float ChromeClientQt::scaleFactor()
 {
-    notImplemented();
-    return 1;
+    if (!m_webPage)
+        return 1;
+    return m_webPage->d->pixelRatio;
 }
 
-
 void ChromeClientQt::focus()
 {
     if (!m_webPage)

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list