Changeset 95472 in webkit


Ignore:
Timestamp:
Sep 19, 2011 2:09:56 PM (13 years ago)
Author:
alexis.menard@openbossa.org
Message:

[Qt][WK2] Make loading errors API easier to use.
https://bugs.webkit.org/show_bug.cgi?id=68357

Reviewed by Tor Arne Vestbø.

Make the API to get loading errors easier to use. 95197 introduced
a QJSValue API that is a bit opaque for the client code. Rather than
using a dedicated object, we can just pass the needed information as
parameters of the slot.

  • 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/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/QtWebPageProxy.cpp:

(QtWebPageProxy::loadDidFail):

  • UIProcess/qt/TouchViewInterface.cpp:

(WebKit::TouchViewInterface::loadDidFail):

  • UIProcess/qt/TouchViewInterface.h:
  • UIProcess/qt/ViewInterface.h:
Location:
trunk/Source/WebKit2
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r95448 r95472  
     12011-09-19  Alexis Menard  <alexis.menard@openbossa.org>
     2
     3        [Qt][WK2] Make loading errors API easier to use.
     4        https://bugs.webkit.org/show_bug.cgi?id=68357
     5
     6        Reviewed by Tor Arne Vestbø.
     7
     8        Make the API to get loading errors easier to use. 95197 introduced
     9        a QJSValue API that is a bit opaque for the client code. Rather than
     10        using a dedicated object, we can just pass the needed information as
     11        parameters of the slot.
     12
     13        * UIProcess/API/qt/qdesktopwebview.cpp:
     14        (QDesktopWebViewPrivate::loadDidFail):
     15        * UIProcess/API/qt/qdesktopwebview.h:
     16        * UIProcess/API/qt/qdesktopwebview_p.h:
     17        * UIProcess/API/qt/qtouchwebpage.h:
     18        * UIProcess/API/qt/tests/commonviewtests/tst_commonviewtests.cpp:
     19        (tst_CommonViewTests::loadNonexistentFileUrl):
     20        * UIProcess/API/qt/tests/commonviewtests/webviewabstraction.cpp:
     21        (WebViewAbstraction::WebViewAbstraction):
     22        (WebViewAbstraction::touchViewLoadFailed):
     23        (WebViewAbstraction::desktopViewLoadFailed):
     24        * UIProcess/API/qt/tests/commonviewtests/webviewabstraction.h:
     25        * UIProcess/qt/QtWebPageProxy.cpp:
     26        (QtWebPageProxy::loadDidFail):
     27        * UIProcess/qt/TouchViewInterface.cpp:
     28        (WebKit::TouchViewInterface::loadDidFail):
     29        * UIProcess/qt/TouchViewInterface.h:
     30        * UIProcess/qt/ViewInterface.h:
     31
    1322011-09-19  Dan Bernstein  <mitz@apple.com>
    233
  • trunk/Source/WebKit2/UIProcess/API/qt/qdesktopwebview.cpp

    r95197 r95472  
    2222#include "qdesktopwebview.h"
    2323#include "qdesktopwebview_p.h"
     24#include "qweberror.h"
    2425
    2526#include <QGraphicsSceneResizeEvent>
     
    145146}
    146147
    147 void QDesktopWebViewPrivate::loadDidFail(const QJSValue& error)
    148 {
    149     emit q->loadFailed(error);
     148void QDesktopWebViewPrivate::loadDidFail(const QWebError& error)
     149{
     150    emit q->loadFailed(static_cast<QDesktopWebView::ErrorType>(error.type()), error.errorCode(), error.url());
    150151}
    151152
  • trunk/Source/WebKit2/UIProcess/API/qt/qdesktopwebview.h

    r95197 r95472  
    5555    Q_PROPERTY(QWebNavigationController* navigation READ navigationController CONSTANT)
    5656    Q_ENUMS(NavigationPolicy)
    57 
     57    Q_ENUMS(ErrorType)
    5858public:
    5959    enum NavigationPolicy {
     
    6161        DownloadPolicy,
    6262        IgnorePolicy
     63    };
     64
     65    enum ErrorType {
     66        EngineError,
     67        NetworkError,
     68        HttpError,
    6369    };
    6470
     
    8086    void loadStarted();
    8187    void loadSucceeded();
    82     // The parameter needs to be explicitly named to work in QML.
    83     void loadFailed(const QJSValue& error);
     88    void loadFailed(QDesktopWebView::ErrorType errorType, int errorCode, const QUrl& url);
    8489    void loadProgressChanged(int progress);
    8590    void urlChanged(const QUrl&);
  • trunk/Source/WebKit2/UIProcess/API/qt/qdesktopwebview_p.h

    r95197 r95472  
    7272    virtual void loadDidCommit();
    7373    virtual void loadDidSucceed();
    74     virtual void loadDidFail(const QJSValue&);
     74    virtual void loadDidFail(const QWebError&);
    7575    virtual void didChangeLoadProgress(int);
    7676
  • trunk/Source/WebKit2/UIProcess/API/qt/qtouchwebpage.h

    r95197 r95472  
    4242    Q_PROPERTY(int loadProgress READ loadProgress NOTIFY loadProgressChanged)
    4343    Q_PROPERTY(QWebNavigationController* navigation READ navigationController CONSTANT)
     44    Q_ENUMS(ErrorType)
     45public:
     46    enum ErrorType {
     47        EngineError,
     48        NetworkError,
     49        HttpError,
     50    };
    4451
    45 public:
    4652    QTouchWebPage(QSGItem* parent = 0);
    4753
     
    6470    void loadStarted();
    6571    void loadSucceeded();
    66     // The parameter needs to be explicitly named to work in QML.
    67     void loadFailed(const QJSValue& error);
     72    void loadFailed(QTouchWebPage::ErrorType errorType, int errorCode, const QUrl& url);
    6873    void loadProgressChanged(int progress);
    6974
  • trunk/Source/WebKit2/UIProcess/API/qt/tests/commonviewtests/tst_commonviewtests.cpp

    r95197 r95472  
    9898
    9999    viewAbstraction->load(QUrl::fromLocalFile(QLatin1String(TESTS_SOURCE_DIR "/html/file_that_does_not_exist.html")));
    100     QVERIFY(waitForSignal(viewAbstraction.data(), SIGNAL(loadFailed(QJSValue))));
     100    QVERIFY(waitForSignal(viewAbstraction.data(), SIGNAL(loadFailed(QDesktopWebView::ErrorType, int, QUrl))));
    101101
    102102    QCOMPARE(loadFailedSpy.size(), 1);
  • trunk/Source/WebKit2/UIProcess/API/qt/tests/commonviewtests/webviewabstraction.cpp

    r95197 r95472  
    3636    connect(touchWebView()->page(), SIGNAL(loadStarted()), this, SLOT(touchViewLoadStarted()));
    3737    connect(touchWebView()->page(), SIGNAL(loadSucceeded()), this, SLOT(touchViewLoadSucceeded()));
    38     connect(touchWebView()->page(), SIGNAL(loadFailed(QJSValue)), this, SLOT(touchViewLoadFailed(QJSValue)));
     38    connect(touchWebView()->page(), SIGNAL(loadFailed(QTouchWebPage::ErrorType, int, const QUrl&)), this, SLOT(touchViewLoadFailed(QTouchWebPage::ErrorType, int, const QUrl&)));
    3939    connect(touchWebView()->page(), SIGNAL(loadProgressChanged(int)), this, SLOT(touchViewLoadProgressChanged(int)));
    4040
     
    4444    connect(desktopWebView(), SIGNAL(loadStarted()), this, SLOT(desktopViewLoadStarted()));
    4545    connect(desktopWebView(), SIGNAL(loadSucceeded()), this, SLOT(desktopViewLoadSucceeded()));
    46     connect(desktopWebView(), SIGNAL(loadFailed(QJSValue)), this, SLOT(desktopViewLoadFailed(QJSValue)));
     46    connect(desktopWebView(), SIGNAL(loadFailed(QDesktopWebView::ErrorType, int, const QUrl&)), this, SLOT(desktopViewLoadFailed(QDesktopWebView::ErrorType, int, const QUrl&)));
    4747    connect(desktopWebView(), SIGNAL(loadProgressChanged(int)), this, SLOT(desktopViewLoadProgressChanged(int)));
    4848}
     
    134134}
    135135
    136 void WebViewAbstraction::touchViewLoadFailed(const QJSValue& error)
     136void WebViewAbstraction::touchViewLoadFailed(QTouchWebPage::ErrorType errorType, int errorCode, const QUrl& url)
    137137{
    138     m_touchViewSignalsCounter[SIGNAL(loadFailed(QJSValue))]++;
    139     if (m_touchViewSignalsCounter[SIGNAL(loadFailed(QJSValue))] == m_desktopViewSignalsCounter[SIGNAL(loadFailed(QJSValue))])
    140         emit loadFailed(error);
     138    m_touchViewSignalsCounter[SIGNAL(loadFailed(QTouchWebPage::ErrorType, int, const QUrl&))]++;
     139    if (m_touchViewSignalsCounter[SIGNAL(loadFailed(QTouchWebPage::ErrorType, int, const QUrl&))] == m_desktopViewSignalsCounter[SIGNAL(loadFailed(QTouchWebPage::ErrorType, int, QUrl))])
     140        emit loadFailed(static_cast<QDesktopWebView::ErrorType>(errorType), errorCode, url);
    141141}
    142142
    143 void WebViewAbstraction::desktopViewLoadFailed(const QJSValue& error)
     143void WebViewAbstraction::desktopViewLoadFailed(QDesktopWebView::ErrorType errorType, int errorCode, const QUrl& url)
    144144{
    145     m_desktopViewSignalsCounter[SIGNAL(loadFailed(QJSValue))]++;
    146     if (m_touchViewSignalsCounter[SIGNAL(loadFailed(QJSValue))] == m_desktopViewSignalsCounter[SIGNAL(loadFailed(QJSValue))])
    147         emit loadFailed(error);
     145    m_desktopViewSignalsCounter[SIGNAL(loadFailed(QDesktopWebView::ErrorType, int, const QUrl&))]++;
     146    if (m_touchViewSignalsCounter[SIGNAL(loadFailed(QDesktopWebView::ErrorType, int, const QUrl&))] == m_desktopViewSignalsCounter[SIGNAL(loadFailed(QDesktopWebView::ErrorType, int, QUrl))])
     147        emit loadFailed(errorType, errorCode, url);
    148148}
    149149
  • trunk/Source/WebKit2/UIProcess/API/qt/tests/commonviewtests/webviewabstraction.h

    r95197 r95472  
    4747    void loadStarted();
    4848    void loadSucceeded();
    49     void loadFailed(const QJSValue&);
     49    void loadFailed(QDesktopWebView::ErrorType, int, const QUrl&);
    5050    void loadProgressChanged(int);
    5151
     
    5555    void touchViewLoadSucceeded();
    5656    void desktopViewLoadSucceeded();
    57     void touchViewLoadFailed(const QJSValue&);
    58     void desktopViewLoadFailed(const QJSValue&);
     57    void touchViewLoadFailed(QTouchWebPage::ErrorType, int, const QUrl&);
     58    void desktopViewLoadFailed(QDesktopWebView::ErrorType, int, const QUrl&);
    5959    void touchViewLoadProgressChanged(int);
    6060    void desktopViewLoadProgressChanged(int);
  • trunk/Source/WebKit2/UIProcess/qt/QtWebPageProxy.cpp

    r95197 r95472  
    408408void QtWebPageProxy::loadDidFail(const QWebError& error)
    409409{
    410     QJSEngine* engine = m_viewInterface->engine();
    411     QJSValue value;
    412     if (engine) {
    413         value = engine->newObject();
    414         value.setProperty(QLatin1String("errorCode"), error.errorCode());
    415         value.setProperty(QLatin1String("url"), error.url().toString());
    416         value.setProperty(QLatin1String("type"), error.type());
    417     }
    418     m_viewInterface->loadDidFail(value);
     410    m_viewInterface->loadDidFail(error);
    419411}
    420412
  • trunk/Source/WebKit2/UIProcess/qt/TouchViewInterface.cpp

    r95197 r95472  
    2626#include "qtouchwebview.h"
    2727#include "qtouchwebview_p.h"
     28#include "qweberror.h"
    2829
    2930#include <QDeclarativeEngine>
     
    132133}
    133134
    134 void TouchViewInterface::loadDidFail(const QJSValue& error)
     135void TouchViewInterface::loadDidFail(const QWebError& error)
    135136{
    136     emit m_pageView->loadFailed(error);
     137    emit m_pageView->loadFailed(static_cast<QTouchWebPage::ErrorType>(error.type()), error.errorCode(), error.url());
    137138}
    138139
  • trunk/Source/WebKit2/UIProcess/qt/TouchViewInterface.h

    r95197 r95472  
    6767    virtual void loadDidCommit();
    6868    virtual void loadDidSucceed();
    69     virtual void loadDidFail(const QJSValue&);
     69    virtual void loadDidFail(const QWebError&);
    7070    virtual void didChangeLoadProgress(int);
    7171
  • trunk/Source/WebKit2/UIProcess/qt/ViewInterface.h

    r95197 r95472  
    2727#include <WebKit2/WKBase.h>
    2828
     29class QWebError;
     30
    2931QT_BEGIN_NAMESPACE
    3032class QCursor;
     
    3234class QImage;
    3335class QJSEngine;
    34 class QJSValue;
    3536class QMimeData;
    3637class QPoint;
     
    7677    virtual void loadDidCommit() = 0;
    7778    virtual void loadDidSucceed() = 0;
    78     virtual void loadDidFail(const QJSValue&) = 0;
     79    virtual void loadDidFail(const QWebError&) = 0;
    7980    virtual void didChangeLoadProgress(int) = 0;
    8081
Note: See TracChangeset for help on using the changeset viewer.