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
--- 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)