Add a 'isMainFrame' parameter to QWebNavigationRequest.

https://bugs.webkit.org/show_bug.cgi?id=118860

Patch by Alexandre Abreu <alexandre.abreu@canonical.com> on 2013-08-28
Reviewed by Simon Hausmann.

* UIProcess/API/qt/qwebnavigationrequest.cpp:
(QWebNavigationRequestPrivate::QWebNavigationRequestPrivate):
(QWebNavigationRequest::QWebNavigationRequest):
(QWebNavigationRequest::navigationType):
(QWebNavigationRequest::isMainFrame):
* UIProcess/API/qt/qwebnavigationrequest_p.h:
* UIProcess/API/qt/tests/publicapi/tst_publicapi.cpp:
* UIProcess/qt/QtWebPagePolicyClient.cpp:
(WebKit::QtWebPagePolicyClient::decidePolicyForNavigationAction):
* UIProcess/qt/QtWebPagePolicyClient.h:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154724 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 7e676a9d
......@@ -57,7 +57,7 @@ public:
qmlRegisterType<QQuickWebView>(uri, 3, 0, "WebView");
qmlRegisterUncreatableType<QQuickWebPage>(uri, 3, 0, "WebPage", QObject::tr("Cannot create separate instance of WebPage, use WebView"));
qmlRegisterUncreatableType<QNetworkReply>(uri, 3, 0, "NetworkReply", QObject::tr("Cannot create separate instance of NetworkReply"));
qmlRegisterUncreatableType<QWebNavigationRequest>(uri, 3, 0, "NavigationRequest", QObject::tr("Cannot create separate instance of NavigationRequest"));
qmlRegisterUncreatableType<QWebNavigationRequest, 1>(uri, 3, 1, "NavigationRequest", QObject::tr("Cannot create separate instance of NavigationRequest"));
qmlRegisterUncreatableType<QWebLoadRequest>(uri, 3, 0, "WebLoadRequest", QObject::tr("Cannot create separate instance of WebLoadRequest"));
#endif
}
......
2013-08-28 Alexandre Abreu <alexandre.abreu@canonical.com>
Add a 'isMainFrame' parameter to QWebNavigationRequest.
https://bugs.webkit.org/show_bug.cgi?id=118860
Reviewed by Simon Hausmann.
* UIProcess/API/qt/qwebnavigationrequest.cpp:
(QWebNavigationRequestPrivate::QWebNavigationRequestPrivate):
(QWebNavigationRequest::QWebNavigationRequest):
(QWebNavigationRequest::navigationType):
(QWebNavigationRequest::isMainFrame):
* UIProcess/API/qt/qwebnavigationrequest_p.h:
* UIProcess/API/qt/tests/publicapi/tst_publicapi.cpp:
* UIProcess/qt/QtWebPagePolicyClient.cpp:
(WebKit::QtWebPagePolicyClient::decidePolicyForNavigationAction):
* UIProcess/qt/QtWebPagePolicyClient.h:
2013-08-27 Luciano Wolf <luciano.wolf@openbossa.org>
100% cpu usage for "transition: opacity" animation
......
......@@ -25,12 +25,13 @@
class QWebNavigationRequestPrivate {
public:
QWebNavigationRequestPrivate(const QUrl& url, Qt::MouseButton mouseButton, Qt::KeyboardModifiers keyboardModifiers, QQuickWebView::NavigationType navigationType)
QWebNavigationRequestPrivate(const QUrl& url, Qt::MouseButton mouseButton, Qt::KeyboardModifiers keyboardModifiers, QQuickWebView::NavigationType navigationType, bool isMainFrame)
: url(url)
, mouseButton(mouseButton)
, keyboardModifiers(keyboardModifiers)
, action(QQuickWebView::AcceptRequest)
, navigationType(navigationType)
, isMainFrame(isMainFrame)
{
}
......@@ -43,11 +44,12 @@ public:
Qt::KeyboardModifiers keyboardModifiers;
QQuickWebView::NavigationRequestAction action;
QQuickWebView::NavigationType navigationType;
bool isMainFrame;
};
QWebNavigationRequest::QWebNavigationRequest(const QUrl& url, Qt::MouseButton mouseButton, Qt::KeyboardModifiers keyboardModifiers, QQuickWebView::NavigationType navigationType, QObject* parent)
QWebNavigationRequest::QWebNavigationRequest(const QUrl& url, Qt::MouseButton mouseButton, Qt::KeyboardModifiers keyboardModifiers, QQuickWebView::NavigationType navigationType, bool isMainFrame, QObject* parent)
: QObject(parent)
, d(new QWebNavigationRequestPrivate(url, mouseButton, keyboardModifiers, navigationType))
, d(new QWebNavigationRequestPrivate(url, mouseButton, keyboardModifiers, navigationType, isMainFrame))
{
}
......@@ -89,3 +91,8 @@ QQuickWebView::NavigationType QWebNavigationRequest::navigationType() const
{
return d->navigationType;
}
bool QWebNavigationRequest::isMainFrame() const
{
return d->isMainFrame;
}
......@@ -35,9 +35,10 @@ class QWEBKIT_EXPORT QWebNavigationRequest : public QObject {
Q_PROPERTY(int keyboardModifiers READ keyboardModifiers CONSTANT FINAL)
Q_PROPERTY(QQuickWebView::NavigationRequestAction action READ action WRITE setAction NOTIFY actionChanged FINAL)
Q_PROPERTY(QQuickWebView::NavigationType navigationType READ navigationType CONSTANT FINAL)
Q_PROPERTY(bool isMainFrame READ isMainFrame CONSTANT FINAL REVISION 1)
public:
QWebNavigationRequest(const QUrl& url, Qt::MouseButton mouseButton, Qt::KeyboardModifiers keyboardModifiers, QQuickWebView::NavigationType navigationType, QObject* parent = 0);
QWebNavigationRequest(const QUrl& url, Qt::MouseButton mouseButton, Qt::KeyboardModifiers keyboardModifiers, QQuickWebView::NavigationType navigationType, bool isMainFrame, QObject* parent = 0);
~QWebNavigationRequest();
QUrl url() const;
......@@ -48,6 +49,8 @@ public:
void setAction(QQuickWebView::NavigationRequestAction action);
QQuickWebView::NavigationType navigationType() const;
bool isMainFrame() const;
Q_SIGNALS:
void actionChanged();
......
......@@ -90,6 +90,7 @@ static QStringList expectedAPI = QStringList()
<< "QWebNavigationRequest.keyboardModifiers --> int"
<< "QWebNavigationRequest.action --> QQuickWebView::NavigationRequestAction"
<< "QWebNavigationRequest.navigationType --> QQuickWebView::NavigationType"
<< "QWebNavigationRequest.isMainFrame --> bool"
<< "QWebNavigationRequest.actionChanged() --> void"
;
......
......@@ -44,11 +44,11 @@ QtWebPagePolicyClient::QtWebPagePolicyClient(WKPageRef pageRef, QQuickWebView* w
WKPageSetPagePolicyClient(pageRef, &policyClient);
}
void QtWebPagePolicyClient::decidePolicyForNavigationAction(const QUrl& url, Qt::MouseButton mouseButton, Qt::KeyboardModifiers keyboardModifiers, QQuickWebView::NavigationType navigationType, WKFramePolicyListenerRef listener)
void QtWebPagePolicyClient::decidePolicyForNavigationAction(const QUrl& url, Qt::MouseButton mouseButton, Qt::KeyboardModifiers keyboardModifiers, QQuickWebView::NavigationType navigationType, bool isMainFrame, 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, mouseButton, keyboardModifiers, navigationType);
QWebNavigationRequest navigationRequest(url, mouseButton, keyboardModifiers, navigationType, isMainFrame);
emit m_webView->navigationRequested(&navigationRequest);
switch (navigationRequest.action()) {
......@@ -121,12 +121,13 @@ static QQuickWebView::NavigationType toQuickWebViewNavigationType(WKFrameNavigat
return QQuickWebView::OtherNavigation;
}
void QtWebPagePolicyClient::decidePolicyForNavigationAction(WKPageRef, WKFrameRef frame, WKFrameNavigationType navigationType, WKEventModifiers modifiers, WKEventMouseButton mouseButton, WKURLRequestRef request, WKFramePolicyListenerRef listener, WKTypeRef, const void* clientInfo)
void QtWebPagePolicyClient::decidePolicyForNavigationAction(WKPageRef page, 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 qUrl = WKURLCopyQUrl(requestURL.get());
toQtWebPagePolicyClient(clientInfo)->decidePolicyForNavigationAction(qUrl, toQtMouseButton(mouseButton), toQtKeyboardModifiers(modifiers), toQuickWebViewNavigationType(navigationType), listener);
bool isMainFrame = (WKPageGetMainFrame(page) == frame);
toQtWebPagePolicyClient(clientInfo)->decidePolicyForNavigationAction(qUrl, toQtMouseButton(mouseButton), toQtKeyboardModifiers(modifiers), toQuickWebViewNavigationType(navigationType), isMainFrame, listener);
}
void QtWebPagePolicyClient::decidePolicyForResponse(WKPageRef page, WKFrameRef frame, WKURLResponseRef response, WKURLRequestRef, WKFramePolicyListenerRef listener, WKTypeRef, const void*)
......
......@@ -36,7 +36,7 @@ public:
QtWebPagePolicyClient(WKPageRef, QQuickWebView*);
private:
void decidePolicyForNavigationAction(const QUrl&, Qt::MouseButton, Qt::KeyboardModifiers, QQuickWebView::NavigationType, WKFramePolicyListenerRef);
void decidePolicyForNavigationAction(const QUrl&, Qt::MouseButton, Qt::KeyboardModifiers, QQuickWebView::NavigationType, bool isMainFrame, WKFramePolicyListenerRef);
// WKPagePolicyClient callbacks.
static void decidePolicyForNavigationAction(WKPageRef, WKFrameRef, WKFrameNavigationType, WKEventModifiers, WKEventMouseButton, WKURLRequestRef, WKFramePolicyListenerRef, WKTypeRef userData, const void* clientInfo);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment