Changeset 95197 in webkit


Ignore:
Timestamp:
Sep 15, 2011 9:54:57 AM (13 years ago)
Author:
alexis.menard@openbossa.org
Message:

[Qt][WK2] Make QWebError more friendly to QML.
https://bugs.webkit.org/show_bug.cgi?id=67785

Reviewed by Simon Hausmann.

Make sure that we can use the loading errors in QML. We send it via a QJSValue which
has the properties needed to get the error code, the url and the type of error.

  • UIProcess/API/qt/qdesktopwebview.cpp:

(QDesktopWebViewPrivate::loadDidFail):
(QDesktopWebViewPrivate::engine):

  • 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/API/qt/tests/testwindow.h:
  • UIProcess/qt/QtWebPageProxy.cpp:

(QtWebPageProxy::loadDidFail):

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

(WebKit::TouchViewInterface::loadDidFail):
(WebKit::TouchViewInterface::engine):

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

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r95195 r95197  
     12011-09-15  Alexis Menard  <alexis.menard@openbossa.org>
     2
     3        [Qt][WK2] Make QWebError more friendly to QML.
     4        https://bugs.webkit.org/show_bug.cgi?id=67785
     5
     6        Reviewed by Simon Hausmann.
     7
     8        Make sure that we can use the loading errors in QML. We send it via a QJSValue which
     9        has the properties needed to get the error code, the url and the type of error.
     10
     11        * UIProcess/API/qt/qdesktopwebview.cpp:
     12        (QDesktopWebViewPrivate::loadDidFail):
     13        (QDesktopWebViewPrivate::engine):
     14        * UIProcess/API/qt/qdesktopwebview.h:
     15        * UIProcess/API/qt/qdesktopwebview_p.h:
     16        * UIProcess/API/qt/qtouchwebpage.h:
     17        * UIProcess/API/qt/tests/commonviewtests/tst_commonviewtests.cpp:
     18        (tst_CommonViewTests::loadNonexistentFileUrl):
     19        * UIProcess/API/qt/tests/commonviewtests/webviewabstraction.cpp:
     20        (WebViewAbstraction::WebViewAbstraction):
     21        (WebViewAbstraction::touchViewLoadFailed):
     22        (WebViewAbstraction::desktopViewLoadFailed):
     23        * UIProcess/API/qt/tests/commonviewtests/webviewabstraction.h:
     24        * UIProcess/API/qt/tests/testwindow.h:
     25        * UIProcess/qt/QtWebPageProxy.cpp:
     26        (QtWebPageProxy::loadDidFail):
     27        * UIProcess/qt/QtWebPageProxy.h:
     28        * UIProcess/qt/TouchViewInterface.cpp:
     29        (WebKit::TouchViewInterface::loadDidFail):
     30        (WebKit::TouchViewInterface::engine):
     31        * UIProcess/qt/TouchViewInterface.h:
     32        * UIProcess/qt/ViewInterface.h:
     33
    1342011-09-15  Adam Roben  <aroben@apple.com>
    235
  • trunk/Source/WebKit2/UIProcess/API/qt/qdesktopwebview.cpp

    r94979 r95197  
    2525#include <QGraphicsSceneResizeEvent>
    2626#include <QStyleOptionGraphicsItem>
     27#include <QtDeclarative/qdeclarativeengine.h>
    2728#include <QtDeclarative/qsgcanvas.h>
    2829#include <QtDeclarative/qsgevent.h>
    2930#include <QtDeclarative/qsgitem.h>
     31#include <QtDeclarative/qsgview.h>
    3032#include <QtGui/QCursor>
    3133#include <QtGui/QFileDialog>
     
    143145}
    144146
    145 void QDesktopWebViewPrivate::loadDidFail(const QWebError& error)
     147void QDesktopWebViewPrivate::loadDidFail(const QJSValue& error)
    146148{
    147149    emit q->loadFailed(error);
     
    383385}
    384386
     387QJSEngine* QDesktopWebViewPrivate::engine()
     388{
     389    QSGView* view = qobject_cast<QSGView*>(q->canvas());
     390    if (view)
     391        return view->engine();
     392    return 0;
     393}
     394
    385395void QDesktopWebViewPrivate::chooseFiles(WKOpenPanelResultListenerRef listenerRef, const QStringList& selectedFileNames, ViewInterface::FileChooserType type)
    386396{
  • trunk/Source/WebKit2/UIProcess/API/qt/qdesktopwebview.h

    r93427 r95197  
    2929
    3030class QDesktopWebViewPrivate;
    31 class QWebError;
    3231class QWebNavigationController;
    3332
     
    8180    void loadStarted();
    8281    void loadSucceeded();
    83     void loadFailed(const QWebError&);
     82    // The parameter needs to be explicitly named to work in QML.
     83    void loadFailed(const QJSValue& error);
    8484    void loadProgressChanged(int progress);
    8585    void urlChanged(const QUrl&);
  • trunk/Source/WebKit2/UIProcess/API/qt/qdesktopwebview_p.h

    r94979 r95197  
    7272    virtual void loadDidCommit();
    7373    virtual void loadDidSucceed();
    74     virtual void loadDidFail(const QWebError&);
     74    virtual void loadDidFail(const QJSValue&);
    7575    virtual void didChangeLoadProgress(int);
    7676
     
    8080    virtual void processDidCrash();
    8181    virtual void didRelaunchProcess();
     82
     83    virtual QJSEngine* engine();
    8284
    8385    virtual void chooseFiles(WKOpenPanelResultListenerRef, const QStringList& selectedFileNames, ViewInterface::FileChooserType);
  • trunk/Source/WebKit2/UIProcess/API/qt/qtouchwebpage.h

    r94673 r95197  
    3030class QTouchWebPagePrivate;
    3131class QTouchWebPageProxy;
    32 class QWebError;
    3332class QWebNavigationController;
    3433
     
    6564    void loadStarted();
    6665    void loadSucceeded();
    67     void loadFailed(const QWebError&);
     66    // The parameter needs to be explicitly named to work in QML.
     67    void loadFailed(const QJSValue& error);
    6868    void loadProgressChanged(int progress);
    6969
  • trunk/Source/WebKit2/UIProcess/API/qt/tests/commonviewtests/tst_commonviewtests.cpp

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

    r92373 r95197  
    3636    connect(touchWebView()->page(), SIGNAL(loadStarted()), this, SLOT(touchViewLoadStarted()));
    3737    connect(touchWebView()->page(), SIGNAL(loadSucceeded()), this, SLOT(touchViewLoadSucceeded()));
    38     connect(touchWebView()->page(), SIGNAL(loadFailed(QWebError)), this, SLOT(touchViewLoadFailed(QWebError)));
     38    connect(touchWebView()->page(), SIGNAL(loadFailed(QJSValue)), this, SLOT(touchViewLoadFailed(QJSValue)));
    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(QWebError)), this, SLOT(desktopViewLoadFailed(QWebError)));
     46    connect(desktopWebView(), SIGNAL(loadFailed(QJSValue)), this, SLOT(desktopViewLoadFailed(QJSValue)));
    4747    connect(desktopWebView(), SIGNAL(loadProgressChanged(int)), this, SLOT(desktopViewLoadProgressChanged(int)));
    4848}
     
    134134}
    135135
    136 void WebViewAbstraction::touchViewLoadFailed(const QWebError& error)
     136void WebViewAbstraction::touchViewLoadFailed(const QJSValue& error)
    137137{
    138     m_touchViewSignalsCounter[SIGNAL(loadFailed(QWebError))]++;
    139     if (m_touchViewSignalsCounter[SIGNAL(loadFailed(QWebError))] == m_desktopViewSignalsCounter[SIGNAL(loadFailed(QWebError))])
     138    m_touchViewSignalsCounter[SIGNAL(loadFailed(QJSValue))]++;
     139    if (m_touchViewSignalsCounter[SIGNAL(loadFailed(QJSValue))] == m_desktopViewSignalsCounter[SIGNAL(loadFailed(QJSValue))])
    140140        emit loadFailed(error);
    141141}
    142142
    143 void WebViewAbstraction::desktopViewLoadFailed(const QWebError& error)
     143void WebViewAbstraction::desktopViewLoadFailed(const QJSValue& error)
    144144{
    145     m_desktopViewSignalsCounter[SIGNAL(loadFailed(QWebError))]++;
    146     if (m_touchViewSignalsCounter[SIGNAL(loadFailed(QWebError))] == m_desktopViewSignalsCounter[SIGNAL(loadFailed(QWebError))])
     145    m_desktopViewSignalsCounter[SIGNAL(loadFailed(QJSValue))]++;
     146    if (m_touchViewSignalsCounter[SIGNAL(loadFailed(QJSValue))] == m_desktopViewSignalsCounter[SIGNAL(loadFailed(QJSValue))])
    147147        emit loadFailed(error);
    148148}
  • trunk/Source/WebKit2/UIProcess/API/qt/tests/commonviewtests/webviewabstraction.h

    r91985 r95197  
    4747    void loadStarted();
    4848    void loadSucceeded();
    49     void loadFailed(const QWebError&);
     49    void loadFailed(const QJSValue&);
    5050    void loadProgressChanged(int);
    5151
     
    5555    void touchViewLoadSucceeded();
    5656    void desktopViewLoadSucceeded();
    57     void touchViewLoadFailed(const QWebError&);
    58     void desktopViewLoadFailed(const QWebError&);
     57    void touchViewLoadFailed(const QJSValue&);
     58    void desktopViewLoadFailed(const QJSValue&);
    5959    void touchViewLoadProgressChanged(int);
    6060    void desktopViewLoadProgressChanged(int);
  • trunk/Source/WebKit2/UIProcess/API/qt/tests/testwindow.h

    r91863 r95197  
    2323#include <QResizeEvent>
    2424#include <QScopedPointer>
    25 #include <QtDeclarative/qsgcanvas.h>
     25#include <QtDeclarative/qsgview.h>
    2626#include <QtDeclarative/qsgitem.h>
    2727
    2828// TestWindow: Utility class to ignore QGraphicsView details.
    29 class TestWindow : public QSGCanvas {
     29class TestWindow : public QSGView {
    3030public:
    3131    inline TestWindow(QSGItem* webView);
  • trunk/Source/WebKit2/UIProcess/qt/QtWebPageProxy.cpp

    r94979 r95197  
    2222#include "QtWebPageProxy.h"
    2323
     24#include "qweberror.h"
    2425#include "qwkpreferences_p.h"
    2526
     
    4546#include <QApplication>
    4647#include <QGraphicsSceneMouseEvent>
     48#include <QJSEngine>
    4749#include <QStyle>
    4850#include <QTouchEvent>
     
    406408void QtWebPageProxy::loadDidFail(const QWebError& error)
    407409{
    408     m_viewInterface->loadDidFail(error);
     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);
    409419}
    410420
  • trunk/Source/WebKit2/UIProcess/qt/QtWebPageProxy.h

    r93784 r95197  
    4444QT_END_NAMESPACE
    4545
     46class QWebError;
    4647class QWKHistory;
    4748class QWKPreferences;
  • trunk/Source/WebKit2/UIProcess/qt/TouchViewInterface.cpp

    r94672 r95197  
    2626#include "qtouchwebview.h"
    2727#include "qtouchwebview_p.h"
     28
     29#include <QDeclarativeEngine>
     30#include <QSGView>
    2831
    2932namespace WebKit {
     
    129132}
    130133
    131 void TouchViewInterface::loadDidFail(const QWebError& error)
     134void TouchViewInterface::loadDidFail(const QJSValue& error)
    132135{
    133136    emit m_pageView->loadFailed(error);
     
    159162}
    160163
     164QJSEngine* TouchViewInterface::engine()
     165{
     166    QSGView* view = qobject_cast<QSGView*>(m_pageView->canvas());
     167    if (view)
     168        return view->engine();
     169    return 0;
    161170}
     171
     172}
  • trunk/Source/WebKit2/UIProcess/qt/TouchViewInterface.h

    r94979 r95197  
    6767    virtual void loadDidCommit();
    6868    virtual void loadDidSucceed();
    69     virtual void loadDidFail(const QWebError&);
     69    virtual void loadDidFail(const QJSValue&);
    7070    virtual void didChangeLoadProgress(int);
    7171
     
    7575    virtual void processDidCrash();
    7676    virtual void didRelaunchProcess();
     77
     78    virtual QJSEngine* engine();
    7779
    7880    virtual void chooseFiles(WKOpenPanelResultListenerRef, const QStringList&, FileChooserType) { }
  • trunk/Source/WebKit2/UIProcess/qt/ViewInterface.h

    r94979 r95197  
    2727#include <WebKit2/WKBase.h>
    2828
    29 class QWebError;
    30 
    3129QT_BEGIN_NAMESPACE
    3230class QCursor;
    3331class QGraphicsWidget;
    3432class QImage;
     33class QJSEngine;
     34class QJSValue;
    3535class QMimeData;
    3636class QPoint;
     
    7676    virtual void loadDidCommit() = 0;
    7777    virtual void loadDidSucceed() = 0;
    78     virtual void loadDidFail(const QWebError&) = 0;
     78    virtual void loadDidFail(const QJSValue&) = 0;
    7979    virtual void didChangeLoadProgress(int) = 0;
    8080
     
    8585    virtual void didRelaunchProcess() = 0;
    8686
     87    virtual QJSEngine* engine() = 0;
     88
    8789    virtual void chooseFiles(WKOpenPanelResultListenerRef, const QStringList& selectedFileNames, FileChooserType) = 0;
    8890};
Note: See TracChangeset for help on using the changeset viewer.