Title: [115191] trunk
Revision
115191
Author
ves...@webkit.org
Date
2012-04-25 06:29:00 -0700 (Wed, 25 Apr 2012)

Log Message

[Qt] Make the web view's url property follow the active url

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

The url property of the webview now reflects the 'active' url of the
page, which maps to either the currently loading url, in the case of
an ongoing load, or the result of a load, even when the load failed.

In practice this means that setting the url though QML, or navigating
to a new url in the page by e.g clicking, will both instantly change
the url-property of the webview to the target url. This differs from
earlier behavior, where we would update the url when the load
committed.

An optional argument is added to loadHtml(), to allow setting
the unreachable url when providing replacement content for failed
loads.

A slight change in the activeUrl() implementation is also done,
where we now favour the url of an pending API request, even when
we don't have a mainframe yet.

Finally, the location bar in the minibrowser is updated to behave
a bit more like normal browsers in terms of when the url will change
and how active focus is handled.

Reviewed by Simon Hausmann.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (115190 => 115191)


--- trunk/Source/WebKit2/ChangeLog	2012-04-25 13:15:06 UTC (rev 115190)
+++ trunk/Source/WebKit2/ChangeLog	2012-04-25 13:29:00 UTC (rev 115191)
@@ -1,3 +1,58 @@
+2012-04-18  Tor Arne Vestbø  <tor.arne.ves...@nokia.com>
+
+        [Qt] Make the web view's url property follow the active url
+
+        https://bugs.webkit.org/show_bug.cgi?id=77554
+
+        The url property of the webview now reflects the 'active' url of the
+        page, which maps to either the currently loading url, in the case of
+        an ongoing load, or the result of a load, even when the load failed.
+
+        In practice this means that setting the url though QML, or navigating
+        to a new url in the page by e.g clicking, will both instantly change
+        the url-property of the webview to the target url. This differs from
+        earlier behavior, where we would update the url when the load
+        committed.
+
+        An optional argument is added to loadHtml(), to allow setting
+        the unreachable url when providing replacement content for failed
+        loads.
+
+        A slight change in the activeUrl() implementation is also done,
+        where we now favour the url of an pending API request, even when
+        we don't have a mainframe yet.
+
+        Finally, the location bar in the minibrowser is updated to behave
+        a bit more like normal browsers in terms of when the url will change
+        and how active focus is handled.
+
+        Reviewed by Simon Hausmann.
+
+        * UIProcess/API/qt/qquickwebview.cpp:
+        (QQuickWebViewPrivate::onComponentComplete):
+        (QQuickWebView::reload):
+        (QQuickWebView::url):
+        (QQuickWebView::setUrl):
+        (QQuickWebView::loadHtml):
+        * UIProcess/API/qt/qquickwebview_p.h:
+        * UIProcess/API/qt/tests/qmltests/DesktopBehavior.pro:
+        * UIProcess/API/qt/tests/qmltests/WebView.pro:
+        * UIProcess/API/qt/tests/qmltests/WebView/tst_loadUrl.qml:
+        * UIProcess/API/qt/tests/qmltests/common/link.html: Added.
+        * UIProcess/API/qt/tests/qmltests/common/redirect.html: Added.
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::activeURL):
+        * UIProcess/qt/QtWebPageLoadClient.cpp:
+        (QtWebPageLoadClient::QtWebPageLoadClient):
+        (QtWebPageLoadClient::didStartProvisionalLoadForFrame):
+        (QtWebPageLoadClient::didReceiveServerRedirectForProvisionalLoadForFrame):
+        (QtWebPageLoadClient::didCommitLoadForFrame):
+        (QtWebPageLoadClient::dispatchLoadFailed):
+        (QtWebPageLoadClient::didFailProvisionalLoadWithErrorForFrame):
+        (QtWebPageLoadClient::didFailLoadWithErrorForFrame):
+        * UIProcess/qt/QtWebPageLoadClient.h:
+        (QtWebPageLoadClient):
+
 2012-04-24  Enrica Casucci  <enr...@apple.com>
 
         REGRESSION (r109022) Safari not placing service data on pasteboard.

Modified: trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp (115190 => 115191)


--- trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp	2012-04-25 13:15:06 UTC (rev 115190)
+++ trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp	2012-04-25 13:29:00 UTC (rev 115191)
@@ -50,9 +50,12 @@
 
 #include <_javascript_Core/InitializeThreading.h>
 #include <QDateTime>
+#include <QtQml/QQmlEngine>
+#include <QtQuick/QQuickCanvas>
+#include <WKOpenPanelResultListener.h>
 #include <WebCore/IntPoint.h>
 #include <WebCore/IntRect.h>
-#include <WKOpenPanelResultListener.h>
+#include <WebCore/KURL.h>
 #include <wtf/Assertions.h>
 #include <wtf/MainThread.h>
 #include <wtf/text/WTFString.h>
@@ -231,10 +234,11 @@
 
 void QQuickWebViewPrivate::onComponentComplete()
 {
-    if (m_deferedUrlToLoad.isEmpty())
+    if (m_deferredUrlToLoad.isEmpty())
         return;
 
-    q_ptr->setUrl(m_deferedUrlToLoad);
+    q_ptr->setUrl(m_deferredUrlToLoad);
+    m_deferredUrlToLoad.clear();
 }
 
 void QQuickWebViewPrivate::setNeedsDisplay()
@@ -1197,6 +1201,17 @@
 void QQuickWebView::reload()
 {
     Q_D(QQuickWebView);
+
+    WebFrameProxy* mainFrame = d->webPageProxy->mainFrame();
+    if (mainFrame && !mainFrame->unreachableURL().isEmpty() && mainFrame->url() != blankURL()) {
+        // We have an unreachable url, but haven't loaded alternative content
+        // for it (an error page eg.), so WebCore doesn't know about the unreachable
+        // url, and will try to reload the currently committed url instead. We don't
+        // want that, so we override the reload here by doing a manual load.
+        d->webPageProxy->loadURL(mainFrame->unreachableURL());
+        return;
+    }
+
     const bool reloadFromOrigin = true;
     d->webPageProxy->reload(reloadFromOrigin);
 }
@@ -1204,10 +1219,12 @@
 QUrl QQuickWebView::url() const
 {
     Q_D(const QQuickWebView);
-    RefPtr<WebFrameProxy> mainFrame = d->webPageProxy->mainFrame();
-    if (!mainFrame)
-        return QUrl();
-    return QUrl(QString(mainFrame->url()));
+
+    if (!isComponentComplete())
+        return d->m_deferredUrlToLoad;
+
+    Q_ASSERT(d->m_currentUrl == d->webPageProxy->activeURL());
+    return QUrl(d->m_currentUrl);
 }
 
 void QQuickWebView::setUrl(const QUrl& url)
@@ -1217,14 +1234,26 @@
     if (url.isEmpty())
         return;
 
-    if (!isComponentComplete()) {
-        d->m_deferedUrlToLoad = url;
-        return;
-    }
+    if (!isComponentComplete())
+        d->m_deferredUrlToLoad = url;
+    else
+        d->webPageProxy->loadURL(url.toString());
 
-    d->webPageProxy->loadURL(url.toString());
+    emitUrlChangeIfNeeded();
 }
 
+// Make sure we don't emit urlChanged unless it actually changed
+void QQuickWebView::emitUrlChangeIfNeeded()
+{
+    Q_D(QQuickWebView);
+
+    WTF::String activeUrl = d->webPageProxy->activeURL();
+    if (activeUrl != d->m_currentUrl) {
+        d->m_currentUrl = activeUrl;
+        emit urlChanged();
+    }
+}
+
 QUrl QQuickWebView::icon() const
 {
     Q_D(const QQuickWebView);
@@ -1531,12 +1560,19 @@
     External objects such as stylesheets or images referenced in the HTML
     document are located relative to \a baseUrl.
 
+    If an \a unreachableUrl is passed it is used as the url for the loaded
+    content. This is typically used to display error pages for a failed
+    load.
+
     \sa load()
 */
-void QQuickWebView::loadHtml(const QString& html, const QUrl& baseUrl)
+void QQuickWebView::loadHtml(const QString& html, const QUrl& baseUrl, const QUrl& unreachableUrl)
 {
     Q_D(QQuickWebView);
-    d->webPageProxy->loadHTMLString(html, baseUrl.toString());
+    if (unreachableUrl.isValid())
+        d->webPageProxy->loadAlternateHTMLString(html, baseUrl.toString(), unreachableUrl.toString());
+    else
+        d->webPageProxy->loadHTMLString(html, baseUrl.toString());
 }
 
 QPointF QQuickWebView::pageItemPos()

Modified: trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h (115190 => 115191)


--- trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h	2012-04-25 13:15:06 UTC (rev 115190)
+++ trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h	2012-04-25 13:29:00 UTC (rev 115191)
@@ -149,7 +149,7 @@
     void setZoomFactor(qreal);
 
 public Q_SLOTS:
-    void loadHtml(const QString& html, const QUrl& baseUrl = QUrl());
+    void loadHtml(const QString& html, const QUrl& baseUrl = QUrl(), const QUrl& unreachableUrl = QUrl());
 
     void goBack();
     void goForward();
@@ -202,6 +202,8 @@
     QQuickWebView(WKContextRef, WKPageGroupRef, QQuickItem* parent = 0);
     WKPageRef pageRef() const;
 
+    void emitUrlChangeIfNeeded();
+
     Q_PRIVATE_SLOT(d_func(), void _q_suspend());
     Q_PRIVATE_SLOT(d_func(), void _q_resume());
     Q_PRIVATE_SLOT(d_func(), void _q_contentViewportChanged(const QPointF&));

Modified: trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h (115190 => 115191)


--- trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h	2012-04-25 13:15:06 UTC (rev 115190)
+++ trunk/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h	2012-04-25 13:29:00 UTC (rev 115191)
@@ -194,7 +194,8 @@
     bool m_loadStartedSignalSent;
     bool m_dialogActive;
     QUrl m_iconURL;
-    QUrl m_deferedUrlToLoad;
+    QUrl m_deferredUrlToLoad;
+    WTF::String m_currentUrl;
 };
 
 class QQuickWebViewLegacyPrivate : public QQuickWebViewPrivate {

Modified: trunk/Source/WebKit2/UIProcess/API/qt/tests/publicapi/tst_publicapi.cpp (115190 => 115191)


--- trunk/Source/WebKit2/UIProcess/API/qt/tests/publicapi/tst_publicapi.cpp	2012-04-25 13:15:06 UTC (rev 115190)
+++ trunk/Source/WebKit2/UIProcess/API/qt/tests/publicapi/tst_publicapi.cpp	2012-04-25 13:29:00 UTC (rev 115191)
@@ -70,6 +70,7 @@
     << "QQuickWebView.iconChanged() --> void"
     << "QQuickWebView.linkHovered(QUrl,QString) --> void"
     << "QQuickWebView.navigationRequested(QWebNavigationRequest*) --> void"
+    << "QQuickWebView.loadHtml(QString,QUrl,QUrl) --> void"
     << "QQuickWebView.loadHtml(QString,QUrl) --> void"
     << "QQuickWebView.loadHtml(QString) --> void"
     << "QQuickWebView.goBack() --> void"

Modified: trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior.pro (115190 => 115191)


--- trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior.pro	2012-04-25 13:15:06 UTC (rev 115190)
+++ trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior.pro	2012-04-25 13:29:00 UTC (rev 115191)
@@ -15,10 +15,5 @@
 DEFINES += IMPORT_DIR=\"\\\"$${ROOT_BUILD_DIR}$${QMAKE_DIR_SEP}imports\\\"\"
 
 OTHER_FILES += \
-    DesktopBehavior/DesktopWebView.qml \
-    DesktopBehavior/tst_linkHovered.qml \
-    DesktopBehavior/tst_loadHtml.qml \
-    DesktopBehavior/tst_messaging.qml \
-    DesktopBehavior/tst_navigationRequested.qml \
-    DesktopBehavior/tst_singleFileupload.qml \
-    DesktopBehavior/tst_multiFileupload.qml
+    DesktopBehavior/*.qml \
+    common/*

Modified: trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_loadUrl.qml (115190 => 115191)


--- trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_loadUrl.qml	2012-04-25 13:15:06 UTC (rev 115190)
+++ trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_loadUrl.qml	2012-04-25 13:29:00 UTC (rev 115191)
@@ -10,6 +10,8 @@
     property int numLoadStarted: 0
     property int numLoadSucceeded: 0
 
+    focus: true
+
     onLoadProgressChanged: {
         if (watchProgress && webView.loadProgress != 100) {
             watchProgress = false
@@ -27,6 +29,8 @@
     TestCase {
         id: test
         name: "WebViewLoadUrl"
+        when: windowShown
+
         function test_loadIgnoreEmptyUrl() {
             var url = ""
 
@@ -58,5 +62,63 @@
             verify(!watchProgress)
             compare(webView.url, url)
         }
+
+        function test_urlProperty() {
+            var url = ""
+
+            webView.url = ""
+            compare(webView.url, url)
+            verify(webView.waitForLoadSucceeded())
+            compare(webView.url, url)
+
+            var bogusSite = "http://www.somesitethatdoesnotexist.abc/"
+            webView.url = ""
+            compare(webView.url, bogusSite)
+            verify(webView.waitForLoadFailed())
+            compare(webView.url, bogusSite)
+
+            webView.url = "" // Reset from previous test
+            verify(webView.waitForLoadSucceeded())
+
+            var handleLoadFailed = function(loadRequest) {
+                if (loadRequest.status == WebView.LoadFailedStatus) {
+                    compare(webView.url, bogusSite)
+                    compare(loadRequest.url, bogusSite)
+                    webView.loadHtml("load failed", bogusSite, bogusSite)
+                }
+            }
+            webView.loadingChanged.connect(handleLoadFailed)
+            webView.url = ""
+            compare(webView.url, bogusSite)
+            verify(webView.waitForLoadSucceeded())
+            compare(webView.url, bogusSite)
+            webView.loadingChanged.disconnect(handleLoadFailed)
+
+            var dataUrl = "data:text/html,foo"
+            webView.url = ""
+            compare(webView.url, dataUrl)
+
+            var redirectUrl = Qt.resolvedUrl("../common/redirect.html")
+            webView.url = ""
+            compare(webView.url, redirectUrl)
+            verify(webView.waitForLoadSucceeded())
+            compare(webView.url, redirectUrl)
+            verify(webView.waitForLoadSucceeded())
+            compare(webView.url, url)
+
+            var linkUrl = Qt.resolvedUrl("../common/link.html")
+            webView.url = ""
+            compare(webView.url, linkUrl)
+            verify(webView.waitForLoadSucceeded())
+            compare(webView.url, linkUrl)
+            webView.loadingChanged.connect(function(loadRequest) {
+                compare(webView.url, loadRequest.url)
+                compare(webView.url, url)
+            })
+            webView.forceActiveFocus()
+            keyPress(Qt.Key_Return) // Link is focused
+            verify(webView.waitForLoadSucceeded())
+            compare(webView.url, url)
+        }
     }
 }

Modified: trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView.pro (115190 => 115191)


--- trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView.pro	2012-04-25 13:15:06 UTC (rev 115190)
+++ trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView.pro	2012-04-25 13:29:00 UTC (rev 115191)
@@ -14,18 +14,5 @@
 DEFINES += IMPORT_DIR=\"\\\"$${ROOT_BUILD_DIR}$${QMAKE_DIR_SEP}imports\\\"\"
 
 OTHER_FILES += \
-    WebView/tst_favIconLoad.qml \
-    WebView/tst_download.qml \
-    WebView/tst_geopermission.qml \
-    WebView/tst_itemSelector.qml \
-    WebView/tst_javaScriptDialogs.qml \
-    WebView/tst_loadFail.qml \
-    WebView/tst_loadIgnore.qml \
-    WebView/tst_loadHtml.qml \
-    WebView/tst_loadProgress.qml \
-    WebView/tst_loadProgressSignal.qml \
-    WebView/tst_preferences.qml \
-    WebView/tst_properties.qml \
-    WebView/tst_titleChanged.qml \
-    WebView/tst_applicationScheme.qml \
-    WebView/tst_origin.qml
+    WebView/tst_*.qml \
+    common/*

Added: trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/link.html (0 => 115191)


--- trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/link.html	                        (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/link.html	2012-04-25 13:29:00 UTC (rev 115191)
@@ -0,0 +1,6 @@
+<!doctype html>
+<html>
+<body _onload_="document.links['foo'].focus();">
+<a name="foo" href=""
+</body>
+</html>

Added: trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/redirect.html (0 => 115191)


--- trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/redirect.html	                        (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/redirect.html	2012-04-25 13:29:00 UTC (rev 115191)
@@ -0,0 +1,8 @@
+<!doctype html>
+<html>
+<head>
+<meta http-equiv="refresh" content="2; url=""
+</head>
+<body>
+</body>
+</html>

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (115190 => 115191)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2012-04-25 13:15:06 UTC (rev 115190)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2012-04-25 13:29:00 UTC (rev 115191)
@@ -657,13 +657,13 @@
 
 String WebPageProxy::activeURL() const
 {
-    if (!m_mainFrame)
-        return String();
-
     // If there is a currently pending url, it is the active URL.
     if (!m_pendingAPIRequestURL.isNull())
         return m_pendingAPIRequestURL;
 
+    if (!m_mainFrame)
+        return String();
+
     if (!m_mainFrame->unreachableURL().isEmpty())
         return m_mainFrame->unreachableURL();
 

Modified: trunk/Source/WebKit2/UIProcess/qt/QtWebPageLoadClient.cpp (115190 => 115191)


--- trunk/Source/WebKit2/UIProcess/qt/QtWebPageLoadClient.cpp	2012-04-25 13:15:06 UTC (rev 115190)
+++ trunk/Source/WebKit2/UIProcess/qt/QtWebPageLoadClient.cpp	2012-04-25 13:29:00 UTC (rev 115191)
@@ -39,6 +39,7 @@
     loadClient.version = kWKPageLoaderClientCurrentVersion;
     loadClient.clientInfo = this;
     loadClient.didStartProvisionalLoadForFrame = didStartProvisionalLoadForFrame;
+    loadClient.didReceiveServerRedirectForProvisionalLoadForFrame = didReceiveServerRedirectForProvisionalLoadForFrame;
     loadClient.didFailProvisionalLoadWithErrorForFrame = didFailProvisionalLoadWithErrorForFrame;
     loadClient.didCommitLoadForFrame = didCommitLoadForFrame;
     loadClient.didFinishLoadForFrame = didFinishLoadForFrame;
@@ -56,21 +57,26 @@
 void QtWebPageLoadClient::didStartProvisionalLoadForFrame(const QUrl& url)
 {
     QWebLoadRequest loadRequest(url, QQuickWebView::LoadStartedStatus);
+    m_webView->emitUrlChangeIfNeeded();
     m_webView->d_func()->didChangeLoadingState(&loadRequest);
 }
 
+void QtWebPageLoadClient::didReceiveServerRedirectForProvisionalLoadForFrame(const QUrl& url)
+{
+    m_webView->emitUrlChangeIfNeeded();
+}
+
 void QtWebPageLoadClient::didCommitLoadForFrame()
 {
     emit m_webView->navigationHistoryChanged();
-    emit m_webView->urlChanged();
     emit m_webView->titleChanged();
     m_webView->d_func()->loadDidCommit();
 }
 
 void QtWebPageLoadClient::didSameDocumentNavigationForFrame()
 {
+    m_webView->emitUrlChangeIfNeeded();
     emit m_webView->navigationHistoryChanged();
-    emit m_webView->urlChanged();
 }
 
 void QtWebPageLoadClient::didReceiveTitleForFrame()
@@ -93,16 +99,31 @@
     m_webView->d_func()->loadDidSucceed();
 }
 
-void QtWebPageLoadClient::dispatchLoadFailed(WKErrorRef error)
+void QtWebPageLoadClient::dispatchLoadFailed(WKFrameRef frame, WKErrorRef error)
 {
     int errorCode = WKErrorGetErrorCode(error);
     if (toImpl(error)->platformError().isCancellation() || errorCode == kWKErrorCodeFrameLoadInterruptedByPolicyChange || errorCode == kWKErrorCodePlugInWillHandleLoad) {
+        // The active url might have changed
+        m_webView->emitUrlChangeIfNeeded();
+
         // Make sure that LoadStartedStatus has a counterpart when e.g. requesting a download.
         dispatchLoadSucceeded();
+
         return;
     }
 
     QtWebError qtError(error);
+
+    // We set the unreachable url unconditionally so that the current
+    // active url of the webview when the loadingChanged signal is
+    // emitted reflects the failed url, not the previously committed
+    // url. This also ensures that if the user does not do a loadHtml
+    // with an error page and and unreachable url, as a reponse to the
+    // failed load, we can still detect the failed url for reloads.
+    WebFrameProxy* wkframe = toImpl(frame);
+    wkframe->setUnreachableURL(toImpl(error)->failingURL());
+    m_webView->emitUrlChangeIfNeeded();
+
     QWebLoadRequest loadRequest(qtError.url(), QQuickWebView::LoadFailedStatus, qtError.description(), static_cast<QQuickWebView::ErrorDomain>(qtError.type()), qtError.errorCode());
     emit m_webView->loadingChanged(&loadRequest);
 }
@@ -129,11 +150,22 @@
     toQtWebPageLoadClient(clientInfo)->didStartProvisionalLoadForFrame(qUrl);
 }
 
+void QtWebPageLoadClient::didReceiveServerRedirectForProvisionalLoadForFrame(WKPageRef, WKFrameRef frame, WKTypeRef, const void* clientInfo)
+{
+    if (!WKFrameIsMainFrame(frame))
+        return;
+    WebFrameProxy* wkframe = toImpl(frame);
+    QString urlStr(wkframe->provisionalURL());
+    QUrl qUrl = urlStr;
+    toQtWebPageLoadClient(clientInfo)->didReceiveServerRedirectForProvisionalLoadForFrame(qUrl);
+}
+
 void QtWebPageLoadClient::didFailProvisionalLoadWithErrorForFrame(WKPageRef, WKFrameRef frame, WKErrorRef error, WKTypeRef, const void* clientInfo)
 {
     if (!WKFrameIsMainFrame(frame))
         return;
-    toQtWebPageLoadClient(clientInfo)->dispatchLoadFailed(error);
+
+    toQtWebPageLoadClient(clientInfo)->dispatchLoadFailed(frame, error);
 }
 
 void QtWebPageLoadClient::didCommitLoadForFrame(WKPageRef, WKFrameRef frame, WKTypeRef, const void* clientInfo)
@@ -154,7 +186,7 @@
 {
     if (!WKFrameIsMainFrame(frame))
         return;
-    toQtWebPageLoadClient(clientInfo)->dispatchLoadFailed(error);
+    toQtWebPageLoadClient(clientInfo)->dispatchLoadFailed(frame, error);
 }
 
 void QtWebPageLoadClient::didSameDocumentNavigationForFrame(WKPageRef page, WKFrameRef frame, WKSameDocumentNavigationType type, WKTypeRef userData, const void* clientInfo)

Modified: trunk/Source/WebKit2/UIProcess/qt/QtWebPageLoadClient.h (115190 => 115191)


--- trunk/Source/WebKit2/UIProcess/qt/QtWebPageLoadClient.h	2012-04-25 13:15:06 UTC (rev 115190)
+++ trunk/Source/WebKit2/UIProcess/qt/QtWebPageLoadClient.h	2012-04-25 13:29:00 UTC (rev 115191)
@@ -40,6 +40,7 @@
 
 private:
     void didStartProvisionalLoadForFrame(const QUrl&);
+    void didReceiveServerRedirectForProvisionalLoadForFrame(const QUrl&);
     void didCommitLoadForFrame();
     void didSameDocumentNavigationForFrame();
     void didReceiveTitleForFrame();
@@ -47,11 +48,12 @@
     void didChangeBackForwardList();
 
     void dispatchLoadSucceeded();
-    void dispatchLoadFailed(WKErrorRef);
+    void dispatchLoadFailed(WKFrameRef, WKErrorRef);
     void setLoadProgress(int);
 
     // WKPageLoadClient callbacks.
     static void didStartProvisionalLoadForFrame(WKPageRef, WKFrameRef, WKTypeRef userData, const void* clientInfo);
+    static void didReceiveServerRedirectForProvisionalLoadForFrame(WKPageRef, WKFrameRef, WKTypeRef userData, const void* clientInfo);
     static void didFailProvisionalLoadWithErrorForFrame(WKPageRef, WKFrameRef, WKErrorRef, WKTypeRef userData, const void* clientInfo);
     static void didCommitLoadForFrame(WKPageRef, WKFrameRef, WKTypeRef userData, const void* clientInfo);
     static void didFinishLoadForFrame(WKPageRef, WKFrameRef, WKTypeRef userData, const void* clientInfo);

Modified: trunk/Tools/ChangeLog (115190 => 115191)


--- trunk/Tools/ChangeLog	2012-04-25 13:15:06 UTC (rev 115190)
+++ trunk/Tools/ChangeLog	2012-04-25 13:29:00 UTC (rev 115191)
@@ -1,3 +1,17 @@
+2012-04-18  Tor Arne Vestbø  <tor.arne.ves...@nokia.com>
+
+        [Qt] Make the web view's url property follow the active url
+
+        https://bugs.webkit.org/show_bug.cgi?id=77554
+
+        Update  the location bar in the minibrowser to behave
+        a bit more like normal browsers in terms of when the url will change
+        and how active focus is handled.
+
+        Reviewed by Simon Hausmann.
+
+        * MiniBrowser/qt/qml/BrowserWindow.qml:
+
 2012-04-25  Philippe Normand  <pnorm...@igalia.com>
 
         Webkit build fails due to missing gstreamer include file on Kubuntu 8.04

Modified: trunk/Tools/MiniBrowser/qt/qml/BrowserWindow.qml (115190 => 115191)


--- trunk/Tools/MiniBrowser/qt/qml/BrowserWindow.qml	2012-04-25 13:15:06 UTC (rev 115190)
+++ trunk/Tools/MiniBrowser/qt/qml/BrowserWindow.qml	2012-04-25 13:29:00 UTC (rev 115191)
@@ -41,10 +41,12 @@
 
     function load(address) {
         webView.url = ""
+        webView.forceActiveFocus()
     }
 
     function reload() {
         webView.reload()
+        webView.forceActiveFocus()
     }
 
     function focusAddressBar() {
@@ -251,10 +253,10 @@
                     left: parent.left
                 }
                 radius: 3
-                width: parent.width / 100 * webView.loadProgress
+                width: parent.width / 100 * Math.max(5, webView.loadProgress)
                 color: "blue"
                 opacity: 0.3
-                visible: webView.loadProgress != 100
+                visible: webView.loading
             }
             Image {
                 id: favIcon
@@ -271,6 +273,7 @@
                 id: addressLine
                 clip: true
                 selectByMouse: true
+                horizontalAlignment: TextInput.AlignLeft
                 font {
                     pointSize: 11
                     family: "Sans"
@@ -283,9 +286,21 @@
                 }
 
                 Keys.onReturnPressed:{
-                    console.log("going to: ", addressLine.text)
-                    webView.url = ""
+                    console.log("Navigating to: ", addressLine.text)
+                    load(utils.urlFromUserInput(addressLine.text))
                 }
+
+                property url url
+
+                onUrlChanged: {
+                    if (activeFocus)
+                        return;
+
+                    text = url
+                    cursorPosition = 0
+                }
+
+                onActiveFocusChanged: url = ""
             }
         }
     }
@@ -301,12 +316,17 @@
 
         onTitleChanged: pageTitleChanged(title)
         onUrlChanged: {
-            addressLine.text = url
+            addressLine.url = ""
+
             if (options.printLoadedUrls)
-                console.log("Loaded:", webView.url.toString());
-            forceActiveFocus();
+                console.log("WebView url changed:", webView.url.toString());
         }
 
+        onLoadingChanged: {
+            if (!loading && loadRequest.status == WebView.LoadFailedStatus)
+                webView.loadHtml("Failed to load " + loadRequest.url, "", loadRequest.url)
+        }
+
         experimental.itemSelector: ItemSelector { }
         experimental.alertDialog: AlertDialog { }
         experimental.confirmDialog: ConfirmDialog { }

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2/PageLoadBasic.cpp (115190 => 115191)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2/PageLoadBasic.cpp	2012-04-25 13:15:06 UTC (rev 115190)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2/PageLoadBasic.cpp	2012-04-25 13:29:00 UTC (rev 115191)
@@ -138,6 +138,10 @@
     WKRetainPtr<WKURLRef> url(AdoptWK, Util::createURLForResource("simple", "html"));
     WKPageLoadURL(webView.page(), url.get());
 
+    WKRetainPtr<WKURLRef> activeUrl = adoptWK(WKPageCopyActiveURL(webView.page()));
+    ASSERT_NOT_NULL(activeUrl.get());
+    EXPECT_TRUE(WKURLIsEqual(activeUrl.get(), url.get()));
+
     Util::run(&test1Done);
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to