[QT][WK2]Add (experimental) viewport info view to Minibrowser/qt.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 15 Dec 2011 12:38:42 +0000 (12:38 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 15 Dec 2011 12:38:42 +0000 (12:38 +0000)
https://bugs.webkit.org/show_bug.cgi?id=72893

Patch by Michael Brüning <michael.bruning@nokia.com> on 2011-12-15
Reviewed by Kenneth Rohde Christiansen.

This patch extends QQuickWebViewExperimental by a property named
viewportInfo, which contains the viewport scalability and
layout and contents size information. This property is exposed to
QML through the experimental extension for QQuickWebView.

.:

* Source/qtwebkit-export.map:

Source/WebKit/qt:

* declarative/experimental/plugin.cpp:

Source/WebKit2:

* Target.pri:
* UIProcess/API/qt/qquickwebview.cpp:
(QQuickWebViewPrivate::didChangeContentsSize):
(QQuickWebViewPrivate::computeViewportConstraints):
(QQuickWebViewPrivate::PostTransitionState::apply): Added applying
contentsSize to viewportInfo.
(QQuickWebViewExperimental::QQuickWebViewExperimental):
(QQuickWebViewExperimental::viewportInfo):
* UIProcess/API/qt/qquickwebview_p.h:
* UIProcess/API/qt/qquickwebview_p_p.h: Moved PostTransitionState::apply
to qquickwebview.cpp. Added friend QWebViewportInfo.
* UIProcess/API/qt/qwebviewportinfo.cpp: Added.
(QWebViewportInfo::QWebViewportInfo):
(QWebViewportInfo::~QWebViewportInfo):
(QWebViewportInfo::contentsSize):
(QWebViewportInfo::currentScale):
(QWebViewportInfo::devicePixelRatio):
(QWebViewportInfo::initialScale):
(QWebViewportInfo::minimumScale):
(QWebViewportInfo::maximumScale):
(QWebViewportInfo::isScalable):
(QWebViewportInfo::layoutSize):
(QWebViewportInfo::didUpdateContentsSize):
(QWebViewportInfo::didUpdateCurrentScale):
(QWebViewportInfo::didUpdateViewportConstraints):
* UIProcess/API/qt/qwebviewportinfo_p.h: Added.
* UIProcess/qt/QtViewportInteractionEngine.h:
(WebKit::QtViewportInteractionEngine::Constraints::Constraints): Added layoutSize.
(WebKit::QtViewportInteractionEngine::constraints): Added property to access m_contraints.

Tools:

* MiniBrowser/qt/MiniBrowser.pro:
* MiniBrowser/qt/MiniBrowser.qrc:
* MiniBrowser/qt/icons/info.png: Added.
* MiniBrowser/qt/qml/BrowserWindow.qml:
* MiniBrowser/qt/qml/ViewportInfoItem.qml: Added.

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

18 files changed:
ChangeLog
Source/WebKit/qt/ChangeLog
Source/WebKit/qt/declarative/experimental/plugin.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/Target.pri
Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp
Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h
Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h
Source/WebKit2/UIProcess/API/qt/qwebviewportinfo.cpp [new file with mode: 0644]
Source/WebKit2/UIProcess/API/qt/qwebviewportinfo_p.h [new file with mode: 0644]
Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.h
Source/qtwebkit-export.map
Tools/ChangeLog
Tools/MiniBrowser/qt/MiniBrowser.pro
Tools/MiniBrowser/qt/MiniBrowser.qrc
Tools/MiniBrowser/qt/icons/info.png [new file with mode: 0644]
Tools/MiniBrowser/qt/qml/BrowserWindow.qml
Tools/MiniBrowser/qt/qml/ViewportInfoItem.qml [new file with mode: 0644]

index 4af94ff..8fae954 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2011-12-15  Michael Brüning  <michael.bruning@nokia.com>
+
+        [QT][WK2]Add (experimental) viewport info view to Minibrowser/qt.
+        https://bugs.webkit.org/show_bug.cgi?id=72893
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        This patch extends QQuickWebViewExperimental by a property named
+        viewportInfo, which contains the viewport scalability and
+        layout and contents size information. This property is exposed to
+        QML through the experimental extension for QQuickWebView.
+
+        * Source/qtwebkit-export.map:
+
 2011-12-14  Ryosuke Niwa  <rniwa@webkit.org>
 
         Add a manual test for caret blinking during forward deletion
index aece8f2..9ffba50 100644 (file)
@@ -1,3 +1,17 @@
+2011-12-15  Michael Brüning  <michael.bruning@nokia.com>
+
+        [QT][WK2]Add (experimental) viewport info view to Minibrowser/qt.
+        https://bugs.webkit.org/show_bug.cgi?id=72893
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        This patch extends QQuickWebViewExperimental by a property named
+        viewportInfo, which contains the viewport scalability and
+        layout and contents size information. This property is exposed to
+        QML through the experimental extension for QQuickWebView.
+
+        * declarative/experimental/plugin.cpp:
+
 2011-12-15  Alexander Færøy  <ahf@0x90.dk>
 
         [Qt] Remove unnecessary methods and members from DeviceOrientationClientQt
index 3b39a2e..d881eb8 100644 (file)
@@ -20,6 +20,7 @@
 #include "qquickwebpage_p.h"
 #include "qquickwebview_p.h"
 #include "qwebdownloaditem_p.h"
+#include "qwebviewportinfo_p.h"
 
 #include "qwebnavigationhistory_p.h"
 
@@ -49,6 +50,8 @@ public:
         qmlRegisterExtendedType<QQuickWebView, QQuickWebViewExperimentalExtension>(uri, 3, 0, "WebView");
         qmlRegisterUncreatableType<QQuickWebViewExperimental>(uri, 3, 0, "QQuickWebViewExperimental",
             QObject::tr("Cannot create separate instance of QQuickWebViewExperimental"));
+        qmlRegisterUncreatableType<QWebViewportInfo>(uri, 3, 0, "QWebViewportInfo",
+            QObject::tr("Cannot create separate instance of QWebViewportInfo"));
     }
 };
 
index c3ec832..5983ff3 100644 (file)
@@ -1,3 +1,45 @@
+2011-12-15  Michael Brüning  <michael.bruning@nokia.com>
+
+        [QT][WK2]Add (experimental) viewport info view to Minibrowser/qt.
+        https://bugs.webkit.org/show_bug.cgi?id=72893
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        This patch extends QQuickWebViewExperimental by a property named
+        viewportInfo, which contains the viewport scalability and
+        layout and contents size information. This property is exposed to
+        QML through the experimental extension for QQuickWebView.
+
+        * Target.pri:
+        * UIProcess/API/qt/qquickwebview.cpp:
+        (QQuickWebViewPrivate::didChangeContentsSize):
+        (QQuickWebViewPrivate::computeViewportConstraints):
+        (QQuickWebViewPrivate::PostTransitionState::apply): Added applying
+        contentsSize to viewportInfo.
+        (QQuickWebViewExperimental::QQuickWebViewExperimental):
+        (QQuickWebViewExperimental::viewportInfo):
+        * UIProcess/API/qt/qquickwebview_p.h:
+        * UIProcess/API/qt/qquickwebview_p_p.h: Moved PostTransitionState::apply
+        to qquickwebview.cpp. Added friend QWebViewportInfo.
+        * UIProcess/API/qt/qwebviewportinfo.cpp: Added.
+        (QWebViewportInfo::QWebViewportInfo):
+        (QWebViewportInfo::~QWebViewportInfo):
+        (QWebViewportInfo::contentsSize):
+        (QWebViewportInfo::currentScale):
+        (QWebViewportInfo::devicePixelRatio):
+        (QWebViewportInfo::initialScale):
+        (QWebViewportInfo::minimumScale):
+        (QWebViewportInfo::maximumScale):
+        (QWebViewportInfo::isScalable):
+        (QWebViewportInfo::layoutSize):
+        (QWebViewportInfo::didUpdateContentsSize):
+        (QWebViewportInfo::didUpdateCurrentScale):
+        (QWebViewportInfo::didUpdateViewportConstraints):
+        * UIProcess/API/qt/qwebviewportinfo_p.h: Added.
+        * UIProcess/qt/QtViewportInteractionEngine.h:
+        (WebKit::QtViewportInteractionEngine::Constraints::Constraints): Added layoutSize.
+        (WebKit::QtViewportInteractionEngine::constraints): Added property to access m_contraints.
+
 2011-12-15  Simon Hausmann  <simon.hausmann@nokia.com>
 
         [WK2] WebPage::m_useFixedLayout variable unininitialized
index 2ea3f6e..a06a161 100644 (file)
@@ -184,6 +184,7 @@ HEADERS += \
     UIProcess/API/qt/qwebnavigationhistory_p_p.h \
     UIProcess/API/qt/qquickwebview_p.h \
     UIProcess/API/qt/qquickwebview_p_p.h \
+    UIProcess/API/qt/qwebviewportinfo_p.h \
     UIProcess/Authentication/AuthenticationChallengeProxy.h \
     UIProcess/Authentication/AuthenticationDecisionListener.h \
     UIProcess/Authentication/WebCredential.h \
@@ -504,6 +505,7 @@ SOURCES += \
     UIProcess/API/qt/qwebnavigationhistory.cpp \
     UIProcess/API/qt/qquickwebview.cpp \
     UIProcess/API/qt/qwebpreferences.cpp \
+    UIProcess/API/qt/qwebviewportinfo.cpp \
     UIProcess/Authentication/AuthenticationChallengeProxy.cpp \
     UIProcess/Authentication/AuthenticationDecisionListener.cpp \
     UIProcess/Authentication/WebCredential.cpp \
index 29db3ee..969eb59 100644 (file)
@@ -40,6 +40,7 @@
 #include "qwebnavigationhistory_p_p.h"
 #include "qwebpreferences_p.h"
 #include "qwebpreferences_p_p.h"
+#include "qwebviewportinfo_p.h"
 
 #include <JavaScriptCore/InitializeThreading.h>
 #include <QDeclarativeEngine>
@@ -177,6 +178,7 @@ void QQuickWebViewPrivate::_q_resume()
 
 void QQuickWebViewPrivate::didChangeContentsSize(const QSize& newSize)
 {
+    Q_Q(QQuickWebView);
     if (useTraditionalDesktopBehaviour)
         return;
 
@@ -188,6 +190,8 @@ void QQuickWebViewPrivate::didChangeContentsSize(const QSize& newSize)
 
     pageView->setWidth(newSize.width());
     pageView->setHeight(newSize.height());
+
+    q->m_experimental->viewportInfo()->didUpdateContentsSize();
 }
 
 void QQuickWebViewPrivate::didChangeViewportProperties(const WebCore::ViewportArguments& args)
@@ -270,6 +274,7 @@ void QQuickWebViewPrivate::updateVisibleContentRectAndScale()
 
     // FIXME: Once we support suspend and resume, this should be delayed until the page is active if the page is suspended.
     webPageProxy()->setFixedVisibleContentRect(alignedVisibleContentRect);
+    q->m_experimental->viewportInfo()->didUpdateCurrentScale();
 }
 
 void QQuickWebViewPrivate::_q_viewportTrajectoryVectorChanged(const QPointF& trajectoryVector)
@@ -312,6 +317,22 @@ void QQuickWebViewPrivate::updateViewportSize()
     updateVisibleContentRectAndScale();
 }
 
+void QQuickWebViewPrivate::PostTransitionState::apply()
+{
+    p->interactionEngine->reset();
+    p->interactionEngine->applyConstraints(p->computeViewportConstraints());
+    p->interactionEngine->pagePositionRequest(position);
+
+    if (contentsSize.isValid()) {
+        p->pageView->setWidth(contentsSize.width());
+        p->pageView->setHeight(contentsSize.height());
+        p->q_ptr->experimental()->viewportInfo()->didUpdateContentsSize();
+    }
+
+    position = QPoint();
+    contentsSize = QSize();
+}
+
 QtViewportInteractionEngine::Constraints QQuickWebViewPrivate::computeViewportConstraints()
 {
     Q_Q(QQuickWebView);
@@ -341,6 +362,9 @@ QtViewportInteractionEngine::Constraints QQuickWebViewPrivate::computeViewportCo
     newConstraints.maximumScale = attr.maximumScale;
     newConstraints.devicePixelRatio = attr.devicePixelRatio;
     newConstraints.isUserScalable = !!attr.userScalable;
+    newConstraints.layoutSize = attr.layoutSize;
+
+    q->m_experimental->viewportInfo()->didUpdateViewportConstraints();
 
     return newConstraints;
 }
@@ -540,6 +564,7 @@ QQuickWebViewExperimental::QQuickWebViewExperimental(QQuickWebView *webView)
     : QObject(webView)
     , q_ptr(webView)
     , d_ptr(webView->d_ptr.data())
+    , m_viewportInfo(new QWebViewportInfo(webView->d_ptr.data(), this))
 {
 }
 
@@ -644,6 +669,11 @@ void QQuickWebViewExperimental::goBackTo(int index)
     d_ptr->navigationHistory->d->goBackTo(index);
 }
 
+QWebViewportInfo* QQuickWebViewExperimental::viewportInfo()
+{
+    return m_viewportInfo;
+}
+
 QQuickWebView::QQuickWebView(QQuickItem* parent)
     : QQuickItem(parent)
     , d_ptr(new QQuickWebViewPrivate(this))
index b6d7629..9222e74 100644 (file)
@@ -34,6 +34,7 @@ class QWebDownloadItem;
 class QWebNavigationHistory;
 class QWebPreferences;
 class QWebPermissionRequest;
+class QWebViewportInfo;
 
 namespace WTR {
 class PlatformWebView;
@@ -174,6 +175,7 @@ class QWEBKIT_EXPORT QQuickWebViewExperimental : public QObject {
     Q_PROPERTY(QDeclarativeComponent* promptDialog READ promptDialog WRITE setPromptDialog NOTIFY promptDialogChanged)
     Q_PROPERTY(QDeclarativeComponent* itemSelector READ itemSelector WRITE setItemSelector NOTIFY itemSelectorChanged)
     Q_PROPERTY(bool useTraditionalDesktopBehaviour READ useTraditionalDesktopBehaviour WRITE setUseTraditionalDesktopBehaviour)
+    Q_PROPERTY(QWebViewportInfo* viewportInfo READ viewportInfo CONSTANT FINAL)
 
 public:
     QQuickWebViewExperimental(QQuickWebView* webView);
@@ -187,6 +189,8 @@ public:
     void setPromptDialog(QDeclarativeComponent*);
     QDeclarativeComponent* itemSelector() const;
     void setItemSelector(QDeclarativeComponent*);
+    
+    QWebViewportInfo* viewportInfo();
 
     bool useTraditionalDesktopBehaviour() const;
     QWebNavigationHistory* navigationHistory() const;
@@ -209,6 +213,7 @@ Q_SIGNALS:
 private:
     QQuickWebView* q_ptr;
     QQuickWebViewPrivate* d_ptr;
+    QWebViewportInfo* m_viewportInfo;
 
     friend class QtWebPageProxy;
     friend class QtWebPageUIClient;
index ca0c9cd..debdfda 100644 (file)
@@ -45,6 +45,7 @@ class WebPageProxy;
 }
 class QtWebPageProxy;
 class QWebNavigationHistory;
+class QWebViewportInfo;
 
 QT_BEGIN_NAMESPACE
 class QDeclarativeComponent;
@@ -55,6 +56,7 @@ class QQuickWebViewPrivate {
     Q_DECLARE_PUBLIC(QQuickWebView)
     friend class QQuickWebViewExperimental;
     friend class QQuickWebPage;
+    friend class QWebViewportInfo;
 
 public:
     static QQuickWebViewPrivate* get(QQuickWebView* q) { return q->d_ptr.data(); }
@@ -122,20 +124,7 @@ private:
             : p(parent)
         { }
 
-        void apply()
-        {
-            p->interactionEngine->reset();
-            p->interactionEngine->applyConstraints(p->computeViewportConstraints());
-            p->interactionEngine->pagePositionRequest(position);
-
-            if (contentsSize.isValid()) {
-                p->pageView->setWidth(contentsSize.width());
-                p->pageView->setHeight(contentsSize.height());
-            }
-
-            position = QPoint();
-            contentsSize = QSize();
-        }
+        void apply();
 
         QQuickWebViewPrivate* p;
         QSize contentsSize;
diff --git a/Source/WebKit2/UIProcess/API/qt/qwebviewportinfo.cpp b/Source/WebKit2/UIProcess/API/qt/qwebviewportinfo.cpp
new file mode 100644 (file)
index 0000000..018938a
--- /dev/null
@@ -0,0 +1,110 @@
+/*
+ * 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 "qwebviewportinfo_p.h"
+
+#include "qquickwebview_p.h"
+#include "qquickwebview_p_p.h"
+
+QWebViewportInfo::QWebViewportInfo(QQuickWebViewPrivate* webViewPrivate, QObject* parent)
+    : QObject(parent)
+    , m_webViewPrivate(webViewPrivate)
+{
+
+}
+
+QWebViewportInfo::~QWebViewportInfo()
+{
+
+}
+
+QSize QWebViewportInfo::contentsSize() const
+{
+    return QSize(m_webViewPrivate->pageView->width(), m_webViewPrivate->pageView->height());
+}
+
+qreal QWebViewportInfo::currentScale() const
+{
+    return m_webViewPrivate->pageView->scale();
+}
+
+QVariant QWebViewportInfo::devicePixelRatio() const
+{
+    if (!m_webViewPrivate->interactionEngine)
+        return QVariant();
+
+    return m_webViewPrivate->interactionEngine->constraints().devicePixelRatio;
+}
+
+QVariant QWebViewportInfo::initialScale() const
+{
+    if (!m_webViewPrivate->interactionEngine)
+        return QVariant();
+
+    return m_webViewPrivate->interactionEngine->constraints().initialScale;
+}
+
+QVariant QWebViewportInfo::minimumScale() const
+{
+    if (!m_webViewPrivate->interactionEngine)
+        return QVariant();
+
+    return m_webViewPrivate->interactionEngine->constraints().minimumScale;
+}
+
+QVariant QWebViewportInfo::maximumScale() const
+{
+    if (!m_webViewPrivate->interactionEngine)
+        return QVariant();
+
+    return m_webViewPrivate->interactionEngine->constraints().maximumScale;
+}
+
+QVariant QWebViewportInfo::isScalable() const
+{
+    if (!m_webViewPrivate->interactionEngine)
+        return QVariant();
+
+    return m_webViewPrivate->interactionEngine->constraints().isUserScalable;
+}
+
+QVariant QWebViewportInfo::layoutSize() const
+{
+    if (!m_webViewPrivate->interactionEngine)
+        return QVariant();
+
+    return m_webViewPrivate->interactionEngine->constraints().layoutSize;
+}
+
+void QWebViewportInfo::didUpdateContentsSize()
+{
+    emit contentsSizeUpdated();
+}
+
+void QWebViewportInfo::didUpdateCurrentScale()
+{
+    emit currentScaleUpdated();
+}
+
+void QWebViewportInfo::didUpdateViewportConstraints()
+{
+    emit viewportConstraintsUpdated();
+}
diff --git a/Source/WebKit2/UIProcess/API/qt/qwebviewportinfo_p.h b/Source/WebKit2/UIProcess/API/qt/qwebviewportinfo_p.h
new file mode 100644 (file)
index 0000000..13231e7
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * 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 qwebviewportinfp_p_h
+#define qwebviewportinfo_p_h
+
+#include "qwebkitglobal.h"
+
+#include <QtCore/QObject>
+#include <QtCore/QPointer>
+#include <QtCore/QSize>
+#include <QtCore/QVariant>
+#include <QtDeclarative/QtDeclarative>
+
+namespace WebCore {
+class ViewportAttributes;
+}
+class QQuickWebViewPrivate;
+
+class QWEBKIT_EXPORT QWebViewportInfo : public QObject {
+    Q_OBJECT
+    Q_PROPERTY(QSize contentsSize READ contentsSize NOTIFY contentsSizeUpdated)
+    Q_PROPERTY(qreal currentScale READ currentScale NOTIFY currentScaleUpdated)
+    Q_PROPERTY(QVariant devicePixelRatio READ devicePixelRatio NOTIFY viewportConstraintsUpdated)
+    Q_PROPERTY(QVariant initialScale READ initialScale NOTIFY viewportConstraintsUpdated)
+    Q_PROPERTY(QVariant isScalable READ isScalable NOTIFY viewportConstraintsUpdated)
+    Q_PROPERTY(QVariant maximumScale READ maximumScale NOTIFY viewportConstraintsUpdated)
+    Q_PROPERTY(QVariant minimumScale READ minimumScale NOTIFY viewportConstraintsUpdated)
+    Q_PROPERTY(QVariant layoutSize READ layoutSize NOTIFY viewportConstraintsUpdated)
+
+signals:
+    void contentsSizeUpdated();
+    void currentScaleUpdated();
+    void viewportConstraintsUpdated();
+
+public:
+    QWebViewportInfo(QQuickWebViewPrivate* webviewPrivate, QObject* parent = 0);
+    virtual ~QWebViewportInfo();
+
+    QSize contentsSize() const;
+    qreal currentScale() const;
+    QVariant devicePixelRatio() const;
+    QVariant initialScale() const;
+    QVariant isScalable() const;
+    QVariant layoutSize() const;
+    QVariant maximumScale() const;
+    QVariant minimumScale() const;
+
+    void didUpdateContentsSize();
+    void didUpdateCurrentScale();
+    void didUpdateViewportConstraints();
+
+private:
+    QQuickWebViewPrivate* m_webViewPrivate;
+};
+
+#endif // qwebviewportinfo_p
index 3628997..634b9c8 100644 (file)
@@ -54,6 +54,7 @@ public:
             , maximumScale(1.8)
             , devicePixelRatio(1.0)
             , isUserScalable(true)
+            , layoutSize(QSize())
         { }
 
         qreal initialScale;
@@ -61,6 +62,7 @@ public:
         qreal maximumScale;
         qreal devicePixelRatio;
         bool isUserScalable;
+        QSize layoutSize;
     };
 
     bool event(QEvent*);
@@ -94,6 +96,7 @@ public:
     void zoomToAreaGestureEnded(const QPointF& touchPoint, const QRectF& targetArea);
     void focusEditableArea(const QRectF& caretArea, const QRectF& targetArea);
 
+    const Constraints& constraints() const { return m_constraints; }
 Q_SIGNALS:
     void contentSuspendRequested();
     void contentResumeRequested();
index b77693c..83205c8 100644 (file)
@@ -130,6 +130,9 @@ qwk_1.0 {
         *QWebDownloadItem;
         non-virtual?thunk?to?QWebDownloadItem*;
         QWebDownloadItem::*;
+        *QWebViewportInfo;
+        non-virtual?thunk?to?QWebViewportInfo;
+        QWebViewportInfo::*;
         *QQuickWebPage;
         non-virtual?thunk?to?QQuickWebPage*;
         QQuickWebPage::*;
index 5ad65aa..4777de0 100644 (file)
@@ -1,3 +1,21 @@
+2011-12-15  Michael Brüning  <michael.bruning@nokia.com>
+
+        [QT][WK2]Add (experimental) viewport info view to Minibrowser/qt.
+        https://bugs.webkit.org/show_bug.cgi?id=72893
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        This patch extends QQuickWebViewExperimental by a property named
+        viewportInfo, which contains the viewport scalability and
+        layout and contents size information. This property is exposed to
+        QML through the experimental extension for QQuickWebView.
+
+        * MiniBrowser/qt/MiniBrowser.pro:
+        * MiniBrowser/qt/MiniBrowser.qrc:
+        * MiniBrowser/qt/icons/info.png: Added.
+        * MiniBrowser/qt/qml/BrowserWindow.qml:
+        * MiniBrowser/qt/qml/ViewportInfoItem.qml: Added.
+
 2011-12-15  Shinya Kawanaka  <shinyak@google.com>
 
         [chromium] WebViewHost::requestCheckingOfText should return immediately if text is empty.
index 8237217..cbe7794 100644 (file)
@@ -31,4 +31,5 @@ RESOURCES += MiniBrowser.qrc
 
 OTHER_FILES += \
     qml/BrowserWindow.qml \
-    qml/ItemSelector.qml
+    qml/ItemSelector.qml \
+    qml/ViewportInfoItem.qml
index b7ebf45..266683d 100644 (file)
@@ -1,5 +1,6 @@
 <RCC>
     <qresource prefix="/">
+        <file>icons/info.png</file>
         <file>icons/next.png</file>
         <file>icons/previous.png</file>
         <file>icons/refresh.png</file>
@@ -8,6 +9,7 @@
         <file>qml/BrowserWindow.qml</file>
         <file>qml/ItemSelector.qml</file>
         <file>qml/MockTouchPoint.qml</file>
+        <file>qml/ViewportInfoItem.qml</file>
         <file>useragentlist.txt</file>
     </qresource>
 </RCC>
diff --git a/Tools/MiniBrowser/qt/icons/info.png b/Tools/MiniBrowser/qt/icons/info.png
new file mode 100644 (file)
index 0000000..db483ff
Binary files /dev/null and b/Tools/MiniBrowser/qt/icons/info.png differ
index a221553..2d6e629 100644 (file)
@@ -160,6 +160,25 @@ Rectangle {
                     }
                 }
             }
+
+            Rectangle {
+                id: viewportInfoButton
+                height: navigationBar.height - 2
+                width: height
+                color: "#efefef"
+
+                Image {
+                    anchors.centerIn: parent
+                    source: "../icons/info.png"
+                }
+
+                MouseArea {
+                    anchors.fill: parent
+                    onClicked: {
+                       viewportInfoItem.visible = !viewportInfoItem.visible
+                    }
+                }
+            }
         }
         Rectangle {
             color: "white"
@@ -235,6 +254,18 @@ Rectangle {
         experimental.itemSelector: ItemSelector { }
     }
 
+    ViewportInfoItem {
+        id: viewportInfoItem
+        anchors {
+            top: navigationBar.bottom
+            left: parent.left
+            right: parent.right
+            bottom: parent.bottom
+        }
+        visible: false
+        viewportInfo : webView.experimental.viewportInfo
+    }
+
     Keys.onPressed: {
         if (((event.modifiers & Qt.ControlModifier) && event.key == Qt.Key_L) || event.key == Qt.key_F6) {
             focusAddressBar()
diff --git a/Tools/MiniBrowser/qt/qml/ViewportInfoItem.qml b/Tools/MiniBrowser/qt/qml/ViewportInfoItem.qml
new file mode 100644 (file)
index 0000000..423b70a
--- /dev/null
@@ -0,0 +1,63 @@
+import QtQuick 2.0
+import QtWebKit 3.0
+
+Rectangle {
+    property var viewportInfo
+
+    color: "black"
+    opacity: 0.8
+
+    Text {
+        id: viewportInfoLabel
+        text: "Viewport Info"
+        color: "white"
+    }
+    Text {
+        id: currentScaleLabel
+        anchors.top: viewportInfoLabel.bottom
+        text: "Current scale: " + viewportInfo.currentScale
+        color: "white"
+    }
+    Text {
+        id: initialScaleLabel
+        anchors.top: currentScaleLabel.bottom
+        text: "Initial scale: " + viewportInfo.initialScale
+        color: "white"
+    }
+    Text {
+        id: minimumScaleLabel
+        anchors.top: initialScaleLabel.bottom
+        text: "Minimum scale: " + viewportInfo.minimumScale
+        color: "white"
+    }
+    Text {
+        id: maximumScaleLabel
+        anchors.top: minimumScaleLabel.bottom
+        text: "Maximum scale: " + viewportInfo.maximumScale
+        color: "white"
+    }
+    Text {
+        id: devicePixelRatioLabel
+        anchors.top: maximumScaleLabel.bottom
+        text: "Device pixel ration: " + viewportInfo.devicePixelRatio
+        color: "white"
+    }
+    Text {
+        id: contentsSizeLabel
+        anchors.top: devicePixelRatioLabel.bottom
+        text: "Contents size: (" + viewportInfo.contentsSize.width + "x" + viewportInfo.contentsSize.height + ")"
+        color: "white"
+    }
+    Text {
+        id: layoutSizeLabel
+        anchors.top: contentsSizeLabel.bottom
+        text: "Viewport layout size: (" + viewportInfo.layoutSize.width + "x" + viewportInfo.layoutSize.height + ")"
+        color: "white"
+    }
+    Text {
+        id: scalableLabel
+        anchors.top: layoutSizeLabel.bottom
+        text: "View " + (viewportInfo.isScalable ? "is " : "is not " ) + "scalable."
+        color: "white"
+    }
+}