Skip to content
Permalink
Browse files
[Qt] API changes to QWebNavigationRequest
https://bugs.webkit.org/show_bug.cgi?id=78821

Reviewed by Kenneth Rohde Christiansen.

Changes discussed in API review at Szeged: rename 'button' to 'mouseButton',
rename 'modifiers' to 'keyboardModifiers', remove 'originatingUrl' and
use the enum type for 'action'.

* UIProcess/API/qt/qwebnavigationrequest.cpp:
(QWebNavigationRequestPrivate::QWebNavigationRequestPrivate):
(QWebNavigationRequestPrivate):
(QWebNavigationRequest::QWebNavigationRequest):
(QWebNavigationRequest::setAction):
(QWebNavigationRequest::mouseButton):
(QWebNavigationRequest::keyboardModifiers):
(QWebNavigationRequest::action):
* UIProcess/API/qt/qwebnavigationrequest_p.h:
* UIProcess/API/qt/tests/publicapi/tst_publicapi.cpp:
* UIProcess/API/qt/tests/qmltests/DesktopBehavior/tst_navigationRequested.qml:
* UIProcess/qt/QtWebPagePolicyClient.cpp:
(QtWebPagePolicyClient::decidePolicyForNavigationAction):
* UIProcess/qt/QtWebPagePolicyClient.h:
(QtWebPagePolicyClient):

Canonical link: https://commits.webkit.org/96867@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@109106 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Caio Marcelo de Oliveira Filho committed Feb 28, 2012
1 parent c136af9 commit 9705a7ebc2668397964a4d9284e1207b5d0d2c97
@@ -1,3 +1,30 @@
2012-02-27 Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org>

[Qt] API changes to QWebNavigationRequest
https://bugs.webkit.org/show_bug.cgi?id=78821

Reviewed by Kenneth Rohde Christiansen.

Changes discussed in API review at Szeged: rename 'button' to 'mouseButton',
rename 'modifiers' to 'keyboardModifiers', remove 'originatingUrl' and
use the enum type for 'action'.

* UIProcess/API/qt/qwebnavigationrequest.cpp:
(QWebNavigationRequestPrivate::QWebNavigationRequestPrivate):
(QWebNavigationRequestPrivate):
(QWebNavigationRequest::QWebNavigationRequest):
(QWebNavigationRequest::setAction):
(QWebNavigationRequest::mouseButton):
(QWebNavigationRequest::keyboardModifiers):
(QWebNavigationRequest::action):
* UIProcess/API/qt/qwebnavigationrequest_p.h:
* UIProcess/API/qt/tests/publicapi/tst_publicapi.cpp:
* UIProcess/API/qt/tests/qmltests/DesktopBehavior/tst_navigationRequested.qml:
* UIProcess/qt/QtWebPagePolicyClient.cpp:
(QtWebPagePolicyClient::decidePolicyForNavigationAction):
* UIProcess/qt/QtWebPagePolicyClient.h:
(QtWebPagePolicyClient):

2012-02-28 Shinya Kawanaka <shinyak@chromium.org>

Element should be able to have multiple shadow roots.
@@ -25,12 +25,10 @@

class QWebNavigationRequestPrivate {
public:
QWebNavigationRequestPrivate(const QUrl& url, const QUrl& originatingUrl, Qt::MouseButton button,
Qt::KeyboardModifiers modifiers, QQuickWebView::NavigationType navigationType)
QWebNavigationRequestPrivate(const QUrl& url, Qt::MouseButton mouseButton, Qt::KeyboardModifiers keyboardModifiers, QQuickWebView::NavigationType navigationType)
: url(url)
, originatingUrl(originatingUrl)
, button(button)
, modifiers(modifiers)
, mouseButton(mouseButton)
, keyboardModifiers(keyboardModifiers)
, action(QQuickWebView::AcceptRequest)
, navigationType(navigationType)
{
@@ -41,17 +39,15 @@ class QWebNavigationRequestPrivate {
}

QUrl url;
QUrl originatingUrl;
Qt::MouseButton button;
Qt::KeyboardModifiers modifiers;
int action;
Qt::MouseButton mouseButton;
Qt::KeyboardModifiers keyboardModifiers;
QQuickWebView::NavigationRequestAction action;
QQuickWebView::NavigationType navigationType;
};

QWebNavigationRequest::QWebNavigationRequest(const QUrl& url, const QUrl& originatingUrl, Qt::MouseButton button,
Qt::KeyboardModifiers modifiers, QQuickWebView::NavigationType navigationType, QObject* parent)
QWebNavigationRequest::QWebNavigationRequest(const QUrl& url, Qt::MouseButton mouseButton, Qt::KeyboardModifiers keyboardModifiers, QQuickWebView::NavigationType navigationType, QObject* parent)
: QObject(parent)
, d(new QWebNavigationRequestPrivate(url, originatingUrl, button, modifiers, navigationType))
, d(new QWebNavigationRequestPrivate(url, mouseButton, keyboardModifiers, navigationType))
{
}

@@ -60,7 +56,7 @@ QWebNavigationRequest::~QWebNavigationRequest()
delete d;
}

void QWebNavigationRequest::setAction(int action)
void QWebNavigationRequest::setAction(QQuickWebView::NavigationRequestAction action)
{
if (d->action == action)
return;
@@ -74,24 +70,19 @@ QUrl QWebNavigationRequest::url() const
return d->url;
}

QUrl QWebNavigationRequest::originatingUrl() const
int QWebNavigationRequest::mouseButton() const
{
return d->originatingUrl;
return int(d->mouseButton);
}

int QWebNavigationRequest::button() const
int QWebNavigationRequest::keyboardModifiers() const
{
return int(d->button);
return int(d->keyboardModifiers);
}

int QWebNavigationRequest::modifiers() const
QQuickWebView::NavigationRequestAction QWebNavigationRequest::action() const
{
return int(d->modifiers);
}

int QWebNavigationRequest::action() const
{
return int(d->action);
return d->action;
}

QQuickWebView::NavigationType QWebNavigationRequest::navigationType() const
@@ -31,24 +31,21 @@ class QWebNavigationRequestPrivate;
class QWEBKIT_EXPORT QWebNavigationRequest : public QObject {
Q_OBJECT
Q_PROPERTY(QUrl url READ url CONSTANT FINAL)
Q_PROPERTY(QUrl originatingUrl READ originatingUrl CONSTANT FINAL)
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(int mouseButton READ mouseButton CONSTANT FINAL)
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)

public:
QWebNavigationRequest(const QUrl& url, const QUrl& originatingUrl, Qt::MouseButton button, Qt::KeyboardModifiers modifiers,
QQuickWebView::NavigationType navigationType, QObject* parent = 0);
QWebNavigationRequest(const QUrl& url, Qt::MouseButton mouseButton, Qt::KeyboardModifiers keyboardModifiers, QQuickWebView::NavigationType navigationType, QObject* parent = 0);
~QWebNavigationRequest();

QUrl url() const;
QUrl originatingUrl() const;
int button() const;
int modifiers() const;
int action() const;
int mouseButton() const;
int keyboardModifiers() const;
QQuickWebView::NavigationRequestAction action() const;

void setAction(int action);
void setAction(QQuickWebView::NavigationRequestAction action);
QQuickWebView::NavigationType navigationType() const;

Q_SIGNALS:
@@ -83,10 +83,9 @@ static QStringList expectedAPI = QStringList()
<< "QWebLoadRequest.errorDomain --> QQuickWebView::ErrorDomain"
<< "QWebLoadRequest.errorCode --> int"
<< "QWebNavigationRequest.url --> QUrl"
<< "QWebNavigationRequest.originatingUrl --> QUrl"
<< "QWebNavigationRequest.button --> int"
<< "QWebNavigationRequest.modifiers --> int"
<< "QWebNavigationRequest.action --> int"
<< "QWebNavigationRequest.mouseButton --> int"
<< "QWebNavigationRequest.keyboardModifiers --> int"
<< "QWebNavigationRequest.action --> QQuickWebView::NavigationRequestAction"
<< "QWebNavigationRequest.navigationType --> QQuickWebView::NavigationType"
<< "QWebNavigationRequest.actionChanged() --> void"
;
@@ -8,7 +8,6 @@ Item {
property int expectedLength: 0
property int totalBytes: 0
property bool shouldDownload: false
property string originatingUrl: ""
property url beginUrl: Qt.resolvedUrl("../common/test2.html")
property url endUrl: Qt.resolvedUrl("../common/test1.html")

@@ -22,11 +21,10 @@ Item {
onNavigationRequested: {
if (shouldDownload)
request.action = WebViewExperimental.DownloadRequest
else if (request.button == Qt.MiddleButton && request.modifiers & Qt.ControlModifier) {
else if (request.mouseButton == Qt.MiddleButton && request.keyboardModifiers & Qt.ControlModifier) {
otherWebView.load(request.url)
request.action = WebView.IgnoreRequest
}
originatingUrl = request.originatingUrl
}

experimental.onDownloadRequested: {
@@ -78,7 +76,6 @@ Item {
downloadSpy.clear()
downloadFinishedSpy.clear()
shouldDownload = false
originatingUrl = ""
}

function test_usePolicy() {
@@ -115,15 +112,5 @@ Item {
compare(downloadFinishedSpy.count, 1)
compare(totalBytes, expectedLength)
}

function test_originatingUrl() {
webView.load(beginUrl)
verify(webView.waitForLoadSucceeded())
mouseClick(webView, 100, 100, Qt.LeftButton)
verify(webView.waitForLoadSucceeded())
compare(webView.title, "Test page 1")
compare(webView.url, endUrl)
compare(originatingUrl, beginUrl)
}
}
}
@@ -41,12 +41,11 @@ QtWebPagePolicyClient::QtWebPagePolicyClient(WKPageRef pageRef, QQuickWebView* w
WKPageSetPagePolicyClient(pageRef, &policyClient);
}

void QtWebPagePolicyClient::decidePolicyForNavigationAction(const QUrl& url, const QUrl& originatingUrl, 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, 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, navigationType);
QWebNavigationRequest navigationRequest(url, mouseButton, keyboardModifiers, navigationType);
emit m_webView->navigationRequested(&navigationRequest);

switch (navigationRequest.action()) {
@@ -123,9 +122,8 @@ void QtWebPagePolicyClient::decidePolicyForNavigationAction(WKPageRef, WKFrameRe
{
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), toQuickWebViewNavigationType(navigationType), listener);
toQtWebPagePolicyClient(clientInfo)->decidePolicyForNavigationAction(qUrl, toQtMouseButton(mouseButton), toQtKeyboardModifiers(modifiers), toQuickWebViewNavigationType(navigationType), listener);
}

void QtWebPagePolicyClient::decidePolicyForResponse(WKPageRef page, WKFrameRef frame, WKURLResponseRef response, WKURLRequestRef, WKFramePolicyListenerRef listener, WKTypeRef, const void*)
@@ -31,7 +31,7 @@ class QtWebPagePolicyClient {
QtWebPagePolicyClient(WKPageRef, QQuickWebView*);

private:
void decidePolicyForNavigationAction(const QUrl&, const QUrl&, Qt::MouseButton, Qt::KeyboardModifiers, QQuickWebView::NavigationType, WKFramePolicyListenerRef);
void decidePolicyForNavigationAction(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);

0 comments on commit 9705a7e

Please sign in to comment.