[SCM] WebKit Debian packaging branch, webkit-1.2, updated. upstream/1.1.90-6072-g9a69373
eric at webkit.org
eric at webkit.org
Thu Apr 8 00:54:50 UTC 2010
The following commit has been merged in the webkit-1.2 branch:
commit 57bd733731e1659b537d61db2b0222eed38d2401
Author: eric at webkit.org <eric at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Tue Jan 5 19:44:02 2010 +0000
2010-01-05 Yael Aharon <yael.aharon at nokia.com>
Reviewed by Kenneth Rohde Christiansen.
[Qt] Reimplement EventSender::leapForward
https://bugs.webkit.org/show_bug.cgi?id=33114
Follow Windows implementation of leapForward. When leapForward is called,
messages are queued and posted after the timeout. A new event loop is created to
handle those messages and the additional messages that are created as a result.
* DumpRenderTree/qt/DumpRenderTree.pro:
* DumpRenderTree/qt/EventSenderQt.cpp:
(EventSender::EventSender):
(EventSender::mouseDown):
(EventSender::mouseUp):
(EventSender::mouseMoveTo):
(EventSender::leapForward):
(EventSender::sendOrQueueEvent):
(EventSender::replaySavedEvents):
(EventSender::eventFilter):
* DumpRenderTree/qt/EventSenderQt.h:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@52816 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index 4b1b9c8..bcb228e 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,3 +1,26 @@
+2010-01-05 Yael Aharon <yael.aharon at nokia.com>
+
+ Reviewed by Kenneth Rohde Christiansen.
+
+ [Qt] Reimplement EventSender::leapForward
+ https://bugs.webkit.org/show_bug.cgi?id=33114
+
+ Follow Windows implementation of leapForward. When leapForward is called,
+ messages are queued and posted after the timeout. A new event loop is created to
+ handle those messages and the additional messages that are created as a result.
+
+ * DumpRenderTree/qt/DumpRenderTree.pro:
+ * DumpRenderTree/qt/EventSenderQt.cpp:
+ (EventSender::EventSender):
+ (EventSender::mouseDown):
+ (EventSender::mouseUp):
+ (EventSender::mouseMoveTo):
+ (EventSender::leapForward):
+ (EventSender::sendOrQueueEvent):
+ (EventSender::replaySavedEvents):
+ (EventSender::eventFilter):
+ * DumpRenderTree/qt/EventSenderQt.h:
+
2010-01-05 Adam Barth <abarth at webkit.org>
Reviewed by Darin Adler.
diff --git a/WebKitTools/DumpRenderTree/qt/DumpRenderTree.pro b/WebKitTools/DumpRenderTree/qt/DumpRenderTree.pro
index f138b7a..0c3281b 100644
--- a/WebKitTools/DumpRenderTree/qt/DumpRenderTree.pro
+++ b/WebKitTools/DumpRenderTree/qt/DumpRenderTree.pro
@@ -20,7 +20,7 @@ DESTDIR = ../../../bin
CONFIG += link_pkgconfig
PKGCONFIG += fontconfig
-QT = core gui network
+QT = core gui network testlib
macx: QT += xml
HEADERS = $$BASEDIR/WorkQueue.h \
diff --git a/WebKitTools/DumpRenderTree/qt/EventSenderQt.cpp b/WebKitTools/DumpRenderTree/qt/EventSenderQt.cpp
index b3459cb..13c3419 100644
--- a/WebKitTools/DumpRenderTree/qt/EventSenderQt.cpp
+++ b/WebKitTools/DumpRenderTree/qt/EventSenderQt.cpp
@@ -31,6 +31,8 @@
//#include <QtDebug>
+#include <QtTest/QtTest>
+
#define KEYCODE_DEL 127
#define KEYCODE_BACKSPACE 8
#define KEYCODE_LEFTARROW 0xf702
@@ -38,11 +40,28 @@
#define KEYCODE_UPARROW 0xf700
#define KEYCODE_DOWNARROW 0xf701
+#define DRT_MESSAGE_DONE (QEvent::User + 1)
+
+struct DRTEventQueue {
+ QEvent* m_event;
+ int m_delay;
+};
+
+static DRTEventQueue eventQueue[1024];
+static unsigned endOfQueue;
+static unsigned startOfQueue;
EventSender::EventSender(QWebPage* parent)
: QObject(parent)
{
m_page = parent;
+ m_mouseButtonPressed = false;
+ m_drag = false;
+ memset(eventQueue, 0, sizeof(eventQueue));
+ endOfQueue = 0;
+ startOfQueue = 0;
+ m_eventLoop = 0;
+ m_page->view()->installEventFilter(this);
}
void EventSender::mouseDown(int button)
@@ -70,8 +89,8 @@ void EventSender::mouseDown(int button)
m_mouseButtons |= mouseButton;
// qDebug() << "EventSender::mouseDown" << frame;
- QMouseEvent event(QEvent::MouseButtonPress, m_mousePos, m_mousePos, mouseButton, m_mouseButtons, Qt::NoModifier);
- QApplication::sendEvent(m_page, &event);
+ QMouseEvent* event = new QMouseEvent(QEvent::MouseButtonPress, m_mousePos, m_mousePos, mouseButton, m_mouseButtons, Qt::NoModifier);
+ sendOrQueueEvent(event);
}
void EventSender::mouseUp(int button)
@@ -99,21 +118,21 @@ void EventSender::mouseUp(int button)
m_mouseButtons &= ~mouseButton;
// qDebug() << "EventSender::mouseUp" << frame;
- QMouseEvent event(QEvent::MouseButtonRelease, m_mousePos, m_mousePos, mouseButton, m_mouseButtons, Qt::NoModifier);
- QApplication::sendEvent(m_page, &event);
+ QMouseEvent* event = new QMouseEvent(QEvent::MouseButtonRelease, m_mousePos, m_mousePos, mouseButton, m_mouseButtons, Qt::NoModifier);
+ sendOrQueueEvent(event);
}
void EventSender::mouseMoveTo(int x, int y)
{
// qDebug() << "EventSender::mouseMoveTo" << x << y;
m_mousePos = QPoint(x, y);
- QMouseEvent event(QEvent::MouseMove, m_mousePos, m_mousePos, Qt::NoButton, m_mouseButtons, Qt::NoModifier);
- QApplication::sendEvent(m_page, &event);
+ QMouseEvent* event = new QMouseEvent(QEvent::MouseMove, m_mousePos, m_mousePos, Qt::NoButton, m_mouseButtons, Qt::NoModifier);
+ sendOrQueueEvent(event);
}
void EventSender::leapForward(int ms)
{
- m_timeLeap += ms;
+ eventQueue[endOfQueue].m_delay = ms;
//qDebug() << "EventSender::leapForward" << ms;
}
@@ -375,3 +394,76 @@ redo:
return frame;
return 0;
}
+
+void EventSender::sendOrQueueEvent(QEvent* event)
+{
+ // Mouse move events are queued if
+ // 1. A previous event was queued.
+ // 2. A delay was set-up by leapForward().
+ // 3. A call to mouseMoveTo while the mouse button is pressed could initiate a drag operation, and that does not return until mouseUp is processed.
+ // To be safe and avoid a deadlock, this event is queued.
+ if (endOfQueue == startOfQueue && !eventQueue[endOfQueue].m_delay && (!(m_mouseButtonPressed && (m_eventLoop && event->type() == QEvent::MouseButtonRelease)))) {
+ QApplication::sendEvent(m_page->view(), event);
+ delete event;
+ return;
+ }
+ eventQueue[endOfQueue++].m_event = event;
+ eventQueue[endOfQueue].m_delay = 0;
+ replaySavedEvents(event->type() != QEvent::MouseMove);
+}
+
+void EventSender::replaySavedEvents(bool flush)
+{
+ if (startOfQueue < endOfQueue) {
+ // First send all the events that are ready to be sent
+ while (!eventQueue[startOfQueue].m_delay && startOfQueue < endOfQueue) {
+ QEvent* ev = eventQueue[startOfQueue++].m_event;
+ QApplication::postEvent(m_page->view(), ev); // ev deleted by the system
+ }
+ if (startOfQueue == endOfQueue) {
+ // Reset the queue
+ startOfQueue = 0;
+ endOfQueue = 0;
+ } else {
+ QTest::qWait(eventQueue[startOfQueue].m_delay);
+ eventQueue[startOfQueue].m_delay = 0;
+ }
+ }
+ if (!flush)
+ return;
+
+ // Send a marker event, it will tell us when it is safe to exit the new event loop
+ QEvent* drtEvent = new QEvent((QEvent::Type)DRT_MESSAGE_DONE);
+ QApplication::postEvent(m_page->view(), drtEvent);
+
+ // Start an event loop for async handling of Drag & Drop
+ m_eventLoop = new QEventLoop;
+ m_eventLoop->exec();
+ delete m_eventLoop;
+ m_eventLoop = 0;
+}
+
+bool EventSender::eventFilter(QObject* watched, QEvent* event)
+{
+ if (watched != m_page->view())
+ return false;
+ switch (event->type()) {
+ case QEvent::Leave:
+ return true;
+ case QEvent::MouseButtonPress:
+ m_mouseButtonPressed = true;
+ break;
+ case QEvent::MouseMove:
+ if (m_mouseButtonPressed)
+ m_drag = true;
+ break;
+ case QEvent::MouseButtonRelease:
+ m_mouseButtonPressed = false;
+ m_drag = false;
+ break;
+ case DRT_MESSAGE_DONE:
+ m_eventLoop->exit();
+ return true;
+ }
+ return false;
+}
diff --git a/WebKitTools/DumpRenderTree/qt/EventSenderQt.h b/WebKitTools/DumpRenderTree/qt/EventSenderQt.h
index 8e9467a..0a30cd5 100644
--- a/WebKitTools/DumpRenderTree/qt/EventSenderQt.h
+++ b/WebKitTools/DumpRenderTree/qt/EventSenderQt.h
@@ -31,6 +31,7 @@
#include <QApplication>
#include <QEvent>
+#include <QEventLoop>
#include <QMouseEvent>
#include <QObject>
#include <QPoint>
@@ -48,6 +49,7 @@ class EventSender : public QObject {
Q_OBJECT
public:
EventSender(QWebPage* parent);
+ virtual bool eventFilter(QObject* watched, QEvent* event);
public slots:
void mouseDown(int button = 0);
@@ -69,10 +71,15 @@ public slots:
private:
void sendTouchEvent(QEvent::Type);
+ void sendOrQueueEvent(QEvent*);
+ void replaySavedEvents(bool flush);
QPoint m_mousePos;
Qt::MouseButtons m_mouseButtons;
QWebPage* m_page;
int m_timeLeap;
+ bool m_mouseButtonPressed;
+ bool m_drag;
+ QEventLoop* m_eventLoop;
QWebFrame* frameUnderMouse() const;
#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
QList<QTouchEvent::TouchPoint> m_touchPoints;
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list