[WK2] [Qt] Implement MouseDown/MouseUp/MouseMoveTo functions for WebKit2 EventSender

https://bugs.webkit.org/show_bug.cgi?id=68556

Implement the MouseDown/MouseUp/MouseMoveTo functions on Qt platform.

Source/WebKit2:

Patch by Chang Shu <cshu@webkit.org> on 2011-09-23
Reviewed by Darin Adler.

* Shared/API/c/WKGeometry.h:
(operator==):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::mouseEventSyncForTesting): initialize "handled"

Tools:

Patch by Chang Shu <cshu@webkit.org> on 2011-09-23
Reviewed by Darin Adler.

* WebKitTestRunner/EventSenderProxy.h:
* WebKitTestRunner/InjectedBundle/EventSendingController.h:
* WebKitTestRunner/PlatformWebView.h:
* WebKitTestRunner/mac/EventSenderProxy.mm:
(WTR::EventSenderProxy::EventSenderProxy):
(WTR::EventSenderProxy::leapForward):
* WebKitTestRunner/qt/EventSenderProxyQt.cpp:
(WTR::EventSenderProxy::EventSenderProxy):
(WTR::getMouseButton):
(WTR::getModifiers):
(WTR::EventSenderProxy::updateClickCountForButton):
(WTR::EventSenderProxy::createGraphicsSceneMouseEvent):
(WTR::EventSenderProxy::mouseDown):
(WTR::EventSenderProxy::mouseUp):
(WTR::EventSenderProxy::mouseMoveTo):
(WTR::EventSenderProxy::leapForward):
(WTR::EventSenderProxy::sendOrQueueEvent):
(WTR::EventSenderProxy::replaySavedEvents):
* WebKitTestRunner/qt/PlatformWebViewQt.cpp:
(WTR::PlatformWebView::postEvent):
* WebKitTestRunner/qt/WebKitTestRunner.pro:

LayoutTests:

Unskip passed tests.

Patch by Chang Shu <cshu@webkit.org> on 2011-09-23
Reviewed by Darin Adler.

* platform/qt-wk2/Skipped:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@95878 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 1440c07a
2011-09-23 Chang Shu <cshu@webkit.org>
[WK2] [Qt] Implement MouseDown/MouseUp/MouseMoveTo functions for WebKit2 EventSender
https://bugs.webkit.org/show_bug.cgi?id=68556
Implement the MouseDown/MouseUp/MouseMoveTo functions on Qt platform.
Unskip passed tests.
Reviewed by Darin Adler.
* platform/qt-wk2/Skipped:
gh@apple.com>
Strict mode does not work in non-trivial nested functions.
......@@ -70,19 +70,15 @@ compositing/video/video-poster.html
editing/deleting/delete-by-word-001.html
editing/deleting/delete-by-word-002.html
editing/deleting/delete-ligature-002.html
editing/deleting/delete-ligature-003.html
editing/deleting/merge-paragraph-from-p-with-style.html
editing/deleting/skip-virama-001.html
editing/deleting/smart-delete-001.html
editing/deleting/smart-delete-002.html
editing/deleting/smart-delete-003.html
editing/deleting/smart-delete-004.html
editing/execCommand/findString-2.html
editing/input/emacs-ctrl-o.html
editing/input/option-page-up-down.html
editing/input/scroll-viewport-page-up-down.html
editing/inserting/typing-tab-designmode-forms.html
editing/inserting/typing-tab-designmode.html
editing/pasteboard/4944770-2.html
editing/pasteboard/copy-standalone-image-crash.html
editing/pasteboard/emacs-cntl-y-001.html
editing/pasteboard/smart-paste-001.html
......@@ -92,13 +88,9 @@ editing/pasteboard/smart-paste-004.html
editing/pasteboard/smart-paste-005.html
editing/pasteboard/smart-paste-007.html
editing/pasteboard/smart-paste-008.html
editing/selection/14971.html
editing/selection/5354455-1.html
editing/selection/5354455-2.html
editing/selection/anchor-focus2.html
editing/selection/anchor-focus3.html
editing/selection/button-right-click.html
editing/selection/click-in-focusable-link-should-not-clear-selection.html
editing/selection/click-in-margins-inside-editable-div.html
editing/selection/click-in-padding-with-multiple-line-boxes.html
editing/selection/context-menu-on-text.html
......@@ -106,40 +98,28 @@ editing/selection/doubleclick-crash.html
editing/selection/doubleclick-whitespace-crash.html
editing/selection/doubleclick-whitespace-img-crash.html
editing/selection/doubleclick-whitespace.html
editing/selection/drag-select-1.html
editing/selection/drag-select-rapidly.html
editing/selection/drag-start-event-client-x-y.html
editing/selection/empty-cell-right-click.html
editing/selection/expanding-selections.html
editing/selection/expanding-selections2.html
editing/selection/fake-doubleclick.html
editing/selection/inline-closest-leaf-child.html
editing/selection/last-empty-inline.html
editing/selection/move-begin-end.html
editing/selection/paragraph-granularity.html
editing/selection/select-out-of-editable.html
editing/selection/select-out-of-floated-contenteditable.html
editing/selection/select-out-of-floated-input.html
editing/selection/select-out-of-floated-textarea.html
editing/selection/selection-actions.html
editing/selection/user-drag-element-and-user-select-none.html
editing/selection/word-granularity.html
editing/undo/undo-smart-delete-reversed-selection.html
editing/undo/undo-smart-delete-word.html
editing/selection/caret-ltr-right.html
editing/selection/caret-rtl-2-left.html
editing/selection/click-before-and-after-table.html
editing/selection/inline-closest-leaf-child.html
fast/block/positioning/hittest-on-relative-positioned-children.html
fast/dom/vertical-scrollbar-in-rtl.html
fast/dynamic/layer-hit-test-crash.html
fast/encoding/mailto-always-utf-8.html
fast/events/access-key-self-destruct.html
fast/events/autoscroll-in-textfield.html
fast/events/autoscroll-nonscrollable-iframe-in-scrollable-div.html
fast/events/autoscroll-with-non-scrollable-parent.html
fast/events/bogus-dropEffect-effectAllowed.html
fast/events/context-no-deselect.html
fast/events/context-onmousedown-event.html
fast/events/contextmenu-scrolled-page-with-frame.html
fast/events/continuous-platform-wheelevent-in-scrolling-div.html
fast/events/dblclick-addEventListener.html
fast/events/fire-mousedown-while-pressing-mouse-button.html
fast/events/inputText-never-fired-on-keydown-cancel.html
fast/events/mouse-click-events.html
fast/events/mouseup-from-button2.html
......@@ -153,22 +133,19 @@ fast/events/scroll-in-scaled-page-with-overflow-hidden.html
fast/events/selectstart-prevent-selection-on-right-click.html
fast/events/wheelevent-in-horizontal-scrollbar-in-rtl.html
fast/events/wheelevent-in-vertical-scrollbar-in-rtl.html
fast/events/zoom-dblclick.html
fast/forms/access-key.html
fast/forms/focus-change-on-keypress.html
fast/forms/focus-selection-textarea.html
fast/forms/implicit-submission.html
fast/forms/input-text-double-click.html
fast/forms/interactive-validation-attach-assertion.html
fast/forms/legend-access-key.html
fast/forms/onselect-textfield.html
fast/forms/search-cancel-button-mouseup.html
fast/forms/select-accesskey.html
fast/forms/range/range-drag.html
fast/loader/policy-delegate-action-hit-test-zoomed.html
fast/repaint/selection-rl.html
fast/text/offsetForPosition-complex-fallback.html
fast/text/reset-drag-on-mouse-down.html
fast/writing-mode/horizontal-bt-replaced-selection.html
fast/writing-mode/vertical-lr-replaced-selection.html
fast/writing-mode/vertical-rl-replaced-selection.html
plugins/keyboard-events.html
scrollbars/scrollevent-iframe-no-scrolling-wheel.html
......@@ -177,8 +154,6 @@ fast/forms/form-associated-element-crash3.html
http/tests/security/isolatedWorld/userGestureEvents.html
plugins/resize-from-plugin.html
svg/custom/foreignObject-crash-on-hover.xml
svg/custom/mouse-move-on-svg-container-standalone.svg
svg/custom/mouse-move-on-svg-container.xhtml
svg/custom/mouse-move-on-svg-root-standalone.svg
svg/custom/mouse-move-on-svg-root.xhtml
......
2011-09-23 Chang Shu <cshu@webkit.org>
[WK2] [Qt] Implement MouseDown/MouseUp/MouseMoveTo functions for WebKit2 EventSender
https://bugs.webkit.org/show_bug.cgi?id=68556
Implement the MouseDown/MouseUp/MouseMoveTo functions on Qt platform.
Reviewed by Darin Adler.
* Shared/API/c/WKGeometry.h:
(operator==):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::mouseEventSyncForTesting): initialize "handled"
2011-09-23 Anders Carlsson <andersca@apple.com>
Move WebHitTestResult files to Shared/ in the Xcode project
......
......@@ -91,6 +91,11 @@ WK_EXPORT WKRect WKRectGetValue(WKRectRef rect);
#ifdef __cplusplus
}
inline bool operator==(const WKPoint& a, const WKPoint& b)
{
return a.x == b.x && a.y == b.y;
}
#endif
#endif /* WKGeometry_h */
......@@ -1056,11 +1056,8 @@ void WebPage::mouseEventSyncForTesting(const WebMouseEvent& mouseEvent, bool& ha
handled = true;
return;
}
if (m_pageOverlay) {
// Let the page overlay handle the event.
handled = m_pageOverlay->mouseEvent(mouseEvent);
}
handled = m_pageOverlay && m_pageOverlay->mouseEvent(mouseEvent);
if (!handled) {
CurrentEvent currentEvent(mouseEvent);
......
2011-09-23 Chang Shu <cshu@webkit.org>
[WK2] [Qt] Implement MouseDown/MouseUp/MouseMoveTo functions for WebKit2 EventSender
https://bugs.webkit.org/show_bug.cgi?id=68556
Implement the MouseDown/MouseUp/MouseMoveTo functions on Qt platform.
Reviewed by Darin Adler.
* WebKitTestRunner/EventSenderProxy.h:
* WebKitTestRunner/InjectedBundle/EventSendingController.h:
* WebKitTestRunner/PlatformWebView.h:
* WebKitTestRunner/mac/EventSenderProxy.mm:
(WTR::EventSenderProxy::EventSenderProxy):
(WTR::EventSenderProxy::leapForward):
* WebKitTestRunner/qt/EventSenderProxyQt.cpp:
(WTR::EventSenderProxy::EventSenderProxy):
(WTR::getMouseButton):
(WTR::getModifiers):
(WTR::EventSenderProxy::updateClickCountForButton):
(WTR::EventSenderProxy::createGraphicsSceneMouseEvent):
(WTR::EventSenderProxy::mouseDown):
(WTR::EventSenderProxy::mouseUp):
(WTR::EventSenderProxy::mouseMoveTo):
(WTR::EventSenderProxy::leapForward):
(WTR::EventSenderProxy::sendOrQueueEvent):
(WTR::EventSenderProxy::replaySavedEvents):
* WebKitTestRunner/qt/PlatformWebViewQt.cpp:
(WTR::PlatformWebView::postEvent):
* WebKitTestRunner/qt/WebKitTestRunner.pro:
2011-09-23 Lei Zhang <thestig@chromium.org>
[chromium] Make the layout test script's kill timeout proportional to --time-out-ms
......@@ -33,23 +33,12 @@ class TestController;
class EventSenderProxy {
public:
EventSenderProxy(TestController* testController)
: m_testController(testController)
, m_time(0)
, m_position()
, m_leftMouseButtonDown(false)
, m_clickCount(0)
, m_clickTime(0)
, m_clickPosition()
, m_clickButton(kWKEventMouseButtonNoButton)
, eventNumber(0)
{
}
EventSenderProxy(TestController*);
void mouseDown(unsigned button, WKEventModifiers);
void mouseUp(unsigned button, WKEventModifiers);
void mouseMoveTo(double x, double y);
void leapForward(int milliseconds) { m_time += milliseconds / 1000.0; }
void leapForward(int milliseconds);
void keyDown(WKStringRef key, WKEventModifiers, unsigned location);
......@@ -59,6 +48,12 @@ private:
double currentEventTime() { return m_time; }
void updateClickCountForButton(int button);
#if PLATFORM(QT)
void sendOrQueueEvent(QEvent*);
void replaySavedEvents();
QGraphicsSceneMouseEvent* createGraphicsSceneMouseEvent(QEvent::Type, const QPoint& pos, const QPoint& screenPos, Qt::MouseButton, Qt::MouseButtons, Qt::KeyboardModifiers);
#endif
double m_time;
WKPoint m_position;
bool m_leftMouseButtonDown;
......@@ -66,7 +61,11 @@ private:
double m_clickTime;
WKPoint m_clickPosition;
WKEventMouseButton m_clickButton;
#if PLATFORM(MAC)
int eventNumber;
#elif PLATFORM(QT)
Qt::MouseButtons m_mouseButtons;
#endif
};
} // namespace WTR
......
......@@ -31,7 +31,7 @@
#include <WebKit2/WKGeometry.h>
#include <wtf/PassRefPtr.h>
#if !PLATFORM(MAC)
#if !PLATFORM(MAC) && !PLATFORM(QT)
#define USE_WEBPROCESS_EVENT_SIMULATION
#endif
......
......@@ -67,6 +67,7 @@ public:
#if PLATFORM(QT)
bool sendEvent(QEvent*);
void postEvent(QEvent*);
#endif
WKRect windowFrame();
......
......@@ -97,9 +97,17 @@ static int buildModifierFlags(WKEventModifiers modifiers)
return flags;
}
static bool operator==(const WKPoint& a, const WKPoint& b)
EventSenderProxy::EventSenderProxy(TestController* testController)
: m_testController(testController)
, m_time(0)
, m_position()
, m_leftMouseButtonDown(false)
, m_clickCount(0)
, m_clickTime(0)
, m_clickPosition()
, m_clickButton(kWKEventMouseButtonNoButton)
, eventNumber(0)
{
return a.x == b.x && a.y == b.y;
}
void EventSenderProxy::updateClickCountForButton(int button)
......@@ -183,6 +191,11 @@ void EventSenderProxy::mouseMoveTo(double x, double y)
[targetView mouseMoved:event];
}
void EventSenderProxy::leapForward(int milliseconds)
{
m_time += milliseconds / 1000.0;
}
void EventSenderProxy::keyDown(WKStringRef key, WKEventModifiers modifiers, unsigned keyLocation)
{
NSString* character = [NSString stringWithCString:toSTD(key).c_str()
......
......@@ -29,7 +29,7 @@
#include "PlatformWebView.h"
#include "TestController.h"
#include <QKeyEvent>
#include <WebCore/NotImplemented.h>
#include <QtTest/QtTest>
#include <WebKit2/WKPagePrivate.h>
#include <WebKit2/WKStringQt.h>
......@@ -42,7 +42,56 @@ namespace WTR {
#define KEYCODE_UPARROW 0xf700
#define KEYCODE_DOWNARROW 0xf701
Qt::KeyboardModifiers getModifiers(WKEventModifiers modifiersRef)
struct WTREventQueue {
QEvent* m_event;
int m_delay;
};
static WTREventQueue eventQueue[1024];
static unsigned endOfQueue;
static unsigned startOfQueue;
EventSenderProxy::EventSenderProxy(TestController* testController)
: m_testController(testController)
, m_time(0)
, m_position()
, m_leftMouseButtonDown(false)
, m_clickCount(0)
, m_clickTime(0)
, m_clickPosition()
, m_clickButton(kWKEventMouseButtonNoButton)
, m_mouseButtons(0)
{
memset(eventQueue, 0, sizeof(eventQueue));
endOfQueue = 0;
startOfQueue = 0;
}
static Qt::MouseButton getMouseButton(unsigned button)
{
Qt::MouseButton mouseButton;
switch (button) {
case 0:
mouseButton = Qt::LeftButton;
break;
case 1:
mouseButton = Qt::MidButton;
break;
case 2:
mouseButton = Qt::RightButton;
break;
case 3:
// fast/events/mouse-click-events expects the 4th button to be treated as the middle button
mouseButton = Qt::MidButton;
break;
default:
mouseButton = Qt::LeftButton;
break;
}
return mouseButton;
}
static Qt::KeyboardModifiers getModifiers(WKEventModifiers modifiersRef)
{
Qt::KeyboardModifiers modifiers = 0;
......@@ -191,19 +240,106 @@ void EventSenderProxy::keyDown(WKStringRef keyRef, WKEventModifiers modifiersRef
m_testController->mainWebView()->sendEvent(&event2);
}
void EventSenderProxy::mouseDown(unsigned, WKEventModifiers)
void EventSenderProxy::updateClickCountForButton(int button)
{
if (m_time - m_clickTime < QApplication::doubleClickInterval() / 1000.0 && m_position == m_clickPosition && button == m_clickButton) {
++m_clickCount;
m_clickTime = m_time;
return;
}
m_clickCount = 1;
m_clickTime = m_time;
m_clickPosition = m_position;
m_clickButton = button;
}
QGraphicsSceneMouseEvent* EventSenderProxy::createGraphicsSceneMouseEvent(QEvent::Type type, const QPoint& pos, const QPoint& screenPos, Qt::MouseButton button, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers)
{
QGraphicsSceneMouseEvent* event;
event = new QGraphicsSceneMouseEvent(type);
event->setPos(pos);
event->setScreenPos(screenPos);
event->setButton(button);
event->setButtons(buttons);
event->setModifiers(modifiers);
return event;
}
void EventSenderProxy::mouseDown(unsigned button, WKEventModifiers wkModifiers)
{
Qt::KeyboardModifiers modifiers = getModifiers(wkModifiers);
Qt::MouseButton mouseButton = getMouseButton(button);
updateClickCountForButton(button);
m_mouseButtons |= mouseButton;
QPoint mousePos(m_position.x, m_position.y);
QGraphicsSceneMouseEvent* event = createGraphicsSceneMouseEvent((m_clickCount == 2) ? QEvent::GraphicsSceneMouseDoubleClick : QEvent::GraphicsSceneMousePress,
mousePos, mousePos, mouseButton, m_mouseButtons, modifiers);
sendOrQueueEvent(event);
}
void EventSenderProxy::mouseUp(unsigned button, WKEventModifiers)
{
Qt::MouseButton mouseButton = getMouseButton(button);
m_mouseButtons &= ~mouseButton;
QPoint mousePos(m_position.x, m_position.y);
QGraphicsSceneMouseEvent* event = createGraphicsSceneMouseEvent(QEvent::GraphicsSceneMouseRelease,
mousePos, mousePos, mouseButton, m_mouseButtons, Qt::NoModifier);
sendOrQueueEvent(event);
}
void EventSenderProxy::mouseMoveTo(double x, double y)
{
notImplemented();
m_position.x = x;
m_position.y = y;
QPoint mousePos(m_position.x, m_position.y);
QGraphicsSceneMouseEvent* event = createGraphicsSceneMouseEvent(QEvent::GraphicsSceneMouseMove,
mousePos, mousePos, Qt::NoButton, m_mouseButtons, Qt::NoModifier);
sendOrQueueEvent(event);
}
void EventSenderProxy::leapForward(int ms)
{
eventQueue[endOfQueue].m_delay = ms;
}
void EventSenderProxy::mouseUp(unsigned, WKEventModifiers)
void EventSenderProxy::sendOrQueueEvent(QEvent* event)
{
notImplemented();
if (endOfQueue == startOfQueue && !eventQueue[endOfQueue].m_delay) {
m_testController->mainWebView()->sendEvent(event);
delete event;
return;
}
eventQueue[endOfQueue++].m_event = event;
eventQueue[endOfQueue].m_delay = 0;
replaySavedEvents();
}
void EventSenderProxy::mouseMoveTo(double, double)
void EventSenderProxy::replaySavedEvents()
{
notImplemented();
if (startOfQueue < endOfQueue) {
while (!eventQueue[startOfQueue].m_delay && startOfQueue < endOfQueue) {
QEvent* ev = eventQueue[startOfQueue++].m_event;
m_testController->mainWebView()->postEvent(ev);
}
if (startOfQueue == endOfQueue) {
startOfQueue = 0;
endOfQueue = 0;
} else {
QTest::qWait(eventQueue[startOfQueue].m_delay);
eventQueue[startOfQueue].m_delay = 0;
}
}
}
} // namespace WTR
......@@ -107,4 +107,9 @@ bool PlatformWebView::sendEvent(QEvent* event)
return QCoreApplication::sendEvent(m_view->wkView(), event);
}
void PlatformWebView::postEvent(QEvent* event)
{
QCoreApplication::postEvent(m_view->wkView(), event);
}
} // namespace WTR
......@@ -31,7 +31,7 @@ unix:!mac:!symbian:!embedded {
PKGCONFIG += fontconfig
}
QT = core gui network declarative
QT = core gui network declarative testlib
HEADERS = \
$$BASEDIR/EventSenderProxy.h \
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment