• Piotr Kalinowski's avatar
    Route ShowContextMenuAtPoint correctly for emulated events · a5289b95
    Piotr Kalinowski authored
    RWHIER::ShowContextMenutAtPoint used last_mouse_move_target_ to
    determine RenderWidgetHostImpl instance to forward the call to. It
    acknowledged that tracked view may have been destroyed since remembering
    it, and it first checked if it was in view map.
    
    This check used to fail for nullptr without crashing leading to an early
    return. However, IsViewInMap implementation changed since then and now
    if there were no mouse enter/leave events earlier, the browser would
    crash trying to dereference nullptr.
    
    This happens when devtools on the desktop connect to a mobile instance
    of the browser and forward a right click event on the page.
    TouchEmulator will convert it directly to the call to show context menu,
    but since remote devtools do not forward mouse move events, as the
    mobile does not even have a mouse, this variable will be empty.
    
    However, TouchEmulator already has a target view associated with
    emulated touch event that is being converted to context menu request. So
    pass that along and use it.
    
    Bug: 987665
    Change-Id: I1bf8012827e9397f911a3c12efc984815ad37901
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1718571Reviewed-by: default avatarJames MacLean <wjmaclean@chromium.org>
    Reviewed-by: default avatarKen Buchanan <kenrb@chromium.org>
    Commit-Queue: James MacLean <wjmaclean@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#682308}
    a5289b95
touch_emulator.cc 20.2 KB