Bug 1385071 - Don't do the default action for key inputs that are handled by APZ. r=masayuki draft
authorRyan Hunt <rhunt@eqrion.net>
Sun, 30 Jul 2017 13:08:17 -0400
changeset 620711 724b110fd55c5935df589f1cbcc0b3380028a1ed
parent 620710 a6bb4b7fff3488dea62b9114aa164814c74561a4
child 620712 77543ef3f28bdbb8ef77e984097ce75cdf333c82
push id72133
push userbmo:rhunt@eqrion.net
push dateThu, 03 Aug 2017 20:23:49 +0000
reviewersmasayuki
bugs1385071
milestone57.0a1
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)