summaryrefslogtreecommitdiff
path: root/Source/WebKit2
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebKit2')
-rw-r--r--Source/WebKit2/ChangeLog130
-rw-r--r--Source/WebKit2/Target.pri3
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qquickurlschemedelegate.cpp27
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qquickurlschemedelegate_p.h11
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp16
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_applicationScheme.qml8
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/qrctest.html6
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/qmltests/resources.qrc1
-rw-r--r--Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeRenderer.cpp4
-rw-r--r--Source/WebKit2/UIProcess/PageViewportController.cpp49
-rw-r--r--Source/WebKit2/UIProcess/PageViewportController.h8
-rw-r--r--Source/WebKit2/UIProcess/qt/PageViewportControllerClientQt.cpp21
-rw-r--r--Source/WebKit2/UIProcess/qt/QtWebPageSGNode.cpp7
-rw-r--r--Source/WebKit2/WebProcess/WebPage/WebPage.cpp4
14 files changed, 252 insertions, 43 deletions
diff --git a/Source/WebKit2/ChangeLog b/Source/WebKit2/ChangeLog
index 64e7283e3..f6c99bedf 100644
--- a/Source/WebKit2/ChangeLog
+++ b/Source/WebKit2/ChangeLog
@@ -1,3 +1,133 @@
+2013-01-24 Michael Brüning <michael.bruning@digia.com>
+
+ [Qt][WK2] Pages / resources cannot be loaded from qrc files.
+ https://bugs.webkit.org/show_bug.cgi?id=107031
+
+ Reviewed by Jocelyn Turcotte.
+
+ Enables WebKit2 Qt applications to load files from the bundled
+ qrc files. This is achieved by adding a url scheme handler for
+ the "qrc" scheme using the application scheme handler and ignoring
+ all handlers for the qrc application scheme that the application might
+ set.
+
+ * UIProcess/API/qt/qquickurlschemedelegate.cpp:
+ (QQuickQrcSchemeDelegate::QQuickQrcSchemeDelegate):
+ (QQuickQrcSchemeDelegate::readResourceAndSend):
+ * UIProcess/API/qt/qquickurlschemedelegate_p.h:
+ (QQuickQrcSchemeDelegate):
+ * UIProcess/API/qt/qquickwebview.cpp:
+ (QQuickWebViewPrivate::initialize):
+ (QQuickWebViewExperimental::schemeDelegates_Append):
+ (QQuickWebViewExperimental::invokeApplicationSchemeHandler):
+ * UIProcess/API/qt/tests/qmltests/WebView/tst_applicationScheme.qml:
+ * UIProcess/API/qt/tests/qmltests/common/qrctest.html: Added.
+ * UIProcess/API/qt/tests/qmltests/resources.qrc:
+
+ (WebKit::NetworkResourceLoader::connectionToWebProcessDidClose):
+ * NetworkProcess/NetworkResourceLoader.h:
+
+2013-01-17 Poul Sysolyatin <psytonx@gmail.com>
+
+ 32-bit build for Qt5 on Mac OS fails.
+ https://bugs.webkit.org/show_bug.cgi?id=107094
+
+ We need to define NS_BUILD_32_LIKE_64 for 32-bit build for Mac OS.
+ Fixed 32-bit build detection for support Qt5.
+
+ Reviewed by Benjamin Poulain.
+
+ * Target.pri:
+
+2013-01-09 Andras Becsi <andras.becsi@digia.com>
+
+ [Qt][EFL][WK2] Remove redundant device pixel ratio adjustment from PageViewportController
+ https://bugs.webkit.org/show_bug.cgi?id=106355
+
+ Reviewed by Kenneth Rohde Christiansen.
+
+ Since r137597 Qt uses the device pixel ratio of the underlying
+ platform window as the device pixel ratio in WebCore.
+ The tiles are rendered with the effective scale (scale adjusted with
+ the device scale factor) and the projection matrix is also adjusted
+ with the device pixel ratio when painting.
+ As a result we can follow the same approach as QtQuick and all the
+ coordinates in PageViewportController need to be in device independent
+ pixels (UI pixels) thus we do no longer need to adjust with the device
+ pixel ratio when calculating the viewport attributes.
+ This simplifies the logic significantly and increases robustness,
+ but does not allow to set a custom device pixel ratio different from
+ the factor of the underlying platform (eg. for testing purposes).
+ This patch is conceptually a follow-up of r137597 and fixes layout
+ and canvas size on retina display.
+
+ * UIProcess/PageViewportController.cpp:
+ (WebKit::PageViewportController::PageViewportController):
+ (WebKit::PageViewportController::innerBoundedViewportScale):
+ (WebKit::PageViewportController::outerBoundedViewportScale):
+ (WebKit::PageViewportController::pixelAlignedFloatPoint):
+ (WebKit::PageViewportController::boundContentsPosition):
+ (WebKit::PageViewportController::didRenderFrame):
+ (WebKit::PageViewportController::pageTransitionViewportReady):
+ (WebKit::PageViewportController::didChangeContentsVisibility):
+ (WebKit::PageViewportController::syncVisibleContents):
+ (WebKit::PageViewportController::visibleContentsSize):
+ (WebKit::PageViewportController::applyScaleAfterRenderingContents):
+ (WebKit::PageViewportController::updateMinimumScaleToFit):
+ * UIProcess/PageViewportController.h:
+ (WebKit::PageViewportController::currentContentsScale):
+ (PageViewportController):
+ * UIProcess/efl/PageViewportControllerClientEfl.cpp:
+ (WebKit::PageViewportControllerClientEfl::updateViewportSize):
+ Adjust the viewport size with the device pixel ratio to keep previous
+ behaviour.
+ * UIProcess/qt/PageViewportControllerClientQt.cpp:
+ (WebKit::PageViewportControllerClientQt::focusEditableArea):
+ (WebKit::PageViewportControllerClientQt::zoomToAreaGestureEnded):
+ * UIProcess/qt/QtWebPageSGNode.cpp:
+ (WebKit::ContentsSGNode::clipRect):
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::sendViewportAttributesChanged):
+
+2013-01-03 Jocelyn Turcotte <jocelyn.turcotte@digia.com>
+
+ [Qt] Fix a crash when the QQuickWebPage is destroyed between the scene graph sync and render.
+ https://bugs.webkit.org/show_bug.cgi?id=106018
+
+ Reviewed by Simon Hausmann.
+
+ The main and rendering threads are only guaranteed to be synchronised in
+ the updatePaintNode call. In every other cases, QQuickItems cannot be
+ safely accessed from the rendering thread.
+
+ Do as the first patch version in
+ https://bugs.webkit.org/show_bug.cgi?id=104574 was doing and copy the
+ ratio value directly to fix the issue.
+
+ Also add a note about the threading issue in QQuickWebPage::updatePaintNode.
+
+ * UIProcess/API/qt/qquickwebpage.cpp:
+ (QQuickWebPage::updatePaintNode):
+ * UIProcess/qt/QtWebPageSGNode.cpp:
+ (WebKit::QtWebPageSGNode::QtWebPageSGNode):
+ * UIProcess/qt/QtWebPageSGNode.h:
+ (QtWebPageSGNode):
+ (WebKit::QtWebPageSGNode::devicePixelRatio):
+ (WebKit::QtWebPageSGNode::setDevicePixelRatio):
+
+2012-12-19 Kenneth Rohde Christiansen <kenneth@webkit.org>
+
+ [EFL][Qt][WK2] Going back to 47-amazing-css3-animation-demos shows nothing or wrong position
+ https://bugs.webkit.org/show_bug.cgi?id=104414
+
+ Reviewed by Simon Hausmann.
+
+ When contents size changes, make sure to apply any pending position
+ change if possible.
+
+ * UIProcess/PageViewportController.cpp:
+ (WebKit::PageViewportController::didChangeContentsSize):
+
2012-12-13 Andras Becsi <andras.becsi@digia.com>
[Qt][WK2] Fix painting on Mac with retina display
diff --git a/Source/WebKit2/Target.pri b/Source/WebKit2/Target.pri
index 098b5b954..aeefadee7 100644
--- a/Source/WebKit2/Target.pri
+++ b/Source/WebKit2/Target.pri
@@ -866,6 +866,9 @@ have?(QTQUICK) {
mac: {
use?(QTKIT) {
DEFINES += NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
+ isEqual(QT_ARCH, "i386") {
+ DEFINES+=NS_BUILD_32_LIKE_64
+ }
INCLUDEPATH += \
$$PWD/../../WebKitLibraries/
HEADERS += \
diff --git a/Source/WebKit2/UIProcess/API/qt/qquickurlschemedelegate.cpp b/Source/WebKit2/UIProcess/API/qt/qquickurlschemedelegate.cpp
index e5d63043b..19f14d5c4 100644
--- a/Source/WebKit2/UIProcess/API/qt/qquickurlschemedelegate.cpp
+++ b/Source/WebKit2/UIProcess/API/qt/qquickurlschemedelegate.cpp
@@ -24,6 +24,10 @@
#include "qquicknetworkreply_p.h"
#include "qquicknetworkrequest_p.h"
+#include <QtCore/QFile>
+#include <QtCore/QFileInfo>
+#include <QtCore/QMimeDatabase>
+
QQuickUrlSchemeDelegate::QQuickUrlSchemeDelegate(QObject* parent)
: QObject(parent)
, m_request(new QQuickNetworkRequest(this))
@@ -51,4 +55,27 @@ QQuickNetworkReply* QQuickUrlSchemeDelegate::reply() const
return m_reply;
}
+QQuickQrcSchemeDelegate::QQuickQrcSchemeDelegate(const QUrl& url)
+ : QQuickUrlSchemeDelegate()
+ , m_fileName(QLatin1Char(':') + url.path())
+{
+}
+
+void QQuickQrcSchemeDelegate::readResourceAndSend()
+{
+ QFile file(m_fileName);
+ QFileInfo fileInfo(file);
+ if (fileInfo.isDir() || !file.open(QIODevice::ReadOnly | QIODevice::Unbuffered))
+ return;
+
+ QByteArray fileData(file.readAll());
+ QMimeDatabase mimeDb;
+ QMimeType mimeType = mimeDb.mimeTypeForFileNameAndData(m_fileName, fileData);
+ file.close();
+
+ reply()->setData(fileData);
+ reply()->setContentType(mimeType.name());
+ reply()->send();
+}
+
#include "moc_qquickurlschemedelegate_p.cpp"
diff --git a/Source/WebKit2/UIProcess/API/qt/qquickurlschemedelegate_p.h b/Source/WebKit2/UIProcess/API/qt/qquickurlschemedelegate_p.h
index 6ee602754..596d3c266 100644
--- a/Source/WebKit2/UIProcess/API/qt/qquickurlschemedelegate_p.h
+++ b/Source/WebKit2/UIProcess/API/qt/qquickurlschemedelegate_p.h
@@ -23,6 +23,7 @@
#include "qwebkitglobal.h"
#include <QObject>
+#include <QtCore/QUrl>
#include <QtQuick/qquickitem.h>
class QQuickNetworkRequest;
@@ -53,6 +54,16 @@ private:
QML_DECLARE_TYPE(QQuickUrlSchemeDelegate)
+class QQuickQrcSchemeDelegate : public QQuickUrlSchemeDelegate {
+ Q_OBJECT
+public:
+ QQuickQrcSchemeDelegate(const QUrl& url);
+ void readResourceAndSend();
+
+private:
+ QString m_fileName;
+};
+
#endif // qquickurlschemedelegate_p_h
diff --git a/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp b/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp
index 437d08b94..bf742ad11 100644
--- a/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp
+++ b/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp
@@ -323,6 +323,7 @@ void QQuickWebViewPrivate::initialize(WKContextRef contextRef, WKPageGroupRef pa
pageClient.initialize(q_ptr, pageViewPrivate->eventHandler.data(), &undoController);
webPageProxy->initializeWebPage();
+ webPageProxy->registerApplicationScheme(ASCIILiteral("qrc"));
q_ptr->setAcceptedMouseButtons(Qt::MouseButtonMask);
q_ptr->setAcceptHoverEvents(true);
@@ -1291,6 +1292,12 @@ QQuickUrlSchemeDelegate* QQuickWebViewExperimental::schemeDelegates_At(QQmlListP
void QQuickWebViewExperimental::schemeDelegates_Append(QQmlListProperty<QQuickUrlSchemeDelegate>* property, QQuickUrlSchemeDelegate *scheme)
{
+ if (!scheme->scheme().compare(QLatin1String("qrc"), Qt::CaseInsensitive)) {
+ qWarning("WARNING: The qrc scheme is reserved to be handled internally. The handler will be ignored.");
+ delete scheme;
+ return;
+ }
+
QObject* schemeParent = property->object;
scheme->setParent(schemeParent);
QQuickWebViewExperimental* webViewExperimental = qobject_cast<QQuickWebViewExperimental*>(property->object->parent());
@@ -1328,6 +1335,15 @@ QQmlListProperty<QQuickUrlSchemeDelegate> QQuickWebViewExperimental::schemeDeleg
void QQuickWebViewExperimental::invokeApplicationSchemeHandler(PassRefPtr<QtRefCountedNetworkRequestData> request)
{
RefPtr<QtRefCountedNetworkRequestData> req = request;
+ if (req->data().m_scheme.startsWith("qrc", false)) {
+ QQuickQrcSchemeDelegate qrcDelegate(QUrl(QString(req->data().m_urlString)));
+ qrcDelegate.request()->setNetworkRequestData(req);
+ qrcDelegate.reply()->setNetworkRequestData(req);
+ qrcDelegate.reply()->setWebViewExperimental(this);
+ qrcDelegate.readResourceAndSend();
+ return;
+ }
+
const QObjectList children = schemeParent->children();
for (int index = 0; index < children.count(); index++) {
QQuickUrlSchemeDelegate* delegate = qobject_cast<QQuickUrlSchemeDelegate*>(children.at(index));
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_applicationScheme.qml b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_applicationScheme.qml
index 4fe081298..e561e1a32 100644
--- a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_applicationScheme.qml
+++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_applicationScheme.qml
@@ -113,5 +113,13 @@ TestWebView {
verify(webView.waitForLoadSucceeded())
compare(webView.title, "title with copyright ©")
}
+
+ function test_qrcScheme() {
+ var testUrl = "qrc:///common/qrctest.html"
+ webView.url = testUrl
+ verify(webView.waitForLoadSucceeded())
+ compare(webView.title, "Loaded from qrc.")
+
+ }
}
}
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/qrctest.html b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/qrctest.html
new file mode 100644
index 000000000..98f25fb7e
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/qrctest.html
@@ -0,0 +1,6 @@
+<html>
+<head><title>Loaded from qrc.</title></head>
+<body>
+Hello. I was loaded from a qrc file. Amazing.
+</body>
+</html>
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/resources.qrc b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/resources.qrc
index 1696aaac1..f251865ef 100644
--- a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/resources.qrc
+++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/resources.qrc
@@ -1,5 +1,6 @@
<RCC>
<qresource prefix="/">
<file>common/change-document-title.js</file>
+ <file>common/qrctest.html</file>
</qresource>
</RCC>
diff --git a/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeRenderer.cpp b/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeRenderer.cpp
index 71c4bcbd6..0e88379bf 100644
--- a/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeRenderer.cpp
+++ b/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeRenderer.cpp
@@ -661,7 +661,9 @@ void LayerTreeRenderer::purgeGLResources()
m_surfaceBackingStores.clear();
#endif
- m_rootLayer->removeAllChildren();
+ if (m_rootLayer) {
+ m_rootLayer->removeAllChildren();
+ }
m_rootLayer.clear();
m_rootLayerID = InvalidWebLayerID;
m_layers.clear();
diff --git a/Source/WebKit2/UIProcess/PageViewportController.cpp b/Source/WebKit2/UIProcess/PageViewportController.cpp
index 8d4bc0176..05ff8b98a 100644
--- a/Source/WebKit2/UIProcess/PageViewportController.cpp
+++ b/Source/WebKit2/UIProcess/PageViewportController.cpp
@@ -47,9 +47,9 @@ PageViewportController::PageViewportController(WebKit::WebPageProxy* proxy, Page
, m_initiallyFitToViewport(true)
, m_hasSuspendedContent(false)
, m_hadUserInteraction(false)
- , m_effectiveScale(1)
+ , m_pageScaleFactor(1)
, m_viewportPosIsLocked(false)
- , m_effectiveScaleIsLocked(false)
+ , m_pageScaleFactorIsLocked(false)
{
// Initializing Viewport Raw Attributes to avoid random negative or infinity scale factors
// if there is a race condition between the first layout and setting the viewport attributes for the first time.
@@ -68,15 +68,15 @@ PageViewportController::PageViewportController(WebKit::WebPageProxy* proxy, Page
float PageViewportController::innerBoundedViewportScale(float viewportScale) const
{
- return clampTo(viewportScale, toViewportScale(m_minimumScaleToFit), toViewportScale(m_rawAttributes.maximumScale));
+ return clampTo(viewportScale, m_minimumScaleToFit, m_rawAttributes.maximumScale);
}
float PageViewportController::outerBoundedViewportScale(float viewportScale) const
{
if (m_allowsUserScaling) {
// Bounded by [0.1, 10.0] like the viewport meta code in WebCore.
- float hardMin = toViewportScale(std::max<float>(0.1, 0.5 * m_minimumScaleToFit));
- float hardMax = toViewportScale(std::min<float>(10, 2 * m_rawAttributes.maximumScale));
+ float hardMin = std::max<float>(0.1, 0.5 * m_minimumScaleToFit);
+ float hardMax = std::min<float>(10, 2 * m_rawAttributes.maximumScale);
return clampTo(viewportScale, hardMin, hardMax);
}
return innerBoundedViewportScale(viewportScale);
@@ -122,6 +122,9 @@ void PageViewportController::didChangeContentsSize(const IntSize& newSize)
if (minimumScaleUpdated)
m_client->didChangeViewportAttributes();
+
+ // We might have pending position change which is now possible.
+ syncVisibleContents();
}
void PageViewportController::didRenderFrame(const IntSize& contentsSize, const IntRect& coveredRect)
@@ -142,12 +145,12 @@ void PageViewportController::didRenderFrame(const IntSize& contentsSize, const I
// All position and scale changes resulting from a web process event should
// go through here to be applied on the viewport to avoid showing incomplete
// tiles to the user during a few milliseconds.
- if (m_effectiveScaleIsLocked) {
- m_client->setContentsScale(m_effectiveScale, false);
- m_effectiveScaleIsLocked = false;
+ if (m_pageScaleFactorIsLocked) {
+ m_client->setContentsScale(m_pageScaleFactor, false);
+ m_pageScaleFactorIsLocked = false;
}
if (m_viewportPosIsLocked) {
- FloatPoint clampedPos = clampViewportToContents(m_viewportPos, m_effectiveScale);
+ FloatPoint clampedPos = clampViewportToContents(m_viewportPos, m_pageScaleFactor);
// There might be rendered frames not covering our requested position yet, wait for it.
if (FloatRect(clampedPos, viewportSizeInContentsCoordinates()).intersects(coveredRect)) {
m_client->setViewportPosition(clampedPos);
@@ -161,7 +164,7 @@ void PageViewportController::pageTransitionViewportReady()
if (!m_rawAttributes.layoutSize.isEmpty()) {
m_hadUserInteraction = false;
float initialScale = m_initiallyFitToViewport ? m_minimumScaleToFit : m_rawAttributes.initialScale;
- applyScaleAfterRenderingContents(innerBoundedViewportScale(toViewportScale(initialScale)));
+ applyScaleAfterRenderingContents(innerBoundedViewportScale(initialScale));
}
// At this point we should already have received the first viewport arguments and the requested scroll
@@ -177,7 +180,7 @@ void PageViewportController::pageDidRequestScroll(const IntPoint& cssPosition)
if (m_hasSuspendedContent)
return;
- FloatRect endVisibleContentRect(clampViewportToContents(cssPosition, m_effectiveScale), viewportSizeInContentsCoordinates());
+ FloatRect endVisibleContentRect(clampViewportToContents(cssPosition, m_pageScaleFactor), viewportSizeInContentsCoordinates());
if (m_lastFrameCoveredRect.intersects(endVisibleContentRect))
m_client->setViewportPosition(endVisibleContentRect.location());
else
@@ -201,8 +204,8 @@ void PageViewportController::didChangeContentsVisibility(const FloatPoint& viewp
{
if (!m_viewportPosIsLocked)
m_viewportPos = viewportPos;
- if (!m_effectiveScaleIsLocked)
- m_effectiveScale = viewportScale;
+ if (!m_pageScaleFactorIsLocked)
+ m_pageScaleFactor = viewportScale;
syncVisibleContents(trajectoryVector);
}
@@ -213,9 +216,9 @@ void PageViewportController::syncVisibleContents(const FloatPoint& trajectoryVec
if (!drawingArea || m_viewportSize.isEmpty() || m_contentsSize.isEmpty())
return;
- FloatRect visibleContentsRect(clampViewportToContents(m_viewportPos, m_effectiveScale), viewportSizeInContentsCoordinates());
+ FloatRect visibleContentsRect(clampViewportToContents(m_viewportPos, m_pageScaleFactor), viewportSizeInContentsCoordinates());
visibleContentsRect.intersect(FloatRect(FloatPoint::zero(), m_contentsSize));
- drawingArea->setVisibleContentsRect(visibleContentsRect, m_effectiveScale, trajectoryVector);
+ drawingArea->setVisibleContentsRect(visibleContentsRect, m_pageScaleFactor, trajectoryVector);
m_client->didChangeVisibleContents();
}
@@ -240,7 +243,7 @@ void PageViewportController::didChangeViewportAttributes(const WebCore::Viewport
WebCore::FloatSize PageViewportController::viewportSizeInContentsCoordinates() const
{
- return WebCore::FloatSize(m_viewportSize.width() / m_effectiveScale, m_viewportSize.height() / m_effectiveScale);
+ return WebCore::FloatSize(m_viewportSize.width() / m_pageScaleFactor, m_viewportSize.height() / m_pageScaleFactor);
}
void PageViewportController::suspendContent()
@@ -265,8 +268,8 @@ void PageViewportController::resumeContent()
void PageViewportController::applyScaleAfterRenderingContents(float scale)
{
- m_effectiveScale = scale;
- m_effectiveScaleIsLocked = true;
+ m_pageScaleFactor = scale;
+ m_pageScaleFactorIsLocked = true;
syncVisibleContents();
}
@@ -282,9 +285,9 @@ bool PageViewportController::updateMinimumScaleToFit(bool userInitiatedUpdate)
if (m_viewportSize.isEmpty() || m_contentsSize.isEmpty())
return false;
- bool currentlyScaledToFit = fuzzyCompare(m_effectiveScale, toViewportScale(m_minimumScaleToFit), 0.001);
+ bool currentlyScaledToFit = fuzzyCompare(m_pageScaleFactor, m_minimumScaleToFit, 0.001);
- float minimumScale = WebCore::computeMinimumScaleFactorForContentContained(m_rawAttributes, WebCore::roundedIntSize(m_viewportSize), WebCore::roundedIntSize(m_contentsSize), devicePixelRatio());
+ float minimumScale = WebCore::computeMinimumScaleFactorForContentContained(m_rawAttributes, WebCore::roundedIntSize(m_viewportSize), WebCore::roundedIntSize(m_contentsSize), 1);
if (minimumScale <= 0)
return false;
@@ -294,11 +297,11 @@ bool PageViewportController::updateMinimumScaleToFit(bool userInitiatedUpdate)
if (!hasSuspendedContent()) {
if (!m_hadUserInteraction || (userInitiatedUpdate && currentlyScaledToFit))
- applyScaleAfterRenderingContents(toViewportScale(m_minimumScaleToFit));
+ applyScaleAfterRenderingContents(m_minimumScaleToFit);
else {
// Ensure the effective scale stays within bounds.
- float boundedScale = innerBoundedViewportScale(m_effectiveScale);
- if (!fuzzyCompare(boundedScale, m_effectiveScale, 0.001))
+ float boundedScale = innerBoundedViewportScale(m_pageScaleFactor);
+ if (!fuzzyCompare(boundedScale, m_pageScaleFactor, 0.001))
applyScaleAfterRenderingContents(boundedScale);
}
}
diff --git a/Source/WebKit2/UIProcess/PageViewportController.h b/Source/WebKit2/UIProcess/PageViewportController.h
index 029228dde..dadbbbefe 100644
--- a/Source/WebKit2/UIProcess/PageViewportController.h
+++ b/Source/WebKit2/UIProcess/PageViewportController.h
@@ -62,7 +62,7 @@ public:
float devicePixelRatio() const;
float minimumContentsScale() const { return m_minimumScaleToFit; }
float maximumContentsScale() const { return m_rawAttributes.maximumScale; }
- float currentContentsScale() const { return fromViewportScale(m_effectiveScale); }
+ float currentContentsScale() const { return m_pageScaleFactor; }
void setHadUserInteraction(bool didUserInteract) { m_hadUserInteraction = didUserInteract; }
@@ -79,8 +79,6 @@ public:
void pageDidRequestScroll(const WebCore::IntPoint& cssPosition);
private:
- float fromViewportScale(float scale) const { return scale / devicePixelRatio(); }
- float toViewportScale(float scale) const { return scale * devicePixelRatio(); }
void syncVisibleContents(const WebCore::FloatPoint &trajectoryVector = WebCore::FloatPoint::zero());
void applyScaleAfterRenderingContents(float scale);
void applyPositionAfterRenderingContents(const WebCore::FloatPoint& pos);
@@ -103,10 +101,10 @@ private:
WebCore::FloatSize m_viewportSize;
WebCore::FloatSize m_contentsSize;
WebCore::IntSize m_clientContentsSize;
- float m_effectiveScale; // Should always be cssScale * devicePixelRatio.
+ float m_pageScaleFactor;
bool m_viewportPosIsLocked;
- bool m_effectiveScaleIsLocked;
+ bool m_pageScaleFactorIsLocked;
WebCore::FloatRect m_lastFrameCoveredRect;
};
diff --git a/Source/WebKit2/UIProcess/qt/PageViewportControllerClientQt.cpp b/Source/WebKit2/UIProcess/qt/PageViewportControllerClientQt.cpp
index b8ccd977b..c0eb16ab9 100644
--- a/Source/WebKit2/UIProcess/qt/PageViewportControllerClientQt.cpp
+++ b/Source/WebKit2/UIProcess/qt/PageViewportControllerClientQt.cpp
@@ -46,7 +46,7 @@ PageViewportControllerClientQt::PageViewportControllerClientQt(QQuickWebView* vi
, m_lastCommittedScale(-1)
, m_zoomOutScale(0)
, m_isUserInteracting(false)
- , m_ignoreViewportChanges(true)
+ , m_ignoreViewportChanges(false)
{
m_scaleAnimation->setDuration(kScaleAnimationDurationMillis);
m_scaleAnimation->setEasingCurve(QEasingCurve::OutCubic);
@@ -124,15 +124,12 @@ void PageViewportControllerClientQt::flickMoveStarted()
m_controller->suspendContent();
m_lastScrollPosition = m_viewportItem->contentPos();
-
- m_ignoreViewportChanges = false;
}
void PageViewportControllerClientQt::flickMoveEnded()
{
// This method is called on the end of the pan or pan kinetic animation.
- m_ignoreViewportChanges = true;
if (!m_isUserInteracting)
m_controller->resumeContent();
}
@@ -153,10 +150,12 @@ void PageViewportControllerClientQt::scaleAnimationStateChanged(QAbstractAnimati
{
switch (newState) {
case QAbstractAnimation::Running:
+ m_ignoreViewportChanges = true;
m_viewportItem->cancelFlick();
m_controller->suspendContent();
break;
case QAbstractAnimation::Stopped:
+ m_ignoreViewportChanges = false;
m_controller->resumeContent();
break;
default:
@@ -182,12 +181,12 @@ void PageViewportControllerClientQt::focusEditableArea(const QRectF& caretArea,
// This can only happen as a result of a user interaction.
ASSERT(m_controller->hadUserInteraction());
- const float editingFixedScale = 2 * m_controller->devicePixelRatio();
+ const float editingFixedScale = 2;
float targetScale = m_controller->innerBoundedViewportScale(editingFixedScale);
const QRectF viewportRect = m_viewportItem->boundingRect();
qreal x;
- const qreal borderOffset = 10 * m_controller->devicePixelRatio();
+ const qreal borderOffset = 10;
if ((targetArea.width() + borderOffset) * targetScale <= viewportRect.width()) {
// Center the input field in the middle of the view, if it is smaller than
// the view at the scale target.
@@ -221,12 +220,12 @@ void PageViewportControllerClientQt::zoomToAreaGestureEnded(const QPointF& touch
if (m_controller->hasSuspendedContent())
return;
- const float margin = 10 * m_controller->devicePixelRatio(); // We want at least a little bit of margin.
+ const float margin = 10; // We want at least a little bit of margin.
QRectF endArea = targetArea.adjusted(-margin, -margin, margin, margin);
const QRectF viewportRect = m_viewportItem->boundingRect();
- qreal minViewportScale = qreal(2.5) * m_controller->devicePixelRatio();
+ qreal minViewportScale = qreal(2.5);
qreal targetScale = viewportRect.size().width() / endArea.size().width();
targetScale = m_controller->innerBoundedViewportScale(qMin(minViewportScale, targetScale));
qreal currentScale = m_pageItem->contentsScale();
@@ -268,7 +267,7 @@ void PageViewportControllerClientQt::zoomToAreaGestureEnded(const QPointF& touch
break;
case ZoomBack: {
if (m_scaleStack.isEmpty()) {
- targetScale = m_controller->minimumContentsScale() * m_controller->devicePixelRatio();
+ targetScale = m_controller->minimumContentsScale();
endPosition.setY(hotspot.y() - viewportHotspot.y() / targetScale);
endPosition.setX(0);
m_zoomOutScale = 0;
@@ -318,8 +317,8 @@ QRectF PageViewportControllerClientQt::nearestValidVisibleContentsRect() const
void PageViewportControllerClientQt::setViewportPosition(const FloatPoint& contentsPoint)
{
QPointF newPosition((m_pageItem->position() + QPointF(contentsPoint)) * m_pageItem->contentsScale());
+ // The contentX and contentY property changes trigger a visible rect update.
m_viewportItem->setContentPos(newPosition);
- updateViewportController();
}
void PageViewportControllerClientQt::setContentsScale(float localScale, bool treatAsInitialValue)
@@ -427,6 +426,7 @@ void PageViewportControllerClientQt::pinchGestureStarted(const QPointF& pinchCen
clearRelativeZoomState();
+ m_ignoreViewportChanges = true;
m_controller->suspendContent();
m_lastPinchCenterInViewportCoordinates = pinchCenterInViewportCoordinates;
@@ -461,6 +461,7 @@ void PageViewportControllerClientQt::pinchGestureEnded()
if (!m_controller->allowsUserScaling())
return;
+ m_ignoreViewportChanges = false;
m_pinchStartScale = -1;
// This will take care of resuming the content, even if no animation was performed.
diff --git a/Source/WebKit2/UIProcess/qt/QtWebPageSGNode.cpp b/Source/WebKit2/UIProcess/qt/QtWebPageSGNode.cpp
index 7b6c1ee87..f536c4217 100644
--- a/Source/WebKit2/UIProcess/qt/QtWebPageSGNode.cpp
+++ b/Source/WebKit2/UIProcess/qt/QtWebPageSGNode.cpp
@@ -87,9 +87,12 @@ private:
for (const QSGClipNode* clip = clipList(); clip; clip = clip->clipList()) {
QMatrix4x4 clipMatrix;
- if (clip->matrix())
+ if (pageNode()->devicePixelRatio() != 1.0) {
+ clipMatrix.scale(pageNode()->devicePixelRatio());
+ if (clip->matrix())
+ clipMatrix *= (*clip->matrix());
+ } else if (clip->matrix())
clipMatrix = *clip->matrix();
- clipMatrix.scale(pageNode()->devicePixelRatio());
QRectF currentClip;
diff --git a/Source/WebKit2/WebProcess/WebPage/WebPage.cpp b/Source/WebKit2/WebProcess/WebPage/WebPage.cpp
index 3c256ec84..f8efcbf40 100644
--- a/Source/WebKit2/WebProcess/WebPage/WebPage.cpp
+++ b/Source/WebKit2/WebProcess/WebPage/WebPage.cpp
@@ -1018,13 +1018,13 @@ void WebPage::sendViewportAttributesChanged()
// Recalculate the recommended layout size, when the available size (device pixel) changes.
Settings* settings = m_page->settings();
- int minimumLayoutFallbackWidth = std::max(settings->layoutFallbackWidth(), int(m_viewportSize.width() / m_page->deviceScaleFactor()));
+ int minimumLayoutFallbackWidth = std::max(settings->layoutFallbackWidth(), m_viewportSize.width());
// If unset we use the viewport dimensions. This fits with the behavior of desktop browsers.
int deviceWidth = (settings->deviceWidth() > 0) ? settings->deviceWidth() : m_viewportSize.width();
int deviceHeight = (settings->deviceHeight() > 0) ? settings->deviceHeight() : m_viewportSize.height();
- ViewportAttributes attr = computeViewportAttributes(m_page->viewportArguments(), minimumLayoutFallbackWidth, deviceWidth, deviceHeight, m_page->deviceScaleFactor(), m_viewportSize);
+ ViewportAttributes attr = computeViewportAttributes(m_page->viewportArguments(), minimumLayoutFallbackWidth, deviceWidth, deviceHeight, 1, m_viewportSize);
attr.initialScale = m_page->viewportArguments().zoom; // Resets auto (-1) if no value was set by user.
// This also takes care of the relayout.