Commit 05d03036 authored by joi@chromium.org's avatar joi@chromium.org

Revert 113177 - process all ui events before posting closure because menu...

Revert 113177 - process all ui events before posting closure because menu depends on ui events to quit.
 Add new RunClosureAfterAllPendingUIEvents for toolkit views.

BUG=104359
TEST=BookmarkBarViewTest in interactive_ui_tests will pass


Review URL: http://codereview.chromium.org/8799020

Reason for revert: http://build.chromium.org/p/chromium.chromiumos/builders/Linux%20ChromeOS%20Aura/builds/1514

TBR=oshima@chromium.org
Review URL: http://codereview.chromium.org/8821012

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@113183 0039d316-1c4b-4281-b951-d872f2087c98
parent e92569c2
......@@ -97,11 +97,6 @@ void MoveMouseToCenterAndPress(
int state,
const base::Closure& task);
#if defined(TOOLKIT_VIEWS)
// Runs |closure| after processing all pending ui events.
void RunClosureAfterAllPendingUIEvents(const base::Closure& closure);
#endif
} // ui_controls
#endif // CHROME_BROWSER_AUTOMATION_UI_CONTROLS_H_
......@@ -5,7 +5,6 @@
#include "chrome/browser/automation/ui_controls.h"
#include "base/logging.h"
#include "base/message_loop.h"
#include "chrome/browser/automation/ui_controls_internal.h"
#include "ui/aura/desktop.h"
#include "ui/views/view.h"
......@@ -70,9 +69,4 @@ void MoveMouseToCenterAndPress(views::View* view,
SendMouseEventsNotifyWhenDone(button, state, task);
}
void RunClosureAfterAllPendingUIEvents(const base::Closure& task) {
// On windows, posting UI events is synchronous so just post the closure.
MessageLoopForUI::current()->PostTask(FROM_HERE, task);
}
} // namespace ui_controls
......@@ -70,6 +70,22 @@ bool Matcher(const base::NativeEvent& event) {
event->xclient.message_type == MarkerEventAtom();
}
void RunClosureAfterEvents(const base::Closure closure) {
if (closure.is_null())
return;
static XEvent* marker_event = NULL;
if (!marker_event) {
marker_event = new XEvent();
marker_event->xclient.type = ClientMessage;
marker_event->xclient.display = NULL;
marker_event->xclient.window = None;
marker_event->xclient.format = 8;
}
marker_event->xclient.message_type = MarkerEventAtom();
aura::Desktop::GetInstance()->PostNativeEvent(marker_event);
new EventWaiter(closure, &Matcher);
}
} // namespace
namespace ui_controls {
......@@ -117,7 +133,9 @@ bool SendKeyPressNotifyWhenDone(gfx::NativeWindow window,
SetMaskAndKeycodeThenSend(&xevent, ShiftMask, XK_Shift_L);
if (alt)
SetMaskAndKeycodeThenSend(&xevent, Mod1Mask, XK_Alt_L);
xevent.xkey.keycode = ui::XKeysymForWindowsKeyCode(key, shift);
xevent.xkey.keycode =
XKeysymToKeycode(base::MessagePumpX::GetDefaultXDisplay(),
ui::XKeysymForWindowsKeyCode(key, shift));
aura::Desktop::GetInstance()->PostNativeEvent(&xevent);
// Send key release events.
......@@ -130,7 +148,7 @@ bool SendKeyPressNotifyWhenDone(gfx::NativeWindow window,
if (control)
SetKeycodeAndSendThenUnmask(&xevent, ControlMask, XK_Control_L);
DCHECK(!xevent.xkey.state);
RunClosureAfterAllPendingUIEvents(closure);
RunClosureAfterEvents(closure);
return true;
}
......@@ -147,7 +165,7 @@ bool SendMouseMoveNotifyWhenDone(long x, long y, const base::Closure& closure) {
xmotion->same_screen = True;
// Desktop will take care of other necessary fields.
aura::Desktop::GetInstance()->PostNativeEvent(&xevent);
RunClosureAfterAllPendingUIEvents(closure);
RunClosureAfterEvents(closure);
return false;
}
......@@ -190,7 +208,7 @@ bool SendMouseEventsNotifyWhenDone(MouseButton type,
xevent.xbutton.type = ButtonRelease;
desktop->PostNativeEvent(&xevent);
}
RunClosureAfterAllPendingUIEvents(closure);
RunClosureAfterEvents(closure);
return false;
}
......@@ -208,20 +226,4 @@ void MoveMouseToCenterAndPress(views::View* view, MouseButton button,
SendMouseEventsNotifyWhenDone(button, state, closure);
}
void RunClosureAfterAllPendingUIEvents(const base::Closure& closure) {
if (closure.is_null())
return;
static XEvent* marker_event = NULL;
if (!marker_event) {
marker_event = new XEvent();
marker_event->xclient.type = ClientMessage;
marker_event->xclient.display = NULL;
marker_event->xclient.window = None;
marker_event->xclient.format = 8;
}
marker_event->xclient.message_type = MarkerEventAtom();
aura::Desktop::GetInstance()->PostNativeEvent(marker_event);
new EventWaiter(closure, &Matcher);
}
} // namespace ui_controls
......@@ -310,13 +310,4 @@ void MoveMouseToCenterAndPress(GtkWidget* widget,
}
#endif
#if defined(TOOLKIT_VIEWS)
void RunClosureAfterAllPendingUIEvents(const base::Closure& task) {
// Send noop event and run task.
int x, y;
gdk_window_at_pointer(&x, &y);
SendMouseMoveNotifyWhenDone(x, y, task);
}
#endif
} // namespace ui_controls
......@@ -27,7 +27,6 @@ bool SendMouseMoveImpl(long x, long y, const base::Closure& task);
bool SendMouseEventsImpl(MouseButton type,
int state,
const base::Closure& task);
void RunClosureAfterAllPendingUITasksImpl(const base::Closure& task);
#endif
} // namespace internal
......
......@@ -5,7 +5,6 @@
#include "chrome/browser/automation/ui_controls.h"
#include "base/callback.h"
#include "base/message_loop.h"
#include "chrome/browser/automation/ui_controls_internal.h"
#include "ui/gfx/point.h"
#include "ui/views/view.h"
......@@ -66,9 +65,4 @@ void MoveMouseToCenterAndPress(views::View* view,
SendMouseEventsNotifyWhenDone(button, state, task);
}
void RunClosureAfterAllPendingUIEvents(const base::Closure& closure) {
// On windows, posting UI events is synchronous so just post the closure.
MessageLoopForUI::current()->PostTask(FROM_HERE, closure);
}
} // ui_controls
......@@ -70,11 +70,9 @@ void ViewEventTestBase::Done() {
PostMessage(window_->GetNativeWindow(), WM_USER, 0, 0);
#endif
// If we're in a nested message loop, as is the case with menus, we
// need to quit twice. The second quit does that for us. Finish all
// pending UI events before posting closure because events it may be
// executed before UI events are executed.
ui_controls::RunClosureAfterAllPendingUIEvents(MessageLoop::QuitClosure());
// If we're in a nested message loop, as is the case with menus, we need
// to quit twice. The second quit does that for us.
MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure());
}
void ViewEventTestBase::SetUp() {
......
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