[Qt][WK2] navigationType is missing in new API
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 23 Feb 2012 07:22:03 +0000 (07:22 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 23 Feb 2012 07:22:03 +0000 (07:22 +0000)
https://bugs.webkit.org/show_bug.cgi?id=78867

Patch by Michael Tyutyunik <michael.tyutyunik@nokia.com> on 2012-02-22
Reviewed by Simon Hausmann.

In QtWebPagePolicyClient::decidePolicyForNavigationAction()
navigationType argument is dropped by mistake. Adding it back
and make it available through NavigationRequest.

* UIProcess/API/qt/qquickwebview_p.h:
* UIProcess/API/qt/qwebnavigationrequest.cpp:
(QWebNavigationRequestPrivate::QWebNavigationRequestPrivate):
(QWebNavigationRequestPrivate):
(QWebNavigationRequest::QWebNavigationRequest):
(QWebNavigationRequest::navigationType):
* UIProcess/API/qt/qwebnavigationrequest_p.h:
* UIProcess/qt/QtWebPagePolicyClient.cpp:
(QtWebPagePolicyClient::decidePolicyForNavigationAction):
(toQuickWebViewNavigationType):
* UIProcess/qt/QtWebPagePolicyClient.h:
(QtWebPagePolicyClient):

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

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h
Source/WebKit2/UIProcess/API/qt/qwebnavigationrequest.cpp
Source/WebKit2/UIProcess/API/qt/qwebnavigationrequest_p.h
Source/WebKit2/UIProcess/qt/QtWebPagePolicyClient.cpp
Source/WebKit2/UIProcess/qt/QtWebPagePolicyClient.h

index 5aa206f..1ae81c3 100644 (file)
@@ -1,3 +1,27 @@
+2012-02-22  Michael Tyutyunik  <michael.tyutyunik@nokia.com>
+
+        [Qt][WK2] navigationType is missing in new API
+        https://bugs.webkit.org/show_bug.cgi?id=78867
+
+        Reviewed by Simon Hausmann.
+
+        In QtWebPagePolicyClient::decidePolicyForNavigationAction()
+        navigationType argument is dropped by mistake. Adding it back
+        and make it available through NavigationRequest.
+
+        * UIProcess/API/qt/qquickwebview_p.h:
+        * UIProcess/API/qt/qwebnavigationrequest.cpp:
+        (QWebNavigationRequestPrivate::QWebNavigationRequestPrivate):
+        (QWebNavigationRequestPrivate):
+        (QWebNavigationRequest::QWebNavigationRequest):
+        (QWebNavigationRequest::navigationType):
+        * UIProcess/API/qt/qwebnavigationrequest_p.h:
+        * UIProcess/qt/QtWebPagePolicyClient.cpp:
+        (QtWebPagePolicyClient::decidePolicyForNavigationAction):
+        (toQuickWebViewNavigationType):
+        * UIProcess/qt/QtWebPagePolicyClient.h:
+        (QtWebPagePolicyClient):
+
 2012-02-22  Anders Carlsson  <andersca@apple.com>
 
         Implement TiledCoreAnimationDrawingAreaProxy::deviceScaleFactorDidChange
index 8095cd1..b1fc925 100644 (file)
@@ -76,6 +76,7 @@ class QWEBKIT_EXPORT QQuickWebView : public QQuickItem {
     Q_PROPERTY(bool canReload READ canReload NOTIFY navigationStateChanged FINAL)
     Q_ENUMS(NavigationRequestAction)
     Q_ENUMS(ErrorDomain)
+    Q_ENUMS(NavigationType)
 
 public:
     enum NavigationRequestAction {
@@ -89,6 +90,16 @@ public:
         HttpErrorDomain,
         DownloadErrorDomain
     };
+
+    enum NavigationType {
+        LinkClickedNavigation,
+        FormSubmittedNavigation,
+        BackForwardNavigation,
+        ReloadNavigation,
+        FormResubmittedNavigation,
+        OtherNavigation
+    };
+
     QQuickWebView(QQuickItem* parent = 0);
     virtual ~QQuickWebView();
 
index 5208a06..3a63f80 100644 (file)
 
 class QWebNavigationRequestPrivate {
 public:
-    QWebNavigationRequestPrivate(const QUrl& url, const QUrl& originatingUrl, Qt::MouseButton button, Qt::KeyboardModifiers modifiers)
+    QWebNavigationRequestPrivate(const QUrl& url, const QUrl& originatingUrl, Qt::MouseButton button,
+                                 Qt::KeyboardModifiers modifiers, QQuickWebView::NavigationType navigationType)
         : url(url)
         , originatingUrl(originatingUrl)
         , button(button)
         , modifiers(modifiers)
         , action(QQuickWebView::AcceptRequest)
+        , navigationType(navigationType)
     {
     }
 
@@ -43,11 +45,13 @@ public:
     Qt::MouseButton button;
     Qt::KeyboardModifiers modifiers;
     int action;
+    QQuickWebView::NavigationType navigationType;
 };
 
-QWebNavigationRequest::QWebNavigationRequest(const QUrl& url, const QUrl& originatingUrl, Qt::MouseButton button, Qt::KeyboardModifiers modifiers, QObject* parent)
+QWebNavigationRequest::QWebNavigationRequest(const QUrl& url, const QUrl& originatingUrl, Qt::MouseButton button,
+                                             Qt::KeyboardModifiers modifiers, QQuickWebView::NavigationType navigationType, QObject* parent)
     : QObject(parent)
-    , d(new QWebNavigationRequestPrivate(url, originatingUrl, button, modifiers))
+    , d(new QWebNavigationRequestPrivate(url, originatingUrl, button, modifiers, navigationType))
 {
 }
 
@@ -90,3 +94,7 @@ int QWebNavigationRequest::action() const
     return int(d->action);
 }
 
+QQuickWebView::NavigationType QWebNavigationRequest::navigationType() const
+{
+    return d->navigationType;
+}
index 986b1c1..46333f0 100644 (file)
@@ -20,6 +20,7 @@
 #ifndef qwebnavigationrequest_p_h
 #define qwebnavigationrequest_p_h
 
+#include "qquickwebview_p.h"
 #include "qwebkitglobal.h"
 
 #include <QtCore/QObject>
@@ -34,9 +35,11 @@ class QWEBKIT_EXPORT QWebNavigationRequest : public QObject {
     Q_PROPERTY(int button READ button CONSTANT FINAL)
     Q_PROPERTY(int modifiers READ modifiers CONSTANT FINAL)
     Q_PROPERTY(int action READ action WRITE setAction NOTIFY actionChanged FINAL)
+    Q_PROPERTY(QQuickWebView::NavigationType navigationType READ navigationType CONSTANT FINAL)
 
 public:
-    QWebNavigationRequest(const QUrl& url, const QUrl& originatingUrl, Qt::MouseButton button, Qt::KeyboardModifiers modifiers, QObject* parent = 0);
+    QWebNavigationRequest(const QUrl& url, const QUrl& originatingUrl, Qt::MouseButton button, Qt::KeyboardModifiers modifiers,
+                          QQuickWebView::NavigationType navigationType, QObject* parent = 0);
     ~QWebNavigationRequest();
 
     QUrl url() const;
@@ -46,6 +49,7 @@ public:
     int action() const;
 
     void setAction(int action);
+    QQuickWebView::NavigationType navigationType() const;
 
 Q_SIGNALS:
     void actionChanged();
index e77fb14..ad8ced7 100644 (file)
@@ -23,7 +23,6 @@
 
 #include "WKFrame.h"
 #include "WKURLQt.h"
-#include "qquickwebview_p.h"
 #include "qquickwebview_p_p.h"
 #include "qwebnavigationrequest_p.h"
 #include <QtCore/QObject>
@@ -42,11 +41,12 @@ QtWebPagePolicyClient::QtWebPagePolicyClient(WKPageRef pageRef, QQuickWebView* w
     WKPageSetPagePolicyClient(pageRef, &policyClient);
 }
 
-void QtWebPagePolicyClient::decidePolicyForNavigationAction(const QUrl& url, const QUrl& originatingUrl, Qt::MouseButton mouseButton, Qt::KeyboardModifiers keyboardModifiers, WKFramePolicyListenerRef listener)
+void QtWebPagePolicyClient::decidePolicyForNavigationAction(const QUrl& url, const QUrl& originatingUrl, Qt::MouseButton mouseButton,
+                                                            Qt::KeyboardModifiers keyboardModifiers, QQuickWebView::NavigationType navigationType, WKFramePolicyListenerRef listener)
 {
     // NOTE: even though the C API (and the WebKit2 IPC) supports an asynchronous answer, this is not currently working.
     // We are expected to call the listener immediately. See the patch for https://bugs.webkit.org/show_bug.cgi?id=53785.
-    QWebNavigationRequest navigationRequest(url, originatingUrl, mouseButton, keyboardModifiers);
+    QWebNavigationRequest navigationRequest(url, originatingUrl, mouseButton, keyboardModifiers, navigationType);
     emit m_webView->navigationRequested(&navigationRequest);
 
     switch (navigationRequest.action()) {
@@ -99,13 +99,33 @@ static Qt::KeyboardModifiers toQtKeyboardModifiers(WKEventModifiers modifiers)
     return qtModifiers;
 }
 
-void QtWebPagePolicyClient::decidePolicyForNavigationAction(WKPageRef, WKFrameRef frame, WKFrameNavigationType, WKEventModifiers modifiers, WKEventMouseButton mouseButton, WKURLRequestRef request, WKFramePolicyListenerRef listener, WKTypeRef, const void* clientInfo)
+static QQuickWebView::NavigationType toQuickWebViewNavigationType(WKFrameNavigationType navigationType)
+{
+    switch (navigationType) {
+    case kWKFrameNavigationTypeLinkClicked:
+        return QQuickWebView::LinkClickedNavigation;
+    case kWKFrameNavigationTypeFormSubmitted:
+        return QQuickWebView::FormSubmittedNavigation;
+    case kWKFrameNavigationTypeBackForward:
+        return QQuickWebView::BackForwardNavigation;
+    case kWKFrameNavigationTypeReload:
+        return QQuickWebView::ReloadNavigation;
+    case kWKFrameNavigationTypeFormResubmitted:
+        return QQuickWebView::FormResubmittedNavigation;
+    case kWKFrameNavigationTypeOther:
+        return QQuickWebView::OtherNavigation;
+    }
+    ASSERT_NOT_REACHED();
+    return QQuickWebView::OtherNavigation;
+}
+
+void QtWebPagePolicyClient::decidePolicyForNavigationAction(WKPageRef, WKFrameRef frame, WKFrameNavigationType navigationType, WKEventModifiers modifiers, WKEventMouseButton mouseButton, WKURLRequestRef request, WKFramePolicyListenerRef listener, WKTypeRef, const void* clientInfo)
 {
     WKRetainPtr<WKURLRef> frameURL(AdoptWK, WKFrameCopyURL(frame));
     WKRetainPtr<WKURLRef> requestURL(AdoptWK, WKURLRequestCopyURL(request));
     QUrl qUrlFrame = WKURLCopyQUrl(frameURL.get());
     QUrl qUrl = WKURLCopyQUrl(requestURL.get());
-    toQtWebPagePolicyClient(clientInfo)->decidePolicyForNavigationAction(qUrl, qUrlFrame, toQtMouseButton(mouseButton), toQtKeyboardModifiers(modifiers), listener);
+    toQtWebPagePolicyClient(clientInfo)->decidePolicyForNavigationAction(qUrl, qUrlFrame, toQtMouseButton(mouseButton), toQtKeyboardModifiers(modifiers), toQuickWebViewNavigationType(navigationType), listener);
 }
 
 void QtWebPagePolicyClient::decidePolicyForResponse(WKPageRef page, WKFrameRef frame, WKURLResponseRef response, WKURLRequestRef, WKFramePolicyListenerRef listener, WKTypeRef, const void*)
index 8c60213..e393d54 100644 (file)
 #ifndef QtWebPagePolicyClient_h
 #define QtWebPagePolicyClient_h
 
+#include "qquickwebview_p.h"
 #include <QtCore/QUrl>
 #include <WKPage.h>
 
 class QQuickWebView;
-
 class QtWebPagePolicyClient {
 public:
     QtWebPagePolicyClient(WKPageRef, QQuickWebView*);
 
 private:
-    void decidePolicyForNavigationAction(const QUrl&, const QUrl&, Qt::MouseButton, Qt::KeyboardModifiers, WKFramePolicyListenerRef);
+    void decidePolicyForNavigationAction(const QUrl&, const QUrl&, Qt::MouseButton, Qt::KeyboardModifiers, QQuickWebView::NavigationType, WKFramePolicyListenerRef);
 
     // WKPagePolicyClient callbacks.
     static void decidePolicyForNavigationAction(WKPageRef, WKFrameRef, WKFrameNavigationType, WKEventModifiers, WKEventMouseButton, WKURLRequestRef, WKFramePolicyListenerRef, WKTypeRef userData, const void* clientInfo);