Title: [126582] trunk/Source/WebKit2
- Revision
- 126582
- Author
- [email protected]
- Date
- 2012-08-24 06:50:46 -0700 (Fri, 24 Aug 2012)
Log Message
[Qt][WK2] Fix custom device pixel ratio propagation and add QML API tests
https://bugs.webkit.org/show_bug.cgi?id=88531
Reviewed by Kenneth Rohde Christiansen.
Defer setting the custom device pixel ratio until the page item has
a valid size to make sure that the scale factor reaches the web process.
QML test based on patch by Alexander Færøy.
* UIProcess/API/qt/qquickwebview.cpp:
(QQuickWebViewPrivate::QQuickWebViewPrivate):
(QQuickWebViewPrivate::didRelaunchProcess):
(QQuickWebViewPrivate::didChangeContentsSize):
(QQuickWebViewFlickablePrivate::didChangeContentsSize):
(QQuickWebViewExperimental::devicePixelRatio):
(QQuickWebViewExperimental::setDevicePixelRatio):
* UIProcess/API/qt/qquickwebview_p.h:
* UIProcess/API/qt/qquickwebview_p_p.h:
(QQuickWebViewPrivate):
* UIProcess/API/qt/tests/qmltests/WebView/tst_devicePixelRatio.qml: Added.
Test case for the QML device pixel ratio API.
Modified Paths
Added Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (126581 => 126582)
--- trunk/Source/WebKit2/ChangeLog 2012-08-24 13:46:37 UTC (rev 126581)
+++ trunk/Source/WebKit2/ChangeLog 2012-08-24 13:50:46 UTC (rev 126582)
@@ -1,3 +1,28 @@
+2012-08-24 Andras Becsi <[email protected]>
+
+ [Qt][WK2] Fix custom device pixel ratio propagation and add QML API tests
+ https://bugs.webkit.org/show_bug.cgi?id=88531
+
+ Reviewed by Kenneth Rohde Christiansen.
+
+ Defer setting the custom device pixel ratio until the page item has
+ a valid size to make sure that the scale factor reaches the web process.
+
+ QML test based on patch by Alexander Færøy.
+
+ * UIProcess/API/qt/qquickwebview.cpp:
+ (QQuickWebViewPrivate::QQuickWebViewPrivate):
+ (QQuickWebViewPrivate::didRelaunchProcess):
+ (QQuickWebViewPrivate::didChangeContentsSize):
+ (QQuickWebViewFlickablePrivate::didChangeContentsSize):
+ (QQuickWebViewExperimental::devicePixelRatio):
+ (QQuickWebViewExperimental::setDevicePixelRatio):
+ * UIProcess/API/qt/qquickwebview_p.h:
+ * UIProcess/API/qt/qquickwebview_p_p.h:
+ (QQuickWebViewPrivate):
+ * UIProcess/API/qt/tests/qmltests/WebView/tst_devicePixelRatio.qml: Added.
+ Test case for the QML device pixel ratio API.
+
2012-08-24 Kangil Han <[email protected]>
[EFL] Fix compile warning
Modified: trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp (126581 => 126582)
--- trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp 2012-08-24 13:46:37 UTC (rev 126581)
+++ trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp 2012-08-24 13:50:46 UTC (rev 126582)
@@ -272,6 +272,7 @@
, m_navigatorQtObjectEnabled(false)
, m_renderToOffscreenBuffer(false)
, m_allowAnyHTTPSCertificateForLocalHost(false)
+ , m_customDevicePixelRatio(0)
, m_loadProgress(0)
{
viewport->setClip(true);
@@ -473,7 +474,10 @@
{
qWarning("WARNING: The web process has been successfully restarted.");
+ // Reset to default so that the later update can reach the web process.
+ webPageProxy->setCustomDeviceScaleFactor(0);
webPageProxy->drawingArea()->setSize(viewSize(), IntSize());
+
updateViewportSize();
updateUserScripts();
}
@@ -789,6 +793,20 @@
emit q_ptr->experimental()->messageReceived(variantMap);
}
+void QQuickWebViewPrivate::didChangeContentsSize(const QSize& newSize)
+{
+ if (newSize.isEmpty() || !m_customDevicePixelRatio || webPageProxy->deviceScaleFactor() == m_customDevicePixelRatio)
+ return;
+
+ // DrawingAreaProxy returns early if the page size is empty
+ // and the device pixel ratio property is propagated from QML
+ // before the QML page item has a valid size yet, thus the
+ // information would not reach the web process.
+ // Set the custom device pixel ratio requested from QML as soon
+ // as the content item has a valid size.
+ webPageProxy->setCustomDeviceScaleFactor(m_customDevicePixelRatio);
+}
+
QQuickWebViewLegacyPrivate::QQuickWebViewLegacyPrivate(QQuickWebView* viewport)
: QQuickWebViewPrivate(viewport)
{
@@ -877,6 +895,7 @@
Q_Q(QQuickWebView);
pageView->setContentsSize(newSize); // emits contentsSizeChanged()
+ QQuickWebViewPrivate::didChangeContentsSize(newSize);
m_viewportHandler->pageContentsSizeChanged(newSize, q->boundingRect().size().toSize());
}
@@ -1233,19 +1252,23 @@
down but still provide a better looking image.
*/
-double QQuickWebViewExperimental::devicePixelRatio() const
+qreal QQuickWebViewExperimental::devicePixelRatio() const
{
Q_D(const QQuickWebView);
+
+ if (d->m_customDevicePixelRatio)
+ return d->m_customDevicePixelRatio;
+
return d->webPageProxy->deviceScaleFactor();
}
-void QQuickWebViewExperimental::setDevicePixelRatio(double devicePixelRatio)
+void QQuickWebViewExperimental::setDevicePixelRatio(qreal devicePixelRatio)
{
Q_D(QQuickWebView);
- if (devicePixelRatio == this->devicePixelRatio())
+ if (0 >= devicePixelRatio || devicePixelRatio == this->devicePixelRatio())
return;
- d->webPageProxy->setCustomDeviceScaleFactor(devicePixelRatio);
+ d->m_customDevicePixelRatio = devicePixelRatio;
emit devicePixelRatioChanged();
}
Modified: trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h (126581 => 126582)
--- trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h 2012-08-24 13:46:37 UTC (rev 126581)
+++ trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h 2012-08-24 13:50:46 UTC (rev 126582)
@@ -255,7 +255,7 @@
Q_PROPERTY(int preferredMinimumContentsWidth WRITE setPreferredMinimumContentsWidth READ preferredMinimumContentsWidth NOTIFY preferredMinimumContentsWidthChanged)
Q_PROPERTY(int deviceWidth WRITE setDeviceWidth READ deviceWidth NOTIFY deviceWidthChanged)
Q_PROPERTY(int deviceHeight WRITE setDeviceHeight READ deviceHeight NOTIFY deviceHeightChanged)
- Q_PROPERTY(double devicePixelRatio READ devicePixelRatio WRITE setDevicePixelRatio NOTIFY devicePixelRatioChanged)
+ Q_PROPERTY(qreal devicePixelRatio READ devicePixelRatio WRITE setDevicePixelRatio NOTIFY devicePixelRatioChanged)
Q_PROPERTY(QWebNavigationHistory* navigationHistory READ navigationHistory CONSTANT FINAL)
@@ -312,8 +312,8 @@
void setDeviceWidth(int);
int deviceHeight() const;
void setDeviceHeight(int);
- double devicePixelRatio() const;
- void setDevicePixelRatio(double);
+ qreal devicePixelRatio() const;
+ void setDevicePixelRatio(qreal);
QList<QUrl> userScripts() const;
void setUserScripts(const QList<QUrl>& userScripts);
QUrl remoteInspectorUrl() const;
Modified: trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h (126581 => 126582)
--- trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h 2012-08-24 13:46:37 UTC (rev 126581)
+++ trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h 2012-08-24 13:50:46 UTC (rev 126582)
@@ -128,7 +128,7 @@
WebCore::IntSize viewSize() const;
void didReceiveMessageFromNavigatorQtObject(const String& message);
virtual void pageDidRequestScroll(const QPoint& pos) { }
- virtual void didChangeContentsSize(const QSize& newSize) { }
+ virtual void didChangeContentsSize(const QSize& newSize);
void processDidCrash();
void didRelaunchProcess();
PassOwnPtr<WebKit::DrawingAreaProxy> createDrawingAreaProxy();
@@ -190,6 +190,7 @@
bool m_navigatorQtObjectEnabled;
bool m_renderToOffscreenBuffer;
bool m_allowAnyHTTPSCertificateForLocalHost;
+ qreal m_customDevicePixelRatio;
WTF::String m_iconUrl;
int m_loadProgress;
WTF::String m_currentUrl;
Added: trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_devicePixelRatio.qml (0 => 126582)
--- trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_devicePixelRatio.qml (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_devicePixelRatio.qml 2012-08-24 13:50:46 UTC (rev 126582)
@@ -0,0 +1,62 @@
+import QtQuick 2.0
+import QtTest 1.0
+import QtWebKit 3.0
+import QtWebKit.experimental 1.0
+import "../common"
+
+
+TestWebView {
+ id: webView
+ property variant lastResult
+ width: 400
+ height: 300
+ focus: true
+
+ SignalSpy {
+ id: resultSpy
+ target: webView
+ signalName: "lastResultChanged"
+ }
+
+ TestCase {
+ name: "DevicePixelRatio"
+
+ function init() {
+ resultSpy.clear()
+ webView.lastResult = null
+ }
+
+ function test_devicePixelRatio() {
+ resultSpy.clear()
+ webView.url = ""
+ webView.experimental.devicePixelRatio = 2.0
+ verify(webView.waitForLoadSucceeded())
+
+ webView.experimental.evaluateJavaScript(
+ "(function() { return window.devicePixelRatio })()",
+ function(result) {
+ webView.lastResult = result
+ })
+
+ resultSpy.wait()
+ compare(webView.lastResult, 2.0)
+ compare(webView.lastResult, webView.experimental.devicePixelRatio)
+ }
+
+ function test_devicePixelRatioMediaQuery() {
+ resultSpy.clear()
+ webView.url = ""
+ webView.experimental.devicePixelRatio = 2.0
+ verify(webView.waitForLoadSucceeded())
+
+ webView.experimental.evaluateJavaScript(
+ "(function() { return window.matchMedia(\"(-webkit-device-pixel-ratio: 2)\").matches })()",
+ function(result) {
+ webView.lastResult = result
+ })
+
+ resultSpy.wait()
+ verify(webView.lastResult)
+ }
+ }
+}
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes