Rename deviceDPI to devicePixelRatio https://bugs.webkit.org/show_bug.cgi?id=85049
authorahf@0x90.dk <ahf@0x90.dk@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 3 May 2012 08:54:44 +0000 (08:54 +0000)
committerahf@0x90.dk <ahf@0x90.dk@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 3 May 2012 08:54:44 +0000 (08:54 +0000)
Reviewed by Kenneth Rohde Christiansen.

Source/WebCore:

No new tests added since this is a minor refactoring with no changes
that should affect tests.

* page/Settings.cpp:
(WebCore::Settings::Settings):
* page/Settings.h:
(WebCore::Settings::setDevicePixelRatio):
(WebCore::Settings::devicePixelRatio):
(Settings):

Source/WebKit2:

Add experimental QML API to set and get the device pixel ratio.

* Shared/WebPreferencesStore.h:
(WebKit):
* UIProcess/API/qt/qquickwebview.cpp:
(QQuickWebViewFlickablePrivate::updateViewportSize):
(QQuickWebViewExperimental::devicePixelRatio):
(QQuickWebViewExperimental::setDevicePixelRatio):
* UIProcess/API/qt/qquickwebview_p.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::sendViewportAttributesChanged):
(WebKit::WebPage::updatePreferences):

Tools:

Use 1.5 as device pixel ratio for the Qt MiniBrowser.

* MiniBrowser/qt/qml/BrowserWindow.qml:

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

Source/WebCore/ChangeLog
Source/WebCore/page/Settings.cpp
Source/WebCore/page/Settings.h
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/WebPreferencesStore.h
Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp
Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h
Source/WebKit2/WebProcess/WebPage/WebPage.cpp
Tools/ChangeLog
Tools/MiniBrowser/qt/qml/BrowserWindow.qml

index 388ca5c..59dcd96 100644 (file)
@@ -1,3 +1,20 @@
+2012-05-02  Alexander Færøy  <ahf@0x90.dk>
+
+        Rename deviceDPI to devicePixelRatio
+        https://bugs.webkit.org/show_bug.cgi?id=85049
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        No new tests added since this is a minor refactoring with no changes
+        that should affect tests.
+
+        * page/Settings.cpp:
+        (WebCore::Settings::Settings):
+        * page/Settings.h:
+        (WebCore::Settings::setDevicePixelRatio):
+        (WebCore::Settings::devicePixelRatio):
+        (Settings):
+
 2012-05-03  Nikolas Zimmermann  <nzimmermann@rim.com>
 
         Fix multiple begin values support - especially with seeking through setCurrentTime
 2012-05-03  Nikolas Zimmermann  <nzimmermann@rim.com>
 
         Fix multiple begin values support - especially with seeking through setCurrentTime
index e889412..0887817 100644 (file)
@@ -133,7 +133,7 @@ Settings::Settings(Page* page)
     , m_validationMessageTimerMagnification(50)
     , m_minimumAccelerated2dCanvasSize(257 * 256)
     , m_layoutFallbackWidth(980)
     , m_validationMessageTimerMagnification(50)
     , m_minimumAccelerated2dCanvasSize(257 * 256)
     , m_layoutFallbackWidth(980)
-    , m_deviceDPI(240)
+    , m_devicePixelRatio(1.0)
     , m_maximumDecodedImageSize(numeric_limits<size_t>::max())
     , m_deviceWidth(480)
     , m_deviceHeight(854)
     , m_maximumDecodedImageSize(numeric_limits<size_t>::max())
     , m_deviceWidth(480)
     , m_deviceHeight(854)
index d92b6df..39af5c7 100644 (file)
@@ -461,8 +461,8 @@ namespace WebCore {
         void setDeviceHeight(int height) { m_deviceHeight = height; }
         int deviceHeight() const { return m_deviceHeight; }
 
         void setDeviceHeight(int height) { m_deviceHeight = height; }
         int deviceHeight() const { return m_deviceHeight; }
 
-        void setDeviceDPI(int deviceDPI) { m_deviceDPI = deviceDPI; }
-        int deviceDPI() const { return m_deviceDPI; }
+        void setDevicePixelRatio(double devicePixelRatio) { m_devicePixelRatio = devicePixelRatio; }
+        double devicePixelRatio() const { return m_devicePixelRatio; }
 
         void setForceCompositingMode(bool flag) { m_forceCompositingMode = flag; }
         bool forceCompositingMode() { return m_forceCompositingMode; }
 
         void setForceCompositingMode(bool flag) { m_forceCompositingMode = flag; }
         bool forceCompositingMode() { return m_forceCompositingMode; }
@@ -592,7 +592,7 @@ namespace WebCore {
         int m_validationMessageTimerMagnification;
         int m_minimumAccelerated2dCanvasSize;
         int m_layoutFallbackWidth;
         int m_validationMessageTimerMagnification;
         int m_minimumAccelerated2dCanvasSize;
         int m_layoutFallbackWidth;
-        int m_deviceDPI;
+        double m_devicePixelRatio;
         size_t m_maximumDecodedImageSize;
         int m_deviceWidth;
         int m_deviceHeight;
         size_t m_maximumDecodedImageSize;
         int m_deviceWidth;
         int m_deviceHeight;
index d2dc989..91e5f43 100644 (file)
@@ -1,3 +1,23 @@
+2012-05-02  Alexander Færøy  <ahf@0x90.dk>
+
+        Rename deviceDPI to devicePixelRatio
+        https://bugs.webkit.org/show_bug.cgi?id=85049
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Add experimental QML API to set and get the device pixel ratio.
+
+        * Shared/WebPreferencesStore.h:
+        (WebKit):
+        * UIProcess/API/qt/qquickwebview.cpp:
+        (QQuickWebViewFlickablePrivate::updateViewportSize):
+        (QQuickWebViewExperimental::devicePixelRatio):
+        (QQuickWebViewExperimental::setDevicePixelRatio):
+        * UIProcess/API/qt/qquickwebview_p.h:
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::sendViewportAttributesChanged):
+        (WebKit::WebPage::updatePreferences):
+
 2012-05-02  Jon Lee  <jonlee@apple.com>
 
         Migrate permission functions to Notification from NotificationCenter
 2012-05-02  Jon Lee  <jonlee@apple.com>
 
         Migrate permission functions to Notification from NotificationCenter
index df011fd..80f7a70 100644 (file)
@@ -129,8 +129,8 @@ namespace WebKit {
     macro(MinimumLogicalFontSize, minimumLogicalFontSize, UInt32, uint32_t, 9) \
     macro(DefaultFontSize, defaultFontSize, UInt32, uint32_t, 16) \
     macro(DefaultFixedFontSize, defaultFixedFontSize, UInt32, uint32_t, 13) \
     macro(MinimumLogicalFontSize, minimumLogicalFontSize, UInt32, uint32_t, 9) \
     macro(DefaultFontSize, defaultFontSize, UInt32, uint32_t, 16) \
     macro(DefaultFixedFontSize, defaultFixedFontSize, UInt32, uint32_t, 13) \
-    macro(LayoutFallbackWidth, layoutFallbackWidth, UInt32, uint32_t, 0) \
-    macro(DeviceDPI, deviceDPI, UInt32, uint32_t, 240) \
+    macro(LayoutFallbackWidth, layoutFallbackWidth, UInt32, uint32_t, 980) \
+    macro(DevicePixelRatio, devicePixelRatio, Double, double, 1.0) \
     macro(DeviceWidth, deviceWidth, UInt32, uint32_t, 480) \
     macro(DeviceHeight, deviceHeight, UInt32, uint32_t, 854) \
     macro(PDFDisplayMode, pdfDisplayMode, UInt32, uint32_t, 1) \
     macro(DeviceWidth, deviceWidth, UInt32, uint32_t, 480) \
     macro(DeviceHeight, deviceHeight, UInt32, uint32_t, 854) \
     macro(PDFDisplayMode, pdfDisplayMode, UInt32, uint32_t, 1) \
index 2cd57bc..44fc20e 100644 (file)
@@ -752,10 +752,6 @@ void QQuickWebViewFlickablePrivate::updateViewportSize()
         return;
 
     WebPreferences* wkPrefs = webPageProxy->pageGroup()->preferences();
         return;
 
     WebPreferences* wkPrefs = webPageProxy->pageGroup()->preferences();
-
-    // FIXME: Remove later; Hardcode a value for now to make sure the DPI adjustment is being tested.
-    wkPrefs->setDeviceDPI(160);
-
     wkPrefs->setDeviceWidth(viewportSize.width());
     wkPrefs->setDeviceHeight(viewportSize.height());
 
     wkPrefs->setDeviceWidth(viewportSize.width());
     wkPrefs->setDeviceHeight(viewportSize.height());
 
@@ -1116,6 +1112,22 @@ void QQuickWebViewExperimental::setUserAgent(const QString& userAgent)
     emit userAgentChanged();
 }
 
     emit userAgentChanged();
 }
 
+double QQuickWebViewExperimental::devicePixelRatio() const
+{
+    Q_D(const QQuickWebView);
+    return d->webPageProxy->pageGroup()->preferences()->devicePixelRatio();
+}
+
+void QQuickWebViewExperimental::setDevicePixelRatio(double devicePixelRatio)
+{
+    Q_D(QQuickWebView);
+    if (devicePixelRatio == this->devicePixelRatio())
+        return;
+
+    d->webPageProxy->pageGroup()->preferences()->setDevicePixelRatio(devicePixelRatio);
+    emit devicePixelRatioChanged();
+}
+
 QQuickUrlSchemeDelegate* QQuickWebViewExperimental::schemeDelegates_At(QDeclarativeListProperty<QQuickUrlSchemeDelegate>* property, int index)
 {
     const QObjectList children = property->object->children();
 QQuickUrlSchemeDelegate* QQuickWebViewExperimental::schemeDelegates_At(QDeclarativeListProperty<QQuickUrlSchemeDelegate>* property, int index)
 {
     const QObjectList children = property->object->children();
index d1d00ee..3772fab 100644 (file)
@@ -265,6 +265,7 @@ class QWEBKIT_EXPORT QQuickWebViewExperimental : public QObject {
     Q_PROPERTY(QWebViewportInfo* viewportInfo READ viewportInfo CONSTANT FINAL)
     Q_PROPERTY(QDeclarativeListProperty<QQuickUrlSchemeDelegate> urlSchemeDelegates READ schemeDelegates)
     Q_PROPERTY(QString userAgent READ userAgent WRITE setUserAgent NOTIFY userAgentChanged)
     Q_PROPERTY(QWebViewportInfo* viewportInfo READ viewportInfo CONSTANT FINAL)
     Q_PROPERTY(QDeclarativeListProperty<QQuickUrlSchemeDelegate> urlSchemeDelegates READ schemeDelegates)
     Q_PROPERTY(QString userAgent READ userAgent WRITE setUserAgent NOTIFY userAgentChanged)
+    Q_PROPERTY(double devicePixelRatio READ devicePixelRatio WRITE setDevicePixelRatio NOTIFY devicePixelRatioChanged)
     Q_ENUMS(NavigationRequestActionExperimental)
 
 public:
     Q_ENUMS(NavigationRequestActionExperimental)
 
 public:
@@ -295,6 +296,8 @@ public:
     void setDatabaseQuotaDialog(QDeclarativeComponent*);
     QString userAgent() const;
     void setUserAgent(const QString& userAgent);
     void setDatabaseQuotaDialog(QDeclarativeComponent*);
     QString userAgent() const;
     void setUserAgent(const QString& userAgent);
+    double devicePixelRatio() const;
+    void setDevicePixelRatio(double);
 
     QWebViewportInfo* viewportInfo();
 
 
     QWebViewportInfo* viewportInfo();
 
@@ -344,6 +347,7 @@ Q_SIGNALS:
     void messageReceived(const QVariantMap& message);
     void proxyAuthenticationDialogChanged();
     void userAgentChanged();
     void messageReceived(const QVariantMap& message);
     void proxyAuthenticationDialogChanged();
     void userAgentChanged();
+    void devicePixelRatioChanged();
 
 private:
     QQuickWebView* q_ptr;
 
 private:
     QQuickWebView* q_ptr;
index a90cba7..8c1617b 100644 (file)
@@ -880,7 +880,7 @@ void WebPage::sendViewportAttributesChanged()
 
     int minimumLayoutFallbackWidth = std::max(settings->layoutFallbackWidth(), m_viewportSize.width());
 
 
     int minimumLayoutFallbackWidth = std::max(settings->layoutFallbackWidth(), m_viewportSize.width());
 
-    ViewportAttributes attr = computeViewportAttributes(m_page->viewportArguments(), minimumLayoutFallbackWidth, settings->deviceWidth(), settings->deviceHeight(), settings->deviceDPI(), m_viewportSize);
+    ViewportAttributes attr = computeViewportAttributes(m_page->viewportArguments(), minimumLayoutFallbackWidth, settings->deviceWidth(), settings->deviceHeight(), static_cast<int>(160 * settings->devicePixelRatio()), m_viewportSize);
 
     setResizesToContentsUsingLayoutSize(attr.layoutSize);
     send(Messages::WebPageProxy::DidChangeViewportProperties(attr));
 
     setResizesToContentsUsingLayoutSize(attr.layoutSize);
     send(Messages::WebPageProxy::DidChangeViewportProperties(attr));
@@ -1946,7 +1946,7 @@ void WebPage::updatePreferences(const WebPreferencesStore& store)
     settings->setDefaultFontSize(store.getUInt32ValueForKey(WebPreferencesKey::defaultFontSizeKey()));
     settings->setDefaultFixedFontSize(store.getUInt32ValueForKey(WebPreferencesKey::defaultFixedFontSizeKey()));
     settings->setLayoutFallbackWidth(store.getUInt32ValueForKey(WebPreferencesKey::layoutFallbackWidthKey()));
     settings->setDefaultFontSize(store.getUInt32ValueForKey(WebPreferencesKey::defaultFontSizeKey()));
     settings->setDefaultFixedFontSize(store.getUInt32ValueForKey(WebPreferencesKey::defaultFixedFontSizeKey()));
     settings->setLayoutFallbackWidth(store.getUInt32ValueForKey(WebPreferencesKey::layoutFallbackWidthKey()));
-    settings->setDeviceDPI(store.getUInt32ValueForKey(WebPreferencesKey::deviceDPIKey()));
+    settings->setDevicePixelRatio(store.getDoubleValueForKey(WebPreferencesKey::devicePixelRatioKey()));
     settings->setDeviceWidth(store.getUInt32ValueForKey(WebPreferencesKey::deviceWidthKey()));
     settings->setDeviceHeight(store.getUInt32ValueForKey(WebPreferencesKey::deviceHeightKey()));
     settings->setEditableLinkBehavior(static_cast<WebCore::EditableLinkBehavior>(store.getUInt32ValueForKey(WebPreferencesKey::editableLinkBehaviorKey())));
     settings->setDeviceWidth(store.getUInt32ValueForKey(WebPreferencesKey::deviceWidthKey()));
     settings->setDeviceHeight(store.getUInt32ValueForKey(WebPreferencesKey::deviceHeightKey()));
     settings->setEditableLinkBehavior(static_cast<WebCore::EditableLinkBehavior>(store.getUInt32ValueForKey(WebPreferencesKey::editableLinkBehaviorKey())));
index 5dfcea7..ed86c9e 100644 (file)
@@ -1,3 +1,14 @@
+2012-05-02  Alexander Færøy  <ahf@0x90.dk>
+
+        Rename deviceDPI to devicePixelRatio
+        https://bugs.webkit.org/show_bug.cgi?id=85049
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Use 1.5 as device pixel ratio for the Qt MiniBrowser.
+
+        * MiniBrowser/qt/qml/BrowserWindow.qml:
+
 2012-05-03  Dongwoo Im  <dw.im@samsung.com>
 
         [EFL][DRT] Implement the LayoutTestController's methods related to the Page Visibility API.
 2012-05-03  Dongwoo Im  <dw.im@samsung.com>
 
         [EFL][DRT] Implement the LayoutTestController's methods related to the Page Visibility API.
index 1e7d10a..9567e8b 100644 (file)
@@ -307,6 +307,7 @@ Rectangle {
             forceActiveFocus();
         }
 
             forceActiveFocus();
         }
 
+        experimental.devicePixelRatio: 1.5
         experimental.preferredMinimumContentsWidth: 980
         experimental.itemSelector: ItemSelector { }
         experimental.alertDialog: AlertDialog { }
         experimental.preferredMinimumContentsWidth: 980
         experimental.itemSelector: ItemSelector { }
         experimental.alertDialog: AlertDialog { }