Update reposting of events from menus

This change addresses a potential crash in MenuController::RepostEvent, along with a regression in touch event reposting on Chrome OS.

In MenuController::SetSelectionOnPointerDown the call of Cancel can lead to the deletion of the source of the event. RepostEvent can crash while attempting to transform the event location to screen coordinates. This change performs the transform before cancelling.

In MenuController::OnTouchEvent a call was added to RepostEvent. On Windows this eventually leads to the closing of the menu after capture is released. However this does not occur on Chrome OS, leading to the menu never closing. This change refactors out the Repost/Cancel logic from SetSelectionOnPointerDown into RepostEventAndCancel, providing one location to handle the reposting and shutdown logic differences of Windows and Chrome OS. SetSelectionOnPointerDown and OnTouchEvent now use this.

TEST=MenuControllerTest.AsynchronousRepostEvent, MenuControllerTest.AsynchronousTouchEventRepostEvent, as well as manual testing on a Chromebook to confirm touch regression has been fixed.
BUG=557130

Review URL: https://codereview.chromium.org/1586353004

Cr-Commit-Position: refs/heads/master@{#370143}
3 files changed