Created
November 18, 2011 15:33
-
-
Save Slow3000/1376768 to your computer and use it in GitHub Desktop.
QWebViewportAttributes patch (code part)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From af876c2c6b0d285f313f43cc3bb117af7a2695bc Mon Sep 17 00:00:00 2001 | |
From: Michael Bruning <michael.bruning@nokia.com> | |
Date: Fri, 18 Nov 2011 16:26:13 +0100 | |
Subject: [PATCH] Add experimental QWebViewportAttributes class to experimental API | |
This patch introduces the QWebViewportAttributes which provides infor- | |
mation about the ViewportAttributes in the touch version of the | |
QQuickWebView class. | |
--- | |
.../WebKit/qt/declarative/experimental/plugin.cpp | 3 + | |
Source/WebKit2/Target.pri | 2 + | |
Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp | 9 ++ | |
Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h | 4 + | |
.../UIProcess/API/qt/qwebviewportattributes.cpp | 84 ++++++++++++++++++++ | |
.../UIProcess/API/qt/qwebviewportattributes_p.h | 68 ++++++++++++++++ | |
6 files changed, 170 insertions(+), 0 deletions(-) | |
create mode 100644 Source/WebKit2/UIProcess/API/qt/qwebviewportattributes.cpp | |
create mode 100644 Source/WebKit2/UIProcess/API/qt/qwebviewportattributes_p.h | |
diff --git a/Source/WebKit/qt/declarative/experimental/plugin.cpp b/Source/WebKit/qt/declarative/experimental/plugin.cpp | |
index 3e682fd..73d0201 100644 | |
--- a/Source/WebKit/qt/declarative/experimental/plugin.cpp | |
+++ b/Source/WebKit/qt/declarative/experimental/plugin.cpp | |
@@ -19,6 +19,7 @@ | |
#include "qquickwebpage_p.h" | |
#include "qquickwebview_p.h" | |
+#include "qwebviewportattributes_p.h" | |
#include <QtDeclarative/qdeclarative.h> | |
#include <QtDeclarative/qdeclarativeextensionplugin.h> | |
@@ -43,6 +44,8 @@ public: | |
qmlRegisterExtendedType<QQuickWebView, QQuickWebViewExperimentalExtension>(uri, 3, 0, "WebView"); | |
qmlRegisterUncreatableType<QQuickWebViewExperimental>(uri, 3, 0, "QQuickWebViewExperimental", | |
QObject::tr("Cannot create separate instance of QQuickWebViewExperimental")); | |
+ qmlRegisterUncreatableType<QWebViewportAttributes>(uri, 3, 0, "QWebViewportAttributes", | |
+ QObject::tr("Cannot create separate instance of QWebViewportAttributes")); | |
} | |
}; | |
diff --git a/Source/WebKit2/Target.pri b/Source/WebKit2/Target.pri | |
index 7b26da8..5526a38 100644 | |
--- a/Source/WebKit2/Target.pri | |
+++ b/Source/WebKit2/Target.pri | |
@@ -250,6 +250,7 @@ HEADERS += \ | |
UIProcess/API/qt/qquickwebpage_p_p.h \ | |
UIProcess/API/qt/qquickwebview_p.h \ | |
UIProcess/API/qt/qquickwebview_p_p.h \ | |
+ UIProcess/API/qt/qwebviewportattributes_p.h \ | |
UIProcess/Authentication/AuthenticationChallengeProxy.h \ | |
UIProcess/Authentication/AuthenticationDecisionListener.h \ | |
UIProcess/Authentication/WebCredential.h \ | |
@@ -552,6 +553,7 @@ SOURCES += \ | |
UIProcess/API/qt/qquickwebpage.cpp \ | |
UIProcess/API/qt/qquickwebview.cpp \ | |
UIProcess/API/qt/qwebpreferences.cpp \ | |
+ UIProcess/API/qt/qwebviewportattributes.cpp \ | |
UIProcess/Authentication/AuthenticationChallengeProxy.cpp \ | |
UIProcess/Authentication/AuthenticationDecisionListener.cpp \ | |
UIProcess/Authentication/WebCredential.cpp \ | |
diff --git a/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp b/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp | |
index cd9f28d..34617fc 100644 | |
--- a/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp | |
+++ b/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp | |
@@ -30,6 +30,7 @@ | |
#include "qquickwebpage_p_p.h" | |
#include "qquickwebview_p_p.h" | |
#include "qwebpreferences_p_p.h" | |
+#include "qwebviewportattributes_p.h" | |
#include <QtDeclarative/QQuickCanvas> | |
#include <QtWidgets/QFileDialog> | |
@@ -219,6 +220,8 @@ QtViewportInteractionEngine::Constraints QQuickWebViewPrivate::computeViewportCo | |
newConstraints.devicePixelRatio = attr.devicePixelRatio; | |
newConstraints.isUserScalable = !!attr.userScalable; | |
+ q->m_experimental->attributes()->updateFromViewportAttributes(attr); | |
+ | |
return newConstraints; | |
} | |
@@ -389,6 +392,7 @@ QQuickWebViewExperimental::QQuickWebViewExperimental(QQuickWebView *webView) | |
: QObject(webView) | |
, q_ptr(webView) | |
, d_ptr(webView->d_ptr.data()) | |
+ , m_attributes(new QWebViewportAttributes(this)) | |
{ | |
} | |
@@ -447,6 +451,11 @@ void QQuickWebViewExperimental::setPromptDialog(QDeclarativeComponent* promptDia | |
emit promptDialogChanged(); | |
} | |
+QWebViewportAttributes* QQuickWebViewExperimental::attributes() | |
+{ | |
+ return m_attributes; | |
+} | |
+ | |
QQuickWebView::QQuickWebView(QQuickItem* parent) | |
: QQuickItem(parent) | |
, d_ptr(new QQuickWebViewPrivate) | |
diff --git a/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h b/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h | |
index 0ebb0aa..da01c9f 100644 | |
--- a/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h | |
+++ b/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h | |
@@ -30,6 +30,7 @@ class QQuickWebViewPrivate; | |
class QQuickWebViewExperimental; | |
class QWebDownloadItem; | |
class QWebPreferences; | |
+class QWebViewportAttributes; | |
namespace WTR { | |
class PlatformWebView; | |
@@ -141,6 +142,7 @@ class QWEBKIT_EXPORT QQuickWebViewExperimental : public QObject { | |
Q_PROPERTY(QDeclarativeComponent* alertDialog READ alertDialog WRITE setAlertDialog NOTIFY alertDialogChanged) | |
Q_PROPERTY(QDeclarativeComponent* confirmDialog READ confirmDialog WRITE setConfirmDialog NOTIFY confirmDialogChanged) | |
Q_PROPERTY(QDeclarativeComponent* promptDialog READ promptDialog WRITE setPromptDialog NOTIFY promptDialogChanged) | |
+ Q_PROPERTY(QWebViewportAttributes* attributes READ attributes CONSTANT FINAL) | |
public: | |
QQuickWebViewExperimental(QQuickWebView* webView); | |
@@ -152,6 +154,7 @@ public: | |
void setConfirmDialog(QDeclarativeComponent*); | |
QDeclarativeComponent* promptDialog() const; | |
void setPromptDialog(QDeclarativeComponent*); | |
+ QWebViewportAttributes* attributes(); | |
public Q_SLOTS: | |
void setUseTraditionalDesktopBehaviour(bool enable); | |
@@ -164,6 +167,7 @@ Q_SIGNALS: | |
private: | |
QQuickWebView* q_ptr; | |
QQuickWebViewPrivate* d_ptr; | |
+ QWebViewportAttributes* m_attributes; | |
Q_DECLARE_PRIVATE(QQuickWebView) | |
Q_DECLARE_PUBLIC(QQuickWebView) | |
diff --git a/Source/WebKit2/UIProcess/API/qt/qwebviewportattributes.cpp b/Source/WebKit2/UIProcess/API/qt/qwebviewportattributes.cpp | |
new file mode 100644 | |
index 0000000..faa11fd | |
--- /dev/null | |
+++ b/Source/WebKit2/UIProcess/API/qt/qwebviewportattributes.cpp | |
@@ -0,0 +1,84 @@ | |
+/* | |
+ * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies) | |
+ * | |
+ * This library is free software; you can redistribute it and/or | |
+ * modify it under the terms of the GNU Library General Public | |
+ * License as published by the Free Software Foundation; either | |
+ * version 2 of the License, or (at your option) any later version. | |
+ * | |
+ * This program is distributed in the hope that it will be useful, | |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
+ * Library General Public License for more details. | |
+ * | |
+ * You should have received a copy of the GNU Library General Public License | |
+ * along with this program; see the file COPYING.LIB. If not, write to | |
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | |
+ * Boston, MA 02110-1301, USA. | |
+ * | |
+ */ | |
+ | |
+#include "config.h" | |
+#include "qwebviewportattributes_p.h" | |
+ | |
+#include <WebCore/ViewportArguments.h> | |
+ | |
+QWebViewportAttributes::QWebViewportAttributes(QObject* parent) | |
+ : QObject(parent) | |
+{ | |
+ | |
+} | |
+ | |
+QWebViewportAttributes::~QWebViewportAttributes() | |
+{ | |
+ | |
+} | |
+ | |
+qreal QWebViewportAttributes::initialScale() const | |
+{ | |
+ return m_initialScale; | |
+} | |
+ | |
+qreal QWebViewportAttributes::minimumScale() const | |
+{ | |
+ return m_minimumScale; | |
+} | |
+ | |
+qreal QWebViewportAttributes::maximumScale() const | |
+{ | |
+ return m_maximumScale; | |
+} | |
+ | |
+bool QWebViewportAttributes::isScalable() const | |
+{ | |
+ return m_isScalable; | |
+} | |
+ | |
+QSize QWebViewportAttributes::layoutSize() const | |
+{ | |
+ return m_layoutSize; | |
+} | |
+ | |
+void QWebViewportAttributes::updateFromViewportAttributes(const WebCore::ViewportAttributes& attr) | |
+{ | |
+ if (m_initialScale != attr.initialScale) { | |
+ m_initialScale = attr.initialScale; | |
+ emit initialScaleUpdated(); | |
+ } | |
+ if (m_minimumScale != attr.minimumScale) { | |
+ m_minimumScale = attr.minimumScale; | |
+ emit minimumScaleUpdated(); | |
+ } | |
+ if (m_maximumScale != attr.maximumScale) { | |
+ m_maximumScale = attr.maximumScale; | |
+ emit maximumScaleUpdated(); | |
+ } | |
+ if (m_isScalable != !!attr.userScalable) { | |
+ m_isScalable = !!attr.userScalable; | |
+ emit isScalableUpdated(); | |
+ } | |
+ if (m_layoutSize != QSize(attr.layoutSize)) { | |
+ m_layoutSize = attr.layoutSize; | |
+ emit layoutSizeUpdated(); | |
+ } | |
+} | |
diff --git a/Source/WebKit2/UIProcess/API/qt/qwebviewportattributes_p.h b/Source/WebKit2/UIProcess/API/qt/qwebviewportattributes_p.h | |
new file mode 100644 | |
index 0000000..33ee563 | |
--- /dev/null | |
+++ b/Source/WebKit2/UIProcess/API/qt/qwebviewportattributes_p.h | |
@@ -0,0 +1,68 @@ | |
+/* | |
+ * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies) | |
+ * | |
+ * This library is free software; you can redistribute it and/or | |
+ * modify it under the terms of the GNU Library General Public | |
+ * License as published by the Free Software Foundation; either | |
+ * version 2 of the License, or (at your option) any later version. | |
+ * | |
+ * This program is distributed in the hope that it will be useful, | |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
+ * Library General Public License for more details. | |
+ * | |
+ * You should have received a copy of the GNU Library General Public License | |
+ * along with this program; see the file COPYING.LIB. If not, write to | |
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | |
+ * Boston, MA 02110-1301, USA. | |
+ * | |
+ */ | |
+ | |
+#ifndef qwebviewportattributes_p_h | |
+#define qwebviewportattributes_p_h | |
+ | |
+#include "qwebkitglobal.h" | |
+#include <QtCore/QObject> | |
+#include <QtCore/QSize> | |
+#include <QtDeclarative/QtDeclarative> | |
+ | |
+namespace WebCore { | |
+class ViewportAttributes; | |
+} | |
+ | |
+class QWEBKIT_EXPORT QWebViewportAttributes : public QObject { | |
+ Q_OBJECT | |
+ Q_PROPERTY(qreal initialScale READ initialScale NOTIFY initialScaleUpdated) | |
+ Q_PROPERTY(qreal minimumScale READ minimumScale NOTIFY minimumScaleUpdated) | |
+ Q_PROPERTY(qreal maximumScale READ maximumScale NOTIFY maximumScaleUpdated) | |
+ Q_PROPERTY(bool isScalable READ isScalable NOTIFY isScalableUpdated) | |
+ Q_PROPERTY(QSize layoutSize READ layoutSize NOTIFY layoutSizeUpdated) | |
+ | |
+signals: | |
+ void initialScaleUpdated(); | |
+ void maximumScaleUpdated(); | |
+ void minimumScaleUpdated(); | |
+ void isScalableUpdated(); | |
+ void layoutSizeUpdated(); | |
+ | |
+public: | |
+ QWebViewportAttributes(QObject* parent = 0); | |
+ virtual ~QWebViewportAttributes(); | |
+ | |
+ qreal initialScale() const; | |
+ qreal minimumScale() const; | |
+ qreal maximumScale() const; | |
+ bool isScalable() const; | |
+ | |
+ QSize layoutSize() const; | |
+ | |
+ void updateFromViewportAttributes(const WebCore::ViewportAttributes& attr); | |
+private: | |
+ qreal m_initialScale; | |
+ qreal m_minimumScale; | |
+ qreal m_maximumScale; | |
+ bool m_isScalable; | |
+ QSize m_layoutSize; | |
+}; | |
+ | |
+#endif // qwebviewportattributes_p_h | |
-- | |
1.7.4.1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment