https://bugs.webkit.org/show_bug.cgi?id=73145
Reviewed by Simon Hausmann.
Move QtWebPageProxy::startDrag to QtWebPageEventHandler::startDrag
and call it straight from QtPageClient.
* UIProcess/API/qt/qquickwebview.cpp:
(QQuickWebViewPrivate::QQuickWebViewPrivate):
* UIProcess/qt/QtWebPageEventHandler.cpp:
(dragOperationToDropAction):
(dragOperationToDropActions):
(dropActionToDragOperation):
Now these functions are static inline and not part of QtWebPageEventHandler
anymore.
(QtWebPageEventHandler::QtWebPageEventHandler):
(QtWebPageEventHandler::startDrag):
* UIProcess/qt/QtWebPageEventHandler.h:
* UIProcess/qt/QtWebPageProxy.cpp:
(QtWebPageProxy::startDrag): removed.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@102579
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2011-12-09 Jesus Sanchez-Palencia <jesus.palencia@openbossa.org>
+
+ [Qt][WK2] Move startDrag implementation to QtWebPageEventHandler
+ https://bugs.webkit.org/show_bug.cgi?id=73145
+
+ Reviewed by Simon Hausmann.
+
+ Move QtWebPageProxy::startDrag to QtWebPageEventHandler::startDrag
+ and call it straight from QtPageClient.
+
+ * UIProcess/API/qt/qquickwebview.cpp:
+ (QQuickWebViewPrivate::QQuickWebViewPrivate):
+ * UIProcess/qt/QtWebPageEventHandler.cpp:
+ (dragOperationToDropAction):
+ (dragOperationToDropActions):
+ (dropActionToDragOperation):
+ Now these functions are static inline and not part of QtWebPageEventHandler
+ anymore.
+
+ (QtWebPageEventHandler::QtWebPageEventHandler):
+ (QtWebPageEventHandler::startDrag):
+ * UIProcess/qt/QtWebPageEventHandler.h:
+ * UIProcess/qt/QtWebPageProxy.cpp:
+ (QtWebPageProxy::startDrag): removed.
+
2011-12-12 Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org>
[Qt] [WK2] Support customizing popup menus with QML
pageLoadClient.reset(new QtWebPageLoadClient(pageProxy->pageRef(), q_ptr));
pagePolicyClient.reset(new QtWebPagePolicyClient(pageProxy->pageRef(), q_ptr));
pageUIClient.reset(new QtWebPageUIClient(pageProxy->pageRef(), q_ptr));
- eventHandler.reset(new QtWebPageEventHandler(pageProxy->pageRef()));
+ eventHandler.reset(new QtWebPageEventHandler(pageProxy->pageRef(), q_ptr));
// Any page setting should preferrable be set before creating the page, so set them here:
setUseTraditionalDesktopBehaviour(false);
void QtPageClient::startDrag(const WebCore::DragData& dragData, PassRefPtr<ShareableBitmap> dragImage)
{
- m_qtWebPageProxy->startDrag(dragData, dragImage);
+ m_eventHandler->startDrag(dragData, dragImage);
}
void QtPageClient::handleDownloadRequest(DownloadProxy* download)
#include "config.h"
#include "QtWebPageEventHandler.h"
+#include "qquickwebview_p.h"
#include "NativeWebKeyboardEvent.h"
#include "NativeWebMouseEvent.h"
#include "NativeWebWheelEvent.h"
#include <QDrag>
#include <QGraphicsSceneMouseEvent>
#include <QGuiApplication>
+#include <QMimeData>
+#include <QtQuick/QQuickCanvas>
#include <QStyleHints>
#include <QTouchEvent>
#include <WebCore/DragData.h>
using namespace WebKit;
using namespace WebCore;
-Qt::DropAction QtWebPageEventHandler::dragOperationToDropAction(unsigned dragOperation)
+static inline Qt::DropAction dragOperationToDropAction(unsigned dragOperation)
{
Qt::DropAction result = Qt::IgnoreAction;
if (dragOperation & DragOperationCopy)
return result;
}
-Qt::DropActions QtWebPageEventHandler::dragOperationToDropActions(unsigned dragOperations)
+static inline Qt::DropActions dragOperationToDropActions(unsigned dragOperations)
{
Qt::DropActions result = Qt::IgnoreAction;
if (dragOperations & DragOperationCopy)
return result;
}
-WebCore::DragOperation QtWebPageEventHandler::dropActionToDragOperation(Qt::DropActions actions)
+static inline WebCore::DragOperation dropActionToDragOperation(Qt::DropActions actions)
{
unsigned result = 0;
if (actions & Qt::CopyAction)
return (DragOperation)result;
}
-QtWebPageEventHandler::QtWebPageEventHandler(WKPageRef pageRef, WebKit::QtViewportInteractionEngine* viewportInteractionEngine)
+QtWebPageEventHandler::QtWebPageEventHandler(WKPageRef pageRef, QQuickWebView* qmlWebView, WebKit::QtViewportInteractionEngine* viewportInteractionEngine)
: m_webPageProxy(toImpl(pageRef))
, m_interactionEngine(viewportInteractionEngine)
, m_panGestureRecognizer(this)
, m_pinchGestureRecognizer(this)
, m_tapGestureRecognizer(this)
+ , m_webView(qmlWebView)
, m_previousClickButton(Qt::NoButton)
, m_clickCount(0)
{
m_interactionEngine->focusEditableArea(QRectF(caret), QRectF(area));
}
+void QtWebPageEventHandler::startDrag(const WebCore::DragData& dragData, PassRefPtr<ShareableBitmap> dragImage)
+{
+ QImage dragQImage;
+ if (dragImage)
+ dragQImage = dragImage->createQImage();
+ else if (dragData.platformData() && dragData.platformData()->hasImage())
+ dragQImage = qvariant_cast<QImage>(dragData.platformData()->imageData());
+
+ DragOperation dragOperationMask = dragData.draggingSourceOperationMask();
+ QMimeData* mimeData = const_cast<QMimeData*>(dragData.platformData());
+ Qt::DropActions supportedDropActions = dragOperationToDropActions(dragOperationMask);
+
+ QPoint clientPosition;
+ QPoint globalPosition;
+ Qt::DropAction actualDropAction = Qt::IgnoreAction;
+
+ if (QWindow* window = m_webView->canvas()) {
+ QDrag* drag = new QDrag(window);
+ drag->setPixmap(QPixmap::fromImage(dragQImage));
+ drag->setMimeData(mimeData);
+ actualDropAction = drag->exec(supportedDropActions);
+ globalPosition = QCursor::pos();
+ clientPosition = window->mapFromGlobal(globalPosition);
+ }
+
+ m_webPageProxy->dragEnded(clientPosition, globalPosition, dropActionToDragOperation(actualDropAction));
+}
+
#include "moc_QtWebPageEventHandler.cpp"
#include <QTouchEvent>
#include <WKPage.h>
+class QQuickWebView;
+
using namespace WebKit;
class QtWebPageEventHandler : public QObject {
Q_OBJECT
public:
- QtWebPageEventHandler(WKPageRef, WebKit::QtViewportInteractionEngine* = 0);
+ QtWebPageEventHandler(WKPageRef, QQuickWebView*, WebKit::QtViewportInteractionEngine* = 0);
~QtWebPageEventHandler();
- static Qt::DropAction dragOperationToDropAction(unsigned dragOperation);
- static Qt::DropActions dragOperationToDropActions(unsigned dragOperations);
- static WebCore::DragOperation dropActionToDragOperation(Qt::DropActions);
-
bool handleEvent(QEvent*);
void setViewportInteractionEngine(QtViewportInteractionEngine*);
QtViewportInteractionEngine* interactionEngine() { return m_interactionEngine; }
+ void startDrag(const WebCore::DragData&, PassRefPtr<ShareableBitmap> dragImage);
+
protected:
WebPageProxy* m_webPageProxy;
QtViewportInteractionEngine* m_interactionEngine;
QtPanGestureRecognizer m_panGestureRecognizer;
QtPinchGestureRecognizer m_pinchGestureRecognizer;
QtTapGestureRecognizer m_tapGestureRecognizer;
+ QQuickWebView* m_webView;
private:
bool handleKeyPressEvent(QKeyEvent*);
return m_history;
}
-void QtWebPageProxy::startDrag(const WebCore::DragData& dragData, PassRefPtr<ShareableBitmap> dragImage)
-{
- QImage dragQImage;
- if (dragImage)
- dragQImage = dragImage->createQImage();
- else if (dragData.platformData() && dragData.platformData()->hasImage())
- dragQImage = qvariant_cast<QImage>(dragData.platformData()->imageData());
-
-
- DragOperation dragOperationMask = dragData.draggingSourceOperationMask();
- QMimeData* mimeData = const_cast<QMimeData*>(dragData.platformData());
- Qt::DropActions supportedDropActions = QtWebPageEventHandler::dragOperationToDropActions(dragOperationMask);
-
- QPoint clientPosition;
- QPoint globalPosition;
- Qt::DropAction actualDropAction = Qt::IgnoreAction;
-
- if (QWindow* window = m_qmlWebView->canvas()) {
- QDrag* drag = new QDrag(window);
- drag->setPixmap(QPixmap::fromImage(dragQImage));
- drag->setMimeData(mimeData);
- actualDropAction = drag->exec(supportedDropActions);
- globalPosition = QCursor::pos();
- clientPosition = window->mapFromGlobal(globalPosition);
- }
-
- m_webPageProxy->dragEnded(clientPosition, globalPosition, QtWebPageEventHandler::dropActionToDragOperation(actualDropAction));
-}
-
void QtWebPageProxy::handleDownloadRequest(DownloadProxy* download)
{
// This function is responsible for hooking up a DownloadProxy to our API layer
void didChangeContentsSize(const WebCore::IntSize&);
void didChangeViewportProperties(const WebCore::ViewportArguments&);
- void startDrag(const WebCore::DragData&, PassRefPtr<ShareableBitmap> dragImage);
void registerEditCommand(PassRefPtr<WebKit::WebEditCommandProxy>, WebKit::WebPageProxy::UndoOrRedo);
void clearAllEditCommands();
bool canUndoRedo(WebPageProxy::UndoOrRedo);