Bug 1257760 TextInputHandler should dispatch keypress event even when a plugin has focus r=m_kato
authorMasayuki Nakano <masayuki@d-toybox.com>
Wed, 23 Mar 2016 15:31:54 +0900
changeset 290562 d9ab9ff08b5ed22ba63c3b94683af8cb46df56a3
parent 290561 a9851bf7034a37f5d8ae2d65db6281735dc9deb2
child 290563 cdf61a196be88c8e852ec1c4ed0d9b9794e68d2c
push id19656
push usergwagner@mozilla.com
push dateMon, 04 Apr 2016 13:43:23 +0000
treeherderb2g-inbound@e99061fde28a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersm_kato
bugs1257760
milestone48.0a1
Bug 1257760 TextInputHandler should dispatch keypress event even when a plugin has focus r=m_kato When a plugin has focus, TextInputHandler shouldn't send native keydown event to interpretKeyEvents of NSView. However, it should dispatch keypress events because shortcut key handlers wait following keypress event. MozReview-Commit-ID: HpG108s2Rde
widget/cocoa/TextInputHandler.mm
--- a/widget/cocoa/TextInputHandler.mm
+++ b/widget/cocoa/TextInputHandler.mm
@@ -1611,28 +1611,23 @@ TextInputHandler::HandleKeyDownEvent(NSE
 
   if (currentKeyEvent->IsDefaultPrevented()) {
     MOZ_LOG(gLog, LogLevel::Info,
       ("%p TextInputHandler::HandleKeyDownEvent, "
        "keydown event's default is prevented", this));
     return true;
   }
 
-  // None of what follows is needed for plugin keyboard input.  In fact it
-  // may cause trouble -- for example the call to [mView interpretKeyEvents:]
-  // can, in e10s mode, cause each key typed to appear twice in an IME
-  // composition.
-  if (mWidget->IsPluginFocused()) {
-    return true;
-  }
-
   // Let Cocoa interpret the key events, caching IsIMEComposing first.
   bool wasComposing = IsIMEComposing();
   bool interpretKeyEventsCalled = false;
-  if (IsIMEEnabled() || IsASCIICapableOnly()) {
+  // Don't call interpretKeyEvents when a plugin has focus.  If we call it,
+  // for example, a character is inputted twice during a composition in e10s
+  // mode.
+  if (!mWidget->IsPluginFocused() && (IsIMEEnabled() || IsASCIICapableOnly())) {
     MOZ_LOG(gLog, LogLevel::Info,
       ("%p TextInputHandler::HandleKeyDownEvent, calling interpretKeyEvents",
        this));
     [mView interpretKeyEvents:[NSArray arrayWithObject:aNativeEvent]];
     interpretKeyEventsCalled = true;
     MOZ_LOG(gLog, LogLevel::Info,
       ("%p TextInputHandler::HandleKeyDownEvent, called interpretKeyEvents",
        this));