[Qt] Make navigation actions properly usable in QML.
authoralexis.menard@openbossa.org <alexis.menard@openbossa.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 4 Aug 2011 14:57:04 +0000 (14:57 +0000)
committeralexis.menard@openbossa.org <alexis.menard@openbossa.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 4 Aug 2011 14:57:04 +0000 (14:57 +0000)
https://bugs.webkit.org/show_bug.cgi?id=65624

Source/WebKit2:

Add a new class that is exposed in QML to control the navigation
like reload/stop/back/forward. Enums are not very QML friendly,
it not possible to use enums that are not declared in the same class
than the object exposed in QML, therefore it makes hard the sharing
between the desktop and the touch views. In addition namespaced enums are
even harder to support in QML. QWebNavigationController is
not really meant to be used in C++ but it is exported for convenience
reason (tests and MiniBrowser) so its API is not meant to be public but
exposed in QML through properties and convenience slots. The QML code to use
the navigation action in QML will look like "desktopView.navigation.reload();"
or "if (desktopView.navigation.reloadAction.enabled) ...".

Reviewed by Benjamin Poulain.

* UIProcess/API/qt/WKView.h: To get the forward header generated
* UIProcess/API/qt/qdesktopwebview.cpp:
(QDesktopWebViewPrivate::QDesktopWebViewPrivate):
(QDesktopWebView::navigationController):
* UIProcess/API/qt/qdesktopwebview.h:
* UIProcess/API/qt/qdesktopwebview_p.h:
* UIProcess/API/qt/qmlplugin/plugin.cpp:
(WebKit2QmlPlugin::registerTypes):
* UIProcess/API/qt/qtouchwebpage.cpp:
(QTouchWebPage::navigationController):
(QTouchWebPagePrivate::QTouchWebPagePrivate):
* UIProcess/API/qt/qtouchwebpage.h:
* UIProcess/API/qt/qtouchwebpage_p.h:
* UIProcess/API/qt/qwebnavigationcontroller.cpp: Added.
(QWebNavigationControllerPrivate::QWebNavigationControllerPrivate):
(QWebNavigationController::QWebNavigationController):
(QWebNavigationController::~QWebNavigationController):
(QWebNavigationController::backAction):
(QWebNavigationController::forwardAction):
(QWebNavigationController::stopAction):
(QWebNavigationController::reloadAction):
(QWebNavigationController::navigationAction):
(QWebNavigationController::back):
(QWebNavigationController::forward):
(QWebNavigationController::stop):
(QWebNavigationController::reload):
* UIProcess/API/qt/qwebnavigationcontroller.h: Added.
* UIProcess/API/qt/tests/commonviewtests/webviewabstraction.cpp:
(WebViewAbstraction::triggerNavigationAction):
* UIProcess/API/qt/tests/qdesktopwebview/tst_qdesktopwebview.cpp:
(tst_QDesktopWebView::navigationActionsStatusAtStartup):
(LoadStartedCatcher::onLoadStarted):
(tst_QDesktopWebView::stopActionEnabledAfterLoadStarted):
* UIProcess/API/qt/tests/qtouchwebview/tst_qtouchwebview.cpp:
(tst_QTouchWebView::navigationActionsStatusAtStartup):
* WebKit2API.pri:

Tools:

Fix compilation after the introduction of QWebNavigationController.

Reviewed by Benjamin Poulain.

* MiniBrowser/qt/BrowserView.cpp:
(BrowserView::navigationAction):

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

17 files changed:
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/qt/WKView.h
Source/WebKit2/UIProcess/API/qt/qdesktopwebview.cpp
Source/WebKit2/UIProcess/API/qt/qdesktopwebview.h
Source/WebKit2/UIProcess/API/qt/qdesktopwebview_p.h
Source/WebKit2/UIProcess/API/qt/qmlplugin/plugin.cpp
Source/WebKit2/UIProcess/API/qt/qtouchwebpage.cpp
Source/WebKit2/UIProcess/API/qt/qtouchwebpage.h
Source/WebKit2/UIProcess/API/qt/qtouchwebpage_p.h
Source/WebKit2/UIProcess/API/qt/qwebnavigationcontroller.cpp [new file with mode: 0644]
Source/WebKit2/UIProcess/API/qt/qwebnavigationcontroller.h [new file with mode: 0644]
Source/WebKit2/UIProcess/API/qt/tests/commonviewtests/webviewabstraction.cpp
Source/WebKit2/UIProcess/API/qt/tests/qdesktopwebview/tst_qdesktopwebview.cpp
Source/WebKit2/UIProcess/API/qt/tests/qtouchwebview/tst_qtouchwebview.cpp
Source/WebKit2/WebKit2API.pri
Tools/ChangeLog
Tools/MiniBrowser/qt/BrowserView.cpp

index 645d0ab..009b0c3 100644 (file)
@@ -1,3 +1,59 @@
+2011-08-04  Alexis Menard  <alexis.menard@openbossa.org>
+
+        [Qt] Make navigation actions properly usable in QML.
+        https://bugs.webkit.org/show_bug.cgi?id=65624
+
+        Add a new class that is exposed in QML to control the navigation
+        like reload/stop/back/forward. Enums are not very QML friendly,
+        it not possible to use enums that are not declared in the same class
+        than the object exposed in QML, therefore it makes hard the sharing
+        between the desktop and the touch views. In addition namespaced enums are
+        even harder to support in QML. QWebNavigationController is
+        not really meant to be used in C++ but it is exported for convenience
+        reason (tests and MiniBrowser) so its API is not meant to be public but
+        exposed in QML through properties and convenience slots. The QML code to use
+        the navigation action in QML will look like "desktopView.navigation.reload();"
+        or "if (desktopView.navigation.reloadAction.enabled) ...".
+
+        Reviewed by Benjamin Poulain.
+
+        * UIProcess/API/qt/WKView.h: To get the forward header generated
+        * UIProcess/API/qt/qdesktopwebview.cpp:
+        (QDesktopWebViewPrivate::QDesktopWebViewPrivate):
+        (QDesktopWebView::navigationController):
+        * UIProcess/API/qt/qdesktopwebview.h:
+        * UIProcess/API/qt/qdesktopwebview_p.h:
+        * UIProcess/API/qt/qmlplugin/plugin.cpp:
+        (WebKit2QmlPlugin::registerTypes):
+        * UIProcess/API/qt/qtouchwebpage.cpp:
+        (QTouchWebPage::navigationController):
+        (QTouchWebPagePrivate::QTouchWebPagePrivate):
+        * UIProcess/API/qt/qtouchwebpage.h:
+        * UIProcess/API/qt/qtouchwebpage_p.h:
+        * UIProcess/API/qt/qwebnavigationcontroller.cpp: Added.
+        (QWebNavigationControllerPrivate::QWebNavigationControllerPrivate):
+        (QWebNavigationController::QWebNavigationController):
+        (QWebNavigationController::~QWebNavigationController):
+        (QWebNavigationController::backAction):
+        (QWebNavigationController::forwardAction):
+        (QWebNavigationController::stopAction):
+        (QWebNavigationController::reloadAction):
+        (QWebNavigationController::navigationAction):
+        (QWebNavigationController::back):
+        (QWebNavigationController::forward):
+        (QWebNavigationController::stop):
+        (QWebNavigationController::reload):
+        * UIProcess/API/qt/qwebnavigationcontroller.h: Added.
+        * UIProcess/API/qt/tests/commonviewtests/webviewabstraction.cpp:
+        (WebViewAbstraction::triggerNavigationAction):
+        * UIProcess/API/qt/tests/qdesktopwebview/tst_qdesktopwebview.cpp:
+        (tst_QDesktopWebView::navigationActionsStatusAtStartup):
+        (LoadStartedCatcher::onLoadStarted):
+        (tst_QDesktopWebView::stopActionEnabledAfterLoadStarted):
+        * UIProcess/API/qt/tests/qtouchwebview/tst_qtouchwebview.cpp:
+        (tst_QTouchWebView::navigationActionsStatusAtStartup):
+        * WebKit2API.pri:
+
 2011-08-03  Jeff Miller  <jeffm@apple.com>
 
         Use of AVFoundation should default to off on Windows
index 0b2e0a4..84ba1f7 100644 (file)
@@ -24,5 +24,6 @@
 #include <WebKit2/qdesktopwebview.h>
 #include <WebKit2/qtouchwebview.h>
 #include <WebKit2/qtouchwebpage.h>
+#include <WebKit2/qwebnavigationcontroller.h>
 
 #endif /* WKView_h */
index 56eab72..c603109 100644 (file)
@@ -41,6 +41,7 @@ QDesktopWebViewPrivate::QDesktopWebViewPrivate(QDesktopWebView* q, WKContextRef
     : q(q)
     , page(this, contextRef ? new QWKContext(contextRef) : defaultWKContext(), pageGroupRef)
     , isCrashed(false)
+    , navigationController(0)
 {
 }
 
@@ -209,9 +210,11 @@ QString QDesktopWebView::title() const
     return d->page.title();
 }
 
-QAction* QDesktopWebView::navigationAction(QtWebKit::NavigationAction which) const
+QWebNavigationController* QDesktopWebView::navigationController() const
 {
-    return d->page.navigationAction(which);
+    if (!d->navigationController)
+        d->navigationController = new QWebNavigationController(&d->page);
+    return d->navigationController;
 }
 
 static void paintCrashedPage(QPainter* painter, const QRectF& rect)
index 15821f9..590fabd 100644 (file)
@@ -29,6 +29,7 @@
 
 class QDesktopWebViewPrivate;
 class QWebError;
+class QWebNavigationController;
 
 QT_BEGIN_NAMESPACE
 class QFocusEvent;
@@ -52,11 +53,9 @@ class QWEBKIT_EXPORT QDesktopWebView : public QSGPaintedItem {
     Q_PROPERTY(QString title READ title NOTIFY titleChanged)
     Q_PROPERTY(QUrl url READ url NOTIFY urlChanged)
     Q_PROPERTY(int loadProgress READ loadProgress NOTIFY loadProgressChanged)
-
-    Q_ENUMS(NavigationAction)
+    Q_PROPERTY(QWebNavigationController* navigation READ navigationController CONSTANT)
 
 public:
-
     QDesktopWebView(QSGItem* parent = 0);
     virtual ~QDesktopWebView();
 
@@ -64,7 +63,7 @@ public:
     QString title() const;
     int loadProgress() const;
 
-    Q_INVOKABLE QAction* navigationAction(QtWebKit::NavigationAction which) const;
+    QWebNavigationController* navigationController() const;
 
 public Q_SLOTS:
      void load(const QUrl&);
index 879787e..8c8ad82 100644 (file)
@@ -22,6 +22,7 @@
 #define qdesktopwebview_p_h
 
 #include "qdesktopwebpageproxy.h"
+#include "qwebnavigationcontroller.h"
 #include "ViewInterface.h"
 
 class QDesktopWebView;
@@ -37,6 +38,7 @@ public:
     QDesktopWebPageProxy page;
 
     bool isCrashed;
+    QWebNavigationController* navigationController;
 
 private:
     /* Implementation of ViewInterface */
index 41ea7fd..4bdf42c 100644 (file)
@@ -20,6 +20,7 @@
 #include "qdesktopwebview.h"
 #include "qtouchwebpage.h"
 #include "qtouchwebview.h"
+#include "qwebnavigationcontroller.h"
 
 #include <QtDeclarative/qdeclarative.h>
 #include <QtDeclarative/qdeclarativeextensionplugin.h>
@@ -34,6 +35,7 @@ public:
         Q_ASSERT(QLatin1String(uri) == QLatin1String("QtWebKit.experimental"));
         qmlRegisterType<QDesktopWebView>(uri, 5, 0, "DesktopWebView");
         qmlRegisterType<QTouchWebView>(uri, 5, 0, "TouchWebView");
+        qmlRegisterUncreatableType<QWebNavigationController>(uri, 5, 0, "NavigationController", QObject::tr("Cannot create separate instance of NavigationController"));
         qmlRegisterUncreatableType<QTouchWebPage>(uri, 5, 0, "TouchWebPage", QObject::tr("Cannot create separate instance of TouchWebPage, use TouchWebView"));
     }
 };
index 8fcabf6..cd2b627 100644 (file)
@@ -122,14 +122,17 @@ void QTouchWebPage::geometryChanged(const QRectF& newGeometry, const QRectF& old
         d->page->setDrawingAreaSize(newGeometry.size().toSize());
 }
 
-QAction* QTouchWebPage::navigationAction(QtWebKit::NavigationAction which)
+QWebNavigationController* QTouchWebPage::navigationController() const
 {
-    return d->page->navigationAction(which);
+    if (!d->navigationController)
+        d->navigationController = new QWebNavigationController(d->page);
+    return d->navigationController;
 }
 
 QTouchWebPagePrivate::QTouchWebPagePrivate(QTouchWebPage* view)
     : q(view)
     , page(0)
+    , navigationController(0)
 {
 }
 
index 4cb5ea7..54d7c04 100644 (file)
@@ -30,6 +30,7 @@
 class QTouchWebPagePrivate;
 class QTouchWebPageProxy;
 class QWebError;
+class QWebNavigationController;
 
 namespace WebKit {
     class TouchViewInterface;
@@ -40,6 +41,7 @@ class QWEBKIT_EXPORT QTouchWebPage : public QSGPaintedItem {
     Q_PROPERTY(QString title READ title NOTIFY titleChanged)
     Q_PROPERTY(QUrl url READ url NOTIFY urlChanged)
     Q_PROPERTY(int loadProgress READ loadProgress NOTIFY loadProgressChanged)
+    Q_PROPERTY(QWebNavigationController* navigation READ navigationController CONSTANT)
 
 public:
     QTouchWebPage(QSGItem* parent = 0);
@@ -52,7 +54,7 @@ public:
     Q_INVOKABLE QString title() const;
     int loadProgress() const;
 
-    QAction* navigationAction(QtWebKit::NavigationAction which);
+    QWebNavigationController* navigationController() const;
 
     virtual void paint(QPainter*);
     virtual bool event(QEvent*);
index 4cca30e..489ab1e 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <QMenu>
 #include "qtouchwebpage.h"
+#include "qwebnavigationcontroller.h"
 
 class QRectF;
 class QString;
@@ -42,6 +43,7 @@ public:
 
     QTouchWebPage* const q;
     QTouchWebPageProxy* page;
+    QWebNavigationController* navigationController;
 };
 
 #endif /* qtouchwebpage_p_h */
diff --git a/Source/WebKit2/UIProcess/API/qt/qwebnavigationcontroller.cpp b/Source/WebKit2/UIProcess/API/qt/qwebnavigationcontroller.cpp
new file mode 100644 (file)
index 0000000..87d0cbc
--- /dev/null
@@ -0,0 +1,93 @@
+/*
+ * 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 "qwebnavigationcontroller.h"
+
+#include "QtWebPageProxy.h"
+#include "qwebkittypes.h"
+
+class QWebNavigationControllerPrivate {
+public:
+    QWebNavigationControllerPrivate(QtWebPageProxy* pageProxy)
+        : pageProxy(pageProxy)
+    {
+        ASSERT(pageProxy);
+    }
+
+    QtWebPageProxy* pageProxy;
+};
+
+QWebNavigationController::QWebNavigationController(QtWebPageProxy* pageProxy)
+    : QObject(pageProxy)
+    , d(new QWebNavigationControllerPrivate(pageProxy))
+{
+}
+
+QWebNavigationController::~QWebNavigationController()
+{
+    delete d;
+}
+
+QAction* QWebNavigationController::backAction() const
+{
+    return d->pageProxy->navigationAction(QtWebKit::Back);
+}
+
+QAction* QWebNavigationController::forwardAction() const
+{
+    return d->pageProxy->navigationAction(QtWebKit::Forward);
+}
+
+QAction* QWebNavigationController::stopAction() const
+{
+    return d->pageProxy->navigationAction(QtWebKit::Stop);
+}
+
+QAction* QWebNavigationController::reloadAction() const
+{
+    return d->pageProxy->navigationAction(QtWebKit::Reload);
+}
+
+QAction* QWebNavigationController::navigationAction(QtWebKit::NavigationAction which) const
+{
+    return d->pageProxy->navigationAction(which);
+}
+
+void QWebNavigationController::back()
+{
+    d->pageProxy->navigationAction(QtWebKit::Back)->trigger();
+}
+
+void QWebNavigationController::forward()
+{
+    d->pageProxy->navigationAction(QtWebKit::Forward)->trigger();
+}
+
+void QWebNavigationController::stop()
+{
+    d->pageProxy->navigationAction(QtWebKit::Stop)->trigger();
+}
+
+void QWebNavigationController::reload()
+{
+    d->pageProxy->navigationAction(QtWebKit::Reload)->trigger();
+}
diff --git a/Source/WebKit2/UIProcess/API/qt/qwebnavigationcontroller.h b/Source/WebKit2/UIProcess/API/qt/qwebnavigationcontroller.h
new file mode 100644 (file)
index 0000000..5d3e583
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * 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 qwebnavigationcontroller_h
+#define qwebnavigationcontroller_h
+
+
+#include "qwebkitglobal.h"
+#include "qwebkittypes.h"
+#include <QtCore/QObject>
+
+QT_BEGIN_NAMESPACE
+class QAction;
+QT_END_NAMESPACE
+
+class QtWebPageProxy;
+class QWebNavigationControllerPrivate;
+
+class QWEBKIT_EXPORT QWebNavigationController : public QObject {
+    Q_OBJECT
+    Q_PROPERTY(QAction* backAction READ backAction CONSTANT)
+    Q_PROPERTY(QAction* forwardAction READ forwardAction CONSTANT)
+    Q_PROPERTY(QAction* stopAction READ stopAction CONSTANT)
+    Q_PROPERTY(QAction* reloadAction READ reloadAction CONSTANT)
+public:
+    QWebNavigationController(QtWebPageProxy*);
+    ~QWebNavigationController();
+
+    QAction* backAction() const;
+    QAction* forwardAction() const;
+    QAction* stopAction() const;
+    QAction* reloadAction() const;
+
+    QAction* navigationAction(QtWebKit::NavigationAction which) const;
+
+public slots:
+    void back();
+    void forward();
+    void stop();
+    void reload();
+
+private:
+    QWebNavigationControllerPrivate* d;
+};
+
+#endif // qwebnavigationcontroller_h
index dd9da46..f4e3042 100644 (file)
@@ -20,6 +20,7 @@
 #include <QAction>
 #include <QApplication>
 #include <QDesktopWidget>
+#include <qwebnavigationcontroller.h>
 #include "webviewabstraction.h"
 
 WebViewAbstraction::WebViewAbstraction()
@@ -98,9 +99,9 @@ int WebViewAbstraction::loadProgress() const
 
 void WebViewAbstraction::triggerNavigationAction(QtWebKit::NavigationAction which)
 {
-    QAction* touchAction = touchWebView()->page()->navigationAction(which);
+    QAction* touchAction = touchWebView()->page()->navigationController()->navigationAction(which);
     touchAction->trigger();
-    QAction* desktopAction = desktopWebView()->navigationAction(which);
+    QAction* desktopAction = desktopWebView()->navigationController()->navigationAction(which);
     desktopAction->trigger();
 }
 
index 942c56e..58cb0c5 100644 (file)
@@ -21,6 +21,7 @@
 #include <QScopedPointer>
 #include <QtTest/QtTest>
 #include <qdesktopwebview.h>
+#include <qwebnavigationcontroller.h>
 #include "../testwindow.h"
 #include "../util.h"
 
@@ -63,19 +64,19 @@ inline QDesktopWebView* tst_QDesktopWebView::webView() const
 
 void tst_QDesktopWebView::navigationActionsStatusAtStartup()
 {
-    QAction* backAction = webView()->navigationAction(QtWebKit::Back);
+    QAction* backAction = webView()->navigationController()->backAction();
     QVERIFY(backAction);
     QCOMPARE(backAction->isEnabled(), false);
 
-    QAction* forwardAction = webView()->navigationAction(QtWebKit::Forward);
+    QAction* forwardAction = webView()->navigationController()->forwardAction();
     QVERIFY(forwardAction);
     QCOMPARE(forwardAction->isEnabled(), false);
 
-    QAction* stopAction = webView()->navigationAction(QtWebKit::Stop);
+    QAction* stopAction = webView()->navigationController()->stopAction();
     QVERIFY(stopAction);
     QCOMPARE(stopAction->isEnabled(), false);
 
-    QAction* reloadAction = webView()->navigationAction(QtWebKit::Reload);
+    QAction* reloadAction = webView()->navigationController()->reloadAction();
     QVERIFY(reloadAction);
     QCOMPARE(reloadAction->isEnabled(), false);
 }
@@ -94,7 +95,7 @@ public slots:
     {
         QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection);
 
-        QAction* stopAction = m_webView->navigationAction(QtWebKit::Stop);
+        QAction* stopAction = m_webView->navigationController()->stopAction();
         QVERIFY(stopAction);
         QCOMPARE(stopAction->isEnabled(), true);
     }
@@ -108,7 +109,7 @@ private:
 
 void tst_QDesktopWebView::stopActionEnabledAfterLoadStarted()
 {
-    QAction* stopAction = webView()->navigationAction(QtWebKit::Stop);
+    QAction* stopAction = webView()->navigationController()->stopAction();
     QVERIFY(stopAction);
     QCOMPARE(stopAction->isEnabled(), false);
 
index 3d54931..dbcb480 100644 (file)
@@ -21,6 +21,7 @@
 #include <QtTest/QtTest>
 #include <qtouchwebpage.h>
 #include <qtouchwebview.h>
+#include <qwebnavigationcontroller.h>
 #include "../testwindow.h"
 #include "../util.h"
 
@@ -74,19 +75,19 @@ void tst_QTouchWebView::accessPage()
 
 void tst_QTouchWebView::navigationActionsStatusAtStartup()
 {
-    QAction* backAction = webView()->page()->navigationAction(QtWebKit::Back);
+    QAction* backAction = webView()->page()->navigationController()->backAction();
     QVERIFY(backAction);
     QCOMPARE(backAction->isEnabled(), false);
 
-    QAction* forwardAction = webView()->page()->navigationAction(QtWebKit::Forward);
+    QAction* forwardAction = webView()->page()->navigationController()->forwardAction();
     QVERIFY(forwardAction);
     QCOMPARE(forwardAction->isEnabled(), false);
 
-    QAction* stopAction = webView()->page()->navigationAction(QtWebKit::Stop);
+    QAction* stopAction = webView()->page()->navigationController()->stopAction();
     QVERIFY(stopAction);
     QCOMPARE(stopAction->isEnabled(), false);
 
-    QAction* reloadAction = webView()->page()->navigationAction(QtWebKit::Reload);
+    QAction* reloadAction = webView()->page()->navigationController()->reloadAction();
     QVERIFY(reloadAction);
     QCOMPARE(reloadAction->isEnabled(), false);
 }
index d70ac69..3754998 100644 (file)
@@ -49,6 +49,7 @@ WEBKIT2_API_SOURCES = \
     $$SOURCE_DIR/WebKit2/UIProcess/API/qt/qtouchwebpage.cpp \
     $$SOURCE_DIR/WebKit2/UIProcess/API/qt/qtouchwebview.cpp \
     $$SOURCE_DIR/WebKit2/UIProcess/API/qt/qweberror.cpp \
+    $$SOURCE_DIR/WebKit2/UIProcess/API/qt/qwebnavigationcontroller.cpp \
     $$SOURCE_DIR/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp \
     $$SOURCE_DIR/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleBackForwardList.cpp \
     $$SOURCE_DIR/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleBackForwardListItem.cpp \
@@ -131,6 +132,7 @@ WEBKIT2_API_HEADERS += \
     $$SOURCE_DIR/WebKit2/UIProcess/API/qt/qweberror.h \
     $$SOURCE_DIR/WebKit2/UIProcess/API/qt/qweberror_p.h \
     $$SOURCE_DIR/WebKit2/UIProcess/API/qt/qwebkittypes.h \
+    $$SOURCE_DIR/WebKit2/UIProcess/API/qt/qwebnavigationcontroller.h \
     $$SOURCE_DIR/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleBackForwardList.h \
     $$SOURCE_DIR/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleBackForwardListItem.h \
     $$SOURCE_DIR/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.h \
index cfd7c62..966a9eb 100644 (file)
@@ -1,3 +1,15 @@
+2011-08-04  Alexis Menard  <alexis.menard@openbossa.org>
+
+        [Qt] Make navigation actions properly usable in QML.
+        https://bugs.webkit.org/show_bug.cgi?id=65624
+
+        Fix compilation after the introduction of QWebNavigationController.
+
+        Reviewed by Benjamin Poulain.
+
+        * MiniBrowser/qt/BrowserView.cpp:
+        (BrowserView::navigationAction):
+
 2011-08-04  Adam Barth  <abarth@webkit.org>
 
         Another subtle bug due to lack of testing in main.js.  :(
index b536384..8085062 100644 (file)
@@ -34,6 +34,7 @@
 #include <qdesktopwebview.h>
 #include <qtouchwebview.h>
 #include <qtouchwebpage.h>
+#include <qwebnavigationcontroller.h>
 
 BrowserView::BrowserView(bool useTouchWebView, QWidget* parent)
     : QSGCanvas(parent)
@@ -88,9 +89,9 @@ QDesktopWebView* BrowserView::desktopWebView() const
 QAction* BrowserView::navigationAction(QtWebKit::NavigationAction which) const
 {
     if (desktopWebView())
-        return desktopWebView()->navigationAction(which);
+        return desktopWebView()->navigationController()->navigationAction(which);
     if (touchWebView())
-        return touchWebView()->page()->navigationAction(which);
+        return touchWebView()->page()->navigationController()->navigationAction(which);
     Q_ASSERT(false);
     return 0;
 }