Diff
Modified: trunk/Source/WebKit2/ChangeLog (95196 => 95197)
--- trunk/Source/WebKit2/ChangeLog 2011-09-15 16:46:09 UTC (rev 95196)
+++ trunk/Source/WebKit2/ChangeLog 2011-09-15 16:54:57 UTC (rev 95197)
@@ -1,3 +1,36 @@
+2011-09-15 Alexis Menard <alexis.men...@openbossa.org>
+
+ [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:
+
2011-09-15 Adam Roben <aro...@apple.com>
Remove WebKit2-specific knowledge from the Message class
Modified: trunk/Source/WebKit2/UIProcess/API/qt/qdesktopwebview.cpp (95196 => 95197)
--- trunk/Source/WebKit2/UIProcess/API/qt/qdesktopwebview.cpp 2011-09-15 16:46:09 UTC (rev 95196)
+++ trunk/Source/WebKit2/UIProcess/API/qt/qdesktopwebview.cpp 2011-09-15 16:54:57 UTC (rev 95197)
@@ -24,9 +24,11 @@
#include <QGraphicsSceneResizeEvent>
#include <QStyleOptionGraphicsItem>
+#include <QtDeclarative/qdeclarativeengine.h>
#include <QtDeclarative/qsgcanvas.h>
#include <QtDeclarative/qsgevent.h>
#include <QtDeclarative/qsgitem.h>
+#include <QtDeclarative/qsgview.h>
#include <QtGui/QCursor>
#include <QtGui/QFileDialog>
#include <QtGui/QFocusEvent>
@@ -142,7 +144,7 @@
emit q->loadSucceeded();
}
-void QDesktopWebViewPrivate::loadDidFail(const QWebError& error)
+void QDesktopWebViewPrivate::loadDidFail(const QJSValue& error)
{
emit q->loadFailed(error);
}
@@ -382,6 +384,14 @@
q->update();
}
+QJSEngine* QDesktopWebViewPrivate::engine()
+{
+ QSGView* view = qobject_cast<QSGView*>(q->canvas());
+ if (view)
+ return view->engine();
+ return 0;
+}
+
void QDesktopWebViewPrivate::chooseFiles(WKOpenPanelResultListenerRef listenerRef, const QStringList& selectedFileNames, ViewInterface::FileChooserType type)
{
#ifndef QT_NO_FILEDIALOG
Modified: trunk/Source/WebKit2/UIProcess/API/qt/qdesktopwebview.h (95196 => 95197)
--- trunk/Source/WebKit2/UIProcess/API/qt/qdesktopwebview.h 2011-09-15 16:46:09 UTC (rev 95196)
+++ trunk/Source/WebKit2/UIProcess/API/qt/qdesktopwebview.h 2011-09-15 16:54:57 UTC (rev 95197)
@@ -28,7 +28,6 @@
#include <WebKit2/WKBase.h>
class QDesktopWebViewPrivate;
-class QWebError;
class QWebNavigationController;
QT_BEGIN_NAMESPACE
@@ -80,7 +79,8 @@
void statusBarMessageChanged(const QString&);
void loadStarted();
void loadSucceeded();
- void loadFailed(const QWebError&);
+ // The parameter needs to be explicitly named to work in QML.
+ void loadFailed(const QJSValue& error);
void loadProgressChanged(int progress);
void urlChanged(const QUrl&);
Modified: trunk/Source/WebKit2/UIProcess/API/qt/qdesktopwebview_p.h (95196 => 95197)
--- trunk/Source/WebKit2/UIProcess/API/qt/qdesktopwebview_p.h 2011-09-15 16:46:09 UTC (rev 95196)
+++ trunk/Source/WebKit2/UIProcess/API/qt/qdesktopwebview_p.h 2011-09-15 16:54:57 UTC (rev 95197)
@@ -71,7 +71,7 @@
virtual void loadDidBegin();
virtual void loadDidCommit();
virtual void loadDidSucceed();
- virtual void loadDidFail(const QWebError&);
+ virtual void loadDidFail(const QJSValue&);
virtual void didChangeLoadProgress(int);
virtual void showContextMenu(QSharedPointer<QMenu>);
@@ -80,6 +80,8 @@
virtual void processDidCrash();
virtual void didRelaunchProcess();
+ virtual QJSEngine* engine();
+
virtual void chooseFiles(WKOpenPanelResultListenerRef, const QStringList& selectedFileNames, ViewInterface::FileChooserType);
// PolicyInterface.
Modified: trunk/Source/WebKit2/UIProcess/API/qt/qtouchwebpage.h (95196 => 95197)
--- trunk/Source/WebKit2/UIProcess/API/qt/qtouchwebpage.h 2011-09-15 16:46:09 UTC (rev 95196)
+++ trunk/Source/WebKit2/UIProcess/API/qt/qtouchwebpage.h 2011-09-15 16:54:57 UTC (rev 95197)
@@ -29,7 +29,6 @@
class QTouchWebPagePrivate;
class QTouchWebPageProxy;
-class QWebError;
class QWebNavigationController;
namespace WebKit {
@@ -64,7 +63,8 @@
void titleChanged(const QString&);
void loadStarted();
void loadSucceeded();
- void loadFailed(const QWebError&);
+ // The parameter needs to be explicitly named to work in QML.
+ void loadFailed(const QJSValue& error);
void loadProgressChanged(int progress);
protected:
Modified: trunk/Source/WebKit2/UIProcess/API/qt/tests/commonviewtests/tst_commonviewtests.cpp (95196 => 95197)
--- trunk/Source/WebKit2/UIProcess/API/qt/tests/commonviewtests/tst_commonviewtests.cpp 2011-09-15 16:46:09 UTC (rev 95196)
+++ trunk/Source/WebKit2/UIProcess/API/qt/tests/commonviewtests/tst_commonviewtests.cpp 2011-09-15 16:54:57 UTC (rev 95197)
@@ -97,7 +97,7 @@
QSignalSpy loadFailedSpy(viewAbstraction.data(), SIGNAL(loadStarted()));
viewAbstraction->load(QUrl::fromLocalFile(QLatin1String(TESTS_SOURCE_DIR "/html/file_that_does_not_exist.html")));
- QVERIFY(waitForSignal(viewAbstraction.data(), SIGNAL(loadFailed(QWebError))));
+ QVERIFY(waitForSignal(viewAbstraction.data(), SIGNAL(loadFailed(QJSValue))));
QCOMPARE(loadFailedSpy.size(), 1);
}
Modified: trunk/Source/WebKit2/UIProcess/API/qt/tests/commonviewtests/webviewabstraction.cpp (95196 => 95197)
--- trunk/Source/WebKit2/UIProcess/API/qt/tests/commonviewtests/webviewabstraction.cpp 2011-09-15 16:46:09 UTC (rev 95196)
+++ trunk/Source/WebKit2/UIProcess/API/qt/tests/commonviewtests/webviewabstraction.cpp 2011-09-15 16:54:57 UTC (rev 95197)
@@ -35,7 +35,7 @@
m_touchWebViewWindow.setWindowTitle(QLatin1String("TouchWebView"));
connect(touchWebView()->page(), SIGNAL(loadStarted()), this, SLOT(touchViewLoadStarted()));
connect(touchWebView()->page(), SIGNAL(loadSucceeded()), this, SLOT(touchViewLoadSucceeded()));
- connect(touchWebView()->page(), SIGNAL(loadFailed(QWebError)), this, SLOT(touchViewLoadFailed(QWebError)));
+ connect(touchWebView()->page(), SIGNAL(loadFailed(QJSValue)), this, SLOT(touchViewLoadFailed(QJSValue)));
connect(touchWebView()->page(), SIGNAL(loadProgressChanged(int)), this, SLOT(touchViewLoadProgressChanged(int)));
screenHalf.moveLeft(screenHalf.right());
@@ -43,7 +43,7 @@
m_desktopWebViewWindow.setWindowTitle(QLatin1String("DesktopWebView"));
connect(desktopWebView(), SIGNAL(loadStarted()), this, SLOT(desktopViewLoadStarted()));
connect(desktopWebView(), SIGNAL(loadSucceeded()), this, SLOT(desktopViewLoadSucceeded()));
- connect(desktopWebView(), SIGNAL(loadFailed(QWebError)), this, SLOT(desktopViewLoadFailed(QWebError)));
+ connect(desktopWebView(), SIGNAL(loadFailed(QJSValue)), this, SLOT(desktopViewLoadFailed(QJSValue)));
connect(desktopWebView(), SIGNAL(loadProgressChanged(int)), this, SLOT(desktopViewLoadProgressChanged(int)));
}
@@ -133,17 +133,17 @@
emit loadSucceeded();
}
-void WebViewAbstraction::touchViewLoadFailed(const QWebError& error)
+void WebViewAbstraction::touchViewLoadFailed(const QJSValue& error)
{
- m_touchViewSignalsCounter[SIGNAL(loadFailed(QWebError))]++;
- if (m_touchViewSignalsCounter[SIGNAL(loadFailed(QWebError))] == m_desktopViewSignalsCounter[SIGNAL(loadFailed(QWebError))])
+ m_touchViewSignalsCounter[SIGNAL(loadFailed(QJSValue))]++;
+ if (m_touchViewSignalsCounter[SIGNAL(loadFailed(QJSValue))] == m_desktopViewSignalsCounter[SIGNAL(loadFailed(QJSValue))])
emit loadFailed(error);
}
-void WebViewAbstraction::desktopViewLoadFailed(const QWebError& error)
+void WebViewAbstraction::desktopViewLoadFailed(const QJSValue& error)
{
- m_desktopViewSignalsCounter[SIGNAL(loadFailed(QWebError))]++;
- if (m_touchViewSignalsCounter[SIGNAL(loadFailed(QWebError))] == m_desktopViewSignalsCounter[SIGNAL(loadFailed(QWebError))])
+ m_desktopViewSignalsCounter[SIGNAL(loadFailed(QJSValue))]++;
+ if (m_touchViewSignalsCounter[SIGNAL(loadFailed(QJSValue))] == m_desktopViewSignalsCounter[SIGNAL(loadFailed(QJSValue))])
emit loadFailed(error);
}
Modified: trunk/Source/WebKit2/UIProcess/API/qt/tests/commonviewtests/webviewabstraction.h (95196 => 95197)
--- trunk/Source/WebKit2/UIProcess/API/qt/tests/commonviewtests/webviewabstraction.h 2011-09-15 16:46:09 UTC (rev 95196)
+++ trunk/Source/WebKit2/UIProcess/API/qt/tests/commonviewtests/webviewabstraction.h 2011-09-15 16:54:57 UTC (rev 95197)
@@ -46,7 +46,7 @@
Q_SIGNALS:
void loadStarted();
void loadSucceeded();
- void loadFailed(const QWebError&);
+ void loadFailed(const QJSValue&);
void loadProgressChanged(int);
private Q_SLOTS:
@@ -54,8 +54,8 @@
void desktopViewLoadStarted();
void touchViewLoadSucceeded();
void desktopViewLoadSucceeded();
- void touchViewLoadFailed(const QWebError&);
- void desktopViewLoadFailed(const QWebError&);
+ void touchViewLoadFailed(const QJSValue&);
+ void desktopViewLoadFailed(const QJSValue&);
void touchViewLoadProgressChanged(int);
void desktopViewLoadProgressChanged(int);
Modified: trunk/Source/WebKit2/UIProcess/API/qt/tests/testwindow.h (95196 => 95197)
--- trunk/Source/WebKit2/UIProcess/API/qt/tests/testwindow.h 2011-09-15 16:46:09 UTC (rev 95196)
+++ trunk/Source/WebKit2/UIProcess/API/qt/tests/testwindow.h 2011-09-15 16:54:57 UTC (rev 95197)
@@ -22,11 +22,11 @@
#include <QResizeEvent>
#include <QScopedPointer>
-#include <QtDeclarative/qsgcanvas.h>
+#include <QtDeclarative/qsgview.h>
#include <QtDeclarative/qsgitem.h>
// TestWindow: Utility class to ignore QGraphicsView details.
-class TestWindow : public QSGCanvas {
+class TestWindow : public QSGView {
public:
inline TestWindow(QSGItem* webView);
QScopedPointer<QSGItem> webView;
Modified: trunk/Source/WebKit2/UIProcess/qt/QtWebPageProxy.cpp (95196 => 95197)
--- trunk/Source/WebKit2/UIProcess/qt/QtWebPageProxy.cpp 2011-09-15 16:46:09 UTC (rev 95196)
+++ trunk/Source/WebKit2/UIProcess/qt/QtWebPageProxy.cpp 2011-09-15 16:54:57 UTC (rev 95197)
@@ -21,6 +21,7 @@
#include "config.h"
#include "QtWebPageProxy.h"
+#include "qweberror.h"
#include "qwkpreferences_p.h"
#include "ClientImpl.h"
@@ -44,6 +45,7 @@
#include <QAction>
#include <QApplication>
#include <QGraphicsSceneMouseEvent>
+#include <QJSEngine>
#include <QStyle>
#include <QTouchEvent>
#include <QUndoStack>
@@ -405,7 +407,15 @@
void QtWebPageProxy::loadDidFail(const QWebError& error)
{
- m_viewInterface->loadDidFail(error);
+ QJSEngine* engine = m_viewInterface->engine();
+ QJSValue value;
+ if (engine) {
+ value = engine->newObject();
+ value.setProperty(QLatin1String("errorCode"), error.errorCode());
+ value.setProperty(QLatin1String("url"), error.url().toString());
+ value.setProperty(QLatin1String("type"), error.type());
+ }
+ m_viewInterface->loadDidFail(value);
}
void QtWebPageProxy::didChangeLoadProgress(int newLoadProgress)
Modified: trunk/Source/WebKit2/UIProcess/qt/QtWebPageProxy.h (95196 => 95197)
--- trunk/Source/WebKit2/UIProcess/qt/QtWebPageProxy.h 2011-09-15 16:46:09 UTC (rev 95196)
+++ trunk/Source/WebKit2/UIProcess/qt/QtWebPageProxy.h 2011-09-15 16:54:57 UTC (rev 95197)
@@ -43,6 +43,7 @@
class QUndoStack;
QT_END_NAMESPACE
+class QWebError;
class QWKHistory;
class QWKPreferences;
Modified: trunk/Source/WebKit2/UIProcess/qt/TouchViewInterface.cpp (95196 => 95197)
--- trunk/Source/WebKit2/UIProcess/qt/TouchViewInterface.cpp 2011-09-15 16:46:09 UTC (rev 95196)
+++ trunk/Source/WebKit2/UIProcess/qt/TouchViewInterface.cpp 2011-09-15 16:54:57 UTC (rev 95197)
@@ -26,6 +26,9 @@
#include "qtouchwebview.h"
#include "qtouchwebview_p.h"
+#include <QDeclarativeEngine>
+#include <QSGView>
+
namespace WebKit {
TouchViewInterface::TouchViewInterface(QTouchWebView* viewportView, QTouchWebPage* pageView)
@@ -128,7 +131,7 @@
emit m_pageView->loadSucceeded();
}
-void TouchViewInterface::loadDidFail(const QWebError& error)
+void TouchViewInterface::loadDidFail(const QJSValue& error)
{
emit m_pageView->loadFailed(error);
}
@@ -158,4 +161,12 @@
// FIXME
}
+QJSEngine* TouchViewInterface::engine()
+{
+ QSGView* view = qobject_cast<QSGView*>(m_pageView->canvas());
+ if (view)
+ return view->engine();
+ return 0;
}
+
+}
Modified: trunk/Source/WebKit2/UIProcess/qt/TouchViewInterface.h (95196 => 95197)
--- trunk/Source/WebKit2/UIProcess/qt/TouchViewInterface.h 2011-09-15 16:46:09 UTC (rev 95196)
+++ trunk/Source/WebKit2/UIProcess/qt/TouchViewInterface.h 2011-09-15 16:54:57 UTC (rev 95197)
@@ -66,7 +66,7 @@
virtual void loadDidBegin();
virtual void loadDidCommit();
virtual void loadDidSucceed();
- virtual void loadDidFail(const QWebError&);
+ virtual void loadDidFail(const QJSValue&);
virtual void didChangeLoadProgress(int);
virtual void showContextMenu(QSharedPointer<QMenu>);
@@ -75,6 +75,8 @@
virtual void processDidCrash();
virtual void didRelaunchProcess();
+ virtual QJSEngine* engine();
+
virtual void chooseFiles(WKOpenPanelResultListenerRef, const QStringList&, FileChooserType) { }
private:
Modified: trunk/Source/WebKit2/UIProcess/qt/ViewInterface.h (95196 => 95197)
--- trunk/Source/WebKit2/UIProcess/qt/ViewInterface.h 2011-09-15 16:46:09 UTC (rev 95196)
+++ trunk/Source/WebKit2/UIProcess/qt/ViewInterface.h 2011-09-15 16:54:57 UTC (rev 95197)
@@ -26,12 +26,12 @@
#include <QtGui/QMenu>
#include <WebKit2/WKBase.h>
-class QWebError;
-
QT_BEGIN_NAMESPACE
class QCursor;
class QGraphicsWidget;
class QImage;
+class QJSEngine;
+class QJSValue;
class QMimeData;
class QPoint;
class QRect;
@@ -75,7 +75,7 @@
virtual void loadDidBegin() = 0;
virtual void loadDidCommit() = 0;
virtual void loadDidSucceed() = 0;
- virtual void loadDidFail(const QWebError&) = 0;
+ virtual void loadDidFail(const QJSValue&) = 0;
virtual void didChangeLoadProgress(int) = 0;
virtual void showContextMenu(QSharedPointer<QMenu>) = 0;
@@ -84,6 +84,8 @@
virtual void processDidCrash() = 0;
virtual void didRelaunchProcess() = 0;
+ virtual QJSEngine* engine() = 0;
+
virtual void chooseFiles(WKOpenPanelResultListenerRef, const QStringList& selectedFileNames, FileChooserType) = 0;
};