[Qt] Merge QTouchWebView and QDesktopWebView into one class
authoralexis.menard@openbossa.org <alexis.menard@openbossa.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 10 Nov 2011 14:09:07 +0000 (14:09 +0000)
committeralexis.menard@openbossa.org <alexis.menard@openbossa.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 10 Nov 2011 14:09:07 +0000 (14:09 +0000)
https://bugs.webkit.org/show_bug.cgi?id=71355

Reviewed by Kenneth Rohde Christiansen.

.:

Remove old tests and merge them into the new QQuickWebView directory.

* Source/tests.pri:

Source/WebKit/qt:

Register only QQuickWebView and QQuickWebPage in the plugin.

* declarative/plugin.cpp:
(WebKitQmlPlugin::registerTypes):

Source/WebKit2:

Merge QTouchWebView and QDesktopWebView into one class called
QQuickWebView and its attached page QQuickWebPage. You can switch to the
traditional desktop use case with the private header. Also now on desktop
platforms AC is turn on by default. I also merged our two
subclasses of QtViewInterface into one as the split doesn't make
that much sense anymore. In the future we want to be able to enable the
traditional desktop use case depending the platform the code is running.
API tests and QML tests have been updated.

* Target.pri:
* UIProcess/API/qt/WKView.h:
* UIProcess/API/qt/qbasewebview.cpp: Removed.
* UIProcess/API/qt/qbasewebview_p.h: Removed.
* UIProcess/API/qt/qdesktopwebview.cpp: Removed.
* UIProcess/API/qt/qdesktopwebview.h: Removed.
* UIProcess/API/qt/qdesktopwebview_p.h: Removed.
* UIProcess/API/qt/qquickwebpage.cpp: Renamed from Source/WebKit2/UIProcess/API/qt/qtouchwebpage.cpp.
(QQuickWebPage::QQuickWebPage):
(QQuickWebPage::~QQuickWebPage):
(QQuickWebPage::keyPressEvent):
(QQuickWebPage::keyReleaseEvent):
(QQuickWebPage::inputMethodEvent):
(QQuickWebPage::focusInEvent):
(QQuickWebPage::focusOutEvent):
(QQuickWebPage::mousePressEvent):
(QQuickWebPage::mouseMoveEvent):
(QQuickWebPage::mouseReleaseEvent):
(QQuickWebPage::mouseDoubleClickEvent):
(QQuickWebPage::wheelEvent):
(QQuickWebPage::hoverEnterEvent):
(QQuickWebPage::hoverMoveEvent):
(QQuickWebPage::hoverLeaveEvent):
(QQuickWebPage::dragMoveEvent):
(QQuickWebPage::dragEnterEvent):
(QQuickWebPage::dragLeaveEvent):
(QQuickWebPage::dropEvent):
(QQuickWebPage::geometryChanged):
(QQuickWebPage::event):
(QQuickWebPage::touchEvent):
(QQuickWebPage::itemChange):
(QQuickWebPagePrivate::QQuickWebPagePrivate):
(QQuickWebPagePrivate::initializeSceneGraphConnections):
(QQuickWebPagePrivate::setPageProxy):
(computeEffectiveOpacity):
(QQuickWebPagePrivate::paintToCurrentGLContext):
(QQuickWebPagePrivate::_q_onAfterSceneRender):
(QQuickWebPagePrivate::_q_onSceneGraphInitialized):
* UIProcess/API/qt/qquickwebpage.h: Renamed from Source/WebKit2/UIProcess/API/qt/qtouchwebpage.h.
* UIProcess/API/qt/qquickwebpage_p.h: Renamed from Source/WebKit2/UIProcess/API/qt/qtouchwebpage_p.h.
* UIProcess/API/qt/qquickwebview.cpp: Added.
(QQuickWebViewPrivate::QQuickWebViewPrivate):
(QQuickWebViewPrivate::enableMouseEvents):
(QQuickWebViewPrivate::disableMouseEvents):
(QQuickWebViewPrivate::initialize):
(QQuickWebViewPrivate::initializeDesktop):
(QQuickWebViewPrivate::initializeTouch):
(QQuickWebViewPrivate::loadDidCommit):
(QQuickWebViewPrivate::contentSizeChanged):
(QQuickWebViewPrivate::scrollPositionRequested):
(QQuickWebViewPrivate::_q_viewportUpdated):
(QQuickWebViewPrivate::_q_viewportTrajectoryVectorChanged):
(QQuickWebViewPrivate::_q_onVisibleChanged):
(QQuickWebViewPrivate::updateViewportSize):
(QQuickWebViewPrivate::updateViewportConstraints):
(QQuickWebViewPrivate::didChangeViewportProperties):
(QQuickWebViewPrivate::runJavaScriptAlert):
(QQuickWebViewPrivate::runJavaScriptConfirm):
(QQuickWebViewPrivate::runJavaScriptPrompt):
(QQuickWebViewPrivate::chooseFiles):
(QQuickWebViewPrivate::_q_onOpenPanelFilesSelected):
(QQuickWebViewPrivate::_q_onOpenPanelFinished):
(QQuickWebViewPrivate::setUseTraditionalDesktopBehaviour):
(toPolicyAction):
(hasMetaMethod):
(QQuickWebViewPrivate::navigationPolicyForURL):
(QQuickWebViewPrivate::setPageProxy):
(QQuickWebView::QQuickWebView):
(QQuickWebView::~QQuickWebView):
(QQuickWebView::page):
(QQuickWebView::load):
(QQuickWebView::postMessage):
(QQuickWebView::url):
(QQuickWebView::loadProgress):
(QQuickWebView::title):
(QQuickWebView::navigationController):
(QQuickWebView::preferences):
(QQuickWebView::geometryChanged):
(QQuickWebView::touchEvent):
(QQuickWebView::pageRef):
* UIProcess/API/qt/qquickwebview.h: Renamed from Source/WebKit2/UIProcess/API/qt/qbasewebview.h.
* UIProcess/API/qt/qquickwebview_p.h: Added.
* UIProcess/API/qt/qtouchwebview.cpp: Removed.
* UIProcess/API/qt/qtouchwebview.h: Removed.
* UIProcess/API/qt/qtouchwebview_p.h: Removed.
* UIProcess/API/qt/tests/commonviewtests/commonviewtests.pro: Removed.
* UIProcess/API/qt/tests/commonviewtests/tst_commonviewtests.cpp: Removed.
* UIProcess/API/qt/tests/commonviewtests/webviewabstraction.cpp: Removed.
* UIProcess/API/qt/tests/commonviewtests/webviewabstraction.h: Removed.
* UIProcess/API/qt/tests/qdesktopwebview/tst_qdesktopwebview.cpp: Removed.
* UIProcess/API/qt/tests/qmltests/DesktopWebView/tst_download.qml:
* UIProcess/API/qt/tests/qmltests/DesktopWebView/tst_linkHovered.qml:
* UIProcess/API/qt/tests/qmltests/DesktopWebView/tst_loadFail.qml:
* UIProcess/API/qt/tests/qmltests/DesktopWebView/tst_loadProgress.qml:
* UIProcess/API/qt/tests/qmltests/DesktopWebView/tst_loadProgressSignal.qml:
* UIProcess/API/qt/tests/qmltests/DesktopWebView/tst_loadZeroSizeView.qml:
* UIProcess/API/qt/tests/qmltests/DesktopWebView/tst_messaging.qml:
* UIProcess/API/qt/tests/qmltests/DesktopWebView/tst_navigationPolicyForUrl.qml:
* UIProcess/API/qt/tests/qmltests/DesktopWebView/tst_preferences.qml:
* UIProcess/API/qt/tests/qmltests/DesktopWebView/tst_properties.qml:
* UIProcess/API/qt/tests/qmltests/TouchWebView/tst_load.qml:
* UIProcess/API/qt/tests/qmltests/TouchWebView/tst_loadFail.qml:
* UIProcess/API/qt/tests/qmltests/TouchWebView/tst_loadNegativeSizeView.qml:
* UIProcess/API/qt/tests/qmltests/TouchWebView/tst_loadProgress.qml:
* UIProcess/API/qt/tests/qmltests/TouchWebView/tst_loadProgressSignal.qml:
* UIProcess/API/qt/tests/qmltests/TouchWebView/tst_loadZeroSizeView.qml:
* UIProcess/API/qt/tests/qmltests/TouchWebView/tst_properties.qml:
* UIProcess/API/qt/tests/qmltests/qmltests.pro:
* UIProcess/API/qt/tests/qmltests/tst_qmltests.cpp:
(DesktopWebView::DesktopWebView):
(main):
* UIProcess/API/qt/tests/qquickwebview/qquickwebview.pro: Renamed from Source/WebKit2/UIProcess/API/qt/tests/qdesktopwebview/qdesktopwebview.pro.
* UIProcess/API/qt/tests/qquickwebview/tst_qquickwebview.cpp: Added.
(tst_QQuickWebView::tst_QQuickWebView):
(tst_QQuickWebView::init):
(tst_QQuickWebView::cleanup):
(tst_QQuickWebView::webView):
(tst_QQuickWebView::accessPage):
(tst_QQuickWebView::navigationStatusAtStartup):
(LoadStartedCatcher::LoadStartedCatcher):
(LoadStartedCatcher::onLoadStarted):
(tst_QQuickWebView::stopEnabledAfterLoadStarted):
(tst_QQuickWebView::baseUrl):
(tst_QQuickWebView::loadEmptyUrl):
(tst_QQuickWebView::loadEmptyPageViewVisible):
(tst_QQuickWebView::loadEmptyPageViewHidden):
(tst_QQuickWebView::loadNonexistentFileUrl):
(tst_QQuickWebView::backAndForward):
(tst_QQuickWebView::reload):
(tst_QQuickWebView::stop):
(tst_QQuickWebView::loadProgress):
(tst_QQuickWebView::show):
* UIProcess/API/qt/tests/qtouchwebview/qtouchwebview.pro: Removed.
* UIProcess/API/qt/tests/qtouchwebview/tst_qtouchwebview.cpp: Removed.
* UIProcess/API/qt/tests/testwindow.h:
* UIProcess/TiledDrawingAreaProxy.h:
* UIProcess/qt/QtGestureRecognizer.cpp:
(WebKit::QtGestureRecognizer::QtGestureRecognizer):
(WebKit::QtGestureRecognizer::setViewportInteractionEngine):
* UIProcess/qt/QtGestureRecognizer.h:
* UIProcess/qt/QtPanGestureRecognizer.cpp:
(WebKit::QtPanGestureRecognizer::setViewportInteractionEngine):
(WebKit::QtPanGestureRecognizer::recognize):
* UIProcess/qt/QtPanGestureRecognizer.h:
* UIProcess/qt/QtPinchGestureRecognizer.cpp:
(WebKit::QtPinchGestureRecognizer::recognize):
(WebKit::QtPinchGestureRecognizer::setViewportInteractionEngine):
* UIProcess/qt/QtPinchGestureRecognizer.h:
* UIProcess/qt/QtTouchViewInterface.cpp: Removed.
* UIProcess/qt/QtTouchViewInterface.h: Removed.
* UIProcess/qt/QtViewInterface.cpp: Added.
(WebKit::QtViewInterface::QtViewInterface):
(WebKit::QtViewInterface::didFindZoomableArea):
(WebKit::QtViewInterface::sceneGraphUpdateQueue):
(WebKit::QtViewInterface::setViewNeedsDisplay):
(WebKit::QtViewInterface::drawingAreaSize):
(WebKit::QtViewInterface::contentSizeChanged):
(WebKit::QtViewInterface::scrollPositionRequested):
(WebKit::QtViewInterface::isActive):
(WebKit::QtViewInterface::hasFocus):
(WebKit::QtViewInterface::isVisible):
(WebKit::QtViewInterface::startDrag):
(WebKit::QtViewInterface::didChangeViewportProperties):
(WebKit::QtViewInterface::didChangeUrl):
(WebKit::QtViewInterface::didChangeTitle):
(WebKit::QtViewInterface::didChangeToolTip):
(WebKit::QtViewInterface::didChangeStatusText):
(WebKit::QtViewInterface::didChangeCursor):
(WebKit::QtViewInterface::loadDidBegin):
(WebKit::QtViewInterface::loadDidCommit):
(WebKit::QtViewInterface::loadDidSucceed):
(WebKit::QtViewInterface::loadDidFail):
(WebKit::QtViewInterface::didChangeLoadProgress):
(WebKit::QtViewInterface::didMouseMoveOverElement):
(WebKit::QtViewInterface::showContextMenu):
(WebKit::QtViewInterface::hideContextMenu):
(WebKit::QtViewInterface::runJavaScriptAlert):
(WebKit::QtViewInterface::runJavaScriptConfirm):
(WebKit::QtViewInterface::runJavaScriptPrompt):
(WebKit::QtViewInterface::processDidCrash):
(WebKit::QtViewInterface::didRelaunchProcess):
(WebKit::QtViewInterface::engine):
(WebKit::QtViewInterface::downloadRequested):
(WebKit::QtViewInterface::chooseFiles):
* UIProcess/qt/QtViewInterface.h:
* UIProcess/qt/QtWebPageProxy.h:
(QtWebPageProxy::setViewportInteractionEngine):
* UIProcess/qt/TiledDrawingAreaProxyQt.cpp:
* WebKit2.pri:

Tools:

Make MiniBrowser and WebKitTestRunner work again after the
merge.

* MiniBrowser/qt/BrowserWindow.cpp:
(BrowserWindow::BrowserWindow):
(BrowserWindow::webView):
* MiniBrowser/qt/MiniBrowser.pro:
* MiniBrowser/qt/MiniBrowser.qrc:
* MiniBrowser/qt/MiniBrowserApplication.cpp:
* MiniBrowser/qt/main.cpp:
* MiniBrowser/qt/qml/BrowserWindow.qml:
* MiniBrowser/qt/qml/DesktopView.qml: Removed.
* MiniBrowser/qt/qml/TouchView.qml: Removed.
* WebKitTestRunner/PlatformWebView.h:
* WebKitTestRunner/qt/PlatformWebViewQt.cpp:
(WTR::PlatformWebView::PlatformWebView):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@99845 268f45cc-cd09-0410-ab3c-d52691b4dbfc

75 files changed:
ChangeLog
Source/WebKit/qt/ChangeLog
Source/WebKit/qt/declarative/plugin.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/Target.pri
Source/WebKit2/UIProcess/API/qt/WKView.h
Source/WebKit2/UIProcess/API/qt/qbasewebview.cpp [deleted file]
Source/WebKit2/UIProcess/API/qt/qbasewebview_p.h [deleted file]
Source/WebKit2/UIProcess/API/qt/qdesktopwebview.cpp [deleted file]
Source/WebKit2/UIProcess/API/qt/qdesktopwebview.h [deleted file]
Source/WebKit2/UIProcess/API/qt/qdesktopwebview_p.h [deleted file]
Source/WebKit2/UIProcess/API/qt/qquickwebpage.cpp [moved from Source/WebKit2/UIProcess/API/qt/qtouchwebpage.cpp with 53% similarity]
Source/WebKit2/UIProcess/API/qt/qquickwebpage.h [moved from Source/WebKit2/UIProcess/API/qt/qtouchwebpage.h with 59% similarity]
Source/WebKit2/UIProcess/API/qt/qquickwebpage_p.h [moved from Source/WebKit2/UIProcess/API/qt/qtouchwebpage_p.h with 78% similarity]
Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp [new file with mode: 0644]
Source/WebKit2/UIProcess/API/qt/qquickwebview.h [moved from Source/WebKit2/UIProcess/API/qt/qbasewebview.h with 60% similarity]
Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h [new file with mode: 0644]
Source/WebKit2/UIProcess/API/qt/qtouchwebview.cpp [deleted file]
Source/WebKit2/UIProcess/API/qt/qtouchwebview.h [deleted file]
Source/WebKit2/UIProcess/API/qt/qtouchwebview_p.h [deleted file]
Source/WebKit2/UIProcess/API/qt/tests/commonviewtests/commonviewtests.pro [deleted file]
Source/WebKit2/UIProcess/API/qt/tests/commonviewtests/tst_commonviewtests.cpp [deleted file]
Source/WebKit2/UIProcess/API/qt/tests/commonviewtests/webviewabstraction.cpp [deleted file]
Source/WebKit2/UIProcess/API/qt/tests/commonviewtests/webviewabstraction.h [deleted file]
Source/WebKit2/UIProcess/API/qt/tests/qdesktopwebview/tst_qdesktopwebview.cpp [deleted file]
Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopWebView/tst_download.qml
Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopWebView/tst_linkHovered.qml
Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopWebView/tst_loadFail.qml
Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopWebView/tst_loadProgress.qml
Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopWebView/tst_loadProgressSignal.qml
Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopWebView/tst_loadZeroSizeView.qml
Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopWebView/tst_messaging.qml
Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopWebView/tst_navigationPolicyForUrl.qml
Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopWebView/tst_preferences.qml
Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopWebView/tst_properties.qml
Source/WebKit2/UIProcess/API/qt/tests/qmltests/TouchWebView/tst_load.qml
Source/WebKit2/UIProcess/API/qt/tests/qmltests/TouchWebView/tst_loadFail.qml
Source/WebKit2/UIProcess/API/qt/tests/qmltests/TouchWebView/tst_loadNegativeSizeView.qml
Source/WebKit2/UIProcess/API/qt/tests/qmltests/TouchWebView/tst_loadProgress.qml
Source/WebKit2/UIProcess/API/qt/tests/qmltests/TouchWebView/tst_loadProgressSignal.qml
Source/WebKit2/UIProcess/API/qt/tests/qmltests/TouchWebView/tst_loadZeroSizeView.qml
Source/WebKit2/UIProcess/API/qt/tests/qmltests/TouchWebView/tst_properties.qml
Source/WebKit2/UIProcess/API/qt/tests/qmltests/qmltests.pro
Source/WebKit2/UIProcess/API/qt/tests/qmltests/tst_qmltests.cpp
Source/WebKit2/UIProcess/API/qt/tests/qquickwebview/qquickwebview.pro [moved from Source/WebKit2/UIProcess/API/qt/tests/qdesktopwebview/qdesktopwebview.pro with 100% similarity]
Source/WebKit2/UIProcess/API/qt/tests/qquickwebview/tst_qquickwebview.cpp [new file with mode: 0644]
Source/WebKit2/UIProcess/API/qt/tests/qtouchwebview/qtouchwebview.pro [deleted file]
Source/WebKit2/UIProcess/API/qt/tests/qtouchwebview/tst_qtouchwebview.cpp [deleted file]
Source/WebKit2/UIProcess/API/qt/tests/testwindow.h
Source/WebKit2/UIProcess/TiledDrawingAreaProxy.h
Source/WebKit2/UIProcess/qt/QtGestureRecognizer.cpp
Source/WebKit2/UIProcess/qt/QtGestureRecognizer.h
Source/WebKit2/UIProcess/qt/QtPanGestureRecognizer.cpp
Source/WebKit2/UIProcess/qt/QtPanGestureRecognizer.h
Source/WebKit2/UIProcess/qt/QtPinchGestureRecognizer.cpp
Source/WebKit2/UIProcess/qt/QtPinchGestureRecognizer.h
Source/WebKit2/UIProcess/qt/QtTouchViewInterface.cpp [deleted file]
Source/WebKit2/UIProcess/qt/QtTouchViewInterface.h [deleted file]
Source/WebKit2/UIProcess/qt/QtViewInterface.cpp [new file with mode: 0644]
Source/WebKit2/UIProcess/qt/QtViewInterface.h
Source/WebKit2/UIProcess/qt/QtWebPageProxy.h
Source/WebKit2/UIProcess/qt/TiledDrawingAreaProxyQt.cpp
Source/WebKit2/WebKit2.pri
Source/tests.pri
Tools/ChangeLog
Tools/MiniBrowser/qt/BrowserWindow.cpp
Tools/MiniBrowser/qt/MiniBrowser.pro
Tools/MiniBrowser/qt/MiniBrowser.qrc
Tools/MiniBrowser/qt/MiniBrowserApplication.cpp
Tools/MiniBrowser/qt/main.cpp
Tools/MiniBrowser/qt/qml/BrowserWindow.qml
Tools/MiniBrowser/qt/qml/DesktopView.qml [deleted file]
Tools/MiniBrowser/qt/qml/TouchView.qml [deleted file]
Tools/WebKitTestRunner/PlatformWebView.h
Tools/WebKitTestRunner/qt/PlatformWebViewQt.cpp

index e947284..c0afbb0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2011-11-10  Alexis Menard  <alexis.menard@openbossa.org>
+
+        [Qt] Merge QTouchWebView and QDesktopWebView into one class
+        https://bugs.webkit.org/show_bug.cgi?id=71355
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Remove old tests and merge them into the new QQuickWebView directory.
+
+        * Source/tests.pri:
+
 2011-11-10  Tor Arne Vestbø  <tor.arne.vestbo@nokia.com>
 
         [Qt] Change semantics of the haveQt() function to match API promises
index e5af53a..1929777 100644 (file)
@@ -1,3 +1,15 @@
+2011-11-10  Alexis Menard  <alexis.menard@openbossa.org>
+
+        [Qt] Merge QTouchWebView and QDesktopWebView into one class
+        https://bugs.webkit.org/show_bug.cgi?id=71355
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Register only QQuickWebView and QQuickWebPage in the plugin.
+
+        * declarative/plugin.cpp:
+        (WebKitQmlPlugin::registerTypes):
+
 2011-11-09  Simon Hausmann  <simon.hausmann@nokia.com>
 
         [Qt] Enable exports and constructor functions in static libs
index a51edbc..2b98be7 100644 (file)
@@ -23,9 +23,8 @@
 #include <QtDeclarative/qdeclarativeextensionplugin.h>
 
 #if defined(HAVE_WEBKIT2)
-#include "qdesktopwebview.h"
-#include "qtouchwebpage.h"
-#include "qtouchwebview.h"
+#include "qquickwebpage.h"
+#include "qquickwebview.h"
 #include "qwebdownloaditem.h"
 #include "qwebnavigationcontroller.h"
 #include "qwebpreferences.h"
@@ -50,11 +49,10 @@ public:
 #endif
 
 #if defined(HAVE_WEBKIT2)
-        qmlRegisterType<QDesktopWebView>(uri, 3, 0, "DesktopWebView");
-        qmlRegisterType<QTouchWebView>(uri, 3, 0, "TouchWebView");
+        qmlRegisterType<QQuickWebView>(uri, 3, 0, "WebView");
         qmlRegisterUncreatableType<QWebNavigationController>(uri, 3, 0, "NavigationController", QObject::tr("Cannot create separate instance of NavigationController"));
         qmlRegisterUncreatableType<QWebPreferences>(uri, 3, 0, "WebPreferences", QObject::tr("Cannot create separate instance of WebPreferences"));
-        qmlRegisterUncreatableType<QTouchWebPage>(uri, 3, 0, "TouchWebPage", QObject::tr("Cannot create separate instance of TouchWebPage, use TouchWebView"));
+        qmlRegisterUncreatableType<QQuickWebPage>(uri, 3, 0, "WebPage", QObject::tr("Cannot create separate instance of WebPage, use WebView"));
         qmlRegisterUncreatableType<QNetworkReply>(uri, 3, 0, "NetworkReply", QObject::tr("Cannot create separate instance of NetworkReply"));
         qmlRegisterUncreatableType<QWebDownloadItem>(uri, 5, 0, "DownloadItem", QObject::tr("Cannot create separate instance of DownloadItem"));
 #endif
index edb9005..ed56538 100644 (file)
@@ -1,3 +1,209 @@
+2011-11-10  Alexis Menard  <alexis.menard@openbossa.org>
+
+        [Qt] Merge QTouchWebView and QDesktopWebView into one class
+        https://bugs.webkit.org/show_bug.cgi?id=71355
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Merge QTouchWebView and QDesktopWebView into one class called
+        QQuickWebView and its attached page QQuickWebPage. You can switch to the
+        traditional desktop use case with the private header. Also now on desktop
+        platforms AC is turn on by default. I also merged our two
+        subclasses of QtViewInterface into one as the split doesn't make
+        that much sense anymore. In the future we want to be able to enable the
+        traditional desktop use case depending the platform the code is running.
+        API tests and QML tests have been updated.
+
+        * Target.pri:
+        * UIProcess/API/qt/WKView.h:
+        * UIProcess/API/qt/qbasewebview.cpp: Removed.
+        * UIProcess/API/qt/qbasewebview_p.h: Removed.
+        * UIProcess/API/qt/qdesktopwebview.cpp: Removed.
+        * UIProcess/API/qt/qdesktopwebview.h: Removed.
+        * UIProcess/API/qt/qdesktopwebview_p.h: Removed.
+        * UIProcess/API/qt/qquickwebpage.cpp: Renamed from Source/WebKit2/UIProcess/API/qt/qtouchwebpage.cpp.
+        (QQuickWebPage::QQuickWebPage):
+        (QQuickWebPage::~QQuickWebPage):
+        (QQuickWebPage::keyPressEvent):
+        (QQuickWebPage::keyReleaseEvent):
+        (QQuickWebPage::inputMethodEvent):
+        (QQuickWebPage::focusInEvent):
+        (QQuickWebPage::focusOutEvent):
+        (QQuickWebPage::mousePressEvent):
+        (QQuickWebPage::mouseMoveEvent):
+        (QQuickWebPage::mouseReleaseEvent):
+        (QQuickWebPage::mouseDoubleClickEvent):
+        (QQuickWebPage::wheelEvent):
+        (QQuickWebPage::hoverEnterEvent):
+        (QQuickWebPage::hoverMoveEvent):
+        (QQuickWebPage::hoverLeaveEvent):
+        (QQuickWebPage::dragMoveEvent):
+        (QQuickWebPage::dragEnterEvent):
+        (QQuickWebPage::dragLeaveEvent):
+        (QQuickWebPage::dropEvent):
+        (QQuickWebPage::geometryChanged):
+        (QQuickWebPage::event):
+        (QQuickWebPage::touchEvent):
+        (QQuickWebPage::itemChange):
+        (QQuickWebPagePrivate::QQuickWebPagePrivate):
+        (QQuickWebPagePrivate::initializeSceneGraphConnections):
+        (QQuickWebPagePrivate::setPageProxy):
+        (computeEffectiveOpacity):
+        (QQuickWebPagePrivate::paintToCurrentGLContext):
+        (QQuickWebPagePrivate::_q_onAfterSceneRender):
+        (QQuickWebPagePrivate::_q_onSceneGraphInitialized):
+        * UIProcess/API/qt/qquickwebpage.h: Renamed from Source/WebKit2/UIProcess/API/qt/qtouchwebpage.h.
+        * UIProcess/API/qt/qquickwebpage_p.h: Renamed from Source/WebKit2/UIProcess/API/qt/qtouchwebpage_p.h.
+        * UIProcess/API/qt/qquickwebview.cpp: Added.
+        (QQuickWebViewPrivate::QQuickWebViewPrivate):
+        (QQuickWebViewPrivate::enableMouseEvents):
+        (QQuickWebViewPrivate::disableMouseEvents):
+        (QQuickWebViewPrivate::initialize):
+        (QQuickWebViewPrivate::initializeDesktop):
+        (QQuickWebViewPrivate::initializeTouch):
+        (QQuickWebViewPrivate::loadDidCommit):
+        (QQuickWebViewPrivate::contentSizeChanged):
+        (QQuickWebViewPrivate::scrollPositionRequested):
+        (QQuickWebViewPrivate::_q_viewportUpdated):
+        (QQuickWebViewPrivate::_q_viewportTrajectoryVectorChanged):
+        (QQuickWebViewPrivate::_q_onVisibleChanged):
+        (QQuickWebViewPrivate::updateViewportSize):
+        (QQuickWebViewPrivate::updateViewportConstraints):
+        (QQuickWebViewPrivate::didChangeViewportProperties):
+        (QQuickWebViewPrivate::runJavaScriptAlert):
+        (QQuickWebViewPrivate::runJavaScriptConfirm):
+        (QQuickWebViewPrivate::runJavaScriptPrompt):
+        (QQuickWebViewPrivate::chooseFiles):
+        (QQuickWebViewPrivate::_q_onOpenPanelFilesSelected):
+        (QQuickWebViewPrivate::_q_onOpenPanelFinished):
+        (QQuickWebViewPrivate::setUseTraditionalDesktopBehaviour):
+        (toPolicyAction):
+        (hasMetaMethod):
+        (QQuickWebViewPrivate::navigationPolicyForURL):
+        (QQuickWebViewPrivate::setPageProxy):
+        (QQuickWebView::QQuickWebView):
+        (QQuickWebView::~QQuickWebView):
+        (QQuickWebView::page):
+        (QQuickWebView::load):
+        (QQuickWebView::postMessage):
+        (QQuickWebView::url):
+        (QQuickWebView::loadProgress):
+        (QQuickWebView::title):
+        (QQuickWebView::navigationController):
+        (QQuickWebView::preferences):
+        (QQuickWebView::geometryChanged):
+        (QQuickWebView::touchEvent):
+        (QQuickWebView::pageRef):
+        * UIProcess/API/qt/qquickwebview.h: Renamed from Source/WebKit2/UIProcess/API/qt/qbasewebview.h.
+        * UIProcess/API/qt/qquickwebview_p.h: Added.
+        * UIProcess/API/qt/qtouchwebview.cpp: Removed.
+        * UIProcess/API/qt/qtouchwebview.h: Removed.
+        * UIProcess/API/qt/qtouchwebview_p.h: Removed.
+        * UIProcess/API/qt/tests/commonviewtests/commonviewtests.pro: Removed.
+        * UIProcess/API/qt/tests/commonviewtests/tst_commonviewtests.cpp: Removed.
+        * UIProcess/API/qt/tests/commonviewtests/webviewabstraction.cpp: Removed.
+        * UIProcess/API/qt/tests/commonviewtests/webviewabstraction.h: Removed.
+        * UIProcess/API/qt/tests/qdesktopwebview/tst_qdesktopwebview.cpp: Removed.
+        * UIProcess/API/qt/tests/qmltests/DesktopWebView/tst_download.qml:
+        * UIProcess/API/qt/tests/qmltests/DesktopWebView/tst_linkHovered.qml:
+        * UIProcess/API/qt/tests/qmltests/DesktopWebView/tst_loadFail.qml:
+        * UIProcess/API/qt/tests/qmltests/DesktopWebView/tst_loadProgress.qml:
+        * UIProcess/API/qt/tests/qmltests/DesktopWebView/tst_loadProgressSignal.qml:
+        * UIProcess/API/qt/tests/qmltests/DesktopWebView/tst_loadZeroSizeView.qml:
+        * UIProcess/API/qt/tests/qmltests/DesktopWebView/tst_messaging.qml:
+        * UIProcess/API/qt/tests/qmltests/DesktopWebView/tst_navigationPolicyForUrl.qml:
+        * UIProcess/API/qt/tests/qmltests/DesktopWebView/tst_preferences.qml:
+        * UIProcess/API/qt/tests/qmltests/DesktopWebView/tst_properties.qml:
+        * UIProcess/API/qt/tests/qmltests/TouchWebView/tst_load.qml:
+        * UIProcess/API/qt/tests/qmltests/TouchWebView/tst_loadFail.qml:
+        * UIProcess/API/qt/tests/qmltests/TouchWebView/tst_loadNegativeSizeView.qml:
+        * UIProcess/API/qt/tests/qmltests/TouchWebView/tst_loadProgress.qml:
+        * UIProcess/API/qt/tests/qmltests/TouchWebView/tst_loadProgressSignal.qml:
+        * UIProcess/API/qt/tests/qmltests/TouchWebView/tst_loadZeroSizeView.qml:
+        * UIProcess/API/qt/tests/qmltests/TouchWebView/tst_properties.qml:
+        * UIProcess/API/qt/tests/qmltests/qmltests.pro:
+        * UIProcess/API/qt/tests/qmltests/tst_qmltests.cpp:
+        (DesktopWebView::DesktopWebView):
+        (main):
+        * UIProcess/API/qt/tests/qquickwebview/qquickwebview.pro: Renamed from Source/WebKit2/UIProcess/API/qt/tests/qdesktopwebview/qdesktopwebview.pro.
+        * UIProcess/API/qt/tests/qquickwebview/tst_qquickwebview.cpp: Added.
+        (tst_QQuickWebView::tst_QQuickWebView):
+        (tst_QQuickWebView::init):
+        (tst_QQuickWebView::cleanup):
+        (tst_QQuickWebView::webView):
+        (tst_QQuickWebView::accessPage):
+        (tst_QQuickWebView::navigationStatusAtStartup):
+        (LoadStartedCatcher::LoadStartedCatcher):
+        (LoadStartedCatcher::onLoadStarted):
+        (tst_QQuickWebView::stopEnabledAfterLoadStarted):
+        (tst_QQuickWebView::baseUrl):
+        (tst_QQuickWebView::loadEmptyUrl):
+        (tst_QQuickWebView::loadEmptyPageViewVisible):
+        (tst_QQuickWebView::loadEmptyPageViewHidden):
+        (tst_QQuickWebView::loadNonexistentFileUrl):
+        (tst_QQuickWebView::backAndForward):
+        (tst_QQuickWebView::reload):
+        (tst_QQuickWebView::stop):
+        (tst_QQuickWebView::loadProgress):
+        (tst_QQuickWebView::show):
+        * UIProcess/API/qt/tests/qtouchwebview/qtouchwebview.pro: Removed.
+        * UIProcess/API/qt/tests/qtouchwebview/tst_qtouchwebview.cpp: Removed.
+        * UIProcess/API/qt/tests/testwindow.h:
+        * UIProcess/TiledDrawingAreaProxy.h:
+        * UIProcess/qt/QtGestureRecognizer.cpp:
+        (WebKit::QtGestureRecognizer::QtGestureRecognizer):
+        (WebKit::QtGestureRecognizer::setViewportInteractionEngine):
+        * UIProcess/qt/QtGestureRecognizer.h:
+        * UIProcess/qt/QtPanGestureRecognizer.cpp:
+        (WebKit::QtPanGestureRecognizer::setViewportInteractionEngine):
+        (WebKit::QtPanGestureRecognizer::recognize):
+        * UIProcess/qt/QtPanGestureRecognizer.h:
+        * UIProcess/qt/QtPinchGestureRecognizer.cpp:
+        (WebKit::QtPinchGestureRecognizer::recognize):
+        (WebKit::QtPinchGestureRecognizer::setViewportInteractionEngine):
+        * UIProcess/qt/QtPinchGestureRecognizer.h:
+        * UIProcess/qt/QtTouchViewInterface.cpp: Removed.
+        * UIProcess/qt/QtTouchViewInterface.h: Removed.
+        * UIProcess/qt/QtViewInterface.cpp: Added.
+        (WebKit::QtViewInterface::QtViewInterface):
+        (WebKit::QtViewInterface::didFindZoomableArea):
+        (WebKit::QtViewInterface::sceneGraphUpdateQueue):
+        (WebKit::QtViewInterface::setViewNeedsDisplay):
+        (WebKit::QtViewInterface::drawingAreaSize):
+        (WebKit::QtViewInterface::contentSizeChanged):
+        (WebKit::QtViewInterface::scrollPositionRequested):
+        (WebKit::QtViewInterface::isActive):
+        (WebKit::QtViewInterface::hasFocus):
+        (WebKit::QtViewInterface::isVisible):
+        (WebKit::QtViewInterface::startDrag):
+        (WebKit::QtViewInterface::didChangeViewportProperties):
+        (WebKit::QtViewInterface::didChangeUrl):
+        (WebKit::QtViewInterface::didChangeTitle):
+        (WebKit::QtViewInterface::didChangeToolTip):
+        (WebKit::QtViewInterface::didChangeStatusText):
+        (WebKit::QtViewInterface::didChangeCursor):
+        (WebKit::QtViewInterface::loadDidBegin):
+        (WebKit::QtViewInterface::loadDidCommit):
+        (WebKit::QtViewInterface::loadDidSucceed):
+        (WebKit::QtViewInterface::loadDidFail):
+        (WebKit::QtViewInterface::didChangeLoadProgress):
+        (WebKit::QtViewInterface::didMouseMoveOverElement):
+        (WebKit::QtViewInterface::showContextMenu):
+        (WebKit::QtViewInterface::hideContextMenu):
+        (WebKit::QtViewInterface::runJavaScriptAlert):
+        (WebKit::QtViewInterface::runJavaScriptConfirm):
+        (WebKit::QtViewInterface::runJavaScriptPrompt):
+        (WebKit::QtViewInterface::processDidCrash):
+        (WebKit::QtViewInterface::didRelaunchProcess):
+        (WebKit::QtViewInterface::engine):
+        (WebKit::QtViewInterface::downloadRequested):
+        (WebKit::QtViewInterface::chooseFiles):
+        * UIProcess/qt/QtViewInterface.h:
+        * UIProcess/qt/QtWebPageProxy.h:
+        (QtWebPageProxy::setViewportInteractionEngine):
+        * UIProcess/qt/TiledDrawingAreaProxyQt.cpp:
+        * WebKit2.pri:
+
 2011-11-10  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         Unreviewed. Fix make distcheck build.
index a1ac952..67bec4f 100644 (file)
@@ -243,7 +243,6 @@ HEADERS += \
     UIProcess/WebResourceLoadClient.h \
     UIProcess/WebUIClient.h \
     UIProcess/qt/ClientImpl.h \
-    UIProcess/qt/QtTouchViewInterface.h \
     UIProcess/qt/QtPolicyInterface.h \
     UIProcess/qt/QtGestureRecognizer.h \
     UIProcess/qt/QtPanGestureRecognizer.h \
@@ -487,7 +486,7 @@ SOURCES += \
     UIProcess/WebUIClient.cpp \
     UIProcess/qt/ClientImpl.cpp \
     UIProcess/qt/LayerTreeHostProxyQt.cpp \
-    UIProcess/qt/QtTouchViewInterface.cpp \
+    UIProcess/qt/QtViewInterface.cpp \
     UIProcess/qt/QtGestureRecognizer.cpp \
     UIProcess/qt/QtPanGestureRecognizer.cpp \
     UIProcess/qt/QtPinchGestureRecognizer.cpp \
index 82dea47..373b7df 100644 (file)
@@ -20,9 +20,8 @@
 #ifndef WKView_h
 #define WKView_h
 
-#include <WebKit2/qdesktopwebview.h>
-#include <WebKit2/qtouchwebview.h>
-#include <WebKit2/qtouchwebpage.h>
+#include <WebKit2/qquickwebpage.h>
+#include <WebKit2/qquickwebview.h>
 #include <WebKit2/qwebdownloaditem.h>
 #include <WebKit2/qwebnavigationcontroller.h>
 #include <WebKit2/qwebpreferences.h>
diff --git a/Source/WebKit2/UIProcess/API/qt/qbasewebview.cpp b/Source/WebKit2/UIProcess/API/qt/qbasewebview.cpp
deleted file mode 100644 (file)
index ae707ff..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this program; see the file COPYING.LIB.  If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#include "config.h"
-#include "qbasewebview.h"
-
-#include "QtWebPageProxy.h"
-#include "qbasewebview_p.h"
-#include "qwebnavigationcontroller.h"
-
-QBaseWebViewPrivate::QBaseWebViewPrivate()
-    : q_ptr(0)
-    , navigationController(0)
-{
-}
-
-void QBaseWebViewPrivate::setPageProxy(QtWebPageProxy* pageProxy)
-{
-    this->pageProxy.reset(pageProxy);
-    QObject::connect(pageProxy, SIGNAL(receivedMessageFromNavigatorQtObject(QVariantMap)), q_ptr, SIGNAL(messageReceived(QVariantMap)));
-}
-
-QBaseWebView::QBaseWebView(QBaseWebViewPrivate &dd, QQuickItem *parent)
-    : QQuickPaintedItem(parent)
-    , d_ptr(&dd)
-{
-    d_ptr->q_ptr = this;
-}
-
-QBaseWebView::~QBaseWebView()
-{
-}
-
-void QBaseWebView::load(const QUrl& url)
-{
-    Q_D(QBaseWebView);
-    d->pageProxy->load(url);
-}
-
-void QBaseWebView::postMessage(const QString& message)
-{
-    Q_D(QBaseWebView);
-    d->pageProxy->postMessageToNavigatorQtObject(message);
-}
-
-QUrl QBaseWebView::url() const
-{
-    Q_D(const QBaseWebView);
-    return d->pageProxy->url();
-}
-
-int QBaseWebView::loadProgress() const
-{
-    Q_D(const QBaseWebView);
-    return d->pageProxy->loadProgress();
-}
-
-QString QBaseWebView::title() const
-{
-    Q_D(const QBaseWebView);
-    return d->pageProxy->title();
-}
-
-QWebNavigationController* QBaseWebView::navigationController() const
-{
-    Q_D(const QBaseWebView);
-    if (!d->navigationController)
-        const_cast<QBaseWebViewPrivate*>(d)->navigationController = new QWebNavigationController(d->pageProxy.data());
-    return d->navigationController;
-}
-
-QWebPreferences* QBaseWebView::preferences() const
-{
-    Q_D(const QBaseWebView);
-    return d->pageProxy->preferences();
-}
-
-#include "moc_qbasewebview.cpp"
diff --git a/Source/WebKit2/UIProcess/API/qt/qbasewebview_p.h b/Source/WebKit2/UIProcess/API/qt/qbasewebview_p.h
deleted file mode 100644 (file)
index c3d5cfc..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this program; see the file COPYING.LIB.  If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef qbasewebview_p_h
-#define qbasewebview_p_h
-
-#include "qbasewebview.h"
-
-class QWebNavigationController;
-class QtWebPageProxy;
-
-class QBaseWebViewPrivate {
-    Q_DECLARE_PUBLIC(QBaseWebView)
-public:
-    QBaseWebViewPrivate();
-    virtual ~QBaseWebViewPrivate() { }
-    void setPageProxy(QtWebPageProxy*);
-    QBaseWebView* q_ptr;
-    QScopedPointer<QtWebPageProxy> pageProxy;
-
-    QWebNavigationController* navigationController;
-};
-
-#endif /* qbasewebview_p_h */
diff --git a/Source/WebKit2/UIProcess/API/qt/qdesktopwebview.cpp b/Source/WebKit2/UIProcess/API/qt/qdesktopwebview.cpp
deleted file mode 100644 (file)
index 071dece..0000000
+++ /dev/null
@@ -1,552 +0,0 @@
-/*
- * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this program; see the file COPYING.LIB.  If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#include "config.h"
-#include "qdesktopwebview.h"
-
-#include "QtWebPageProxy.h"
-#include "QtWebError.h"
-#include "UtilsQt.h"
-#include "qdesktopwebview_p.h"
-#include "qwebdownloaditem.h"
-#include "qwebpreferences_p.h"
-#include <QFileDialog>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qquickcanvas.h>
-#include <QtDeclarative/qquickview.h>
-#include <QtGui/QCursor>
-#include <QtGui/QDesktopServices>
-#include <QtGui/QDrag>
-#include <QtGui/QFocusEvent>
-#include <QtGui/QGuiApplication>
-#include <QtGui/QHoverEvent>
-#include <QtGui/QInputMethodEvent>
-#include <QtGui/QKeyEvent>
-#include <QtGui/QTouchEvent>
-#include <QtGui/QWheelEvent>
-#include <QtWidgets/QInputDialog>
-#include <QtWidgets/QMessageBox>
-#include <WKOpenPanelResultListener.h>
-
-QDesktopWebViewPrivate::QDesktopWebViewPrivate()
-    : isCrashed(false)
-{
-}
-
-void QDesktopWebViewPrivate::enableMouseEvents()
-{
-    Q_Q(QDesktopWebView);
-    q->setAcceptedMouseButtons(Qt::MouseButtonMask);
-    q->setAcceptHoverEvents(true);
-}
-
-void QDesktopWebViewPrivate::disableMouseEvents()
-{
-    Q_Q(QDesktopWebView);
-    q->setAcceptedMouseButtons(Qt::NoButton);
-    q->setAcceptHoverEvents(false);
-}
-
-QDesktopWebView* QDesktopWebViewPrivate::webView()
-{
-    return q_func();
-}
-
-void QDesktopWebViewPrivate::setViewNeedsDisplay(const QRect& invalidatedArea)
-{
-    Q_Q(QDesktopWebView);
-    q->update(invalidatedArea);
-}
-
-QSize QDesktopWebViewPrivate::drawingAreaSize()
-{
-    Q_Q(QDesktopWebView);
-    return QSize(q->width(), q->height());
-}
-
-void QDesktopWebViewPrivate::contentSizeChanged(const QSize&)
-{
-}
-
-bool QDesktopWebViewPrivate::isActive()
-{
-    // FIXME: The scene graph did not have the concept of being active or not when this was written.
-    return true;
-}
-
-bool QDesktopWebViewPrivate::hasFocus()
-{
-    Q_Q(QDesktopWebView);
-    return q->hasFocus();
-}
-
-bool QDesktopWebViewPrivate::isVisible()
-{
-    Q_Q(QDesktopWebView);
-    return q->isVisible();
-}
-
-void QDesktopWebViewPrivate::startDrag(Qt::DropActions supportedDropActions, const QImage& dragImage, QMimeData* data, QPoint* clientPosition, QPoint* globalPosition, Qt::DropAction* dropAction)
-{
-    Q_Q(QDesktopWebView);
-    QWindow* window = q->canvas();
-    if (!window)
-        return;
-
-    QDrag* drag = new QDrag(window);
-    drag->setPixmap(QPixmap::fromImage(dragImage));
-    drag->setMimeData(data);
-    *dropAction = drag->exec(supportedDropActions);
-    *globalPosition = QCursor::pos();
-    *clientPosition = window->mapFromGlobal(*globalPosition);
-}
-
-void QDesktopWebViewPrivate::didChangeViewportProperties(const WebCore::ViewportArguments&)
-{
-    // This feature is only used by QTouchWebView.
-}
-
-void QDesktopWebViewPrivate::didFindZoomableArea(const QPoint&, const QRect&)
-{
-    // This feature is only used by QTouchWebView.
-}
-
-void QDesktopWebViewPrivate::didChangeUrl(const QUrl& url)
-{
-    Q_Q(QDesktopWebView);
-    emit q->urlChanged(url);
-}
-
-void QDesktopWebViewPrivate::didChangeTitle(const QString& newTitle)
-{
-    Q_Q(QDesktopWebView);
-    emit q->titleChanged(newTitle);
-}
-
-void QDesktopWebViewPrivate::didChangeToolTip(const QString& newToolTip)
-{
-    // FIXME: Add a proper implementation when Qt 5 supports tooltip.
-}
-
-void QDesktopWebViewPrivate::didChangeStatusText(const QString& newMessage)
-{
-    Q_Q(QDesktopWebView);
-    emit q->statusBarMessageChanged(newMessage);
-}
-
-void QDesktopWebViewPrivate::didChangeCursor(const QCursor& newCursor)
-{
-    // FIXME: This is a temporary fix until we get cursor support in QML items.
-    QGuiApplication::setOverrideCursor(newCursor);
-}
-
-void QDesktopWebViewPrivate::loadDidBegin()
-{
-    Q_Q(QDesktopWebView);
-    emit q->loadStarted();
-}
-
-void QDesktopWebViewPrivate::loadDidCommit()
-{
-    // Not used for QDesktopWebView.
-}
-
-void QDesktopWebViewPrivate::loadDidSucceed()
-{
-    Q_Q(QDesktopWebView);
-    emit q->loadSucceeded();
-}
-
-void QDesktopWebViewPrivate::loadDidFail(const QtWebError& error)
-{
-    Q_Q(QDesktopWebView);
-    emit q->loadFailed(static_cast<QDesktopWebView::ErrorType>(error.type()), error.errorCode(), error.url());
-}
-
-void QDesktopWebViewPrivate::didChangeLoadProgress(int percentageLoaded)
-{
-    Q_Q(QDesktopWebView);
-    emit q->loadProgressChanged(percentageLoaded);
-}
-
-void QDesktopWebViewPrivate::showContextMenu(QSharedPointer<QMenu> menu)
-{
-    Q_Q(QDesktopWebView);
-    // Remove the active menu in case this function is called twice.
-    if (activeMenu)
-        activeMenu->hide();
-
-    if (menu->isEmpty())
-        return;
-
-    QWindow* window = q->canvas();
-    if (!window)
-        return;
-
-    activeMenu = menu;
-
-    activeMenu->window()->winId(); // Ensure that the menu has a window
-    Q_ASSERT(activeMenu->window()->windowHandle());
-    activeMenu->window()->windowHandle()->setTransientParent(window);
-
-    QPoint menuPositionInScene = q->mapToScene(menu->pos()).toPoint();
-    menu->exec(window->mapToGlobal(menuPositionInScene));
-    // The last function to get out of exec() clear the local copy.
-    if (activeMenu == menu)
-        activeMenu.clear();
-}
-
-void QDesktopWebViewPrivate::hideContextMenu()
-{
-    if (activeMenu)
-        activeMenu->hide();
-}
-
-void QDesktopWebViewPrivate::runJavaScriptAlert(const QString& alertText)
-{
-#ifndef QT_NO_MESSAGEBOX
-    Q_Q(QDesktopWebView);
-    const QString title = QObject::tr("JavaScript Alert - %1").arg(q->url().host());
-    disableMouseEvents();
-    QMessageBox::information(0, title, escapeHtml(alertText), QMessageBox::Ok);
-    enableMouseEvents();
-#else
-    Q_UNUSED(alertText);
-#endif
-}
-
-bool QDesktopWebViewPrivate::runJavaScriptConfirm(const QString& message)
-{
-    bool result = true;
-#ifndef QT_NO_MESSAGEBOX
-    Q_Q(QDesktopWebView);
-    const QString title = QObject::tr("JavaScript Confirm - %1").arg(q->url().host());
-    disableMouseEvents();
-    result = QMessageBox::Yes == QMessageBox::information(0, title, escapeHtml(message), QMessageBox::Yes, QMessageBox::No);
-    enableMouseEvents();
-#else
-    Q_UNUSED(message);
-#endif
-    return result;
-}
-
-QString QDesktopWebViewPrivate::runJavaScriptPrompt(const QString& message, const QString& defaultValue, bool& ok)
-{
-#ifndef QT_NO_INPUTDIALOG
-    Q_Q(QDesktopWebView);
-    const QString title = QObject::tr("JavaScript Prompt - %1").arg(q->url().host());
-    disableMouseEvents();
-    QString result = QInputDialog::getText(0, title, escapeHtml(message), QLineEdit::Normal, defaultValue, &ok);
-    enableMouseEvents();
-    return result;
-#else
-    Q_UNUSED(message);
-    return defaultValue;
-#endif
-}
-
-QDesktopWebView::QDesktopWebView(QQuickItem* parent)
-    : QBaseWebView(*(new QDesktopWebViewPrivate), parent)
-{
-    Q_D(QDesktopWebView);
-    d->init();
-}
-
-QDesktopWebView::QDesktopWebView(WKContextRef contextRef, WKPageGroupRef pageGroupRef, QQuickItem* parent)
-    : QBaseWebView(*(new QDesktopWebViewPrivate), parent)
-{
-    Q_D(QDesktopWebView);
-    d->init(contextRef, pageGroupRef);
-}
-
-void QDesktopWebViewPrivate::init(WKContextRef contextRef, WKPageGroupRef pageGroupRef)
-{
-    setPageProxy(new QtWebPageProxy(this, 0, this, contextRef, pageGroupRef));
-    QWebPreferencesPrivate::get(pageProxy->preferences())->setAttribute(QWebPreferencesPrivate::AcceleratedCompositingEnabled, false);
-    pageProxy->init();
-    enableMouseEvents();
-}
-
-QDesktopWebView::~QDesktopWebView()
-{
-}
-
-static void paintCrashedPage(QPainter* painter, const QRectF& rect)
-{
-    painter->fillRect(rect, Qt::gray);
-    painter->drawText(rect, Qt::AlignCenter, QLatin1String(":("));
-}
-
-void QDesktopWebView::keyPressEvent(QKeyEvent* event)
-{
-    this->event(event);
-}
-
-void QDesktopWebView::keyReleaseEvent(QKeyEvent* event)
-{
-    this->event(event);
-}
-
-void QDesktopWebView::inputMethodEvent(QInputMethodEvent* event)
-{
-    this->event(event);
-}
-
-void QDesktopWebView::focusInEvent(QFocusEvent* event)
-{
-    this->event(event);
-}
-
-void QDesktopWebView::focusOutEvent(QFocusEvent* event)
-{
-    this->event(event);
-}
-
-void QDesktopWebView::mousePressEvent(QMouseEvent* event)
-{
-    forceActiveFocus();
-    this->event(event);
-}
-
-void QDesktopWebView::mouseMoveEvent(QMouseEvent* event)
-{
-    this->event(event);
-}
-
-void QDesktopWebView::mouseReleaseEvent(QMouseEvent* event)
-{
-    this->event(event);
-}
-
-void QDesktopWebView::mouseDoubleClickEvent(QMouseEvent* event)
-{
-    this->event(event);
-}
-
-void QDesktopWebView::wheelEvent(QWheelEvent* event)
-{
-    this->event(event);
-}
-
-void QDesktopWebView::hoverEnterEvent(QHoverEvent* event)
-{
-    this->event(event);
-}
-
-void QDesktopWebView::hoverMoveEvent(QHoverEvent* event)
-{
-    this->event(event);
-}
-
-void QDesktopWebView::hoverLeaveEvent(QHoverEvent* event)
-{
-    this->event(event);
-}
-
-void QDesktopWebView::dragMoveEvent(QDragMoveEvent* event)
-{
-    this->event(event);
-}
-
-void QDesktopWebView::dragEnterEvent(QDragEnterEvent* event)
-{
-    this->event(event);
-}
-
-void QDesktopWebView::dragLeaveEvent(QDragLeaveEvent* event)
-{
-    this->event(event);
-}
-
-void QDesktopWebView::dropEvent(QDropEvent* event)
-{
-    this->event(event);
-}
-
-void QDesktopWebView::geometryChanged(const QRectF& newGeometry, const QRectF& oldGeometry)
-{
-    Q_D(QDesktopWebView);
-    QQuickPaintedItem::geometryChanged(newGeometry, oldGeometry);
-    if (newGeometry.size() != oldGeometry.size())
-        d->pageProxy->setDrawingAreaSize(newGeometry.size().toSize());
-}
-
-void QDesktopWebView::paint(QPainter* painter)
-{
-    Q_D(QDesktopWebView);
-    const QRectF rect = boundingRect();
-    if (d->isCrashed) {
-        paintCrashedPage(painter, rect);
-        return;
-    }
-
-    d->pageProxy->paint(painter, rect.toAlignedRect());
-}
-
-bool QDesktopWebView::event(QEvent* ev)
-{
-    Q_D(QDesktopWebView);
-    if (d->pageProxy->handleEvent(ev))
-        return true;
-    if (ev->type() == QEvent::InputMethod)
-        return false; // This is necessary to avoid an endless loop in connection with QQuickItem::event().
-    return QQuickItem::event(ev);
-}
-
-WKPageRef QDesktopWebView::pageRef() const
-{
-    Q_D(const QDesktopWebView);
-    return d->pageProxy->pageRef();
-}
-
-void QDesktopWebViewPrivate::processDidCrash()
-{
-    Q_Q(QDesktopWebView);
-    isCrashed = true;
-    q->update();
-}
-
-void QDesktopWebViewPrivate::didRelaunchProcess()
-{
-    Q_Q(QDesktopWebView);
-    isCrashed = false;
-    q->update();
-}
-
-QJSEngine* QDesktopWebViewPrivate::engine()
-{
-    Q_Q(QDesktopWebView);
-    QQuickView* view = qobject_cast<QQuickView*>(q->canvas());
-    if (view)
-        return view->engine();
-    return 0;
-}
-
-void QDesktopWebViewPrivate::chooseFiles(WKOpenPanelResultListenerRef listenerRef, const QStringList& selectedFileNames, QtViewInterface::FileChooserType type)
-{
-#ifndef QT_NO_FILEDIALOG
-    Q_Q(QDesktopWebView);
-    openPanelResultListener = listenerRef;
-
-    // Qt does not support multiple files suggestion, so we get just the first suggestion.
-    QString selectedFileName;
-    if (!selectedFileNames.isEmpty())
-        selectedFileName = selectedFileNames.at(0);
-
-    Q_ASSERT(!fileDialog);
-
-    QWindow* window = q->canvas();
-    if (!window)
-        return;
-
-    fileDialog = new QFileDialog(0, QString(), selectedFileName);
-    fileDialog->window()->winId(); // Ensure that the dialog has a window
-    Q_ASSERT(fileDialog->window()->windowHandle());
-    fileDialog->window()->windowHandle()->setTransientParent(window);
-
-    fileDialog->open(q_func(), SLOT(_q_onOpenPanelFilesSelected()));
-
-    q_func()->connect(fileDialog, SIGNAL(finished(int)), SLOT(_q_onOpenPanelFinished(int)));
-#endif
-}
-
-void QDesktopWebViewPrivate::_q_onOpenPanelFilesSelected()
-{
-    const QStringList fileList = fileDialog->selectedFiles();
-    Vector<RefPtr<APIObject> > wkFiles(fileList.size());
-
-    for (unsigned i = 0; i < fileList.size(); ++i)
-        wkFiles[i] = WebURL::create(QUrl::fromLocalFile(fileList.at(i)).toString());
-
-    WKOpenPanelResultListenerChooseFiles(openPanelResultListener, toAPI(ImmutableArray::adopt(wkFiles).leakRef()));
-}
-
-void QDesktopWebViewPrivate::_q_onOpenPanelFinished(int result)
-{
-    if (result == QDialog::Rejected)
-        WKOpenPanelResultListenerCancel(openPanelResultListener);
-
-    fileDialog->deleteLater();
-    fileDialog = 0;
-}
-
-void QDesktopWebViewPrivate::didMouseMoveOverElement(const QUrl& linkURL, const QString& linkTitle)
-{
-    if (linkURL == lastHoveredURL && linkTitle == lastHoveredTitle)
-        return;
-    Q_Q(QDesktopWebView);
-    lastHoveredURL = linkURL;
-    lastHoveredTitle = linkTitle;
-    emit q->linkHovered(lastHoveredURL, lastHoveredTitle);
-}
-
-void QDesktopWebViewPrivate::downloadRequested(QWebDownloadItem* downloadItem)
-{
-    if (!downloadItem)
-        return;
-
-    Q_Q(QDesktopWebView);
-
-    QDeclarativeEngine::setObjectOwnership(downloadItem, QDeclarativeEngine::JavaScriptOwnership);
-    emit q->downloadRequested(downloadItem);
-}
-
-static QtPolicyInterface::PolicyAction toPolicyAction(QDesktopWebView::NavigationPolicy policy)
-{
-    switch (policy) {
-    case QDesktopWebView::UsePolicy:
-        return QtPolicyInterface::Use;
-    case QDesktopWebView::DownloadPolicy:
-        return QtPolicyInterface::Download;
-    case QDesktopWebView::IgnorePolicy:
-        return QtPolicyInterface::Ignore;
-    }
-    ASSERT_NOT_REACHED();
-    return QtPolicyInterface::Ignore;
-}
-
-static bool hasMetaMethod(QObject* object, const char* methodName)
-{
-    int methodIndex = object->metaObject()->indexOfMethod(QMetaObject::normalizedSignature(methodName));
-    return methodIndex >= 0 && methodIndex < object->metaObject()->methodCount();
-}
-
-/*!
-    \qmlmethod NavigationPolicy DesktopWebView::navigationPolicyForUrl(url, button, modifiers)
-
-    This method should be implemented by the user of DesktopWebView element.
-
-    It will be called to decide the policy for a navigation: whether the WebView should ignore the navigation,
-    continue it or start a download. The return value must be one of the policies in the NavigationPolicy enumeration.
-*/
-QtPolicyInterface::PolicyAction QDesktopWebViewPrivate::navigationPolicyForURL(const QUrl& url, Qt::MouseButton button, Qt::KeyboardModifiers modifiers)
-{
-    Q_Q(QDesktopWebView);
-    // We need to check this first because invokeMethod() warns if the method doesn't exist for the object.
-    if (!hasMetaMethod(q, "navigationPolicyForUrl(QVariant,QVariant,QVariant)"))
-        return QtPolicyInterface::Use;
-
-    QVariant ret;
-    if (QMetaObject::invokeMethod(q, "navigationPolicyForUrl", Q_RETURN_ARG(QVariant, ret), Q_ARG(QVariant, url), Q_ARG(QVariant, button), Q_ARG(QVariant, QVariant(modifiers))))
-        return toPolicyAction(static_cast<QDesktopWebView::NavigationPolicy>(ret.toInt()));
-    return QtPolicyInterface::Use;
-}
-
-#include "moc_qdesktopwebview.cpp"
diff --git a/Source/WebKit2/UIProcess/API/qt/qdesktopwebview.h b/Source/WebKit2/UIProcess/API/qt/qdesktopwebview.h
deleted file mode 100644 (file)
index d083fa7..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this program; see the file COPYING.LIB.  If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef qdesktopwebview_h
-#define qdesktopwebview_h
-
-#include "qbasewebview.h"
-#include "qwebkitglobal.h"
-
-class QDesktopWebViewPrivate;
-
-QT_BEGIN_NAMESPACE
-class QFocusEvent;
-class QMouseEvent;
-class QHoverEvent;
-class QInputMethodEvent;
-class QKeyEvent;
-class QPainter;
-class QRectF;
-class QDragEnterEvent;
-class QDragMoveEvent;
-class QDragLeaveEvent;
-class QDropEvent;
-class QTouchEvent;
-class QWheelEvent;
-QT_END_NAMESPACE
-
-typedef const struct OpaqueWKContext* WKContextRef;
-typedef const struct OpaqueWKPageGroup* WKPageGroupRef;
-typedef const struct OpaqueWKPage* WKPageRef;
-
-namespace WTR {
-    class PlatformWebView;
-}
-
-class QWEBKIT_EXPORT QDesktopWebView : public QBaseWebView {
-    Q_OBJECT
-public:
-    QDesktopWebView(QQuickItem* parent = 0);
-    virtual ~QDesktopWebView();
-
-Q_SIGNALS:
-    void linkHovered(const QUrl& url, const QString& title);
-
-protected:
-    virtual void keyPressEvent(QKeyEvent*);
-    virtual void keyReleaseEvent(QKeyEvent*);
-    virtual void inputMethodEvent(QInputMethodEvent*);
-    virtual void focusInEvent(QFocusEvent*);
-    virtual void focusOutEvent(QFocusEvent*);
-    virtual void mousePressEvent(QMouseEvent *);
-    virtual void mouseMoveEvent(QMouseEvent *);
-    virtual void mouseReleaseEvent(QMouseEvent *);
-    virtual void mouseDoubleClickEvent(QMouseEvent *);
-    virtual void wheelEvent(QWheelEvent*);
-    virtual void hoverEnterEvent(QHoverEvent*);
-    virtual void hoverMoveEvent(QHoverEvent*);
-    virtual void hoverLeaveEvent(QHoverEvent*);
-    virtual void dragMoveEvent(QDragMoveEvent*);
-    virtual void dragEnterEvent(QDragEnterEvent*);
-    virtual void dragLeaveEvent(QDragLeaveEvent*);
-    virtual void dropEvent(QDropEvent*);
-
-    virtual void geometryChanged(const QRectF&, const QRectF&);
-    void paint(QPainter*);
-    virtual bool event(QEvent*);
-
-private:
-    QDesktopWebView(WKContextRef, WKPageGroupRef, QQuickItem* parent = 0);
-    WKPageRef pageRef() const;
-    Q_PRIVATE_SLOT(d_func(), void _q_onOpenPanelFilesSelected());
-    Q_PRIVATE_SLOT(d_func(), void _q_onOpenPanelFinished(int result));
-
-    friend class WTR::PlatformWebView;
-    Q_DECLARE_PRIVATE(QDesktopWebView)
-};
-
-QML_DECLARE_TYPE(QDesktopWebView)
-Q_DECLARE_METATYPE(QDesktopWebView::NavigationPolicy)
-
-#endif /* qdesktopwebview_h */
diff --git a/Source/WebKit2/UIProcess/API/qt/qdesktopwebview_p.h b/Source/WebKit2/UIProcess/API/qt/qdesktopwebview_p.h
deleted file mode 100644 (file)
index 9325e0b..0000000
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this program; see the file COPYING.LIB.  If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef qdesktopwebview_p_h
-#define qdesktopwebview_p_h
-
-#include "QtPolicyInterface.h"
-#include "QtViewInterface.h"
-#include "qbasewebview_p.h"
-#include "qdesktopwebview.h"
-
-class QFileDialog;
-
-class QDesktopWebViewPrivate : public QBaseWebViewPrivate, public WebKit::QtViewInterface, public WebKit::QtPolicyInterface
-{
-    Q_DECLARE_PUBLIC(QDesktopWebView)
-public:
-    QDesktopWebViewPrivate();
-    void init(WKContextRef = 0, WKPageGroupRef = 0);
-
-    static QDesktopWebView* createViewWithPageGroup(WKPageGroupRef);
-
-    QDesktopWebView* webView();
-    void _q_onOpenPanelFilesSelected();
-    void _q_onOpenPanelFinished(int result);
-    void enableMouseEvents();
-    void disableMouseEvents();
-
-    bool isCrashed;
-
-private:
-    // Implementation of QtViewInterface.
-    virtual void setViewNeedsDisplay(const QRect&);
-
-    virtual QSize drawingAreaSize();
-    virtual void contentSizeChanged(const QSize&);
-    virtual void scrollPositionRequested(const QPoint& pos) { }
-
-    virtual bool isActive();
-    virtual bool hasFocus();
-    virtual bool isVisible();
-
-    virtual void startDrag(Qt::DropActions supportedDropActions, const QImage& dragImage, QMimeData*, QPoint* clientPosition, QPoint* globalPosition, Qt::DropAction* dropAction);
-    virtual void didChangeViewportProperties(const WebCore::ViewportArguments&);
-    virtual void didFindZoomableArea(const QPoint&, const QRect&);
-
-    virtual void didChangeUrl(const QUrl&);
-    virtual void didChangeTitle(const QString&);
-    virtual void didChangeToolTip(const QString&);
-    virtual void didChangeStatusText(const QString&);
-    virtual void didChangeCursor(const QCursor&);
-    virtual void loadDidBegin();
-    virtual void loadDidCommit();
-    virtual void loadDidSucceed();
-    virtual void loadDidFail(const QtWebError&);
-    virtual void didChangeLoadProgress(int);
-
-    virtual void showContextMenu(QSharedPointer<QMenu>);
-    virtual void hideContextMenu();
-
-    virtual void runJavaScriptAlert(const QString&);
-    virtual bool runJavaScriptConfirm(const QString&);
-    virtual QString runJavaScriptPrompt(const QString&, const QString& defaultValue, bool& ok);
-
-    virtual void processDidCrash();
-    virtual void didRelaunchProcess();
-
-    virtual QJSEngine* engine();
-
-    virtual void chooseFiles(WKOpenPanelResultListenerRef, const QStringList& selectedFileNames, QtViewInterface::FileChooserType);
-    virtual void downloadRequested(QWebDownloadItem* downloadItem);
-
-    virtual void didMouseMoveOverElement(const QUrl&, const QString&);
-
-    // QtPolicyInterface.
-    virtual QtPolicyInterface::PolicyAction navigationPolicyForURL(const QUrl&, Qt::MouseButton, Qt::KeyboardModifiers);
-
-    QSharedPointer<QMenu> activeMenu;
-
-    QFileDialog* fileDialog;
-    WKOpenPanelResultListenerRef openPanelResultListener;
-
-    QUrl lastHoveredURL;
-    QString lastHoveredTitle;
-};
-
-#endif /* qdesktopwebview_p_h */
  */
 
 #include "config.h"
-#include "qtouchwebpage.h"
+#include "qquickwebpage.h"
 
 #include "QtWebPageProxy.h"
 #include "TransformationMatrix.h"
-#include "qtouchwebpage_p.h"
-#include <QApplication>
-#include <QGraphicsSceneMouseEvent>
-#include <QPainter>
-#include <QQuickCanvas>
-#include <QSGEngine>
-#include <QUrl>
-
-QTouchWebPage::QTouchWebPage(QQuickItem* parent)
+#include "qquickwebpage_p.h"
+#include "qquickwebview.h"
+#include <QtCore/QUrl>
+#include <QtDeclarative/QQuickCanvas>
+#include <QtDeclarative/QSGEngine>
+
+QQuickWebPage::QQuickWebPage(QQuickItem* parent)
     : QQuickItem(parent)
-    , d(new QTouchWebPagePrivate(this))
+    , d(new QQuickWebPagePrivate(this))
 {
     setFlag(ItemHasContents);
 
     // We do the transform from the top left so the viewport can assume the position 0, 0
     // is always where rendering starts.
     setTransformOrigin(TopLeft);
-    initSceneGraphConnections();
+    d->initializeSceneGraphConnections();
 }
 
-void QTouchWebPage::initSceneGraphConnections()
+QQuickWebPage::~QQuickWebPage()
 {
-    if (d->paintingIsInitialized)
-        return;
-    if (!canvas())
-        return;
-    d->paintingIsInitialized = true;
-    if (sceneGraphEngine())
-        d->_q_onSceneGraphInitialized();
-    else
-        connect(canvas(), SIGNAL(sceneGraphInitialized()), this, SLOT(_q_onSceneGraphInitialized()));
+    delete d;
 }
 
-QTouchWebPage::~QTouchWebPage()
+void QQuickWebPage::keyPressEvent(QKeyEvent* event)
 {
-    delete d;
+    this->event(event);
 }
 
-/*! \reimp
-*/
-bool QTouchWebPage::event(QEvent* ev)
+void QQuickWebPage::keyReleaseEvent(QKeyEvent* event)
 {
-    if (d->pageProxy->handleEvent(ev))
-        return true;
-    return QQuickItem::event(ev);
+    this->event(event);
+}
+
+void QQuickWebPage::inputMethodEvent(QInputMethodEvent* event)
+{
+    this->event(event);
+}
+
+void QQuickWebPage::focusInEvent(QFocusEvent* event)
+{
+    this->event(event);
 }
 
-void QTouchWebPage::keyPressEvent(QKeyEvent* event)
+void QQuickWebPage::focusOutEvent(QFocusEvent* event)
 {
     this->event(event);
 }
 
-void QTouchWebPage::keyReleaseEvent(QKeyEvent* event)
+void QQuickWebPage::mousePressEvent(QMouseEvent* event)
 {
+    forceActiveFocus();
     this->event(event);
 }
 
-void QTouchWebPage::inputMethodEvent(QInputMethodEvent* event)
+void QQuickWebPage::mouseMoveEvent(QMouseEvent* event)
 {
     this->event(event);
 }
 
-void QTouchWebPage::focusInEvent(QFocusEvent* event)
+void QQuickWebPage::mouseReleaseEvent(QMouseEvent* event)
 {
     this->event(event);
 }
 
-void QTouchWebPage::focusOutEvent(QFocusEvent* event)
+void QQuickWebPage::mouseDoubleClickEvent(QMouseEvent* event)
 {
     this->event(event);
 }
 
-void QTouchWebPage::touchEvent(QTouchEvent* event)
+void QQuickWebPage::wheelEvent(QWheelEvent* event)
 {
     this->event(event);
 }
 
-void QTouchWebPage::geometryChanged(const QRectF& newGeometry, const QRectF& oldGeometry)
+void QQuickWebPage::hoverEnterEvent(QHoverEvent* event)
+{
+    this->event(event);
+}
+
+void QQuickWebPage::hoverMoveEvent(QHoverEvent* event)
+{
+    this->event(event);
+}
+
+void QQuickWebPage::hoverLeaveEvent(QHoverEvent* event)
+{
+    this->event(event);
+}
+
+void QQuickWebPage::dragMoveEvent(QDragMoveEvent* event)
+{
+    this->event(event);
+}
+
+void QQuickWebPage::dragEnterEvent(QDragEnterEvent* event)
+{
+    this->event(event);
+}
+
+void QQuickWebPage::dragLeaveEvent(QDragLeaveEvent* event)
+{
+    this->event(event);
+}
+
+void QQuickWebPage::dropEvent(QDropEvent* event)
+{
+    this->event(event);
+}
+
+void QQuickWebPage::geometryChanged(const QRectF& newGeometry, const QRectF& oldGeometry)
 {
     QQuickItem::geometryChanged(newGeometry, oldGeometry);
     if (newGeometry.size() != oldGeometry.size())
         d->pageProxy->setDrawingAreaSize(newGeometry.size().toSize());
 }
 
-QTouchWebPagePrivate::QTouchWebPagePrivate(QTouchWebPage* view)
+bool QQuickWebPage::event(QEvent* ev)
+{
+    if (d->pageProxy->handleEvent(ev))
+        return true;
+    if (ev->type() == QEvent::InputMethod)
+        return false; // This is necessary to avoid an endless loop in connection with QQuickItem::event().
+    return QQuickItem::event(ev);
+}
+
+void QQuickWebPage::touchEvent(QTouchEvent* event)
+{
+    this->event(event);
+}
+
+void QQuickWebPage::itemChange(ItemChange change, const ItemChangeData& data)
+{
+    if (change == ItemSceneChange)
+        d->initializeSceneGraphConnections();
+    QQuickItem::itemChange(change, data);
+}
+
+QQuickWebPagePrivate::QQuickWebPagePrivate(QQuickWebPage* view)
     : q(view)
     , pageProxy(0)
     , navigationController(0)
@@ -116,18 +169,30 @@ QTouchWebPagePrivate::QTouchWebPagePrivate(QTouchWebPage* view)
 {
 }
 
-void QTouchWebPagePrivate::setPageProxy(QtWebPageProxy* pageProxy)
+void QQuickWebPagePrivate::initializeSceneGraphConnections()
+{
+    if (paintingIsInitialized)
+        return;
+    if (!q->canvas())
+        return;
+    paintingIsInitialized = true;
+    if (q->sceneGraphEngine())
+        _q_onSceneGraphInitialized();
+    else
+        QObject::connect(q->canvas(), SIGNAL(sceneGraphInitialized()), q, SLOT(_q_onSceneGraphInitialized()));
+}
+
+void QQuickWebPagePrivate::setPageProxy(QtWebPageProxy* pageProxy)
 {
     ASSERT(!this->pageProxy);
     ASSERT(pageProxy);
     this->pageProxy = pageProxy;
-
 }
 
 static float computeEffectiveOpacity(const QQuickItem* item)
 {
     if (!item)
-        return 1.0;
+        return 1;
 
     float opacity = item->opacity();
     if (opacity < 0.01)
@@ -136,12 +201,13 @@ static float computeEffectiveOpacity(const QQuickItem* item)
     return opacity * computeEffectiveOpacity(item->parentItem());
 }
 
-void QTouchWebPagePrivate::paintToCurrentGLContext()
+void QQuickWebPagePrivate::paintToCurrentGLContext()
 {
     if (!q->isVisible())
         return;
 
     QTransform transform = q->itemTransform(0, 0);
+
     float opacity = computeEffectiveOpacity(q);
     QRectF clipRect = q->parentItem()->mapRectToScene(q->parentItem()->boundingRect());
 
@@ -157,23 +223,16 @@ void QTouchWebPagePrivate::paintToCurrentGLContext()
     glDisable(GL_SCISSOR_TEST);
 }
 
-void QTouchWebPagePrivate::_q_onAfterSceneRender()
+void QQuickWebPagePrivate::_q_onAfterSceneRender()
 {
     // TODO: Allow painting before the scene or in the middle of the scene with an FBO.
     paintToCurrentGLContext();
 }
 
-void QTouchWebPagePrivate::_q_onSceneGraphInitialized()
+void QQuickWebPagePrivate::_q_onSceneGraphInitialized()
 {
     QSGEngine* engine = q->sceneGraphEngine();
     QObject::connect(engine, SIGNAL(afterRendering()), q, SLOT(_q_onAfterSceneRender()), Qt::DirectConnection);
 }
 
-void QTouchWebPage::itemChange(ItemChange change, const ItemChangeData &data)
-{
-    if (change == ItemSceneChange)
-        initSceneGraphConnections();
-    QQuickItem::itemChange(change, data);
-}
-
-#include "moc_qtouchwebpage.cpp"
+#include "moc_qquickwebpage.cpp"
  *
  */
 
-#ifndef qtouchwebpage_h
-#define qtouchwebpage_h
+#ifndef qquickwebpage_h
+#define qquickwebpage_h
 
 #include "qwebkitglobal.h"
 
-#include <QtDeclarative/qquickitem.h>
-#include <QSharedPointer>
+#include <QtCore/QSharedPointer>
+#include <QtDeclarative/QQuickItem>
 
-class QTouchWebPagePrivate;
+class QQuickWebView;
+class QQuickWebPagePrivate;
 class QWebNavigationController;
 class QWebPreferences;
 
 namespace WebKit {
-class QtTouchViewInterface;
+class QtViewInterface;
 }
 
-class QWEBKIT_EXPORT QTouchWebPage : public QQuickItem {
+class QWEBKIT_EXPORT QQuickWebPage : public QQuickItem {
     Q_OBJECT
 public:
-    QTouchWebPage(QQuickItem* parent = 0);
-
-    virtual ~QTouchWebPage();
-
-    virtual bool event(QEvent*);
+    QQuickWebPage(QQuickItem* parent = 0);
+    virtual ~QQuickWebPage();
 
 protected:
     virtual void keyPressEvent(QKeyEvent*);
@@ -49,8 +47,20 @@ protected:
     virtual void inputMethodEvent(QInputMethodEvent*);
     virtual void focusInEvent(QFocusEvent*);
     virtual void focusOutEvent(QFocusEvent*);
+    virtual void mousePressEvent(QMouseEvent*);
+    virtual void mouseMoveEvent(QMouseEvent*);
+    virtual void mouseReleaseEvent(QMouseEvent *);
+    virtual void mouseDoubleClickEvent(QMouseEvent*);
+    virtual void wheelEvent(QWheelEvent*);
+    virtual void hoverEnterEvent(QHoverEvent*);
+    virtual void hoverMoveEvent(QHoverEvent*);
+    virtual void hoverLeaveEvent(QHoverEvent*);
+    virtual void dragMoveEvent(QDragMoveEvent*);
+    virtual void dragEnterEvent(QDragEnterEvent*);
+    virtual void dragLeaveEvent(QDragLeaveEvent*);
+    virtual void dropEvent(QDropEvent*);
     virtual void touchEvent(QTouchEvent*);
-
+    virtual bool event(QEvent*);
     virtual void geometryChanged(const QRectF&, const QRectF&);
     virtual void itemChange(ItemChange, const ItemChangeData&);
 
@@ -58,11 +68,11 @@ private:
     Q_PRIVATE_SLOT(d, void _q_onAfterSceneRender());
     Q_PRIVATE_SLOT(d, void _q_onSceneGraphInitialized());
 
-    void initSceneGraphConnections();
-
-    QTouchWebPagePrivate* d;
-    friend class QTouchWebViewPrivate;
-    friend class WebKit::QtTouchViewInterface;
+    QQuickWebPagePrivate* d;
+    friend class QQuickWebViewPrivate;
+    friend class WebKit::QtViewInterface;
 };
 
-#endif /* qtouchwebpage_h */
+QML_DECLARE_TYPE(QQuickWebPage)
+
+#endif /* qquickwebpage_h */
  *
  */
 
-#ifndef qtouchwebpage_p_h
-#define qtouchwebpage_p_h
+#ifndef qquickwebpage_p_h
+#define qquickwebpage_p_h
 
 #include "QtSGUpdateQueue.h"
-#include "qtouchwebpage.h"
+#include "QtViewInterface.h"
+#include "qquickwebpage.h"
 #include "qwebnavigationcontroller.h"
-#include <QMenu>
 
+QT_BEGIN_NAMESPACE
 class QRectF;
 class QSGNode;
 class QString;
-class QTouchWebPage;
+QT_END_NAMESPACE
 
-class QTouchWebPagePrivate {
+class QQuickWebPage;
+
+class QQuickWebPagePrivate {
 public:
-    QTouchWebPagePrivate(QTouchWebPage* view);
+    QQuickWebPagePrivate(QQuickWebPage* view);
 
     void setPageProxy(QtWebPageProxy*);
 
+    void initializeSceneGraphConnections();
+
     void _q_onAfterSceneRender();
     void _q_onSceneGraphInitialized();
     void paintToCurrentGLContext();
 
-    QTouchWebPage* const q;
+    QQuickWebPage* const q;
     QtWebPageProxy* pageProxy;
     QWebNavigationController* navigationController;
     WebKit::QtSGUpdateQueue sgUpdateQueue;
     bool paintingIsInitialized;
 };
 
-#endif /* qtouchwebpage_p_h */
+#endif /* qquickwebpage_p_h */
diff --git a/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp b/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp
new file mode 100644 (file)
index 0000000..ec297f1
--- /dev/null
@@ -0,0 +1,456 @@
+/*
+ * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this program; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "config.h"
+#include "qquickwebview.h"
+
+#include "QtViewInterface.h"
+#include "QtWebPageProxy.h"
+#include "UtilsQt.h"
+#include "WebPageGroup.h"
+#include "WebPreferences.h"
+
+#include "qquickwebpage_p.h"
+#include "qquickwebview_p.h"
+#include "qwebnavigationcontroller.h"
+#include "qwebpreferences_p.h"
+
+#include <QtDeclarative/QQuickCanvas>
+#include <QtWidgets/QFileDialog>
+#include <QtWidgets/QInputDialog>
+#include <QtWidgets/QMessageBox>
+#include <WKOpenPanelResultListener.h>
+
+QQuickWebViewPrivate::QQuickWebViewPrivate()
+    : q_ptr(0)
+    , navigationController(0)
+    , useTraditionalDesktopBehaviour(false)
+{
+}
+
+void QQuickWebViewPrivate::enableMouseEvents()
+{
+    Q_Q(QQuickWebView);
+    q->setAcceptedMouseButtons(Qt::MouseButtonMask);
+    q->setAcceptHoverEvents(true);
+    pageView->setAcceptedMouseButtons(Qt::MouseButtonMask);
+    pageView->setAcceptHoverEvents(true);
+}
+
+void QQuickWebViewPrivate::disableMouseEvents()
+{
+    Q_Q(QQuickWebView);
+    q->setAcceptedMouseButtons(Qt::NoButton);
+    q->setAcceptHoverEvents(false);
+    pageView->setAcceptedMouseButtons(Qt::NoButton);
+    pageView->setAcceptHoverEvents(false);
+}
+
+void QQuickWebViewPrivate::initialize(QQuickWebView* viewport, WKContextRef contextRef, WKPageGroupRef pageGroupRef)
+{
+    q_ptr = viewport;
+    viewport->setFlags(QQuickItem::ItemClipsChildrenToShape);
+
+    QObject::connect(viewport, SIGNAL(visibleChanged()), viewport, SLOT(_q_onVisibleChanged()));
+    pageView.reset(new QQuickWebPage(viewport));
+    viewInterface.reset(new WebKit::QtViewInterface(viewport, pageView.data()));
+
+    QQuickWebPagePrivate* const pageViewPrivate = pageView.data()->d;
+    setPageProxy(new QtWebPageProxy(viewInterface.data(), 0, this, contextRef, pageGroupRef));
+    pageViewPrivate->setPageProxy(pageProxy.data());
+
+    QWebPreferencesPrivate::get(pageProxy->preferences())->setAttribute(QWebPreferencesPrivate::AcceleratedCompositingEnabled, true);
+    pageProxy->init();
+}
+
+void QQuickWebViewPrivate::initializeDesktop(QQuickWebView* viewport)
+{
+    if (interactionEngine) {
+        QObject::disconnect(interactionEngine.data(), SIGNAL(viewportUpdateRequested()), viewport, SLOT(_q_viewportUpdated()));
+        QObject::disconnect(interactionEngine.data(), SIGNAL(viewportTrajectoryVectorChanged(const QPointF&)), viewport, SLOT(_q_viewportTrajectoryVectorChanged(const QPointF&)));
+    }
+    interactionEngine.reset(0);
+    pageProxy->setViewportInteractionEngine(0);
+    enableMouseEvents();
+}
+
+void QQuickWebViewPrivate::initializeTouch(QQuickWebView* viewport)
+{
+    interactionEngine.reset(new QtViewportInteractionEngine(viewport, pageView.data()));
+    pageProxy->setViewportInteractionEngine(interactionEngine.data());
+    disableMouseEvents();
+    QObject::connect(interactionEngine.data(), SIGNAL(viewportUpdateRequested()), viewport, SLOT(_q_viewportUpdated()));
+    QObject::connect(interactionEngine.data(), SIGNAL(viewportTrajectoryVectorChanged(const QPointF&)), viewport, SLOT(_q_viewportTrajectoryVectorChanged(const QPointF&)));
+    updateViewportSize();
+}
+
+void QQuickWebViewPrivate::loadDidCommit()
+{
+    if (!useTraditionalDesktopBehaviour)
+        interactionEngine->reset();
+}
+
+void QQuickWebViewPrivate::contentSizeChanged(const QSize& newSize)
+{
+    if (useTraditionalDesktopBehaviour)
+        return;
+
+    pageView->setWidth(newSize.width());
+    pageView->setHeight(newSize.height());
+}
+
+void QQuickWebViewPrivate::scrollPositionRequested(const QPoint& pos)
+{
+    if (!useTraditionalDesktopBehaviour)
+        interactionEngine->pagePositionRequest(pos);
+}
+
+void QQuickWebViewPrivate::_q_viewportUpdated()
+{
+    Q_Q(QQuickWebView);
+    const QRectF visibleRectInPageViewCoordinates = q->mapRectToItem(pageView.data(), q->boundingRect()).intersected(pageView->boundingRect());
+    float scale = pageView->scale();
+    pageProxy->setVisibleContentRectAndScale(visibleRectInPageViewCoordinates, scale);
+}
+
+void QQuickWebViewPrivate::_q_viewportTrajectoryVectorChanged(const QPointF& trajectoryVector)
+{
+    pageProxy->setVisibleContentRectTrajectoryVector(trajectoryVector);
+}
+
+void QQuickWebViewPrivate::_q_onVisibleChanged()
+{
+    WebPageProxy* wkPage = toImpl(pageProxy->pageRef());
+
+    wkPage->viewStateDidChange(WebPageProxy::ViewIsVisible);
+}
+
+
+void QQuickWebViewPrivate::updateViewportSize()
+{
+    Q_Q(QQuickWebView);
+    QSize viewportSize = q->boundingRect().size().toSize();
+
+    if (viewportSize.isEmpty())
+        return;
+
+    WebPageProxy* wkPage = toImpl(pageProxy->pageRef());
+    // Let the WebProcess know about the new viewport size, so that
+    // it can resize the content accordingly.
+    wkPage->setViewportSize(viewportSize);
+    updateViewportConstraints();
+    _q_viewportUpdated();
+}
+
+void QQuickWebViewPrivate::updateViewportConstraints()
+{
+    Q_Q(QQuickWebView);
+    QSize availableSize = q->boundingRect().size().toSize();
+
+    if (availableSize.isEmpty())
+        return;
+
+    WebPageProxy* wkPage = toImpl(pageProxy->pageRef());
+    WebPreferences* wkPrefs = wkPage->pageGroup()->preferences();
+
+    // FIXME: Remove later; Hardcode some values for now to make sure the DPI adjustment is being tested.
+    wkPrefs->setDeviceDPI(240);
+    wkPrefs->setDeviceWidth(480);
+    wkPrefs->setDeviceHeight(720);
+
+    int minimumLayoutFallbackWidth = qMax<int>(wkPrefs->layoutFallbackWidth(), availableSize.width());
+
+    WebCore::ViewportAttributes attr = WebCore::computeViewportAttributes(viewportArguments, minimumLayoutFallbackWidth, wkPrefs->deviceWidth(), wkPrefs->deviceHeight(), wkPrefs->deviceDPI(), availableSize);
+    WebCore::restrictMinimumScaleFactorToViewportSize(attr, availableSize);
+    WebCore::restrictScaleFactorToInitialScaleIfNotUserScalable(attr);
+
+    QtViewportInteractionEngine::Constraints newConstraints;
+    newConstraints.initialScale = attr.initialScale;
+    newConstraints.minimumScale = attr.minimumScale;
+    newConstraints.maximumScale = attr.maximumScale;
+    newConstraints.devicePixelRatio = attr.devicePixelRatio;
+    newConstraints.isUserScalable = !!attr.userScalable;
+    interactionEngine->setConstraints(newConstraints);
+
+    // Overwrite minimum scale value with fit-to-view value, unless the the content author
+    // explicitly says no. NB: We can only do this when we know we have a valid size, ie.
+    // after initial layout has completed.
+}
+
+void QQuickWebViewPrivate::didChangeViewportProperties(const WebCore::ViewportArguments& args)
+{
+    if (useTraditionalDesktopBehaviour)
+        return;
+    viewportArguments = args;
+    updateViewportConstraints();
+}
+
+
+void QQuickWebViewPrivate::runJavaScriptAlert(const QString& alertText)
+{
+#ifndef QT_NO_MESSAGEBOX
+    Q_Q(QQuickWebView);
+    const QString title = QObject::tr("JavaScript Alert - %1").arg(q->url().host());
+    disableMouseEvents();
+    QMessageBox::information(0, title, escapeHtml(alertText), QMessageBox::Ok);
+    enableMouseEvents();
+#else
+    Q_UNUSED(alertText);
+#endif
+}
+
+bool QQuickWebViewPrivate::runJavaScriptConfirm(const QString& message)
+{
+    bool result = true;
+#ifndef QT_NO_MESSAGEBOX
+    Q_Q(QQuickWebView);
+    const QString title = QObject::tr("JavaScript Confirm - %1").arg(q->url().host());
+    disableMouseEvents();
+    result = QMessageBox::Yes == QMessageBox::information(0, title, escapeHtml(message), QMessageBox::Yes, QMessageBox::No);
+    enableMouseEvents();
+#else
+    Q_UNUSED(message);
+#endif
+    return result;
+}
+
+QString QQuickWebViewPrivate::runJavaScriptPrompt(const QString& message, const QString& defaultValue, bool& ok)
+{
+#ifndef QT_NO_INPUTDIALOG
+    Q_Q(QQuickWebView);
+    const QString title = QObject::tr("JavaScript Prompt - %1").arg(q->url().host());
+    disableMouseEvents();
+    QString result = QInputDialog::getText(0, title, escapeHtml(message), QLineEdit::Normal, defaultValue, &ok);
+    enableMouseEvents();
+    return result;
+#else
+    Q_UNUSED(message);
+    return defaultValue;
+#endif
+}
+
+void QQuickWebViewPrivate::chooseFiles(WKOpenPanelResultListenerRef listenerRef, const QStringList& selectedFileNames, QtViewInterface::FileChooserType type)
+{
+#ifndef QT_NO_FILEDIALOG
+    Q_Q(QQuickWebView);
+    openPanelResultListener = listenerRef;
+
+    // Qt does not support multiple files suggestion, so we get just the first suggestion.
+    QString selectedFileName;
+    if (!selectedFileNames.isEmpty())
+        selectedFileName = selectedFileNames.at(0);
+
+    Q_ASSERT(!fileDialog);
+
+    QWindow* window = q->canvas();
+    if (!window)
+        return;
+
+    fileDialog = new QFileDialog(0, QString(), selectedFileName);
+    fileDialog->window()->winId(); // Ensure that the dialog has a window
+    Q_ASSERT(fileDialog->window()->windowHandle());
+    fileDialog->window()->windowHandle()->setTransientParent(window);
+
+    fileDialog->open(q, SLOT(_q_onOpenPanelFilesSelected()));
+
+    q->connect(fileDialog, SIGNAL(finished(int)), SLOT(_q_onOpenPanelFinished(int)));
+#endif
+}
+
+void QQuickWebViewPrivate::_q_onOpenPanelFilesSelected()
+{
+    const QStringList fileList = fileDialog->selectedFiles();
+    Vector<RefPtr<APIObject> > wkFiles(fileList.size());
+
+    for (unsigned i = 0; i < fileList.size(); ++i)
+        wkFiles[i] = WebURL::create(QUrl::fromLocalFile(fileList.at(i)).toString());
+
+    WKOpenPanelResultListenerChooseFiles(openPanelResultListener, toAPI(ImmutableArray::adopt(wkFiles).leakRef()));
+}
+
+void QQuickWebViewPrivate::_q_onOpenPanelFinished(int result)
+{
+    if (result == QDialog::Rejected)
+        WKOpenPanelResultListenerCancel(openPanelResultListener);
+
+    fileDialog->deleteLater();
+    fileDialog = 0;
+}
+
+void QQuickWebViewPrivate::setUseTraditionalDesktopBehaviour(bool enable)
+{
+    Q_Q(QQuickWebView);
+    if (enable == useTraditionalDesktopBehaviour)
+        return;
+
+    useTraditionalDesktopBehaviour = enable;
+    if (useTraditionalDesktopBehaviour)
+        initializeDesktop(q);
+    else
+        initializeTouch(q);
+}
+
+static QtPolicyInterface::PolicyAction toPolicyAction(QQuickWebView::NavigationPolicy policy)
+{
+    switch (policy) {
+    case QQuickWebView::UsePolicy:
+        return QtPolicyInterface::Use;
+    case QQuickWebView::DownloadPolicy:
+        return QtPolicyInterface::Download;
+    case QQuickWebView::IgnorePolicy:
+        return QtPolicyInterface::Ignore;
+    }
+    ASSERT_NOT_REACHED();
+    return QtPolicyInterface::Ignore;
+}
+
+static bool hasMetaMethod(QObject* object, const char* methodName)
+{
+    int methodIndex = object->metaObject()->indexOfMethod(QMetaObject::normalizedSignature(methodName));
+    return methodIndex >= 0 && methodIndex < object->metaObject()->methodCount();
+}
+
+/*!
+    \qmlmethod NavigationPolicy DesktopWebView::navigationPolicyForUrl(url, button, modifiers)
+
+    This method should be implemented by the user of DesktopWebView element.
+
+    It will be called to decide the policy for a navigation: whether the WebView should ignore the navigation,
+    continue it or start a download. The return value must be one of the policies in the NavigationPolicy enumeration.
+*/
+QtPolicyInterface::PolicyAction QQuickWebViewPrivate::navigationPolicyForURL(const QUrl& url, Qt::MouseButton button, Qt::KeyboardModifiers modifiers)
+{
+    Q_Q(QQuickWebView);
+    // We need to check this first because invokeMethod() warns if the method doesn't exist for the object.
+    if (!hasMetaMethod(q, "navigationPolicyForUrl(QVariant,QVariant,QVariant)"))
+        return QtPolicyInterface::Use;
+
+    QVariant ret;
+    if (QMetaObject::invokeMethod(q, "navigationPolicyForUrl", Q_RETURN_ARG(QVariant, ret), Q_ARG(QVariant, url), Q_ARG(QVariant, button), Q_ARG(QVariant, QVariant(modifiers))))
+        return toPolicyAction(static_cast<QQuickWebView::NavigationPolicy>(ret.toInt()));
+    return QtPolicyInterface::Use;
+}
+
+void QQuickWebViewPrivate::setPageProxy(QtWebPageProxy* pageProxy)
+{
+    Q_Q(QQuickWebView);
+    this->pageProxy.reset(pageProxy);
+    QObject::connect(pageProxy, SIGNAL(receivedMessageFromNavigatorQtObject(QVariantMap)), q, SIGNAL(messageReceived(QVariantMap)));
+}
+
+QQuickWebView::QQuickWebView(QQuickItem* parent)
+    : QQuickItem(parent)
+    , d_ptr(new QQuickWebViewPrivate)
+{
+    Q_D(QQuickWebView);
+    d->initialize(this);
+    d->initializeTouch(this);
+}
+
+QQuickWebView::QQuickWebView(WKContextRef contextRef, WKPageGroupRef pageGroupRef, QQuickItem* parent)
+    : QQuickItem(parent)
+    , d_ptr(new QQuickWebViewPrivate)
+{
+    Q_D(QQuickWebView);
+    d->initialize(this, contextRef, pageGroupRef);
+    // Used by WebKitTestRunner.
+    d->setUseTraditionalDesktopBehaviour(true);
+}
+
+QQuickWebView::~QQuickWebView()
+{
+}
+
+QQuickWebPage* QQuickWebView::page()
+{
+    Q_D(QQuickWebView);
+    return d->pageView.data();
+}
+
+void QQuickWebView::load(const QUrl& url)
+{
+    Q_D(QQuickWebView);
+    d->pageProxy->load(url);
+}
+
+void QQuickWebView::postMessage(const QString& message)
+{
+    Q_D(QQuickWebView);
+    d->pageProxy->postMessageToNavigatorQtObject(message);
+}
+
+QUrl QQuickWebView::url() const
+{
+    Q_D(const QQuickWebView);
+    return d->pageProxy->url();
+}
+
+int QQuickWebView::loadProgress() const
+{
+    Q_D(const QQuickWebView);
+    return d->pageProxy->loadProgress();
+}
+
+QString QQuickWebView::title() const
+{
+    Q_D(const QQuickWebView);
+    return d->pageProxy->title();
+}
+
+QWebNavigationController* QQuickWebView::navigationController() const
+{
+    Q_D(const QQuickWebView);
+    if (!d->navigationController)
+        const_cast<QQuickWebViewPrivate*>(d)->navigationController = new QWebNavigationController(d->pageProxy.data());
+    return d->navigationController;
+}
+
+QWebPreferences* QQuickWebView::preferences() const
+{
+    Q_D(const QQuickWebView);
+    return d->pageProxy->preferences();
+}
+
+void QQuickWebView::geometryChanged(const QRectF& newGeometry, const QRectF& oldGeometry)
+{
+    Q_D(QQuickWebView);
+    QQuickItem::geometryChanged(newGeometry, oldGeometry);
+    if (newGeometry.size() != oldGeometry.size()) {
+        if (d->useTraditionalDesktopBehaviour) {
+            d->pageView->setWidth(newGeometry.width());
+            d->pageView->setHeight(newGeometry.height());
+        } else
+            d->updateViewportSize();
+    }
+}
+
+void QQuickWebView::touchEvent(QTouchEvent* event)
+{
+    forceActiveFocus();
+    QQuickItem::touchEvent(event);
+}
+
+WKPageRef QQuickWebView::pageRef() const
+{
+    Q_D(const QQuickWebView);
+    return d->pageProxy->pageRef();
+}
+
+#include "moc_qquickwebview.cpp"
  *
  */
 
-#ifndef qbasewebview_h
-#define qbasewebview_h
+#ifndef qquickwebview_h
+#define qquickwebview_h
 
 #include "qwebkitglobal.h"
-#include <QtDeclarative/qquickpainteditem.h>
+#include <QtDeclarative/qquickitem.h>
 
-class QBaseWebViewPrivate;
+class QQuickWebPage;
+class QQuickWebViewPrivate;
 class QWebDownloadItem;
 class QWebNavigationController;
 class QWebPreferences;
 
+namespace WebKit {
+class QtViewInterface;
+}
+
+namespace WTR {
+class PlatformWebView;
+}
+
+typedef const struct OpaqueWKContext* WKContextRef;
+typedef const struct OpaqueWKPageGroup* WKPageGroupRef;
+typedef const struct OpaqueWKPage* WKPageRef;
+
 QT_BEGIN_NAMESPACE
 class QPainter;
 class QUrl;
 QT_END_NAMESPACE
 
-class QWEBKIT_EXPORT QBaseWebView : public QQuickPaintedItem {
+class QWEBKIT_EXPORT QQuickWebView : public QQuickItem {
     Q_OBJECT
     Q_PROPERTY(QString title READ title NOTIFY titleChanged)
     Q_PROPERTY(QUrl url READ url NOTIFY urlChanged)
     Q_PROPERTY(int loadProgress READ loadProgress NOTIFY loadProgressChanged)
     Q_PROPERTY(QWebNavigationController* navigation READ navigationController CONSTANT FINAL)
     Q_PROPERTY(QWebPreferences* preferences READ preferences CONSTANT FINAL)
+    Q_PROPERTY(QQuickWebPage* page READ page CONSTANT FINAL)
     Q_ENUMS(NavigationPolicy)
     Q_ENUMS(ErrorType)
 public:
@@ -56,10 +70,8 @@ public:
         HttpError,
         DownloadError
     };
-    virtual ~QBaseWebView();
-
-    // FIXME: We inherit from QQuickPaintedItem until QDesktopWebView works on top of a plain QQuickItem.
-    void paint(QPainter*) { }
+    QQuickWebView(QQuickItem* parent = 0);
+    virtual ~QQuickWebView();
 
     QUrl url() const;
     QString title() const;
@@ -67,6 +79,7 @@ public:
 
     QWebNavigationController* navigationController() const;
     QWebPreferences* preferences() const;
+    QQuickWebPage* page();
 
 public Q_SLOTS:
      void load(const QUrl&);
@@ -77,19 +90,37 @@ Q_SIGNALS:
     void statusBarMessageChanged(const QString& message);
     void loadStarted();
     void loadSucceeded();
-    void loadFailed(QBaseWebView::ErrorType errorType, int errorCode, const QUrl& url);
+    void loadFailed(QQuickWebView::ErrorType errorType, int errorCode, const QUrl& url);
     void loadProgressChanged(int progress);
     void urlChanged(const QUrl& url);
     void messageReceived(const QVariantMap& message);
     void downloadRequested(QWebDownloadItem* downloadItem);
+    void linkHovered(const QUrl& url, const QString& title);
+    void viewModeChanged();
 
 protected:
-    QBaseWebView(QBaseWebViewPrivate &dd, QQuickItem *parent = 0);
-    // Hides QObject::d_ptr allowing us to use the convenience macros.
-    QScopedPointer<QBaseWebViewPrivate> d_ptr;
+    virtual void geometryChanged(const QRectF&, const QRectF&);
+    virtual void touchEvent(QTouchEvent* event);
+
 private:
-    Q_DECLARE_PRIVATE(QBaseWebView)
+    Q_DECLARE_PRIVATE(QQuickWebView)
+
+    QQuickWebView(WKContextRef, WKPageGroupRef, QQuickItem* parent = 0);
+    WKPageRef pageRef() const;
+
+    Q_PRIVATE_SLOT(d_func(), void _q_viewportUpdated());
+    Q_PRIVATE_SLOT(d_func(), void _q_viewportTrajectoryVectorChanged(const QPointF&));
+    Q_PRIVATE_SLOT(d_func(), void _q_onOpenPanelFilesSelected());
+    Q_PRIVATE_SLOT(d_func(), void _q_onOpenPanelFinished(int result));
+    Q_PRIVATE_SLOT(d_func(), void _q_onVisibleChanged());
+    // Hides QObject::d_ptr allowing us to use the convenience macros.
+    QScopedPointer<QQuickWebViewPrivate> d_ptr;
+
     friend class QtWebPageProxy;
+    friend class WebKit::QtViewInterface;
+    friend class WTR::PlatformWebView;
 };
 
-#endif /* qbasewebview_h */
+QML_DECLARE_TYPE(QQuickWebView)
+
+#endif /* qquickwebview_h */
diff --git a/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h b/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h
new file mode 100644 (file)
index 0000000..defb36a
--- /dev/null
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this program; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef qquickwebview_p_h
+#define qquickwebview_p_h
+
+#include "QtPolicyInterface.h"
+#include "QtViewInterface.h"
+#include "QtViewportInteractionEngine.h"
+#include "QtWebPageProxy.h"
+
+#include "qquickwebview.h"
+
+#include <QtCore/QScopedPointer>
+
+class QWebNavigationController;
+class QtWebPageProxy;
+
+QT_BEGIN_NAMESPACE
+class QFileDialog;
+QT_END_NAMESPACE
+
+class QWEBKIT_EXPORT QQuickWebViewPrivate : public WebKit::QtPolicyInterface {
+    Q_DECLARE_PUBLIC(QQuickWebView)
+public:
+    QQuickWebViewPrivate();
+    virtual ~QQuickWebViewPrivate() { }
+    void setPageProxy(QtWebPageProxy*);
+    void initialize(QQuickWebView* viewport, WKContextRef contextRef = 0, WKPageGroupRef pageGroupRef = 0);
+    void initializeTouch(QQuickWebView* viewport);
+    void initializeDesktop(QQuickWebView* viewport);
+    void enableMouseEvents();
+    void disableMouseEvents();
+
+    void loadDidCommit();
+    void contentSizeChanged(const QSize& newSize);
+    void scrollPositionRequested(const QPoint& pos);
+    void updateViewportSize();
+    void updateViewportConstraints();
+    void setUseTraditionalDesktopBehaviour(bool enable);
+
+    static QQuickWebViewPrivate* get(QQuickWebView* view)
+    {
+        return view->d_ptr.data();
+    }
+
+    void _q_viewportUpdated();
+    void _q_viewportTrajectoryVectorChanged(const QPointF&);
+    void _q_onOpenPanelFilesSelected();
+    void _q_onOpenPanelFinished(int result);
+    void _q_onVisibleChanged();
+
+    // QtPolicyInterface.
+    virtual QtPolicyInterface::PolicyAction navigationPolicyForURL(const QUrl&, Qt::MouseButton, Qt::KeyboardModifiers);
+
+    void chooseFiles(WKOpenPanelResultListenerRef, const QStringList& selectedFileNames, WebKit::QtViewInterface::FileChooserType);
+    void runJavaScriptAlert(const QString&);
+    bool runJavaScriptConfirm(const QString&);
+    QString runJavaScriptPrompt(const QString&, const QString& defaultValue, bool& ok);
+    void didChangeViewportProperties(const WebCore::ViewportArguments& args);
+
+    QScopedPointer<QQuickWebPage> pageView;
+    QScopedPointer<WebKit::QtViewInterface> viewInterface;
+    QScopedPointer<QtViewportInteractionEngine> interactionEngine;
+
+    WebCore::ViewportArguments viewportArguments;
+
+    QQuickWebView* q_ptr;
+    QScopedPointer<QtWebPageProxy> pageProxy;
+
+    QWebNavigationController* navigationController;
+    bool useTraditionalDesktopBehaviour;
+    QFileDialog* fileDialog;
+    WKOpenPanelResultListenerRef openPanelResultListener;
+};
+
+#endif /* qquickwebview_p_h */
diff --git a/Source/WebKit2/UIProcess/API/qt/qtouchwebview.cpp b/Source/WebKit2/UIProcess/API/qt/qtouchwebview.cpp
deleted file mode 100644 (file)
index ec04881..0000000
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this program; see the file COPYING.LIB.  If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#include "config.h"
-#include "qtouchwebview.h"
-
-#include "QtTouchViewInterface.h"
-#include "QtWebPageProxy.h"
-#include "qtouchwebpage_p.h"
-#include "qtouchwebview_p.h"
-#include "qwebpreferences_p.h"
-#include "WebPageGroup.h"
-#include "WebPreferences.h"
-
-void QTouchWebViewPrivate::init(QTouchWebView* viewport)
-{
-    pageView.reset(new QTouchWebPage(viewport));
-    viewInterface.reset(new WebKit::QtTouchViewInterface(viewport, pageView.data()));
-    interactionEngine.reset(new QtViewportInteractionEngine(viewport, pageView.data()));
-    QTouchWebPagePrivate* const pageViewPrivate = pageView.data()->d;
-    setPageProxy(new QtWebPageProxy(viewInterface.data(), interactionEngine.data()));
-    pageViewPrivate->setPageProxy(pageProxy.data());
-    QWebPreferencesPrivate::get(pageProxy->preferences())->setAttribute(QWebPreferencesPrivate::AcceleratedCompositingEnabled, true);
-    pageProxy->init();
-
-    QObject::connect(interactionEngine.data(), SIGNAL(viewportUpdateRequested()), viewport, SLOT(_q_viewportUpdated()));
-    QObject::connect(interactionEngine.data(), SIGNAL(viewportTrajectoryVectorChanged(const QPointF&)), viewport, SLOT(_q_viewportTrajectoryVectorChanged(const QPointF&)));
-}
-
-void QTouchWebViewPrivate::loadDidCommit()
-{
-    interactionEngine->reset();
-}
-
-void QTouchWebViewPrivate::scrollPositionRequested(const QPoint& pos)
-{
-    interactionEngine->pagePositionRequest(pos);
-}
-
-void QTouchWebViewPrivate::_q_viewportUpdated()
-{
-    Q_Q(QTouchWebView);
-    const QRectF visibleRectInPageViewCoordinates = q->mapRectToItem(pageView.data(), q->boundingRect()).intersected(pageView->boundingRect());
-    float scale = pageView->scale();
-    pageProxy->setVisibleContentRectAndScale(visibleRectInPageViewCoordinates, scale);
-}
-
-void QTouchWebViewPrivate::_q_viewportTrajectoryVectorChanged(const QPointF& trajectoryVector)
-{
-    pageProxy->setVisibleContentRectTrajectoryVector(trajectoryVector);
-}
-
-void QTouchWebViewPrivate::updateViewportSize()
-{
-    Q_Q(QTouchWebView);
-    QSize viewportSize = q->boundingRect().size().toSize();
-
-    if (viewportSize.isEmpty())
-        return;
-
-    WebPageProxy* wkPage = toImpl(pageProxy->pageRef());
-
-    // Let the WebProcess know about the new viewport size, so that
-    // it can resize the content accordingly.
-    wkPage->setViewportSize(viewportSize);
-
-    updateViewportConstraints();
-    _q_viewportUpdated();
-}
-
-void QTouchWebViewPrivate::updateViewportConstraints()
-{
-    Q_Q(QTouchWebView);
-    QSize availableSize = q->boundingRect().size().toSize();
-
-    if (availableSize.isEmpty())
-        return;
-
-    WebPageProxy* wkPage = toImpl(pageProxy->pageRef());
-    WebPreferences* wkPrefs = wkPage->pageGroup()->preferences();
-
-    // FIXME: Remove later; Hardcode some values for now to make sure the DPI adjustment is being tested.
-    wkPrefs->setDeviceDPI(240);
-    wkPrefs->setDeviceWidth(480);
-    wkPrefs->setDeviceHeight(720);
-
-    int minimumLayoutFallbackWidth = qMax<int>(wkPrefs->layoutFallbackWidth(), availableSize.width());
-
-    WebCore::ViewportAttributes attr = WebCore::computeViewportAttributes(viewportArguments, minimumLayoutFallbackWidth, wkPrefs->deviceWidth(), wkPrefs->deviceHeight(), wkPrefs->deviceDPI(), availableSize);
-    WebCore::restrictMinimumScaleFactorToViewportSize(attr, availableSize);
-    WebCore::restrictScaleFactorToInitialScaleIfNotUserScalable(attr);
-
-    QtViewportInteractionEngine::Constraints newConstraints;
-    newConstraints.initialScale = attr.initialScale;
-    newConstraints.minimumScale = attr.minimumScale;
-    newConstraints.maximumScale = attr.maximumScale;
-    newConstraints.devicePixelRatio = attr.devicePixelRatio;
-    newConstraints.isUserScalable = !!attr.userScalable;
-    interactionEngine->setConstraints(newConstraints);
-
-    // Overwrite minimum scale value with fit-to-view value, unless the the content author
-    // explicitly says no. NB: We can only do this when we know we have a valid size, ie.
-    // after initial layout has completed.
-}
-
-void QTouchWebViewPrivate::didChangeViewportProperties(const WebCore::ViewportArguments& args)
-{
-    viewportArguments = args;
-    updateViewportConstraints();
-}
-
-QTouchWebView::QTouchWebView(QQuickItem* parent)
-    : QBaseWebView(*(new QTouchWebViewPrivate), parent)
-{
-    Q_D(QTouchWebView);
-    d->init(this);
-    setFlags(QQuickItem::ItemClipsChildrenToShape);
-    connect(this, SIGNAL(visibleChanged()), SLOT(onVisibleChanged()));
-}
-
-QTouchWebView::~QTouchWebView()
-{
-}
-
-QTouchWebPage* QTouchWebView::page()
-{
-    Q_D(QTouchWebView);
-    return d->pageView.data();
-}
-
-void QTouchWebView::geometryChanged(const QRectF& newGeometry, const QRectF& oldGeometry)
-{
-    Q_D(QTouchWebView);
-    QQuickItem::geometryChanged(newGeometry, oldGeometry);
-    if (newGeometry.size() != oldGeometry.size())
-        d->updateViewportSize();
-}
-
-void QTouchWebView::touchEvent(QTouchEvent* event)
-{
-    forceActiveFocus();
-    QQuickItem::touchEvent(event);
-}
-
-void QTouchWebView::onVisibleChanged()
-{
-    Q_D(QTouchWebView);
-    WebPageProxy* wkPage = toImpl(d->pageProxy->pageRef());
-
-    wkPage->viewStateDidChange(WebPageProxy::ViewIsVisible);
-}
-
-#include "moc_qtouchwebview.cpp"
diff --git a/Source/WebKit2/UIProcess/API/qt/qtouchwebview.h b/Source/WebKit2/UIProcess/API/qt/qtouchwebview.h
deleted file mode 100644 (file)
index 1ffa0f5..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this program; see the file COPYING.LIB.  If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef qtouchwebview_h
-#define qtouchwebview_h
-
-#include "qbasewebview.h"
-#include "qwebkitglobal.h"
-#include <QtDeclarative/qquickitem.h>
-
-class QTouchEvent;
-class QTouchWebPage;
-class QTouchWebViewPrivate;
-
-namespace WebKit {
-class QtTouchViewInterface;
-}
-
-class QWEBKIT_EXPORT QTouchWebView : public QBaseWebView
-{
-    Q_OBJECT
-    Q_PROPERTY(QTouchWebPage* page READ page CONSTANT FINAL)
-
-public:
-    QTouchWebView(QQuickItem* parent = 0);
-    ~QTouchWebView();
-
-    QTouchWebPage *page();
-
-protected Q_SLOTS:
-    void onVisibleChanged();
-
-protected:
-    virtual void geometryChanged(const QRectF&, const QRectF&);
-    virtual void touchEvent(QTouchEvent* event);
-
-private:
-    Q_PRIVATE_SLOT(d_func(), void _q_viewportUpdated());
-    Q_PRIVATE_SLOT(d_func(), void _q_viewportTrajectoryVectorChanged(const QPointF&));
-
-    friend class WebKit::QtTouchViewInterface;
-    Q_DECLARE_PRIVATE(QTouchWebView)
-};
-
-QML_DECLARE_TYPE(QTouchWebView)
-
-#endif /* qtouchwebview_h */
diff --git a/Source/WebKit2/UIProcess/API/qt/qtouchwebview_p.h b/Source/WebKit2/UIProcess/API/qt/qtouchwebview_p.h
deleted file mode 100644 (file)
index 2900e1d..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this program; see the file COPYING.LIB.  If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef qtouchwebview_p_h
-#define qtouchwebview_p_h
-
-#include "QtTouchViewInterface.h"
-#include "QtWebPageProxy.h"
-#include "QtViewportInteractionEngine.h"
-#include "qbasewebview_p.h"
-#include <QScopedPointer>
-
-class QTouchWebPage;
-class QTouchWebView;
-
-class QTouchWebViewPrivate : QBaseWebViewPrivate
-{
-    Q_DECLARE_PUBLIC(QTouchWebView)
-public:
-    void init(QTouchWebView* viewport);
-
-    void loadDidCommit();
-    void scrollPositionRequested(const QPoint& pos);
-    void _q_viewportUpdated();
-    void _q_viewportTrajectoryVectorChanged(const QPointF&);
-    void updateViewportSize();
-    void updateViewportConstraints();
-
-    void didChangeViewportProperties(const WebCore::ViewportArguments& args);
-
-    QScopedPointer<QTouchWebPage> pageView;
-    QScopedPointer<WebKit::QtTouchViewInterface> viewInterface;
-    QScopedPointer<QtViewportInteractionEngine> interactionEngine;
-
-    WebCore::ViewportArguments viewportArguments;
-};
-
-#endif /* qtouchwebview_p_h */
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/commonviewtests/commonviewtests.pro b/Source/WebKit2/UIProcess/API/qt/tests/commonviewtests/commonviewtests.pro
deleted file mode 100644 (file)
index 68d7c22..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-include(../tests.pri)
-HEADERS += webviewabstraction.h
-SOURCES += webviewabstraction.cpp
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/commonviewtests/tst_commonviewtests.cpp b/Source/WebKit2/UIProcess/API/qt/tests/commonviewtests/tst_commonviewtests.cpp
deleted file mode 100644 (file)
index a570b0a..0000000
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
-    Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Library General Public
-    License as published by the Free Software Foundation; either
-    version 2 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Library General Public License for more details.
-
-    You should have received a copy of the GNU Library General Public License
-    along with this library; see the file COPYING.LIB.  If not, write to
-    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-    Boston, MA 02110-1301, USA.
-*/
-
-#include <QScopedPointer>
-#include <QSignalSpy>
-#include <QtTest/QtTest>
-#include "webviewabstraction.h"
-#include "../util.h"
-
-class tst_CommonViewTests : public QObject {
-    Q_OBJECT
-public:
-    tst_CommonViewTests();
-
-private slots:
-    void init();
-    void cleanup();
-
-    void baseUrl();
-    void loadEmptyUrl();
-    void loadEmptyPageViewVisible();
-    void loadEmptyPageViewHidden();
-    void loadNonexistentFileUrl();
-    void backAndForward();
-    void reload();
-    void stop();
-    void loadProgress();
-
-    void show();
-private:
-    QScopedPointer<WebViewAbstraction> viewAbstraction;
-};
-
-tst_CommonViewTests::tst_CommonViewTests()
-{
-    addQtWebProcessToPath();
-}
-
-void tst_CommonViewTests::init()
-{
-    viewAbstraction.reset(new WebViewAbstraction);
-}
-
-void tst_CommonViewTests::cleanup()
-{
-    viewAbstraction.reset();
-}
-
-void tst_CommonViewTests::baseUrl()
-{
-    // Test the url is in a well defined state when instanciating the view, but before loading anything.
-    QUrl url;
-    QVERIFY(viewAbstraction->url(url));
-    QVERIFY(url.isEmpty());
-}
-
-void tst_CommonViewTests::loadEmptyUrl()
-{
-    viewAbstraction->load(QUrl());
-    viewAbstraction->load(QUrl(QLatin1String("")));
-}
-
-void tst_CommonViewTests::loadEmptyPageViewVisible()
-{
-    viewAbstraction->show();
-    loadEmptyPageViewHidden();
-}
-
-void tst_CommonViewTests::loadEmptyPageViewHidden()
-{
-    QSignalSpy loadStartedSpy(viewAbstraction.data(), SIGNAL(loadStarted()));
-
-    viewAbstraction->load(QUrl::fromLocalFile(QLatin1String(TESTS_SOURCE_DIR "/html/basic_page.html")));
-    QVERIFY(waitForSignal(viewAbstraction.data(), SIGNAL(loadSucceeded())));
-
-    QCOMPARE(loadStartedSpy.size(), 1);
-}
-
-void tst_CommonViewTests::loadNonexistentFileUrl()
-{
-    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(QBaseWebView::ErrorType, int, QUrl))));
-
-    QCOMPARE(loadFailedSpy.size(), 1);
-}
-
-void tst_CommonViewTests::backAndForward()
-{
-    viewAbstraction->load(QUrl::fromLocalFile(QLatin1String(TESTS_SOURCE_DIR "/html/basic_page.html")));
-    QVERIFY(waitForSignal(viewAbstraction.data(), SIGNAL(loadSucceeded())));
-
-    QUrl url;
-    QVERIFY(viewAbstraction->url(url));
-    QCOMPARE(url.path(), QLatin1String(TESTS_SOURCE_DIR "/html/basic_page.html"));
-
-    viewAbstraction->load(QUrl::fromLocalFile(QLatin1String(TESTS_SOURCE_DIR "/html/basic_page2.html")));
-    QVERIFY(waitForSignal(viewAbstraction.data(), SIGNAL(loadSucceeded())));
-
-    QVERIFY(viewAbstraction->url(url));
-    QCOMPARE(url.path(), QLatin1String(TESTS_SOURCE_DIR "/html/basic_page2.html"));
-
-    viewAbstraction->goBack();
-    QVERIFY(waitForSignal(viewAbstraction.data(), SIGNAL(loadSucceeded())));
-
-    QVERIFY(viewAbstraction->url(url));
-    QCOMPARE(url.path(), QLatin1String(TESTS_SOURCE_DIR "/html/basic_page.html"));
-
-    viewAbstraction->goForward();
-    QVERIFY(waitForSignal(viewAbstraction.data(), SIGNAL(loadSucceeded())));
-
-    QVERIFY(viewAbstraction->url(url));
-    QCOMPARE(url.path(), QLatin1String(TESTS_SOURCE_DIR "/html/basic_page2.html"));
-}
-
-void tst_CommonViewTests::reload()
-{
-    viewAbstraction->load(QUrl::fromLocalFile(QLatin1String(TESTS_SOURCE_DIR "/html/basic_page.html")));
-    QVERIFY(waitForSignal(viewAbstraction.data(), SIGNAL(loadSucceeded())));
-
-    QUrl url;
-    QVERIFY(viewAbstraction->url(url));
-    QCOMPARE(url.path(), QLatin1String(TESTS_SOURCE_DIR "/html/basic_page.html"));
-
-    viewAbstraction->reload();
-    QVERIFY(waitForSignal(viewAbstraction.data(), SIGNAL(loadSucceeded())));
-
-    QVERIFY(viewAbstraction->url(url));
-    QCOMPARE(url.path(), QLatin1String(TESTS_SOURCE_DIR "/html/basic_page.html"));
-}
-
-void tst_CommonViewTests::stop()
-{
-    viewAbstraction->load(QUrl::fromLocalFile(QLatin1String(TESTS_SOURCE_DIR "/html/basic_page.html")));
-    QVERIFY(waitForSignal(viewAbstraction.data(), SIGNAL(loadSucceeded())));
-
-    QUrl url;
-    QVERIFY(viewAbstraction->url(url));
-    QCOMPARE(url.path(), QLatin1String(TESTS_SOURCE_DIR "/html/basic_page.html"));
-
-    // FIXME: This test should be fleshed out. Right now it's just here to make sure we don't crash.
-    viewAbstraction->stop();
-}
-
-void tst_CommonViewTests::loadProgress()
-{
-    QCOMPARE(viewAbstraction->loadProgress(), 0);
-
-    viewAbstraction->load(QUrl::fromLocalFile(QLatin1String(TESTS_SOURCE_DIR "/html/basic_page.html")));
-    QSignalSpy loadProgressChangedSpy(viewAbstraction.data(), SIGNAL(loadProgressChanged(int)));
-    QVERIFY(waitForSignal(viewAbstraction.data(), SIGNAL(loadSucceeded())));
-
-    QVERIFY(loadProgressChangedSpy.count() >= 1);
-
-    QCOMPARE(viewAbstraction->loadProgress(), 100);
-}
-
-void tst_CommonViewTests::show()
-{
-    // This should not crash.
-    viewAbstraction->show();
-    QTest::qWait(200);
-    viewAbstraction->hide();
-}
-
-QTWEBKIT_API_TEST_MAIN(tst_CommonViewTests)
-
-#include "tst_commonviewtests.moc"
-
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/commonviewtests/webviewabstraction.cpp b/Source/WebKit2/UIProcess/API/qt/tests/commonviewtests/webviewabstraction.cpp
deleted file mode 100644 (file)
index 2baa336..0000000
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
-    Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Library General Public
-    License as published by the Free Software Foundation; either
-    version 2 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Library General Public License for more details.
-
-    You should have received a copy of the GNU Library General Public License
-    along with this library; see the file COPYING.LIB.  If not, write to
-    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-    Boston, MA 02110-1301, USA.
-*/
-
-#include <QAction>
-#include <QApplication>
-#include <QDesktopWidget>
-#include <qwebnavigationcontroller.h>
-#include "webviewabstraction.h"
-
-WebViewAbstraction::WebViewAbstraction()
-    : m_touchWebViewWindow(new QTouchWebView)
-    , m_desktopWebViewWindow(new QDesktopWebView)
-{
-    QDesktopWidget* const desktopWidget = QApplication::desktop();
-    const QRect mainScreenGeometry = desktopWidget->availableGeometry();
-
-    QRect screenHalf(mainScreenGeometry.topLeft(), QSize(mainScreenGeometry.width() / 2, mainScreenGeometry.height()));
-    m_touchWebViewWindow.setGeometry(screenHalf);
-    m_touchWebViewWindow.setWindowTitle(QLatin1String("TouchWebView"));
-    connect(touchWebView(), SIGNAL(loadStarted()), this, SLOT(touchViewLoadStarted()));
-    connect(touchWebView(), SIGNAL(loadSucceeded()), this, SLOT(touchViewLoadSucceeded()));
-    connect(touchWebView(), SIGNAL(loadFailed(QBaseWebView::ErrorType, int, const QUrl&)), this, SLOT(touchViewLoadFailed(QBaseWebView::ErrorType, int, const QUrl&)));
-    connect(touchWebView(), SIGNAL(loadProgressChanged(int)), this, SLOT(touchViewLoadProgressChanged(int)));
-
-    screenHalf.moveLeft(screenHalf.right());
-    m_desktopWebViewWindow.setGeometry(screenHalf);
-    m_desktopWebViewWindow.setWindowTitle(QLatin1String("DesktopWebView"));
-    connect(desktopWebView(), SIGNAL(loadStarted()), this, SLOT(desktopViewLoadStarted()));
-    connect(desktopWebView(), SIGNAL(loadSucceeded()), this, SLOT(desktopViewLoadSucceeded()));
-    connect(desktopWebView(), SIGNAL(loadFailed(QBaseWebView::ErrorType, int, const QUrl&)), this, SLOT(desktopViewLoadFailed(QBaseWebView::ErrorType, int, const QUrl&)));
-    connect(desktopWebView(), SIGNAL(loadProgressChanged(int)), this, SLOT(desktopViewLoadProgressChanged(int)));
-}
-
-void WebViewAbstraction::show()
-{
-    m_touchWebViewWindow.show();
-    m_desktopWebViewWindow.show();
-    QTest::qWaitForWindowShown(&m_desktopWebViewWindow);
-}
-
-void WebViewAbstraction::hide()
-{
-    m_touchWebViewWindow.hide();
-    m_desktopWebViewWindow.hide();
-}
-
-void WebViewAbstraction::load(const QUrl& url)
-{
-    touchWebView()->load(url);
-    desktopWebView()->load(url);
-}
-
-bool WebViewAbstraction::url(QUrl& url) const
-{
-    const QUrl touchViewUrl = touchWebView()->url();
-    const QUrl desktopViewUrl = desktopWebView()->url();
-
-    if (touchViewUrl != desktopViewUrl) {
-        qWarning() << "WebViewAbstraction::url(): the URLs are not equals.";
-        qWarning() << "QTouchView's url = " << touchViewUrl;
-        qWarning() << "QDesktopView's url = " << desktopViewUrl;
-        return false;
-    }
-
-    url = touchViewUrl;
-    return true;
-}
-
-int WebViewAbstraction::loadProgress() const
-{
-    int touchViewProgress = touchWebView()->loadProgress();
-    int desktopViewProgress = desktopWebView()->loadProgress();
-
-    if (touchViewProgress != desktopViewProgress) {
-        qWarning() << "WebViewAbstraction::loadProgress(): the load progress are different.";
-        qWarning() << "QTouchView's load progress = " << touchViewProgress;
-        qWarning() << "QDesktopView's load progress = " << desktopViewProgress;
-        return -1;
-    }
-
-    return touchViewProgress;
-}
-
-void WebViewAbstraction::goBack()
-{
-    touchWebView()->navigationController()->goBack();
-    desktopWebView()->navigationController()->goBack();
-}
-
-void WebViewAbstraction::goForward()
-{
-    touchWebView()->navigationController()->goForward();
-    desktopWebView()->navigationController()->goForward();
-}
-
-void WebViewAbstraction::stop()
-{
-    touchWebView()->navigationController()->stop();
-    desktopWebView()->navigationController()->stop();
-}
-
-void WebViewAbstraction::reload()
-{
-    touchWebView()->navigationController()->reload();
-    desktopWebView()->navigationController()->reload();
-}
-
-void WebViewAbstraction::touchViewLoadStarted()
-{
-    m_touchViewSignalsCounter[SIGNAL(loadStarted())]++;
-    if (m_touchViewSignalsCounter[SIGNAL(loadStarted())] == m_desktopViewSignalsCounter[SIGNAL(loadStarted())])
-        emit loadStarted();
-}
-
-void WebViewAbstraction::desktopViewLoadStarted()
-{
-    m_desktopViewSignalsCounter[SIGNAL(loadStarted())]++;
-    if (m_touchViewSignalsCounter[SIGNAL(loadStarted())] == m_desktopViewSignalsCounter[SIGNAL(loadStarted())])
-        emit loadStarted();
-}
-
-void WebViewAbstraction::touchViewLoadSucceeded()
-{
-    m_touchViewSignalsCounter[SIGNAL(loadSucceeded())]++;
-    if (m_touchViewSignalsCounter[SIGNAL(loadSucceeded())] == m_desktopViewSignalsCounter[SIGNAL(loadSucceeded())])
-        emit loadSucceeded();
-}
-
-void WebViewAbstraction::desktopViewLoadSucceeded()
-{
-    m_desktopViewSignalsCounter[SIGNAL(loadSucceeded())]++;
-    if (m_touchViewSignalsCounter[SIGNAL(loadSucceeded())] == m_desktopViewSignalsCounter[SIGNAL(loadSucceeded())])
-        emit loadSucceeded();
-}
-
-void WebViewAbstraction::touchViewLoadFailed(QBaseWebView::ErrorType errorType, int errorCode, const QUrl& url)
-{
-    m_touchViewSignalsCounter[SIGNAL(loadFailed(QBaseWebView::ErrorType, int, QUrl))]++;
-    if (m_touchViewSignalsCounter[SIGNAL(loadFailed(QBaseWebView::ErrorType, int, QUrl))] == m_desktopViewSignalsCounter[SIGNAL(loadFailed(QBaseWebView::ErrorType, int, QUrl))])
-        emit loadFailed(static_cast<QBaseWebView::ErrorType>(errorType), errorCode, url);
-}
-
-void WebViewAbstraction::desktopViewLoadFailed(QBaseWebView::ErrorType errorType, int errorCode, const QUrl& url)
-{
-    m_desktopViewSignalsCounter[SIGNAL(loadFailed(QBaseWebView::ErrorType, int, QUrl))]++;
-    if (m_touchViewSignalsCounter[SIGNAL(loadFailed(QBaseWebView::ErrorType, int, QUrl))] == m_desktopViewSignalsCounter[SIGNAL(loadFailed(QBaseWebView::ErrorType, int, QUrl))])
-        emit loadFailed(errorType, errorCode, url);
-}
-
-void WebViewAbstraction::touchViewLoadProgressChanged(int progress)
-{
-    m_touchViewSignalsCounter[SIGNAL(loadProgressChanged(int))]++;
-    if (m_touchViewSignalsCounter[SIGNAL(loadProgressChanged(int))] == m_desktopViewSignalsCounter[SIGNAL(loadProgressChanged(int))])
-        emit loadProgressChanged(progress);
-}
-
-void WebViewAbstraction::desktopViewLoadProgressChanged(int progress)
-{
-    m_desktopViewSignalsCounter[SIGNAL(loadProgressChanged(int))]++;
-    if (m_touchViewSignalsCounter[SIGNAL(loadProgressChanged(int))] == m_desktopViewSignalsCounter[SIGNAL(loadProgressChanged(int))])
-        emit loadProgressChanged(progress);
-}
-
-QTouchWebView* WebViewAbstraction::touchWebView() const
-{
-    return static_cast<QTouchWebView*>(m_touchWebViewWindow.webView.data());
-}
-
-QDesktopWebView* WebViewAbstraction::desktopWebView() const
-{
-    return static_cast<QDesktopWebView*>(m_desktopWebViewWindow.webView.data());
-}
-
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/commonviewtests/webviewabstraction.h b/Source/WebKit2/UIProcess/API/qt/tests/commonviewtests/webviewabstraction.h
deleted file mode 100644 (file)
index cfcb441..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
-    Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Library General Public
-    License as published by the Free Software Foundation; either
-    version 2 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Library General Public License for more details.
-
-    You should have received a copy of the GNU Library General Public License
-    along with this library; see the file COPYING.LIB.  If not, write to
-    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-    Boston, MA 02110-1301, USA.
-*/
-
-#ifndef webviewabstraction_h
-#define webviewabstraction_h
-
-#include <QHash>
-#include <QUrl>
-#include <QtTest/QtTest>
-#include <qtouchwebpage.h>
-#include <qtouchwebview.h>
-#include <qdesktopwebview.h>
-#include "../testwindow.h"
-
-class WebViewAbstraction : public QObject
-{
-    Q_OBJECT
-public:
-    WebViewAbstraction();
-
-    void show();
-    void hide();
-
-    void load(const QUrl&);
-    bool url(QUrl&) const;
-    int loadProgress() const;
-
-    void goBack();
-    void goForward();
-    void stop();
-    void reload();
-
-Q_SIGNALS:
-    void loadStarted();
-    void loadSucceeded();
-    void loadFailed(QBaseWebView::ErrorType, int, const QUrl&);
-    void loadProgressChanged(int);
-
-private Q_SLOTS:
-    void touchViewLoadStarted();
-    void desktopViewLoadStarted();
-    void touchViewLoadSucceeded();
-    void desktopViewLoadSucceeded();
-    void touchViewLoadFailed(QBaseWebView::ErrorType, int, const QUrl&);
-    void desktopViewLoadFailed(QBaseWebView::ErrorType, int, const QUrl&);
-    void touchViewLoadProgressChanged(int);
-    void desktopViewLoadProgressChanged(int);
-
-private:
-    QTouchWebView* touchWebView() const;
-    QDesktopWebView* desktopWebView() const;
-
-    TestWindow m_touchWebViewWindow;
-    QHash<const char *, unsigned int> m_touchViewSignalsCounter;
-
-    TestWindow m_desktopWebViewWindow;
-    QHash<const char *, unsigned int> m_desktopViewSignalsCounter;
-};
-
-#endif /* webviewabstraction_h */
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qdesktopwebview/tst_qdesktopwebview.cpp b/Source/WebKit2/UIProcess/API/qt/tests/qdesktopwebview/tst_qdesktopwebview.cpp
deleted file mode 100644 (file)
index 7327423..0000000
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
-    Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Library General Public
-    License as published by the Free Software Foundation; either
-    version 2 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Library General Public License for more details.
-
-    You should have received a copy of the GNU Library General Public License
-    along with this library; see the file COPYING.LIB.  If not, write to
-    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-    Boston, MA 02110-1301, USA.
-*/
-
-#include <QScopedPointer>
-#include <QtTest/QtTest>
-#include <qdesktopwebview.h>
-#include <qwebnavigationcontroller.h>
-#include "../testwindow.h"
-#include "../util.h"
-
-class tst_QDesktopWebView : public QObject {
-    Q_OBJECT
-public:
-    tst_QDesktopWebView();
-
-private slots:
-    void init();
-    void cleanup();
-
-    void navigationStatusAtStartup();
-    void stopEnabledAfterLoadStarted();
-
-private:
-    inline QDesktopWebView* webView() const;
-    QScopedPointer<TestWindow> m_window;
-};
-
-tst_QDesktopWebView::tst_QDesktopWebView()
-{
-    addQtWebProcessToPath();
-}
-
-void tst_QDesktopWebView::init()
-{
-    m_window.reset(new TestWindow(new QDesktopWebView()));
-}
-
-void tst_QDesktopWebView::cleanup()
-{
-    m_window.reset();
-}
-
-inline QDesktopWebView* tst_QDesktopWebView::webView() const
-{
-    return static_cast<QDesktopWebView*>(m_window->webView.data());
-}
-
-void tst_QDesktopWebView::navigationStatusAtStartup()
-{
-    QCOMPARE(webView()->navigationController()->canGoBack(), false);
-
-    QCOMPARE(webView()->navigationController()->canGoForward(), false);
-
-    QCOMPARE(webView()->navigationController()->canStop(), false);
-
-    QCOMPARE(webView()->navigationController()->canReload(), false);
-}
-
-class LoadStartedCatcher : public QObject {
-    Q_OBJECT
-public:
-    LoadStartedCatcher(QDesktopWebView* webView)
-        : m_webView(webView)
-    {
-        connect(m_webView, SIGNAL(loadStarted()), this, SLOT(onLoadStarted()));
-    }
-
-public slots:
-    void onLoadStarted()
-    {
-        QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection);
-
-        QCOMPARE(m_webView->navigationController()->canStop(), true);
-    }
-
-signals:
-    void finished();
-
-private:
-    QDesktopWebView* m_webView;
-};
-
-void tst_QDesktopWebView::stopEnabledAfterLoadStarted()
-{
-    QCOMPARE(webView()->navigationController()->canStop(), false);
-
-    LoadStartedCatcher catcher(webView());
-    webView()->load(QUrl::fromLocalFile(QLatin1String(TESTS_SOURCE_DIR "/html/basic_page.html")));
-    waitForSignal(&catcher, SIGNAL(finished()));
-
-    QCOMPARE(webView()->navigationController()->canStop(), true);
-
-    waitForSignal(webView(), SIGNAL(loadSucceeded()));
-}
-
-QTWEBKIT_API_TEST_MAIN(tst_QDesktopWebView)
-
-#include "tst_qdesktopwebview.moc"
-
index 04ff344..123f435 100644 (file)
@@ -2,7 +2,7 @@ import QtQuick 2.0
 import QtTest 1.0
 import QtWebKit 3.0
 
-TouchWebView {
+WebView {
     id: webView
     height: 600
     width: 400
index d0c2967..7539ebf 100644 (file)
@@ -2,7 +2,7 @@ import QtQuick 2.0
 import QtTest 1.0
 import QtWebKit 3.0
 
-TouchWebView {
+WebView {
     id: webView
 
     property variant testUrl
index 36e0c50..b6647b0 100644 (file)
@@ -5,6 +5,11 @@ CONFIG += warn_on testcase
 QT -= testlib
 QT += qmltest
 
+# FIXME: When webkit-private works let's use it.
+load(javascriptcore)
+load(webcore)
+load(webkit2)
+
 # QML files tested are the ones in WebKit source repository.
 DEFINES += QUICK_TEST_SOURCE_DIR=\"\\\"$$PWD\\\"\"
 
index 4ba3e80..f3db4d2 100644 (file)
     Boston, MA 02110-1301, USA.
 */
 
+#include "config.h"
 #include "../util.h"
+
+#include "qquickwebpage.h"
+#include "qquickwebview.h"
+#include "qquickwebview_p.h"
+
 #include <QtQuickTest/quicktest.h>
 #include <QtWidgets/QApplication>
 
+class DesktopWebView : public QQuickWebView {
+public:
+    DesktopWebView(QQuickItem* parent = 0)
+        : QQuickWebView(parent)
+    {
+        QQuickWebViewPrivate::get(this)->setUseTraditionalDesktopBehaviour(true);
+    }
+};
+
 int main(int argc, char** argv)
 {
     suppressDebugOutput();
     // Instantiate QApplication to prevent quick_test_main to instantiate a QGuiApplication.
     // This can be removed as soon as we do not use QtWidgets any more.
     QApplication app(argc, argv);
+    qmlRegisterType<DesktopWebView>("QtWebKitTest", 1, 0, "DesktopWebView");
     return quick_test_main(argc, argv, "qmltests", 0, QUICK_TEST_SOURCE_DIR);
 }
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qquickwebview/tst_qquickwebview.cpp b/Source/WebKit2/UIProcess/API/qt/tests/qquickwebview/tst_qquickwebview.cpp
new file mode 100644 (file)
index 0000000..2a39151
--- /dev/null
@@ -0,0 +1,245 @@
+/*
+    Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to
+    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+    Boston, MA 02110-1301, USA.
+*/
+
+#include "../testwindow.h"
+#include "../util.h"
+
+#include <QScopedPointer>
+#include <QtTest/QtTest>
+#include <qquickwebpage.h>
+#include <qquickwebview.h>
+#include <qwebnavigationcontroller.h>
+
+class tst_QQuickWebView : public QObject {
+    Q_OBJECT
+public:
+    tst_QQuickWebView();
+
+private slots:
+    void init();
+    void cleanup();
+
+    void accessPage();
+    void navigationStatusAtStartup();
+    void stopEnabledAfterLoadStarted();
+    void baseUrl();
+    void loadEmptyUrl();
+    void loadEmptyPageViewVisible();
+    void loadEmptyPageViewHidden();
+    void loadNonexistentFileUrl();
+    void backAndForward();
+    void reload();
+    void stop();
+    void loadProgress();
+
+    void show();
+
+private:
+    inline QQuickWebView* webView() const;
+    QScopedPointer<TestWindow> m_window;
+};
+
+tst_QQuickWebView::tst_QQuickWebView()
+{
+    addQtWebProcessToPath();
+    qRegisterMetaType<QQuickWebPage*>("QQuickWebPage*");
+}
+
+void tst_QQuickWebView::init()
+{
+    m_window.reset(new TestWindow(new QQuickWebView()));
+}
+
+void tst_QQuickWebView::cleanup()
+{
+    m_window.reset();
+}
+
+inline QQuickWebView* tst_QQuickWebView::webView() const
+{
+    return static_cast<QQuickWebView*>(m_window->webView.data());
+}
+
+void tst_QQuickWebView::accessPage()
+{
+    QQuickWebPage* const pageDirectAccess = webView()->page();
+
+    QVariant pagePropertyValue = webView()->property("page");
+    QQuickWebPage* const pagePropertyAccess = pagePropertyValue.value<QQuickWebPage*>();
+    QCOMPARE(pagePropertyAccess, pageDirectAccess);
+}
+
+void tst_QQuickWebView::navigationStatusAtStartup()
+{
+    QCOMPARE(webView()->navigationController()->canGoBack(), false);
+
+    QCOMPARE(webView()->navigationController()->canGoForward(), false);
+
+    QCOMPARE(webView()->navigationController()->canStop(), false);
+
+    QCOMPARE(webView()->navigationController()->canReload(), false);
+}
+
+class LoadStartedCatcher : public QObject {
+    Q_OBJECT
+public:
+    LoadStartedCatcher(QQuickWebView* webView)
+        : m_webView(webView)
+    {
+        connect(m_webView, SIGNAL(loadStarted()), this, SLOT(onLoadStarted()));
+    }
+
+public slots:
+    void onLoadStarted()
+    {
+        QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection);
+
+        QCOMPARE(m_webView->navigationController()->canStop(), true);
+    }
+
+signals:
+    void finished();
+
+private:
+    QQuickWebView* m_webView;
+};
+
+void tst_QQuickWebView::stopEnabledAfterLoadStarted()
+{
+    QCOMPARE(webView()->navigationController()->canStop(), false);
+
+    LoadStartedCatcher catcher(webView());
+    webView()->load(QUrl::fromLocalFile(QLatin1String(TESTS_SOURCE_DIR "/html/basic_page.html")));
+    waitForSignal(&catcher, SIGNAL(finished()));
+
+    QCOMPARE(webView()->navigationController()->canStop(), true);
+
+    waitForSignal(webView(), SIGNAL(loadSucceeded()));
+}
+
+void tst_QQuickWebView::baseUrl()
+{
+    // Test the url is in a well defined state when instanciating the view, but before loading anything.
+    QVERIFY(webView()->url().isEmpty());
+}
+
+void tst_QQuickWebView::loadEmptyUrl()
+{
+    webView()->load(QUrl());
+    webView()->load(QUrl(QLatin1String("")));
+}
+
+void tst_QQuickWebView::loadEmptyPageViewVisible()
+{
+    m_window->show();
+    loadEmptyPageViewHidden();
+}
+
+void tst_QQuickWebView::loadEmptyPageViewHidden()
+{
+    QSignalSpy loadStartedSpy(webView(), SIGNAL(loadStarted()));
+
+    webView()->load(QUrl::fromLocalFile(QLatin1String(TESTS_SOURCE_DIR "/html/basic_page.html")));
+    QVERIFY(waitForSignal(webView(), SIGNAL(loadSucceeded())));
+
+    QCOMPARE(loadStartedSpy.size(), 1);
+}
+
+void tst_QQuickWebView::loadNonexistentFileUrl()
+{
+    QSignalSpy loadFailedSpy(webView(), SIGNAL(loadStarted()));
+
+    webView()->load(QUrl::fromLocalFile(QLatin1String(TESTS_SOURCE_DIR "/html/file_that_does_not_exist.html")));
+    QVERIFY(waitForSignal(webView(), SIGNAL(loadFailed(QQuickWebView::ErrorType, int, QUrl))));
+
+    QCOMPARE(loadFailedSpy.size(), 1);
+}
+
+void tst_QQuickWebView::backAndForward()
+{
+    webView()->load(QUrl::fromLocalFile(QLatin1String(TESTS_SOURCE_DIR "/html/basic_page.html")));
+    QVERIFY(waitForSignal(webView(), SIGNAL(loadSucceeded())));
+
+    QCOMPARE(webView()->url().path(), QLatin1String(TESTS_SOURCE_DIR "/html/basic_page.html"));
+
+    webView()->load(QUrl::fromLocalFile(QLatin1String(TESTS_SOURCE_DIR "/html/basic_page2.html")));
+    QVERIFY(waitForSignal(webView(), SIGNAL(loadSucceeded())));
+
+    QCOMPARE(webView()->url().path(), QLatin1String(TESTS_SOURCE_DIR "/html/basic_page2.html"));
+
+    webView()->navigationController()->goBack();
+    QVERIFY(waitForSignal(webView(), SIGNAL(loadSucceeded())));
+
+    QCOMPARE(webView()->url().path(), QLatin1String(TESTS_SOURCE_DIR "/html/basic_page.html"));
+
+    webView()->navigationController()->goForward();
+    QVERIFY(waitForSignal(webView(), SIGNAL(loadSucceeded())));
+
+    QCOMPARE(webView()->url().path(), QLatin1String(TESTS_SOURCE_DIR "/html/basic_page2.html"));
+}
+
+void tst_QQuickWebView::reload()
+{
+    webView()->load(QUrl::fromLocalFile(QLatin1String(TESTS_SOURCE_DIR "/html/basic_page.html")));
+    QVERIFY(waitForSignal(webView(), SIGNAL(loadSucceeded())));
+
+    QCOMPARE(webView()->url().path(), QLatin1String(TESTS_SOURCE_DIR "/html/basic_page.html"));
+
+    webView()->navigationController()->reload();
+    QVERIFY(waitForSignal(webView(), SIGNAL(loadSucceeded())));
+
+    QCOMPARE(webView()->url().path(), QLatin1String(TESTS_SOURCE_DIR "/html/basic_page.html"));
+}
+
+void tst_QQuickWebView::stop()
+{
+    webView()->load(QUrl::fromLocalFile(QLatin1String(TESTS_SOURCE_DIR "/html/basic_page.html")));
+    QVERIFY(waitForSignal(webView(), SIGNAL(loadSucceeded())));
+
+    QCOMPARE(webView()->url().path(), QLatin1String(TESTS_SOURCE_DIR "/html/basic_page.html"));
+
+    // FIXME: This test should be fleshed out. Right now it's just here to make sure we don't crash.
+    webView()->navigationController()->stop();
+}
+
+void tst_QQuickWebView::loadProgress()
+{
+    QCOMPARE(webView()->loadProgress(), 0);
+
+    webView()->load(QUrl::fromLocalFile(QLatin1String(TESTS_SOURCE_DIR "/html/basic_page.html")));
+    QSignalSpy loadProgressChangedSpy(webView(), SIGNAL(loadProgressChanged(int)));
+    QVERIFY(waitForSignal(webView(), SIGNAL(loadSucceeded())));
+
+    QVERIFY(loadProgressChangedSpy.count() >= 1);
+
+    QCOMPARE(webView()->loadProgress(), 100);
+}
+
+void tst_QQuickWebView::show()
+{
+    // This should not crash.
+    m_window->show();
+    QTest::qWait(200);
+    m_window->hide();
+}
+
+QTWEBKIT_API_TEST_MAIN(tst_QQuickWebView)
+
+#include "tst_qquickwebview.moc"
+
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qtouchwebview/qtouchwebview.pro b/Source/WebKit2/UIProcess/API/qt/tests/qtouchwebview/qtouchwebview.pro
deleted file mode 100644 (file)
index e99c7f4..0000000
+++ /dev/null
@@ -1 +0,0 @@
-include(../tests.pri)
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qtouchwebview/tst_qtouchwebview.cpp b/Source/WebKit2/UIProcess/API/qt/tests/qtouchwebview/tst_qtouchwebview.cpp
deleted file mode 100644 (file)
index 5df2875..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
-    Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Library General Public
-    License as published by the Free Software Foundation; either
-    version 2 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Library General Public License for more details.
-
-    You should have received a copy of the GNU Library General Public License
-    along with this library; see the file COPYING.LIB.  If not, write to
-    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-    Boston, MA 02110-1301, USA.
-*/
-
-#include <QtTest/QtTest>
-#include <qtouchwebpage.h>
-#include <qtouchwebview.h>
-#include <qwebnavigationcontroller.h>
-#include "../testwindow.h"
-#include "../util.h"
-
-Q_DECLARE_METATYPE(QTouchWebPage*);
-
-class tst_QTouchWebView : public QObject {
-    Q_OBJECT
-public:
-    tst_QTouchWebView();
-private slots:
-    void init();
-    void cleanup();
-
-    void accessPage();
-    void navigationStatusAtStartup();
-
-private:
-    inline QTouchWebView* webView() const;
-    QScopedPointer<TestWindow> m_window;
-};
-
-tst_QTouchWebView::tst_QTouchWebView()
-{
-    addQtWebProcessToPath();
-    qRegisterMetaType<QTouchWebPage*>("QTouchWebPage*");
-}
-
-void tst_QTouchWebView::init()
-{
-    m_window.reset(new TestWindow(new QTouchWebView));
-}
-
-void tst_QTouchWebView::cleanup()
-{
-    m_window.reset();
-}
-
-inline QTouchWebView* tst_QTouchWebView::webView() const
-{
-    return static_cast<QTouchWebView*>(m_window->webView.data());
-}
-
-void tst_QTouchWebView::accessPage()
-{
-    QTouchWebPage* const pageDirectAccess = webView()->page();
-
-    QVariant pagePropertyValue = webView()->property("page");
-    QTouchWebPage* const pagePropertyAccess = pagePropertyValue.value<QTouchWebPage*>();
-    QCOMPARE(pagePropertyAccess, pageDirectAccess);
-}
-
-void tst_QTouchWebView::navigationStatusAtStartup()
-{
-    QCOMPARE(webView()->navigationController()->canGoBack(), false);
-
-    QCOMPARE(webView()->navigationController()->canGoForward(), false);
-
-    QCOMPARE(webView()->navigationController()->canStop(), false);
-
-    QCOMPARE(webView()->navigationController()->canReload(), false);
-}
-
-
-QTWEBKIT_API_TEST_MAIN(tst_QTouchWebView)
-
-#include "tst_qtouchwebview.moc"
-
index 87809c3..7b59af9 100644 (file)
@@ -25,7 +25,7 @@
 #include <QtDeclarative/qquickitem.h>
 #include <QtDeclarative/qquickview.h>
 
-// TestWindow: Utility class to ignore QGraphicsView details.
+// TestWindow: Utility class to ignore QQuickView details.
 class TestWindow : public QQuickView {
 public:
     inline TestWindow(QQuickItem* webView);
index 833ebec..5cb1d9d 100644 (file)
@@ -60,8 +60,8 @@ typedef WKView PlatformWebView;
 class WebView;
 typedef WebView PlatformWebView;
 #elif PLATFORM(QT)
-class QtTouchViewInterface;
-typedef QtTouchViewInterface PlatformWebView;
+class QtViewInterface;
+typedef QtViewInterface PlatformWebView;
 #endif
 
 class TiledDrawingAreaProxy : public DrawingAreaProxy {
index bf30b1e..ef1d872 100644 (file)
@@ -32,7 +32,6 @@ QtGestureRecognizer::QtGestureRecognizer(QtViewportInteractionEngine* viewportIn
     : m_viewportInteractionEngine(viewportInteractionEngine)
     , m_state(NoGesture)
 {
-    ASSERT(viewportInteractionEngine);
 }
 
 void QtGestureRecognizer::reset()
@@ -40,4 +39,9 @@ void QtGestureRecognizer::reset()
     m_state = NoGesture;
 }
 
+void QtGestureRecognizer::setViewportInteractionEngine(QtViewportInteractionEngine* engine)
+{
+    m_viewportInteractionEngine = engine;
+}
+
 }
index f5222c7..4cca6bc 100644 (file)
@@ -36,9 +36,10 @@ public:
 
 protected:
     QtGestureRecognizer(QtViewportInteractionEngine*);
+    void setViewportInteractionEngine(QtViewportInteractionEngine*);
     void reset();
 
-    QtViewportInteractionEngine* const m_viewportInteractionEngine;
+    QtViewportInteractionEngine* m_viewportInteractionEngine;
     enum State {
         NoGesture,
         GestureRecognitionStarted,
index 40c979a..abe2692 100644 (file)
@@ -37,8 +37,17 @@ QtPanGestureRecognizer::QtPanGestureRecognizer(QtViewportInteractionEngine* inte
     reset();
 }
 
+void QtPanGestureRecognizer::setViewportInteractionEngine(QtViewportInteractionEngine* engine)
+{
+    QtGestureRecognizer::setViewportInteractionEngine(engine);
+    reset();
+}
+
 bool QtPanGestureRecognizer::recognize(const QTouchEvent* event, qint64 eventTimestampMillis)
 {
+    if (!m_viewportInteractionEngine)
+        return false;
+
     // Pan gesture always starts on TouchBegin unless the engine is suspended, or
     // we ignored the event.
     if (m_state == NoGesture && event->type() != QEvent::TouchBegin)
index 29caf06..514fea8 100644 (file)
@@ -42,6 +42,7 @@ const qreal panningInitialTriggerDistanceThreshold = 5.;
 class QtPanGestureRecognizer : public QtGestureRecognizer {
 public:
     QtPanGestureRecognizer(QtViewportInteractionEngine*);
+    void setViewportInteractionEngine(QtViewportInteractionEngine*);
     bool recognize(const QTouchEvent*, qint64 eventTimestampMillis);
     void reset();
 
index 16db5dd..72467b4 100644 (file)
@@ -57,6 +57,9 @@ QtPinchGestureRecognizer::QtPinchGestureRecognizer(QtViewportInteractionEngine*
 
 bool QtPinchGestureRecognizer::recognize(const QTouchEvent* event)
 {
+    if (!m_viewportInteractionEngine)
+        return false;
+
     const QList<QTouchEvent::TouchPoint>& touchPoints = event->touchPoints();
     if (touchPoints.size() < 2) {
         if (m_state == GestureRecognized)
@@ -130,6 +133,12 @@ bool QtPinchGestureRecognizer::recognize(const QTouchEvent* event)
     return false;
 }
 
+void QtPinchGestureRecognizer::setViewportInteractionEngine(QtViewportInteractionEngine* engine)
+{
+    QtGestureRecognizer::setViewportInteractionEngine(engine);
+    reset();
+}
+
 void QtPinchGestureRecognizer::reset()
 {
     QtGestureRecognizer::reset();
index 30d15fc..208c05a 100644 (file)
@@ -51,6 +51,7 @@ public:
     };
 
     QtPinchGestureRecognizer(QtViewportInteractionEngine*);
+    void setViewportInteractionEngine(QtViewportInteractionEngine*);
     bool recognize(const QTouchEvent*);
     void reset();
 
diff --git a/Source/WebKit2/UIProcess/qt/QtTouchViewInterface.cpp b/Source/WebKit2/UIProcess/qt/QtTouchViewInterface.cpp
deleted file mode 100644 (file)
index 4486880..0000000
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
- * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this program; see the file COPYING.LIB.  If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#include "config.h"
-#include "QtTouchViewInterface.h"
-
-#include "QtWebError.h"
-#include "qtouchwebpage.h"
-#include "qtouchwebpage_p.h"
-#include "qtouchwebview.h"
-#include "qtouchwebview_p.h"
-
-#include <QDeclarativeEngine>
-#include <QQuickView>
-
-namespace WebKit {
-
-QtTouchViewInterface::QtTouchViewInterface(QTouchWebView* viewportView, QTouchWebPage* pageView)
-    : m_viewportView(viewportView)
-    , m_pageView(pageView)
-{
-    Q_ASSERT(m_viewportView);
-    Q_ASSERT(m_pageView);
-}
-
-void QtTouchViewInterface::didFindZoomableArea(const QPoint&, const QRect&)
-{
-}
-
-QtSGUpdateQueue* QtTouchViewInterface::sceneGraphUpdateQueue() const
-{
-    return &m_pageView->d->sgUpdateQueue;
-}
-
-void QtTouchViewInterface::setViewNeedsDisplay(const QRect&)
-{
-    m_pageView->update();
-}
-
-QSize QtTouchViewInterface::drawingAreaSize()
-{
-    return QSize(m_pageView->width(), m_pageView->height());
-}
-
-void QtTouchViewInterface::contentSizeChanged(const QSize& newSize)
-{
-    m_pageView->setWidth(newSize.width());
-    m_pageView->setHeight(newSize.height());
-}
-
-void QtTouchViewInterface::scrollPositionRequested(const QPoint& pos)
-{
-    m_viewportView->d_func()->scrollPositionRequested(pos);
-}
-
-bool QtTouchViewInterface::isActive()
-{
-    // FIXME: The scene graph does not have the concept of being active or not when this was written.
-    return true;
-}
-
-bool QtTouchViewInterface::hasFocus()
-{
-    return m_pageView->hasFocus();
-}
-
-bool QtTouchViewInterface::isVisible()
-{
-    return m_viewportView->isVisible() && m_pageView->isVisible();
-}
-
-void QtTouchViewInterface::startDrag(Qt::DropActions supportedDropActions, const QImage& dragImage, QMimeData* data, QPoint* clientPosition, QPoint* globalPosition, Qt::DropAction* dropAction)
-{
-    // QTouchWebView does not support drag and drop.
-    Q_ASSERT(false);
-}
-
-void QtTouchViewInterface::didChangeViewportProperties(const WebCore::ViewportArguments& args)
-{
-    m_viewportView->d_func()->didChangeViewportProperties(args);
-}
-
-void QtTouchViewInterface::didChangeUrl(const QUrl& url)
-{
-    emit m_viewportView->urlChanged(url);
-}
-
-void QtTouchViewInterface::didChangeTitle(const QString& newTitle)
-{
-    emit m_viewportView->titleChanged(newTitle);
-}
-
-void QtTouchViewInterface::didChangeToolTip(const QString&)
-{
-    // There is not yet any UI defined for the tooltips for mobile so we ignore the change.
-}
-
-void QtTouchViewInterface::didChangeStatusText(const QString&)
-{
-    // There is not yet any UI defined for status text so we ignore the call.
-}
-
-void QtTouchViewInterface::didChangeCursor(const QCursor&)
-{
-    // The cursor is not visible on mobile, just ignore this message.
-}
-
-void QtTouchViewInterface::loadDidBegin()
-{
-    emit m_viewportView->loadStarted();
-}
-
-void QtTouchViewInterface::loadDidCommit()
-{
-    m_viewportView->d_func()->loadDidCommit();
-}
-
-void QtTouchViewInterface::loadDidSucceed()
-{
-    emit m_viewportView->loadSucceeded();
-}
-
-void QtTouchViewInterface::loadDidFail(const QtWebError& error)
-{
-    emit m_viewportView->loadFailed(static_cast<QBaseWebView::ErrorType>(error.type()), error.errorCode(), error.url());
-}
-
-void QtTouchViewInterface::didChangeLoadProgress(int percentageLoaded)
-{
-    emit m_viewportView->loadProgressChanged(percentageLoaded);
-}
-
-void QtTouchViewInterface::showContextMenu(QSharedPointer<QMenu>)
-{
-    // FIXME
-}
-
-void QtTouchViewInterface::hideContextMenu()
-{
-    // FIXME
-}
-
-void QtTouchViewInterface::runJavaScriptAlert(const QString&)
-{
-    // FIXME.
-}
-
-bool QtTouchViewInterface::runJavaScriptConfirm(const QString&)
-{
-    // FIXME.
-    return true;
-}
-
-QString QtTouchViewInterface::runJavaScriptPrompt(const QString&, const QString& defaultValue, bool&)
-{
-    // FIXME.
-    return defaultValue;
-}
-
-void QtTouchViewInterface::processDidCrash()
-{
-    // FIXME
-}
-
-void QtTouchViewInterface::didRelaunchProcess()
-{
-    // FIXME
-}
-
-QJSEngine* QtTouchViewInterface::engine()
-{
-    QQuickView* view = qobject_cast<QQuickView*>(m_pageView->canvas());
-    if (view)
-        return view->engine();
-    return 0;
-}
-
-}
diff --git a/Source/WebKit2/UIProcess/qt/QtTouchViewInterface.h b/Source/WebKit2/UIProcess/qt/QtTouchViewInterface.h
deleted file mode 100644 (file)
index b0d7ec1..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this program; see the file COPYING.LIB.  If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef QtTouchViewInterface_h
-#define QtTouchViewInterface_h
-
-#include "QtViewInterface.h"
-
-class QPointF;
-class QTouchWebPage;
-class QTouchWebView;
-
-namespace WebCore {
-class ViewportArguments;
-}
-
-namespace WebKit {
-
-class QtSGUpdateQueue;
-
-class QtTouchViewInterface : public QtViewInterface {
-public:
-    QtTouchViewInterface(QTouchWebView* viewportView, QTouchWebPage* pageView);
-
-    QtSGUpdateQueue* sceneGraphUpdateQueue() const;
-
-private:
-    // Implementation of QtViewInterface.
-    virtual void setViewNeedsDisplay(const QRect&);
-
-    virtual QSize drawingAreaSize();
-    virtual void contentSizeChanged(const QSize&);
-    virtual void scrollPositionRequested(const QPoint& pos);
-
-    virtual bool isActive();
-    virtual bool hasFocus();
-    virtual bool isVisible();
-
-    virtual void startDrag(Qt::DropActions supportedDropActions, const QImage& dragImage, QMimeData*, QPoint* clientPosition, QPoint* globalPosition, Qt::DropAction*);
-    virtual void didChangeViewportProperties(const WebCore::ViewportArguments&);
-
-    virtual void didFindZoomableArea(const QPoint&, const QRect&);
-
-    virtual void didChangeUrl(const QUrl&);
-    virtual void didChangeTitle(const QString&);
-    virtual void didChangeToolTip(const QString&);
-    virtual void didChangeStatusText(const QString&);
-    virtual void didChangeCursor(const QCursor&);
-    virtual void loadDidBegin();
-    virtual void loadDidCommit();
-    virtual void loadDidSucceed();
-    virtual void loadDidFail(const QtWebError&);
-    virtual void didChangeLoadProgress(int);
-
-    virtual void showContextMenu(QSharedPointer<QMenu>);
-    virtual void hideContextMenu();
-
-    virtual void runJavaScriptAlert(const QString&);
-    virtual bool runJavaScriptConfirm(const QString&);
-    virtual QString runJavaScriptPrompt(const QString&, const QString& defaultValue, bool& ok);
-
-    virtual void processDidCrash();
-    virtual void didRelaunchProcess();
-
-    virtual QJSEngine* engine();
-
-    virtual void chooseFiles(WKOpenPanelResultListenerRef, const QStringList&, FileChooserType) { }
-    virtual void downloadRequested(QWebDownloadItem* downloadItem) { }
-
-    virtual void didMouseMoveOverElement(const QUrl&, const QString&) { }
-
-private:
-    QTouchWebView* const m_viewportView;
-    QTouchWebPage* const m_pageView;
-};
-
-}
-
-#endif // QtTouchViewInterface
diff --git a/Source/WebKit2/UIProcess/qt/QtViewInterface.cpp b/Source/WebKit2/UIProcess/qt/QtViewInterface.cpp
new file mode 100644 (file)
index 0000000..fc7c256
--- /dev/null
@@ -0,0 +1,251 @@
+/*
+ * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this program; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "config.h"
+#include "QtViewInterface.h"
+
+#include "QtWebError.h"
+#include "qquickwebpage.h"
+#include "qquickwebpage_p.h"
+#include "qquickwebview.h"
+#include "qquickwebview_p.h"
+
+#include <QtDeclarative/QDeclarativeEngine>
+#include <QtDeclarative/QQuickView>
+#include <QtGui/QDrag>
+#include <QtGui/QGuiApplication>
+
+namespace WebKit {
+
+QtViewInterface::QtViewInterface(QQuickWebView* viewportView, QQuickWebPage* pageView)
+    : m_viewportView(viewportView)
+    , m_pageView(pageView)
+{
+    Q_ASSERT(m_viewportView);
+    Q_ASSERT(m_pageView);
+}
+
+void QtViewInterface::didFindZoomableArea(const QPoint&, const QRect&)
+{
+}
+
+QtSGUpdateQueue* QtViewInterface::sceneGraphUpdateQueue() const
+{
+    return &m_pageView->d->sgUpdateQueue;
+}
+
+void QtViewInterface::setViewNeedsDisplay(const QRect&)
+{
+    m_pageView->update();
+}
+
+QSize QtViewInterface::drawingAreaSize()
+{
+    return QSize(m_pageView->width(), m_pageView->height());
+}
+
+void QtViewInterface::contentSizeChanged(const QSize& newSize)
+{
+    m_viewportView->d_func()->contentSizeChanged(newSize);
+}
+
+void QtViewInterface::scrollPositionRequested(const QPoint& pos)
+{
+    m_viewportView->d_func()->scrollPositionRequested(pos);
+}
+
+bool QtViewInterface::isActive()
+{
+    // FIXME: The scene graph does not have the concept of being active or not when this was written.
+    return true;
+}
+
+bool QtViewInterface::hasFocus()
+{
+    return m_pageView->hasFocus();
+}
+
+bool QtViewInterface::isVisible()
+{
+    return m_viewportView->isVisible() && m_pageView->isVisible();
+}
+
+void QtViewInterface::startDrag(Qt::DropActions supportedDropActions, const QImage& dragImage, QMimeData* data, QPoint* clientPosition, QPoint* globalPosition, Qt::DropAction* dropAction)
+{
+    QWindow* window = m_viewportView->canvas();
+    if (!window)
+        return;
+
+    QDrag* drag = new QDrag(window);
+    drag->setPixmap(QPixmap::fromImage(dragImage));
+    drag->setMimeData(data);
+    *dropAction = drag->exec(supportedDropActions);
+    *globalPosition = QCursor::pos();
+    *clientPosition = window->mapFromGlobal(*globalPosition);
+}
+
+
+void QtViewInterface::didChangeViewportProperties(const WebCore::ViewportArguments& args)
+{
+    m_viewportView->d_func()->didChangeViewportProperties(args);
+}
+
+void QtViewInterface::didChangeUrl(const QUrl& url)
+{
+    emit m_viewportView->urlChanged(url);
+}
+
+void QtViewInterface::didChangeTitle(const QString& newTitle)
+{
+    emit m_viewportView->titleChanged(newTitle);
+}
+
+void QtViewInterface::didChangeToolTip(const QString&)
+{
+    // There is not yet any UI defined for the tooltips for mobile so we ignore the change.
+}
+
+void QtViewInterface::didChangeStatusText(const QString& newMessage)
+{
+    emit m_viewportView->statusBarMessageChanged(newMessage);
+}
+
+void QtViewInterface::didChangeCursor(const QCursor& newCursor)
+{
+    // FIXME: This is a temporary fix until we get cursor support in QML items.
+    QGuiApplication::setOverrideCursor(newCursor);
+}
+
+void QtViewInterface::loadDidBegin()
+{
+    emit m_viewportView->loadStarted();
+}
+
+void QtViewInterface::loadDidCommit()
+{
+    m_viewportView->d_func()->loadDidCommit();
+}
+
+void QtViewInterface::loadDidSucceed()
+{
+    emit m_viewportView->loadSucceeded();
+}
+
+void QtViewInterface::loadDidFail(const QtWebError& error)
+{
+    emit m_viewportView->loadFailed(static_cast<QQuickWebView::ErrorType>(error.type()), error.errorCode(), error.url());
+}
+
+void QtViewInterface::didChangeLoadProgress(int percentageLoaded)
+{
+    emit m_viewportView->loadProgressChanged(percentageLoaded);
+}
+
+void QtViewInterface::didMouseMoveOverElement(const QUrl& linkURL, const QString& linkTitle)
+{
+    if (linkURL == lastHoveredURL && linkTitle == lastHoveredTitle)
+        return;
+    lastHoveredURL = linkURL;
+    lastHoveredTitle = linkTitle;
+    emit m_viewportView->linkHovered(lastHoveredURL, lastHoveredTitle);
+}
+
+void QtViewInterface::showContextMenu(QSharedPointer<QMenu> menu)
+{
+    // Remove the active menu in case this function is called twice.
+    if (activeMenu)
+        activeMenu->hide();
+
+    if (menu->isEmpty())
+        return;
+
+    QWindow* window = m_viewportView->canvas();
+    if (!window)
+        return;
+
+    activeMenu = menu;
+
+    activeMenu->window()->winId(); // Ensure that the menu has a window
+    Q_ASSERT(activeMenu->window()->windowHandle());
+    activeMenu->window()->windowHandle()->setTransientParent(window);
+
+    QPoint menuPositionInScene = m_viewportView->mapToScene(menu->pos()).toPoint();
+    menu->exec(window->mapToGlobal(menuPositionInScene));
+    // The last function to get out of exec() clear the local copy.
+    if (activeMenu == menu)
+        activeMenu.clear();
+}
+
+void QtViewInterface::hideContextMenu()
+{
+    if (activeMenu)
+        activeMenu->hide();
+}
+
+void QtViewInterface::runJavaScriptAlert(const QString& alertText)
+{
+    m_viewportView->d_func()->runJavaScriptAlert(alertText);
+}
+
+bool QtViewInterface::runJavaScriptConfirm(const QString& message)
+{
+    return m_viewportView->d_func()->runJavaScriptConfirm(message);
+}
+
+QString QtViewInterface::runJavaScriptPrompt(const QString& message, const QString& defaultValue, bool& ok)
+{
+    return m_viewportView->d_func()->runJavaScriptPrompt(message, defaultValue, ok);
+}
+
+void QtViewInterface::processDidCrash()
+{
+    // FIXME
+}
+
+void QtViewInterface::didRelaunchProcess()
+{
+    // FIXME
+}
+
+QJSEngine* QtViewInterface::engine()
+{
+    QQuickView* view = qobject_cast<QQuickView*>(m_pageView->canvas());
+    if (view)
+        return view->engine();
+    return 0;
+}
+
+
+void QtViewInterface::downloadRequested(QWebDownloadItem* downloadItem)
+{
+    if (!downloadItem)
+        return;
+
+    QDeclarativeEngine::setObjectOwnership(downloadItem, QDeclarativeEngine::JavaScriptOwnership);
+    emit m_viewportView->downloadRequested(downloadItem);
+}
+
+void QtViewInterface::chooseFiles(WKOpenPanelResultListenerRef listenerRef, const QStringList& selectedFileNames, QtViewInterface::FileChooserType type)
+{
+    m_viewportView->d_func()->chooseFiles(listenerRef, selectedFileNames, type);
+}
+
+}
+
index b5f5c4b..b078990 100644 (file)
 #include <QMenu>
 #include <QtCore/QSharedPointer>
 #include <QtCore/QSize>
+#include <QtCore/QUrl>
 #include <WebKit2/WKBase.h>
 
+class QQuickWebPage;
+class QQuickWebView;
 class QtWebError;
 class QWebDownloadItem;
 
@@ -37,7 +40,6 @@ class QJSEngine;
 class QMimeData;
 class QPoint;
 class QRect;
-class QUrl;
 class QWidget;
 QT_END_NAMESPACE
 
@@ -47,6 +49,8 @@ class ViewportArguments;
 
 namespace WebKit {
 
+class QtSGUpdateQueue;
+
 class QtViewInterface {
 public:
     enum FileChooserType {
@@ -54,49 +58,61 @@ public:
         MultipleFilesSelection
     };
 
-    virtual void setViewNeedsDisplay(const QRect&) = 0;
+    QtViewInterface(QQuickWebView* viewportView, QQuickWebPage* pageView);
+
+    QtSGUpdateQueue* sceneGraphUpdateQueue() const;
+
+    virtual void setViewNeedsDisplay(const QRect&);
+
+    virtual QSize drawingAreaSize();
+    virtual void contentSizeChanged(const QSize&);
+    virtual void scrollPositionRequested(const QPoint& pos);
+
+    virtual bool isActive();
+    virtual bool hasFocus();
+    virtual bool isVisible();
 
-    virtual QSize drawingAreaSize() = 0;
-    virtual void contentSizeChanged(const QSize&) = 0;
-    virtual void scrollPositionRequested(const QPoint& pos) = 0;
+    virtual void startDrag(Qt::DropActions supportedDropActions, const QImage& dragImage, QMimeData*, QPoint* clientPosition, QPoint* globalPosition, Qt::DropAction*);
+    virtual void didChangeViewportProperties(const WebCore::ViewportArguments&);
 
-    virtual bool isActive() = 0;
-    virtual bool hasFocus() = 0;
-    virtual bool isVisible() = 0;
+    virtual void didFindZoomableArea(const QPoint&, const QRect&);
 
-    virtual void startDrag(Qt::DropActions supportedDropActions, const QImage& dragImage, QMimeData*, QPoint* clientPosition, QPoint* globalPosition, Qt::DropAction*) = 0;
-    virtual void didChangeViewportProperties(const WebCore::ViewportArguments&) = 0;
+    virtual void didChangeUrl(const QUrl&);
+    virtual void didChangeTitle(const QString&);
+    virtual void didChangeToolTip(const QString&);
+    virtual void didChangeStatusText(const QString&);
+    virtual void didChangeCursor(const QCursor&);
+    virtual void loadDidBegin();
+    virtual void loadDidCommit();
+    virtual void loadDidSucceed();
+    virtual void loadDidFail(const QtWebError&);
+    virtual void didChangeLoadProgress(int);
 
-    virtual void didFindZoomableArea(const QPoint&, const QRect&) = 0;
+    virtual void showContextMenu(QSharedPointer<QMenu>);
+    virtual void hideContextMenu();
 
-    virtual void didChangeUrl(const QUrl&) = 0;
-    virtual void didChangeTitle(const QString&) = 0;
-    virtual void didChangeToolTip(const QString&) = 0;
-    virtual void didChangeStatusText(const QString&) = 0;
-    virtual void didChangeCursor(const QCursor&) = 0;
-    virtual void loadDidBegin() = 0;
-    virtual void loadDidCommit() = 0;
-    virtual void loadDidSucceed() = 0;
-    virtual void loadDidFail(const QtWebError&) = 0;
-    virtual void didChangeLoadProgress(int) = 0;
+    virtual void runJavaScriptAlert(const QString&);
+    virtual bool runJavaScriptConfirm(const QString&);
+    virtual QString runJavaScriptPrompt(const QString&, const QString& defaultValue, bool& ok);
 
-    virtual void showContextMenu(QSharedPointer<QMenu>) = 0;
-    virtual void hideContextMenu() = 0;
+    virtual void processDidCrash();
+    virtual void didRelaunchProcess();
 
-    virtual void runJavaScriptAlert(const QString&) = 0;
-    virtual bool runJavaScriptConfirm(const QString&) = 0;
-    virtual QString runJavaScriptPrompt(const QString&, const QString& defaultValue, bool& ok) = 0;
+    virtual QJSEngine* engine();
 
-    virtual void processDidCrash() = 0;
-    virtual void didRelaunchProcess() = 0;
+    virtual void chooseFiles(WKOpenPanelResultListenerRef, const QStringList& selectedFileNames, FileChooserType);
 
-    virtual QJSEngine* engine() = 0;
+    virtual void didMouseMoveOverElement(const QUrl&, const QString&);
 
-    virtual void chooseFiles(WKOpenPanelResultListenerRef, const QStringList& selectedFileNames, FileChooserType) = 0;
+    virtual void downloadRequested(QWebDownloadItem*);
 
-    virtual void didMouseMoveOverElement(const QUrl&, const QString&) = 0;
+private:
+    QQuickWebView* const m_viewportView;
+    QQuickWebPage* const m_pageView;
 
-    virtual void downloadRequested(QWebDownloadItem*) = 0;
+    QSharedPointer<QMenu> activeMenu;
+    QUrl lastHoveredURL;
+    QString lastHoveredTitle;
 };
 
 }
index 2d3e658..eeb690b 100644 (file)
@@ -174,6 +174,8 @@ public:
     void setNavigatorQtObjectEnabled(bool);
     bool navigatorQtObjectEnabled() const { return m_navigatorQtObjectEnabled; }
 
+    void setViewportInteractionEngine(QtViewportInteractionEngine* engine) { m_interactionEngine = engine; m_panGestureRecognizer.setViewportInteractionEngine(engine); m_pinchGestureRecognizer.setViewportInteractionEngine(engine);}
+
     void postMessageToNavigatorQtObject(const QString&);
 
     qreal textZoomFactor() const;
index 489d829..8cec414 100644 (file)
@@ -27,7 +27,7 @@
 #include "TiledDrawingAreaProxy.h"
 
 #include "QtSGUpdateQueue.h"
-#include "QtTouchViewInterface.h"
+#include "QtViewInterface.h"
 #include "ShareableBitmap.h"
 #include "UpdateInfo.h"
 #include "WKAPICast.h"
index 03d0d1b..2291fd9 100644 (file)
@@ -51,11 +51,9 @@ SOURCES += \
     $$PWD/UIProcess/API/C/WKResourceCacheManager.cpp \
     $$PWD/UIProcess/API/cpp/qt/WKStringQt.cpp \
     $$PWD/UIProcess/API/cpp/qt/WKURLQt.cpp \
-    $$PWD/UIProcess/API/qt/qbasewebview.cpp \
-    $$PWD/UIProcess/API/qt/qdesktopwebview.cpp \
     $$PWD/UIProcess/API/qt/qwebdownloaditem.cpp \
-    $$PWD/UIProcess/API/qt/qtouchwebpage.cpp \
-    $$PWD/UIProcess/API/qt/qtouchwebview.cpp \
+    $$PWD/UIProcess/API/qt/qquickwebpage.cpp \
+    $$PWD/UIProcess/API/qt/qquickwebview.cpp \
     $$PWD/UIProcess/API/qt/qwebnavigationcontroller.cpp \
     $$PWD/UIProcess/API/qt/qwebpreferences.cpp \
     $$PWD/WebProcess/InjectedBundle/API/c/WKBundle.cpp \
@@ -132,18 +130,14 @@ HEADERS += \
     $$PWD/UIProcess/API/cpp/WKRetainPtr.h \
     $$PWD/UIProcess/API/cpp/qt/WKStringQt.h \
     $$PWD/UIProcess/API/cpp/qt/WKURLQt.h \
-    $$PWD/UIProcess/API/qt/qbasewebview.h \
-    $$PWD/UIProcess/API/qt/qbasewebview_p.h \
-    $$PWD/UIProcess/API/qt/qdesktopwebview.h \
-    $$PWD/UIProcess/API/qt/qdesktopwebview_p.h \
     $$PWD/UIProcess/API/qt/qwebpreferences.h \
     $$PWD/UIProcess/API/qt/qwebpreferences_p.h \
     $$PWD/UIProcess/API/qt/qwebdownloaditem.h \
     $$PWD/UIProcess/API/qt/qwebdownloaditem_p.h \
-    $$PWD/UIProcess/API/qt/qtouchwebpage.h \
-    $$PWD/UIProcess/API/qt/qtouchwebpage_p.h \
-    $$PWD/UIProcess/API/qt/qtouchwebview.h \
-    $$PWD/UIProcess/API/qt/qtouchwebview_p.h \
+    $$PWD/UIProcess/API/qt/qquickwebpage.h \
+    $$PWD/UIProcess/API/qt/qquickwebpage_p.h \
+    $$PWD/UIProcess/API/qt/qquickwebview.h \
+    $$PWD/UIProcess/API/qt/qquickwebview_p.h \
     $$PWD/UIProcess/API/qt/qwebnavigationcontroller.h \
     $$PWD/WebProcess/InjectedBundle/API/c/WKBundleBackForwardList.h \
     $$PWD/WebProcess/InjectedBundle/API/c/WKBundleBackForwardListItem.h \
index eabe253..1b415fd 100644 (file)
@@ -43,8 +43,6 @@ contains(DEFINES, ENABLE_WEBGL=1) {
     WEBKIT2_TESTS_DIR = $$PWD/WebKit2/UIProcess/API/qt/tests
 
     SUBDIRS += \
-        $$WEBKIT2_TESTS_DIR/qtouchwebview \
-        $$WEBKIT2_TESTS_DIR/qdesktopwebview \
-        $$WEBKIT2_TESTS_DIR/commonviewtests \
+        $$WEBKIT2_TESTS_DIR/qquickwebview \
         $$WEBKIT2_TESTS_DIR/qmltests
 }
index 0798047..9644656 100644 (file)
@@ -1,3 +1,27 @@
+2011-11-10  Alexis Menard  <alexis.menard@openbossa.org>
+
+        [Qt] Merge QTouchWebView and QDesktopWebView into one class
+        https://bugs.webkit.org/show_bug.cgi?id=71355
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Make MiniBrowser and WebKitTestRunner work again after the
+        merge.
+
+        * MiniBrowser/qt/BrowserWindow.cpp:
+        (BrowserWindow::BrowserWindow):
+        (BrowserWindow::webView):
+        * MiniBrowser/qt/MiniBrowser.pro:
+        * MiniBrowser/qt/MiniBrowser.qrc:
+        * MiniBrowser/qt/MiniBrowserApplication.cpp:
+        * MiniBrowser/qt/main.cpp:
+        * MiniBrowser/qt/qml/BrowserWindow.qml:
+        * MiniBrowser/qt/qml/DesktopView.qml: Removed.
+        * MiniBrowser/qt/qml/TouchView.qml: Removed.
+        * WebKitTestRunner/PlatformWebView.h:
+        * WebKitTestRunner/qt/PlatformWebViewQt.cpp:
+        (WTR::PlatformWebView::PlatformWebView):
+
 2011-11-10  Tor Arne Vestbø  <tor.arne.vestbo@nokia.com>
 
         [Qt] Change semantics of the haveQt() function to match API promises
index 1415f4d..f5613b6 100644 (file)
@@ -28,9 +28,9 @@
 
 #include "BrowserWindow.h"
 
-#include "qdesktopwebview.h"
-#include "qtouchwebview.h"
-#include "qtouchwebpage.h"
+#include "config.h"
+#include "qquickwebpage.h"
+#include "qquickwebview_p.h"
 #include "utils.h"
 
 #include <QDeclarativeEngine>
@@ -52,6 +52,8 @@ BrowserWindow::BrowserWindow(WindowOptions* options)
     engine()->rootContext()->setContextProperty("options", options);
     setSource(QUrl("qrc:/qml/BrowserWindow.qml"));
     connect(rootObject(), SIGNAL(pageTitleChanged(QString)), this, SLOT(setWindowTitle(QString)));
+    if (!options->useTouchWebView())
+        QQuickWebViewPrivate::get(rootObject()->property("webview").value<QQuickWebView*>())->setUseTraditionalDesktopBehaviour(true);
     if (options->startMaximized())
         setWindowState(Qt::WindowMaximized);
     else
@@ -61,11 +63,7 @@ BrowserWindow::BrowserWindow(WindowOptions* options)
 
 QObject* BrowserWindow::webView() const
 {
-    QObject* webView = rootObject()->property("webView").value<QDesktopWebView*>();
-    // The webView is created in QML, therefore it might not exist yet.
-    if (!webView)
-        webView = rootObject()->property("webView").value<QTouchWebView*>();
-    return webView;
+    return rootObject()->property("webview").value<QQuickWebView*>();
 }
 
 void BrowserWindow::load(const QString& url)
index 30ecd81..8cad17c 100644 (file)
@@ -24,6 +24,11 @@ DESTDIR = $${ROOT_BUILD_DIR}/bin
 
 CONFIG += qtwebkit
 
+# FIXME: When webkit-private works let's use it.
+load(javascriptcore)
+load(webcore)
+load(webkit2)
+
 QT += network declarative widgets
 macx: QT += xml
 
index 12ddc32..a57a954 100644 (file)
@@ -6,7 +6,5 @@
         <file>icons/stop.png</file>
         <file>qml/BrowserWindow.qml</file>
         <file>useragentlist.txt</file>
-        <file>qml/DesktopView.qml</file>
-        <file>qml/TouchView.qml</file>
     </qresource>
 </RCC>
index ca7f81a..1bb23b1 100644 (file)
@@ -28,8 +28,6 @@
 
 #include "MiniBrowserApplication.h"
 
-#include "qdesktopwebview.h"
-#include "qtouchwebview.h"
 #include "qwebnavigationcontroller.h"
 #include "utils.h"
 #include <QRegExp>
index a20b25e..26877ae 100644 (file)
@@ -30,6 +30,9 @@
 
 #include "MiniBrowserApplication.h"
 #include "UrlLoader.h"
+
+#include <qdeclarative.h>
+
 #include <QDir>
 #include <QLatin1String>
 #include <QRegExp>
index 38cba0f..3f3199e 100644 (file)
@@ -35,8 +35,7 @@ Rectangle {
     property bool canGoBack: false
     property bool canGoForward: false
     property bool canStop: false
-    property int loadProgress: 0
-    property alias webView: viewLoader.item
+    property alias webview: webView
 
     signal pageTitleChanged(string title)
 
@@ -155,10 +154,10 @@ Rectangle {
                     bottom: parent.bottom
                     left: parent.left
                 }
-                width: parent.width / 100 * loadProgress
+                width: parent.width / 100 * webView.loadProgress
                 color: "blue"
                 opacity: 0.3
-                visible: loadProgress != 100
+                visible: webView.loadProgress != 100
             }
 
             TextInput {
@@ -191,32 +190,31 @@ Rectangle {
         }
     }
 
-    Loader {
-        id: viewLoader
+    WebView {
+        id: webView
         anchors {
             top: navigationBar.bottom
             left: parent.left
             right: parent.right
             bottom: parent.bottom
         }
-        source: options.useTouchWebView ? "TouchView.qml" : "DesktopView.qml"
-    }
 
-    Connections {
-        target: viewLoader.item
-        onTitleChanged: pageTitleChanged(viewLoader.item.title)
+        signal navigationStateChanged
+
+        Component.onCompleted: navigation.navigationStateChanged.connect(navigationStateChanged);
+
+        onTitleChanged: pageTitleChanged(title)
         onUrlChanged: {
-            addressLine.text = viewLoader.item.url
+            addressLine.text = url
             if (options.printLoadedUrls)
-                console.log("Loaded:", viewLoader.item.url);
+                console.log("Loaded:", webView.url);
             forceActiveFocus();
         }
         onNavigationStateChanged: {
-            canGoBack = viewLoader.item.navigation.canGoBack
-            canGoForward = viewLoader.item.navigation.canGoForward
-            canStop = viewLoader.item.navigation.canStop
+            canGoBack = navigation.canGoBack
+            canGoForward = navigation.canGoForward
+            canStop = navigation.canStop
         }
-        onLoadProgressChanged: loadProgress = viewLoader.item.loadProgress
     }
 
     Keys.onPressed: {
diff --git a/Tools/MiniBrowser/qt/qml/DesktopView.qml b/Tools/MiniBrowser/qt/qml/DesktopView.qml
deleted file mode 100644 (file)
index 752ddd5..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-import QtQuick 2.0
-import QtWebKit 3.0
-
-DesktopWebView {
-    signal navigationStateChanged
-
-    Component.onCompleted: navigation.navigationStateChanged.connect(navigationStateChanged)
-}
diff --git a/Tools/MiniBrowser/qt/qml/TouchView.qml b/Tools/MiniBrowser/qt/qml/TouchView.qml
deleted file mode 100644 (file)
index 51afdb0..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-import QtQuick 2.0
-import QtWebKit 3.0
-
-TouchWebView {
-    signal navigationStateChanged
-
-    Component.onCompleted: navigation.navigationStateChanged.connect(navigationStateChanged)
-}
index 4a589be..a6d51f2 100644 (file)
@@ -29,8 +29,8 @@
 #include <WebKit2/WKRetainPtr.h>
 
 #if defined(BUILDING_QT__)
-class QDesktopWebView;
-typedef QDesktopWebView* PlatformWKView;
+class QQuickWebView;
+typedef QQuickWebView* PlatformWKView;
 class QQuickView;
 typedef QQuickView* PlatformWindow;
 #elif defined(__APPLE__) && __APPLE__
index 22e3aa6..77c31ff 100644 (file)
@@ -27,7 +27,7 @@
 #include "config.h"
 
 #include "PlatformWebView.h"
-#include "qdesktopwebview.h"
+#include "qquickwebview.h"
 
 #include <QApplication>
 #include <QDeclarativeProperty>
@@ -67,7 +67,7 @@ private:
 };
 
 PlatformWebView::PlatformWebView(WKContextRef contextRef, WKPageGroupRef pageGroupRef)
-    : m_view(new QDesktopWebView(contextRef, pageGroupRef))
+    : m_view(new QQuickWebView(contextRef, pageGroupRef))
     , m_window(new WrapperWindow(m_view))
     , m_windowIsKey(true)
 {