[Qt][WK2] History is not accessible in QML.
authoralexis.menard@openbossa.org <alexis.menard@openbossa.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 12 Dec 2011 15:39:28 +0000 (15:39 +0000)
committeralexis.menard@openbossa.org <alexis.menard@openbossa.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 12 Dec 2011 15:39:28 +0000 (15:39 +0000)
https://bugs.webkit.org/show_bug.cgi?id=73016

Reviewed by Simon Hausmann.

.:

Add the new QWebNavigationHistory in the map file.

* Source/qtwebkit-export.map:

Source/WebKit/qt:

Register QWebNavigationHistory and QWebNavigationListModel in the QML plugin.

* declarative/experimental/plugin.cpp:
(WebKitQmlPlugin::registerTypes):

Source/WebKit2:

Remove the old qwkhistory and create QWebNavigationHistory which is QML
friendly with data models you can plug to a view in QML

* Target.pri:
* UIProcess/API/qt/qquickwebview.cpp:
(QQuickWebViewPrivate::didChangeBackForwardList):
(QQuickWebViewExperimental::navigationHistory):
(QQuickWebViewExperimental::goForwardTo):
(QQuickWebViewExperimental::goBackTo):
* UIProcess/API/qt/qquickwebview_p.h:
* UIProcess/API/qt/qquickwebview_p_p.h:
* UIProcess/API/qt/qwebnavigationhistory.cpp: Added.
(QWebNavigationListModelPrivate::QWebNavigationListModelPrivate):
(QWebNavigationListModelPrivate::createWebNavigationModel):
(QWebNavigationHistoryPrivate::QWebNavigationHistoryPrivate):
(QWebNavigationHistoryPrivate::createHistory):
(QWebNavigationHistoryPrivate::reset):
(QWebNavigationHistoryPrivate::goBackTo):
(QWebNavigationHistoryPrivate::goForwardTo):
(QWebNavigationListModel::QWebNavigationListModel):
(QWebNavigationListModel::~QWebNavigationListModel):
(QWebNavigationListModel::rowCount):
(QWebNavigationListModel::data):
(QWebNavigationHistory::QWebNavigationHistory):
(QWebNavigationHistory::~QWebNavigationHistory):
(QWebNavigationHistory::backItems):
(QWebNavigationHistory::forwardItems):
* UIProcess/API/qt/qwebnavigationhistory_p.h: Added.
* UIProcess/API/qt/qwebnavigationhistory_p_p.h: Renamed from Source/WebKit2/UIProcess/qt/qwkhistory_p.h.
* UIProcess/API/qt/tests/qmltests/WebView/tst_navigationHistory.qml: Added.
* UIProcess/qt/QtWebPageLoadClient.cpp:
(QtWebPageLoadClient::QtWebPageLoadClient):
(QtWebPageLoadClient::didChangeBackForwardList):
* UIProcess/qt/QtWebPageLoadClient.h:
* UIProcess/qt/QtWebPageProxy.cpp:
(QtWebPageProxy::QtWebPageProxy):
(QtWebPageProxy::~QtWebPageProxy):
(QtWebPageProxy::goBackTo):
(QtWebPageProxy::goForwardTo):
(QtWebPageProxy::navigationHistory):
* UIProcess/qt/QtWebPageProxy.h:
* UIProcess/qt/qwkhistory.cpp: Removed.
* UIProcess/qt/qwkhistory.h: Removed.

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

13 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/qt/QtWebPageLoadClient.cpp
Source/WebKit2/UIProcess/qt/QtWebPageLoadClient.h
Source/WebKit2/UIProcess/qt/QtWebPageProxy.cpp
Source/WebKit2/UIProcess/qt/QtWebPageProxy.h
Source/qtwebkit-export.map

index 2338b6b..c5ee30e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2011-12-12  Alexis Menard  <alexis.menard@openbossa.org>
+
+        [Qt][WK2] History is not accessible in QML.
+        https://bugs.webkit.org/show_bug.cgi?id=73016
+
+        Reviewed by Simon Hausmann.
+
+        Add the new QWebNavigationHistory in the map file.
+
+        * Source/qtwebkit-export.map:
+
 2011-12-09  Jesus Sanchez-Palencia  <jesus.palencia@openbossa.org>
 
         [Qt] request parameter of QQuickWebView::navigationRequested is not a registered type
index 21217c3..3b543a1 100644 (file)
@@ -1,3 +1,15 @@
+2011-12-12  Alexis Menard  <alexis.menard@openbossa.org>
+
+        [Qt][WK2] History is not accessible in QML.
+        https://bugs.webkit.org/show_bug.cgi?id=73016
+
+        Reviewed by Simon Hausmann.
+
+        Register QWebNavigationHistory and QWebNavigationListModel in the QML plugin.
+
+        * declarative/experimental/plugin.cpp:
+        (WebKitQmlPlugin::registerTypes):
+
 2011-12-09  Jesus Sanchez-Palencia  <jesus.palencia@openbossa.org>
 
         [Qt] request parameter of QQuickWebView::navigationRequested is not a registered type
index 86312e1..3b39a2e 100644 (file)
@@ -21,6 +21,8 @@
 #include "qquickwebview_p.h"
 #include "qwebdownloaditem_p.h"
 
+#include "qwebnavigationhistory_p.h"
+
 #include <QtDeclarative/qdeclarative.h>
 #include <QtDeclarative/qdeclarativeextensionplugin.h>
 
@@ -42,6 +44,8 @@ public:
         Q_ASSERT(QLatin1String(uri) == QLatin1String("QtWebKit.experimental"));
 
         qmlRegisterUncreatableType<QWebDownloadItem>(uri, 3, 0, "DownloadItem", QObject::tr("Cannot create separate instance of DownloadItem"));
+        qmlRegisterUncreatableType<QWebNavigationListModel>(uri, 3, 0, "NavigationListModel", QObject::tr("Cannot create separate instance of NavigationListModel"));
+        qmlRegisterUncreatableType<QWebNavigationHistory>(uri, 3, 0, "NavigationHistory", QObject::tr("Cannot create separate instance of NavigationHistory"));
         qmlRegisterExtendedType<QQuickWebView, QQuickWebViewExperimentalExtension>(uri, 3, 0, "WebView");
         qmlRegisterUncreatableType<QQuickWebViewExperimental>(uri, 3, 0, "QQuickWebViewExperimental",
             QObject::tr("Cannot create separate instance of QQuickWebViewExperimental"));
index 4711bce..0439b11 100644 (file)
@@ -1,3 +1,54 @@
+2011-12-12  Alexis Menard  <alexis.menard@openbossa.org>
+
+        [Qt][WK2] History is not accessible in QML.
+        https://bugs.webkit.org/show_bug.cgi?id=73016
+
+        Reviewed by Simon Hausmann.
+
+        Remove the old qwkhistory and create QWebNavigationHistory which is QML
+        friendly with data models you can plug to a view in QML
+
+        * Target.pri:
+        * UIProcess/API/qt/qquickwebview.cpp:
+        (QQuickWebViewPrivate::didChangeBackForwardList):
+        (QQuickWebViewExperimental::navigationHistory):
+        (QQuickWebViewExperimental::goForwardTo):
+        (QQuickWebViewExperimental::goBackTo):
+        * UIProcess/API/qt/qquickwebview_p.h:
+        * UIProcess/API/qt/qquickwebview_p_p.h:
+        * UIProcess/API/qt/qwebnavigationhistory.cpp: Added.
+        (QWebNavigationListModelPrivate::QWebNavigationListModelPrivate):
+        (QWebNavigationListModelPrivate::createWebNavigationModel):
+        (QWebNavigationHistoryPrivate::QWebNavigationHistoryPrivate):
+        (QWebNavigationHistoryPrivate::createHistory):
+        (QWebNavigationHistoryPrivate::reset):
+        (QWebNavigationHistoryPrivate::goBackTo):
+        (QWebNavigationHistoryPrivate::goForwardTo):
+        (QWebNavigationListModel::QWebNavigationListModel):
+        (QWebNavigationListModel::~QWebNavigationListModel):
+        (QWebNavigationListModel::rowCount):
+        (QWebNavigationListModel::data):
+        (QWebNavigationHistory::QWebNavigationHistory):
+        (QWebNavigationHistory::~QWebNavigationHistory):
+        (QWebNavigationHistory::backItems):
+        (QWebNavigationHistory::forwardItems):
+        * UIProcess/API/qt/qwebnavigationhistory_p.h: Added.
+        * UIProcess/API/qt/qwebnavigationhistory_p_p.h: Renamed from Source/WebKit2/UIProcess/qt/qwkhistory_p.h.
+        * UIProcess/API/qt/tests/qmltests/WebView/tst_navigationHistory.qml: Added.
+        * UIProcess/qt/QtWebPageLoadClient.cpp:
+        (QtWebPageLoadClient::QtWebPageLoadClient):
+        (QtWebPageLoadClient::didChangeBackForwardList):
+        * UIProcess/qt/QtWebPageLoadClient.h:
+        * UIProcess/qt/QtWebPageProxy.cpp:
+        (QtWebPageProxy::QtWebPageProxy):
+        (QtWebPageProxy::~QtWebPageProxy):
+        (QtWebPageProxy::goBackTo):
+        (QtWebPageProxy::goForwardTo):
+        (QtWebPageProxy::navigationHistory):
+        * UIProcess/qt/QtWebPageProxy.h:
+        * UIProcess/qt/qwkhistory.cpp: Removed.
+        * UIProcess/qt/qwkhistory.h: Removed.
+
 2011-12-09  Jesus Sanchez-Palencia  <jesus.palencia@openbossa.org>
 
         [Qt][WK2] Move startDrag implementation to QtWebPageEventHandler
index 707cf09..fe212fb 100644 (file)
@@ -180,6 +180,8 @@ HEADERS += \
     UIProcess/API/qt/qwebnavigationrequest_p.h \
     UIProcess/API/qt/qquickwebpage_p.h \
     UIProcess/API/qt/qquickwebpage_p_p.h \
+    UIProcess/API/qt/qwebnavigationhistory_p.h \
+    UIProcess/API/qt/qwebnavigationhistory_p_p.h \
     UIProcess/API/qt/qquickwebview_p.h \
     UIProcess/API/qt/qquickwebview_p_p.h \
     UIProcess/Authentication/AuthenticationChallengeProxy.h \
@@ -264,8 +266,6 @@ HEADERS += \
     UIProcess/qt/QtWebPagePolicyClient.h \
     UIProcess/qt/QtWebPageProxy.h \
     UIProcess/qt/QtWebPageUIClient.h \
-    UIProcess/qt/qwkhistory.h \
-    UIProcess/qt/qwkhistory_p.h \
     UIProcess/qt/QtSGUpdateQueue.h \
     UIProcess/qt/QtSGTileNode.h \
     UIProcess/qt/QtViewportInteractionEngine.h \
@@ -498,6 +498,7 @@ SOURCES += \
     UIProcess/API/qt/qwebpermissionrequest.cpp \
     UIProcess/API/qt/qwebnavigationrequest.cpp \
     UIProcess/API/qt/qquickwebpage.cpp \
+    UIProcess/API/qt/qwebnavigationhistory.cpp \
     UIProcess/API/qt/qquickwebview.cpp \
     UIProcess/API/qt/qwebpreferences.cpp \
     UIProcess/Authentication/AuthenticationChallengeProxy.cpp \
@@ -586,7 +587,6 @@ SOURCES += \
     UIProcess/qt/QtWebPagePolicyClient.cpp \
     UIProcess/qt/QtWebPageProxy.cpp \
     UIProcess/qt/QtWebPageUIClient.cpp \
-    UIProcess/qt/qwkhistory.cpp \
     UIProcess/qt/QtSGUpdateQueue.cpp \
     UIProcess/qt/QtSGTileNode.cpp \
     UIProcess/qt/TiledDrawingAreaProxyQt.cpp \
index 44d0911..3b0e645 100644 (file)
@@ -29,6 +29,8 @@
 
 #include "qquickwebpage_p_p.h"
 #include "qquickwebview_p_p.h"
+#include "qwebnavigationhistory_p.h"
+#include "qwebnavigationhistory_p_p.h"
 #include "qwebpreferences_p_p.h"
 
 #include <JavaScriptCore/InitializeThreading.h>
@@ -191,6 +193,11 @@ void QQuickWebViewPrivate::didChangeViewportProperties(const WebCore::ViewportAr
     interactionEngine->applyConstraints(computeViewportConstraints());
 }
 
+void QQuickWebViewPrivate::didChangeBackForwardList()
+{
+    pageProxy->navigationHistory()->d->reset();
+}
+
 void QQuickWebViewPrivate::scrollPositionRequested(const QPoint& pos)
 {
     if (!useTraditionalDesktopBehaviour)
@@ -480,6 +487,11 @@ void QQuickWebViewExperimental::setConfirmDialog(QDeclarativeComponent* confirmD
     emit confirmDialogChanged();
 }
 
+QWebNavigationHistory* QQuickWebViewExperimental::navigationHistory() const
+{
+    return d_ptr->pageProxy->navigationHistory();
+}
+
 QDeclarativeComponent* QQuickWebViewExperimental::promptDialog() const
 {
     Q_D(const QQuickWebView);
@@ -516,6 +528,16 @@ bool QQuickWebViewExperimental::useTraditionalDesktopBehaviour() const
     return d->useTraditionalDesktopBehaviour;
 }
 
+void QQuickWebViewExperimental::goForwardTo(int index)
+{
+    d_ptr->pageProxy->goForwardTo(index);
+}
+
+void QQuickWebViewExperimental::goBackTo(int index)
+{
+    d_ptr->pageProxy->goBackTo(index);
+}
+
 QQuickWebView::QQuickWebView(QQuickItem* parent)
     : QQuickItem(parent)
     , d_ptr(new QQuickWebViewPrivate(this))
index 0d2a3b2..dbe89cb 100644 (file)
@@ -31,6 +31,7 @@ class QQuickWebViewAttached;
 class QQuickWebViewPrivate;
 class QQuickWebViewExperimental;
 class QWebDownloadItem;
+class QWebNavigationHistory;
 class QWebPreferences;
 class QWebPermissionRequest;
 
@@ -169,6 +170,7 @@ QML_DECLARE_TYPEINFO(QQuickWebView, QML_HAS_ATTACHED_PROPERTIES)
 
 class QWEBKIT_EXPORT QQuickWebViewExperimental : public QObject {
     Q_OBJECT
+    Q_PROPERTY(QWebNavigationHistory* navigationHistory READ navigationHistory CONSTANT FINAL)
     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)
@@ -189,9 +191,12 @@ public:
     void setItemSelector(QDeclarativeComponent*);
 
     bool useTraditionalDesktopBehaviour() const;
+    QWebNavigationHistory* navigationHistory() const;
 
 public Q_SLOTS:
     void setUseTraditionalDesktopBehaviour(bool enable);
+    void goBackTo(int index);
+    void goForwardTo(int index);
 
 Q_SIGNALS:
     void alertDialogChanged();
index 75804e8..4c2bab0 100644 (file)
@@ -63,6 +63,7 @@ public:
     void didFinishFirstNonEmptyLayout();
     void didChangeContentsSize(const QSize& newSize);
     void didChangeViewportProperties(const WebCore::ViewportArguments& args);
+    void didChangeBackForwardList();
 
     void scrollPositionRequested(const QPoint& pos);
     void updateViewportSize();
index a2480e3..13afb21 100644 (file)
@@ -45,6 +45,7 @@ QtWebPageLoadClient::QtWebPageLoadClient(WKPageRef pageRef, QQuickWebView* webVi
     loadClient.didChangeProgress = didChangeProgress;
     loadClient.didFinishProgress = didFinishProgress;
     loadClient.didFirstVisuallyNonEmptyLayoutForFrame = didFirstVisuallyNonEmptyLayoutForFrame;
+    loadClient.didChangeBackForwardList = didChangeBackForwardList;
     WKPageSetPageLoaderClient(pageRef, &loadClient);
 }
 
@@ -77,6 +78,11 @@ void QtWebPageLoadClient::didFirstVisuallyNonEmptyLayoutForFrame()
     m_webView->d_func()->didFinishFirstNonEmptyLayout();
 }
 
+void QtWebPageLoadClient::didChangeBackForwardList()
+{
+    m_webView->d_func()->didChangeBackForwardList();
+}
+
 void QtWebPageLoadClient::dispatchLoadSucceeded()
 {
     emit m_webView->navigationStateChanged();
@@ -182,3 +188,8 @@ void QtWebPageLoadClient::didFirstVisuallyNonEmptyLayoutForFrame(WKPageRef, WKFr
         return;
     toQtWebPageLoadClient(clientInfo)->didFirstVisuallyNonEmptyLayoutForFrame();
 }
+
+void QtWebPageLoadClient::didChangeBackForwardList(WKPageRef, WKBackForwardListItemRef, WKArrayRef, const void *clientInfo)
+{
+    toQtWebPageLoadClient(clientInfo)->didChangeBackForwardList();
+}
index 03f2f0e..fbdb92e 100644 (file)
@@ -40,6 +40,7 @@ private:
     void didSameDocumentNavigationForFrame(const QUrl&);
     void didReceiveTitleForFrame(const QString&);
     void didFirstVisuallyNonEmptyLayoutForFrame();
+    void didChangeBackForwardList();
 
     void dispatchLoadSucceeded();
     void dispatchLoadFailed(WKErrorRef);
@@ -57,6 +58,7 @@ private:
     static void didChangeProgress(WKPageRef, const void* clientInfo);
     static void didFinishProgress(WKPageRef, const void* clientInfo);
     static void didFirstVisuallyNonEmptyLayoutForFrame(WKPageRef, WKFrameRef, WKTypeRef userData, const void* clientInfo);
+    static void didChangeBackForwardList(WKPageRef, WKBackForwardListItemRef, WKArrayRef, const void *clientInfo);
 
     QQuickWebView* m_webView;
     int m_loadProgress;
index 5bf3f85..26c02e1 100644 (file)
 #include "qquickwebpage_p.h"
 #include "qwebdownloaditem_p.h"
 #include "qwebdownloaditem_p_p.h"
+#include "qwebnavigationhistory_p.h"
+#include "qwebnavigationhistory_p_p.h"
 #include "qwebpreferences_p.h"
 #include "qwebpreferences_p_p.h"
 
 #include "DownloadProxy.h"
 #include "DrawingAreaProxyImpl.h"
 #include "LayerTreeHostProxy.h"
-#include "qwkhistory.h"
-#include "qwkhistory_p.h"
 #include "QtDownloadManager.h"
 #include "QtPageClient.h"
 #include "QtWebPageEventHandler.h"
@@ -66,7 +66,7 @@ QtWebPageProxy::QtWebPageProxy(QQuickWebPage* qmlWebPage, QQuickWebView* qmlWebV
     , m_navigatorQtObjectEnabled(false)
 {
     m_webPageProxy = m_context->createWebPage(pageClient, toImpl(pageGroupRef));
-    m_history = QWKHistoryPrivate::createHistory(this, m_webPageProxy->backForwardList());
+    m_navigationHistory = adoptPtr(QWebNavigationHistoryPrivate::createHistory(this, toAPI(m_webPageProxy->backForwardList())));
 }
 
 void QtWebPageProxy::init(QtWebPageEventHandler* eventHandler)
@@ -78,7 +78,6 @@ void QtWebPageProxy::init(QtWebPageEventHandler* eventHandler)
 QtWebPageProxy::~QtWebPageProxy()
 {
     m_webPageProxy->close();
-    delete m_history;
 }
 
 void QtWebPageProxy::showContextMenu(QSharedPointer<QMenu> menu)
@@ -210,6 +209,11 @@ void QtWebPageProxy::goBack()
     m_webPageProxy->goBack();
 }
 
+void QtWebPageProxy::goBackTo(int index)
+{
+    m_navigationHistory->d->goBackTo(index);
+}
+
 bool QtWebPageProxy::canGoForward() const
 {
     return m_webPageProxy->canGoForward();
@@ -220,6 +224,11 @@ void QtWebPageProxy::goForward()
     m_webPageProxy->goForward();
 }
 
+void QtWebPageProxy::goForwardTo(int index)
+{
+    m_navigationHistory->d->goForwardTo(index);
+}
+
 bool QtWebPageProxy::loading() const
 {
     RefPtr<WebKit::WebFrameProxy> mainFrame = m_webPageProxy->mainFrame();
@@ -358,9 +367,9 @@ void QtWebPageProxy::setPageAndTextZoomFactors(qreal pageZoomFactor, qreal textZ
     WKPageSetPageAndTextZoomFactors(pageRef(), pageZoomFactor, textZoomFactor);
 }
 
-QWKHistory* QtWebPageProxy::history() const
+QWebNavigationHistory* QtWebPageProxy::navigationHistory() const
 {
-    return m_history;
+    return m_navigationHistory.get();
 }
 
 void QtWebPageProxy::handleDownloadRequest(DownloadProxy* download)
index b0b5dba..9b98c42 100644 (file)
@@ -40,8 +40,8 @@ class QQuickWebView;
 class QtWebError;
 class QtWebPageEventHandler;
 class QWebDownloadItem;
+class QWebNavigationHistory;
 class QWebPreferences;
-class QWKHistory;
 
 namespace WebKit {
 class QtWebContext;
@@ -97,8 +97,10 @@ public:
 
     bool canGoBack() const;
     void goBack();
+    void goBackTo(int index);
     bool canGoForward() const;
     void goForward();
+    void goForwardTo(int index);
     bool loading() const;
     void stop();
     bool canReload() const;
@@ -138,7 +140,7 @@ public:
     void renderToCurrentGLContext(const WebCore::TransformationMatrix&, float);
     void purgeGLResources();
 
-    QWKHistory* history() const;
+    QWebNavigationHistory* navigationHistory() const;
 
     void contextMenuItemSelected(const WebContextMenuItemData& data)
     {
@@ -171,7 +173,7 @@ private:
 #endif
 
     RefPtr<QtWebContext> m_context;
-    QWKHistory* m_history;
+    OwnPtr<QWebNavigationHistory> m_navigationHistory;
 
     mutable OwnPtr<QWebPreferences> m_preferences;
 
index 4b6e75f..b77693c 100644 (file)
@@ -118,6 +118,12 @@ qwk_1.0 {
         *QQuickWebViewExperimental;
         non-virtual?thunk?to?QQuickWebViewExperimental*;
         QQuickWebViewExperimental::*;
+        *QWebNavigationHistory;
+        non-virtual?thunk?to?QWebNavigationHistory*;
+        QWebNavigationHistory::*;
+        *QWebNavigationListModel;
+        non-virtual?thunk?to?QWebNavigationListModel*;
+        QWebNavigationListModel::*;
         *QWebPreferences;
         non-virtual?thunk?to?QWebPreferences*;
         QWebPreferences::*;