Merge lp:~osomon/webbrowser-app/dpr-in-plugin into lp:webbrowser-app

Proposed by Olivier Tilloy
Status: Merged
Approved by: Bill Filler
Approved revision: 378
Merged at revision: 384
Proposed branch: lp:~osomon/webbrowser-app/dpr-in-plugin
Merge into: lp:webbrowser-app
Diff against target: 123 lines (+20/-25)
5 files modified
src/Ubuntu/Components/Extras/Browser/UbuntuWebView.qml (+7/-5)
src/Ubuntu/Components/Extras/Browser/plugin.cpp (+13/-0)
src/app/Browser.qml (+0/-3)
src/app/webbrowser-app.cpp (+0/-16)
src/app/webbrowser-app.qml (+0/-1)
To merge this branch: bzr merge lp:~osomon/webbrowser-app/dpr-in-plugin
Reviewer Review Type Date Requested Status
Bill Filler (community) Approve
PS Jenkins bot continuous-integration Needs Fixing
Review via email: mp+190096@code.launchpad.net

Commit message

Expose the correct DPR on the UbuntuWebView component.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Francis Ginther (fginther) wrote :

mako device was stuck, re-building.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Bill Filler (bfiller) wrote :

works, tested it using this qml file:
import QtQuick 2.0
import Ubuntu.Components.Extras.Browser 0.1

UbuntuWebView {
    width: 360
    height: 640
    url: "http://m.facebook.com"
}

Without this fix facebook comes up really small at wrong dpr. With this fix it comes up at the correct dpr.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Ubuntu/Components/Extras/Browser/UbuntuWebView.qml'
2--- src/Ubuntu/Components/Extras/Browser/UbuntuWebView.qml 2013-10-02 13:55:48 +0000
3+++ src/Ubuntu/Components/Extras/Browser/UbuntuWebView.qml 2013-10-09 11:43:11 +0000
4@@ -28,11 +28,13 @@
5
6 signal newTabRequested(url url)
7
8- property real devicePixelRatio: 1.0
9- onDevicePixelRatioChanged: {
10- // Do not make this patch to QtWebKit a hard requirement.
11- if (experimental.hasOwnProperty('devicePixelRatio')) {
12- experimental.devicePixelRatio = devicePixelRatio
13+ QtObject {
14+ property real devicePixelRatio: QtWebKitDPR
15+ onDevicePixelRatioChanged: {
16+ // Do not make this patch to QtWebKit a hard requirement.
17+ if (_webview.experimental.hasOwnProperty('devicePixelRatio')) {
18+ _webview.experimental.devicePixelRatio = devicePixelRatio
19+ }
20 }
21 }
22
23
24=== modified file 'src/Ubuntu/Components/Extras/Browser/plugin.cpp'
25--- src/Ubuntu/Components/Extras/Browser/plugin.cpp 2013-08-09 07:35:51 +0000
26+++ src/Ubuntu/Components/Extras/Browser/plugin.cpp 2013-10-09 11:43:11 +0000
27@@ -35,9 +35,18 @@
28 #include <QtCore/QThread>
29 #include <QtQml>
30
31+static float getQtWebkitDpr()
32+{
33+ QByteArray stringValue = qgetenv("QTWEBKIT_DPR");
34+ bool ok = false;
35+ float value = stringValue.toFloat(&ok);
36+ return ok ? value : 1.0;
37+}
38+
39 void UbuntuBrowserPlugin::initializeEngine(QQmlEngine* engine, const char* uri)
40 {
41 Q_UNUSED(uri);
42+
43 QDir dataLocation(QStandardPaths::writableLocation(QStandardPaths::DataLocation));
44 if (!dataLocation.exists()) {
45 QDir::root().mkpath(dataLocation.absolutePath());
46@@ -45,6 +54,10 @@
47 QQmlContext* context = engine->rootContext();
48 context->setContextProperty("dataLocation", dataLocation.absolutePath());
49
50+ // Set the desired pixel ratio (not needed once we use Qt’s way of
51+ // calculating the proper pixel ratio by device/screen).
52+ context->setContextProperty("QtWebKitDPR", getQtWebkitDpr());
53+
54 // This singleton lives in its own thread to ensure that
55 // disk I/O is not performed in the UI thread.
56 WebThumbnailUtils& utils = WebThumbnailUtils::instance();
57
58=== modified file 'src/app/Browser.qml'
59--- src/app/Browser.qml 2013-10-07 19:01:57 +0000
60+++ src/app/Browser.qml 2013-10-09 11:43:11 +0000
61@@ -29,7 +29,6 @@
62 id: browser
63
64 property bool chromeless: false
65- property real qtwebkitdpr
66 property bool developerExtrasEnabled: false
67
68 property var webappUrlPatterns: null
69@@ -358,8 +357,6 @@
70 enabled: stack.depth === 0
71 visible: tabsModel.currentWebview === webview
72
73- devicePixelRatio: browser.qtwebkitdpr
74-
75 experimental.preferences.developerExtrasEnabled: browser.developerExtrasEnabled
76
77 experimental.certificateVerificationDialog: CertificateVerificationDialog { }
78
79=== modified file 'src/app/webbrowser-app.cpp'
80--- src/app/webbrowser-app.cpp 2013-09-25 15:33:02 +0000
81+++ src/app/webbrowser-app.cpp 2013-10-09 11:43:11 +0000
82@@ -32,17 +32,6 @@
83 #include "webbrowser-app.h"
84 #include "webbrowser-window.h"
85
86-
87-static float getQtWebkitDpr()
88-{
89- const char* envVar = "QTWEBKIT_DPR";
90- QByteArray stringValue = qgetenv(envVar);
91- bool ok;
92- float value = stringValue.toFloat(&ok);
93- float defaultValue = 1.0;
94- return ok ? value : defaultValue;
95-}
96-
97 WebBrowserApp::WebBrowserApp(int& argc, char** argv)
98 : QApplication(argc, argv)
99 , m_arguments(0)
100@@ -158,11 +147,6 @@
101 browser->setProperty("webappUrlPatterns", urlPatterns);
102 }
103
104- // Set the desired pixel ratio (not needed once we use Qt's way of calculating
105- // the proper pixel ratio by device/screen)
106- float webkitDpr = getQtWebkitDpr();
107- browser->setProperty("qtwebkitdpr", webkitDpr);
108-
109 // When a webapp is being launched (by name), the url is pulled from its 'homepage'.
110 QUrl url;
111 if (m_arguments->webappName().isEmpty()) {
112
113=== modified file 'src/app/webbrowser-app.qml'
114--- src/app/webbrowser-app.qml 2013-09-24 21:46:50 +0000
115+++ src/app/webbrowser-app.qml 2013-10-09 11:43:11 +0000
116@@ -22,7 +22,6 @@
117
118 Window {
119 property alias chromeless: browser.chromeless
120- property alias qtwebkitdpr: browser.qtwebkitdpr
121 property alias developerExtrasEnabled: browser.developerExtrasEnabled
122
123 property alias webappUrlPatterns: browser.webappUrlPatterns

Subscribers

People subscribed via source and target branches

to status/vote changes: