Changeset 90820 in webkit


Ignore:
Timestamp:
Jul 12, 2011 9:15:58 AM (13 years ago)
Author:
andreas.kling@nokia.com
Message:

[Qt][WK2] Add informative loadFailed() signal to web views.
https://bugs.webkit.org/show_bug.cgi?id=64362

Reviewed by Benjamin Poulain.

The web views will now emit loadFailed(QWebError) when a load failure occurs.

The QWebError object currently contains:

  • Type of failure (whether it's an engine, network or protocol error.)
  • The failing URL.
  • Any error code associated with the failure.
  • UIProcess/API/qt/qdesktopwebview.cpp:

(QDesktopWebViewPrivate::loadDidFail):

  • UIProcess/API/qt/qdesktopwebview.h:
  • UIProcess/API/qt/qdesktopwebview_p.h:
  • UIProcess/API/qt/qtouchwebpage.h:
  • UIProcess/API/qt/qweberror.cpp: Added.

(QWebError::QWebError):
(QWebErrorPrivate::createQWebError):
(QWebErrorPrivate::QWebErrorPrivate):
(QWebErrorPrivate::~QWebErrorPrivate):
(QWebError::type):
(QWebError::errorCode):
(QWebError::url):

  • UIProcess/API/qt/qweberror.h: Added.
  • UIProcess/API/qt/qweberror_p.h: Added.
  • UIProcess/API/qt/tests/commonviewtests/tst_commonviewtests.cpp:

(tst_CommonViewTests::loadNonexistentFileUrl):

  • UIProcess/API/qt/tests/commonviewtests/webviewabstraction.cpp:

(WebViewAbstraction::WebViewAbstraction):
(WebViewAbstraction::touchViewLoadFailed):
(WebViewAbstraction::desktopViewLoadFailed):

  • UIProcess/API/qt/tests/commonviewtests/webviewabstraction.h:
  • UIProcess/qt/ClientImpl.cpp:

(dispatchLoadSucceeded):
(dispatchLoadFailed):
(qt_wk_didFailProvisionalLoadWithErrorForFrame):
(qt_wk_didFinishLoadForFrame):
(qt_wk_didFailLoadWithErrorForFrame):

  • UIProcess/qt/QtWebPageProxy.cpp:

(QtWebPageProxy::loadDidFail):

  • UIProcess/qt/QtWebPageProxy.h:
  • UIProcess/qt/TouchViewInterface.cpp:

(WebKit::TouchViewInterface::loadDidFail):

  • UIProcess/qt/TouchViewInterface.h:
  • UIProcess/qt/ViewInterface.h:
  • WebKit2API.pri:
Location:
trunk/Source/WebKit2
Files:
3 added
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r90817 r90820  
     12011-07-12  Andreas Kling  <kling@webkit.org>
     2
     3        [Qt][WK2] Add informative loadFailed() signal to web views.
     4        https://bugs.webkit.org/show_bug.cgi?id=64362
     5
     6        Reviewed by Benjamin Poulain.
     7
     8        The web views will now emit loadFailed(QWebError) when a load failure occurs.
     9
     10        The QWebError object currently contains:
     11        - Type of failure (whether it's an engine, network or protocol error.)
     12        - The failing URL.
     13        - Any error code associated with the failure.
     14
     15        * UIProcess/API/qt/qdesktopwebview.cpp:
     16        (QDesktopWebViewPrivate::loadDidFail):
     17        * UIProcess/API/qt/qdesktopwebview.h:
     18        * UIProcess/API/qt/qdesktopwebview_p.h:
     19        * UIProcess/API/qt/qtouchwebpage.h:
     20        * UIProcess/API/qt/qweberror.cpp: Added.
     21        (QWebError::QWebError):
     22        (QWebErrorPrivate::createQWebError):
     23        (QWebErrorPrivate::QWebErrorPrivate):
     24        (QWebErrorPrivate::~QWebErrorPrivate):
     25        (QWebError::type):
     26        (QWebError::errorCode):
     27        (QWebError::url):
     28        * UIProcess/API/qt/qweberror.h: Added.
     29        * UIProcess/API/qt/qweberror_p.h: Added.
     30        * UIProcess/API/qt/tests/commonviewtests/tst_commonviewtests.cpp:
     31        (tst_CommonViewTests::loadNonexistentFileUrl):
     32        * UIProcess/API/qt/tests/commonviewtests/webviewabstraction.cpp:
     33        (WebViewAbstraction::WebViewAbstraction):
     34        (WebViewAbstraction::touchViewLoadFailed):
     35        (WebViewAbstraction::desktopViewLoadFailed):
     36        * UIProcess/API/qt/tests/commonviewtests/webviewabstraction.h:
     37        * UIProcess/qt/ClientImpl.cpp:
     38        (dispatchLoadSucceeded):
     39        (dispatchLoadFailed):
     40        (qt_wk_didFailProvisionalLoadWithErrorForFrame):
     41        (qt_wk_didFinishLoadForFrame):
     42        (qt_wk_didFailLoadWithErrorForFrame):
     43        * UIProcess/qt/QtWebPageProxy.cpp:
     44        (QtWebPageProxy::loadDidFail):
     45        * UIProcess/qt/QtWebPageProxy.h:
     46        * UIProcess/qt/TouchViewInterface.cpp:
     47        (WebKit::TouchViewInterface::loadDidFail):
     48        * UIProcess/qt/TouchViewInterface.h:
     49        * UIProcess/qt/ViewInterface.h:
     50        * WebKit2API.pri:
     51
    1522011-07-12  Jocelyn Turcotte  <jocelyn.turcotte@nokia.com>
    253
  • trunk/Source/WebKit2/UIProcess/API/qt/qdesktopwebview.cpp

    r90647 r90820  
    113113}
    114114
     115void QDesktopWebViewPrivate::loadDidFail(const QWebError& error)
     116{
     117    emit q->loadFailed(error);
     118}
     119
    115120void QDesktopWebViewPrivate::didChangeLoadProgress(int percentageLoaded)
    116121{
  • trunk/Source/WebKit2/UIProcess/API/qt/qdesktopwebview.h

    r90647 r90820  
    3030
    3131class QDesktopWebViewPrivate;
     32class QWebError;
    3233
    3334namespace WTR {
     
    5758    void loadStarted();
    5859    void loadSucceeded();
     60    void loadFailed(const QWebError&);
    5961    void loadProgress(int progress);
    6062    void urlChanged(const QUrl&);
  • trunk/Source/WebKit2/UIProcess/API/qt/qdesktopwebview_p.h

    r90577 r90820  
    5959    virtual void loadDidBegin();
    6060    virtual void loadDidSucceed();
     61    virtual void loadDidFail(const QWebError&);
    6162    virtual void didChangeLoadProgress(int);
    6263
  • trunk/Source/WebKit2/UIProcess/API/qt/qtouchwebpage.h

    r90766 r90820  
    3030class QTouchWebPagePrivate;
    3131class QTouchWebPageProxy;
     32class QWebError;
    3233
    3334namespace WebKit {
     
    6061    void loadStarted();
    6162    void loadSucceeded();
     63    void loadFailed(const QWebError&);
    6264    void loadProgress(int progress);
    6365
  • trunk/Source/WebKit2/UIProcess/API/qt/tests/commonviewtests/tst_commonviewtests.cpp

    r90647 r90820  
    3434    void loadEmptyPageViewVisible();
    3535    void loadEmptyPageViewHidden();
     36    void loadNonexistentFileUrl();
    3637    void backAndForward();
    3738    void reload();
     
    8182
    8283    QCOMPARE(loadStartedSpy.size(), 1);
     84}
     85
     86void tst_CommonViewTests::loadNonexistentFileUrl()
     87{
     88    QSignalSpy loadFailedSpy(viewAbstraction.data(), SIGNAL(loadStarted()));
     89
     90    viewAbstraction->load(QUrl::fromLocalFile(QLatin1String(TESTS_SOURCE_DIR "/html/file_that_does_not_exist.html")));
     91    QVERIFY(waitForSignal(viewAbstraction.data(), SIGNAL(loadFailed(QWebError))));
     92
     93    QCOMPARE(loadFailedSpy.size(), 1);
    8394}
    8495
  • trunk/Source/WebKit2/UIProcess/API/qt/tests/commonviewtests/webviewabstraction.cpp

    r90647 r90820  
    3535    connect(touchWebView()->page(), SIGNAL(loadStarted()), this, SLOT(touchViewLoadStarted()));
    3636    connect(touchWebView()->page(), SIGNAL(loadSucceeded()), this, SLOT(touchViewLoadSucceeded()));
     37    connect(touchWebView()->page(), SIGNAL(loadFailed(QWebError)), this, SLOT(touchViewLoadFailed(QWebError)));
    3738
    3839    screenHalf.moveLeft(screenHalf.right());
     
    4142    connect(desktopWebView(), SIGNAL(loadStarted()), this, SLOT(desktopViewLoadStarted()));
    4243    connect(desktopWebView(), SIGNAL(loadSucceeded()), this, SLOT(desktopViewLoadSucceeded()));
     44    connect(desktopWebView(), SIGNAL(loadFailed(QWebError)), this, SLOT(desktopViewLoadFailed(QWebError)));
    4345}
    4446
     
    114116}
    115117
     118void WebViewAbstraction::touchViewLoadFailed(const QWebError& error)
     119{
     120    m_touchViewSignalsCounter[SIGNAL(loadFailed(QWebError))]++;
     121    if (m_touchViewSignalsCounter[SIGNAL(loadFailed(QWebError))] == m_desktopViewSignalsCounter[SIGNAL(loadFailed(QWebError))])
     122        emit loadFailed(error);
     123}
     124
     125void WebViewAbstraction::desktopViewLoadFailed(const QWebError& error)
     126{
     127    m_desktopViewSignalsCounter[SIGNAL(loadFailed(QWebError))]++;
     128    if (m_touchViewSignalsCounter[SIGNAL(loadFailed(QWebError))] == m_desktopViewSignalsCounter[SIGNAL(loadFailed(QWebError))])
     129        emit loadFailed(error);
     130}
     131
    116132QTouchWebView* WebViewAbstraction::touchWebView() const
    117133{
  • trunk/Source/WebKit2/UIProcess/API/qt/tests/commonviewtests/webviewabstraction.h

    r90647 r90820  
    4646    void loadStarted();
    4747    void loadSucceeded();
     48    void loadFailed(const QWebError&);
    4849
    4950private Q_SLOTS:
     
    5253    void touchViewLoadSucceeded();
    5354    void desktopViewLoadSucceeded();
     55    void touchViewLoadFailed(const QWebError&);
     56    void desktopViewLoadFailed(const QWebError&);
    5457
    5558private:
  • trunk/Source/WebKit2/UIProcess/qt/ClientImpl.cpp

    r90766 r90820  
    2525#include "WKStringQt.h"
    2626#include "WKURLQt.h"
     27#include "qweberror.h"
     28#include "qweberror_p.h"
    2729#include <qwkcontext.h>
    2830#include <QtWebPageProxy.h>
     
    4648}
    4749
    48 static void loadFinished(WKFrameRef frame, const void* clientInfo, bool ok)
    49 {
    50     if (!WKFrameIsMainFrame(frame))
    51         return;
    52     if (ok)
    53         toQtWebPageProxy(clientInfo)->loadDidSucceed();
    54     else {
    55         // FIXME: loadDidFail().
    56     }
    57     toQtWebPageProxy(clientInfo)->updateNavigationActions();
     50static void dispatchLoadSucceeded(WKFrameRef frame, const void* clientInfo)
     51{
     52    if (!WKFrameIsMainFrame(frame))
     53        return;
     54
     55    toQtWebPageProxy(clientInfo)->updateNavigationActions();
     56    toQtWebPageProxy(clientInfo)->loadDidSucceed();
     57}
     58
     59static void dispatchLoadFailed(WKFrameRef frame, const void* clientInfo, WKErrorRef error)
     60{
     61    if (!WKFrameIsMainFrame(frame))
     62        return;
     63
     64    toQtWebPageProxy(clientInfo)->updateNavigationActions();
     65    toQtWebPageProxy(clientInfo)->loadDidFail(QWebErrorPrivate::createQWebError(error));
    5866}
    5967
     
    7280void qt_wk_didFailProvisionalLoadWithErrorForFrame(WKPageRef page, WKFrameRef frame, WKErrorRef error, WKTypeRef userData, const void* clientInfo)
    7381{
    74     loadFinished(frame, clientInfo, false);
     82    dispatchLoadFailed(frame, clientInfo, error);
    7583}
    7684
     
    93101void qt_wk_didFinishLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo)
    94102{
    95     loadFinished(frame, clientInfo, true);
     103    dispatchLoadSucceeded(frame, clientInfo);
    96104}
    97105
    98106void qt_wk_didFailLoadWithErrorForFrame(WKPageRef page, WKFrameRef frame, WKErrorRef error, WKTypeRef userData, const void* clientInfo)
    99107{
    100     loadFinished(frame, clientInfo, false);
     108    dispatchLoadFailed(frame, clientInfo, error);
    101109}
    102110
  • trunk/Source/WebKit2/UIProcess/qt/QtWebPageProxy.cpp

    r90750 r90820  
    456456}
    457457
     458void QtWebPageProxy::loadDidFail(const QWebError& error)
     459{
     460    m_viewInterface->loadDidFail(error);
     461}
     462
    458463void QtWebPageProxy::didChangeLoadProgress(int newLoadProgress)
    459464{
  • trunk/Source/WebKit2/UIProcess/qt/QtWebPageProxy.h

    r90766 r90820  
    148148    void loadDidBegin();
    149149    void loadDidSucceed();
     150    void loadDidFail(const QWebError&);
    150151    void didChangeLoadProgress(int);
    151152
  • trunk/Source/WebKit2/UIProcess/qt/TouchViewInterface.cpp

    r90750 r90820  
    135135}
    136136
     137void TouchViewInterface::loadDidFail(const QWebError& error)
     138{
     139    emit m_pageView->loadFailed(error);
     140}
     141
    137142void TouchViewInterface::didChangeLoadProgress(int percentageLoaded)
    138143{
  • trunk/Source/WebKit2/UIProcess/qt/TouchViewInterface.h

    r90750 r90820  
    5959    virtual void loadDidBegin();
    6060    virtual void loadDidSucceed();
     61    virtual void loadDidFail(const QWebError&);
    6162    virtual void didChangeLoadProgress(int);
    6263
  • trunk/Source/WebKit2/UIProcess/qt/ViewInterface.h

    r90577 r90820  
    2525#include <QtCore/QSize>
    2626#include <QtGui/QMenu>
     27
     28class QWebError;
    2729
    2830QT_BEGIN_NAMESPACE
     
    6062    virtual void loadDidBegin() = 0;
    6163    virtual void loadDidSucceed() = 0;
     64    virtual void loadDidFail(const QWebError&) = 0;
    6265    virtual void didChangeLoadProgress(int) = 0;
    6366
  • trunk/Source/WebKit2/WebKit2API.pri

    r90647 r90820  
    77    $$SOURCE_DIR/WebKit2/Shared/API/c/WKContextMenuItem.cpp \
    88    $$SOURCE_DIR/WebKit2/Shared/API/c/WKDictionary.cpp \
     9    $$SOURCE_DIR/WebKit2/Shared/API/c/WKError.cpp \
    910    $$SOURCE_DIR/WebKit2/Shared/API/c/WKGraphicsContext.cpp \
    1011    $$SOURCE_DIR/WebKit2/Shared/API/c/WKImage.cpp \
     
    4849    $$SOURCE_DIR/WebKit2/UIProcess/API/qt/qtouchwebpage.cpp \
    4950    $$SOURCE_DIR/WebKit2/UIProcess/API/qt/qtouchwebview.cpp \
     51    $$SOURCE_DIR/WebKit2/UIProcess/API/qt/qweberror.cpp \
    5052    $$SOURCE_DIR/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp \
    5153    $$SOURCE_DIR/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleBackForwardList.cpp \
     
    7072    $$SOURCE_DIR/WebKit2/Shared/API/c/WKContextMenuItemTypes.h \
    7173    $$SOURCE_DIR/WebKit2/Shared/API/c/WKDictionary.h \
     74    $$SOURCE_DIR/WebKit2/Shared/API/c/WKError.h \
    7275    $$SOURCE_DIR/WebKit2/Shared/API/c/WKGeometry.h \
    7376    $$SOURCE_DIR/WebKit2/Shared/API/c/WKGraphicsContext.h \
     
    126129    $$SOURCE_DIR/WebKit2/UIProcess/API/qt/qtouchwebview.h \
    127130    $$SOURCE_DIR/WebKit2/UIProcess/API/qt/qtouchwebview_p.h \
     131    $$SOURCE_DIR/WebKit2/UIProcess/API/qt/qweberror.h \
     132    $$SOURCE_DIR/WebKit2/UIProcess/API/qt/qweberror_p.h \
    128133    $$SOURCE_DIR/WebKit2/UIProcess/API/qt/qwebkittypes.h \
    129134    $$SOURCE_DIR/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleBackForwardList.h \
Note: See TracChangeset for help on using the changeset viewer.