Chromium Code Reviews| Index: Tools/DumpRenderTree/chromium/TestRunner/src/EventSender.cpp |
| diff --git a/Tools/DumpRenderTree/chromium/TestRunner/src/EventSender.cpp b/Tools/DumpRenderTree/chromium/TestRunner/src/EventSender.cpp |
| index 0686fefd165bc2c2831d5c576691d70cc81dc2fb..980700cb06a09074a0c1990c48c38918f570e579 100644 |
| --- a/Tools/DumpRenderTree/chromium/TestRunner/src/EventSender.cpp |
| +++ b/Tools/DumpRenderTree/chromium/TestRunner/src/EventSender.cpp |
| @@ -304,6 +304,8 @@ EventSender::EventSender() |
| bindMethod("zoomPageOut", &EventSender::zoomPageOut); |
| bindMethod("scalePageBy", &EventSender::scalePageBy); |
| + bindProperty("forceLayoutOnEvents", &forceLayoutOnEvents); |
| + |
| // When set to true (the default value), we batch mouse move and mouse up |
| // events so we can simulate drag & drop. |
| bindProperty("dragMode", &dragMode); |
| @@ -337,6 +339,7 @@ void EventSender::reset() |
| currentDragEffectsAllowed = WebKit::WebDragOperationNone; |
| pressedButton = WebMouseEvent::ButtonNone; |
| dragMode.set(true); |
| + forceLayoutOnEvents.set(false); |
| #ifdef WIN32 |
| wmKeyDown.set(WM_KEYDOWN); |
| wmKeyUp.set(WM_KEYUP); |
| @@ -424,6 +427,9 @@ void EventSender::mouseDown(const CppArgumentList& arguments, CppVariant* result |
| if (result) // Could be 0 if invoked asynchronously. |
| result->setNull(); |
| + if (shouldForceLayoutOnEvents()) |
| + webview()->layout(); |
|
ojan
2013/05/21 02:12:38
Nit: Could move this into a helper function, Event
|
| + |
| int buttonNumber = getButtonNumberFromSingleArg(arguments); |
| WEBKIT_ASSERT(buttonNumber != -1); |
| @@ -444,6 +450,9 @@ void EventSender::mouseUp(const CppArgumentList& arguments, CppVariant* result) |
| if (result) // Could be 0 if invoked asynchronously. |
| result->setNull(); |
| + if (shouldForceLayoutOnEvents()) |
| + webview()->layout(); |
| + |
| int buttonNumber = getButtonNumberFromSingleArg(arguments); |
| WEBKIT_ASSERT(buttonNumber != -1); |
| @@ -502,6 +511,8 @@ void EventSender::mouseMoveTo(const CppArgumentList& arguments, CppVariant* resu |
| if (arguments.size() < 2 || !arguments[0].isNumber() || !arguments[1].isNumber()) |
| return; |
| + if (shouldForceLayoutOnEvents()) |
| + webview()->layout(); |
| WebPoint mousePos(arguments[0].toInt32(), arguments[1].toInt32()); |
| @@ -654,7 +665,8 @@ void EventSender::keyDown(const CppArgumentList& arguments, CppVariant* result) |
| eventUp.type = WebInputEvent::KeyUp; |
| // EventSender.m forces a layout here, with at least one |
| // test (fast/forms/focus-control-to-page.html) relying on this. |
| - webview()->layout(); |
| + if (shouldForceLayoutOnEvents()) |
| + webview()->layout(); |
| // In the browser, if a keyboard event corresponds to an editor command, |
| // the command will be dispatched to the renderer just before dispatching |
| @@ -700,7 +712,8 @@ void EventSender::dispatchMessage(const CppArgumentList& arguments, CppVariant* |
| if (msg == WM_DEADCHAR || msg == WM_SYSDEADCHAR) |
| return; |
| - webview()->layout(); |
| + if (shouldForceLayoutOnEvents()) |
| + webview()->layout(); |
| unsigned long lparam = static_cast<unsigned long>(arguments[2].toDouble()); |
| webview()->handleInputEvent(WebInputEventFactory::keyboardEvent(0, msg, arguments[1].toInt32(), lparam)); |
| @@ -854,7 +867,8 @@ static vector<WebString> makeMenuItemStringsFor(WebContextMenuData* contextMenu, |
| void EventSender::contextClick(const CppArgumentList& arguments, CppVariant* result) |
| { |
| - webview()->layout(); |
| + if (shouldForceLayoutOnEvents()) |
| + webview()->layout(); |
| updateClickCountForButton(WebMouseEvent::ButtonRight); |
| @@ -1035,7 +1049,8 @@ void EventSender::cancelTouchPoint(const CppArgumentList& arguments, CppVariant* |
| void EventSender::sendCurrentTouchEvent(const WebInputEvent::Type type) |
| { |
| WEBKIT_ASSERT(static_cast<unsigned>(WebTouchEvent::touchesLengthCap) > touchPoints.size()); |
| - webview()->layout(); |
| + if (shouldForceLayoutOnEvents()) |
| + webview()->layout(); |
| WebTouchEvent touchEvent; |
| touchEvent.type = type; |
| @@ -1072,6 +1087,12 @@ void EventSender::handleMouseWheel(const CppArgumentList& arguments, CppVariant* |
| if (arguments.size() < 2 || !arguments[0].isNumber() || !arguments[1].isNumber()) |
| return; |
| + // Force a layout here just to make sure every position has been |
| + // determined before we send events (as well as all the other methods |
| + // that send an event do). |
| + if (shouldForceLayoutOnEvents()) |
| + webview()->layout(); |
| + |
| int horizontal = arguments[0].toInt32(); |
| int vertical = arguments[1].toInt32(); |
| int paged = false; |