Bug 1385071 - Don't do the default action for key inputs that are handled by APZ. r=masayuki
authorRyan Hunt <rhunt@eqrion.net>
Sun, 30 Jul 2017 13:08:17 -0400
changeset 372841 aafd06fa1990
parent 372840 2d8b3b018cf5
child 372842 91bd0a08cabe
push id93416
push userrhunt@eqrion.net
push dateFri, 04 Aug 2017 15:35:13 +0000
treeherdermozilla-inbound@be1bd1f2cb08 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmasayuki
bugs1385071
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1385071 - Don't do the default action for key inputs that are handled by APZ. r=masayuki Before if a key input was handled with APZ we wouldn't dispatch it to content, because it was guaranteed there wouldn't be any key listeners. Now we are allowing passive key listeners behind a pref, and so we will sometimes handle a key input in APZ and dispatch it to content. When this happens, XBL shouldn't do the default action, otherwise we would double scroll. MozReview-Commit-ID: 2zfszQ3itkp
dom/xbl/nsXBLWindowKeyHandler.cpp
--- a/dom/xbl/nsXBLWindowKeyHandler.cpp
+++ b/dom/xbl/nsXBLWindowKeyHandler.cpp
@@ -499,16 +499,23 @@ nsXBLWindowKeyHandler::HandleEvent(nsIDO
     //     combination, it will be executed when the event is normal keyboard
     //     events...
     bool isReserved = false;
     if (!HasHandlerForEvent(keyEvent, &isReserved)) {
       return NS_OK;
     }
   }
 
+  // If this event was handled by APZ then don't do the default action, and
+  // preventDefault to prevent any other listeners from handling the event.
+  if (widgetKeyboardEvent->mFlags.mHandledByAPZ) {
+    aEvent->PreventDefault();
+    return NS_OK;
+  }
+
   nsCOMPtr<nsIAtom> eventTypeAtom =
     ConvertEventToDOMEventType(*widgetKeyboardEvent);
   return WalkHandlers(keyEvent, eventTypeAtom);
 }
 
 void
 nsXBLWindowKeyHandler::HandleEventOnCaptureInDefaultEventGroup(
                          nsIDOMKeyEvent* aEvent)