Bug 1347351 - nsMenuBarListener::KeyPress() should wait reply event for handling F10 key r?smaug draft
authorMasayuki Nakano <masayuki@d-toybox.com>
Thu, 20 Jul 2017 17:54:44 +0900
changeset 613986 715bbeb41d0e8a4b064e4e416b931977097f8b16
parent 613985 3807492e4156dfea9c42795709975df6bcdc38c7
child 638747 7a8371cb0cc479c826301e420f614da4c3aea04a
push id69883
push usermasayuki@d-toybox.com
push dateSun, 23 Jul 2017 15:43:46 +0000
reviewerssmaug
bugs1347351
milestone56.0a1
Bug 1347351 - nsMenuBarListener::KeyPress() should wait reply event for handling F10 key r?smaug Currently, nsMenuBarListener::KeyPress() handles F10 key before remote content handles it. However, if a remote process has focus, the keyboard event should be handled in the content first. Then, only when it's not consumed in the remote process, menubar should handle the F10 key press. MozReview-Commit-ID: GDf4POAPsTy
layout/xul/nsMenuBarListener.cpp
--- a/layout/xul/nsMenuBarListener.cpp
+++ b/layout/xul/nsMenuBarListener.cpp
@@ -322,16 +322,27 @@ nsMenuBarListener::KeyPress(nsIDOMEvent*
         aKeyEvent->StopPropagation();
         aKeyEvent->PreventDefault();
       }
     }
 #ifndef XP_MACOSX
     // Also need to handle F10 specially on Non-Mac platform.
     else if (nativeKeyEvent->mMessage == eKeyPress && keyCode == NS_VK_F10) {
       if ((GetModifiersForAccessKey(keyEvent) & ~MODIFIER_CONTROL) == 0) {
+        // If the keyboard event should activate the menubar and will be
+        // sent to a remote process, it should be executed with reply
+        // event from the focused remote process.  Note that if the menubar
+        // is active, the event is already marked as "stop cross
+        // process dispatching".  So, in that case, this won't wait
+        // reply from the remote content.
+        if (nativeKeyEvent->WillBeSentToRemoteProcess()) {
+          nativeKeyEvent->StopImmediatePropagation();
+          nativeKeyEvent->MarkAsWaitingReplyFromRemoteProcess();
+          return NS_OK;
+        }
         // The F10 key just went down by itself or with ctrl pressed.
         // In Windows, both of these activate the menu bar.
         mMenuBarFrame->SetActiveByKeyboard();
         ToggleMenuActiveState();
 
         if (mMenuBarFrame->IsActive()) {
 #ifdef MOZ_WIDGET_GTK
           // In GTK, this also opens the first menu.