From 2d636ad4b510da977a6eeb8739c7516b30f6ff9d Mon Sep 17 00:00:00 2001 From: Neil Deakin Date: Tue, 29 Sep 2015 14:49:32 -0400 Subject: [PATCH] Bug 1180761, cancel the event earlier so that space doesn't trigger checkbox change and scroll, r=neil --- dom/tests/mochitest/general/chrome.ini | 1 + .../general/test_spacetopagedown.html | 76 +++++++++++++++++++ dom/xbl/nsXBLPrototypeHandler.cpp | 8 +- 3 files changed, 81 insertions(+), 4 deletions(-) create mode 100644 dom/tests/mochitest/general/test_spacetopagedown.html diff --git a/dom/tests/mochitest/general/chrome.ini b/dom/tests/mochitest/general/chrome.ini index b6b023b42eb6..d34475d27066 100644 --- a/dom/tests/mochitest/general/chrome.ini +++ b/dom/tests/mochitest/general/chrome.ini @@ -6,3 +6,4 @@ skip-if = buildapp == 'b2g' || os == 'android' [test_offsets.js] [test_offsets.xul] skip-if = buildapp == 'mulet' +[test_spacetopagedown.html] diff --git a/dom/tests/mochitest/general/test_spacetopagedown.html b/dom/tests/mochitest/general/test_spacetopagedown.html new file mode 100644 index 000000000000..03f840f3d687 --- /dev/null +++ b/dom/tests/mochitest/general/test_spacetopagedown.html @@ -0,0 +1,76 @@ + + + + + + + + + + +Checkbox + +

Text

+ +

+ +
+
+ + diff --git a/dom/xbl/nsXBLPrototypeHandler.cpp b/dom/xbl/nsXBLPrototypeHandler.cpp index 4cba65f280b4..be2120918acf 100644 --- a/dom/xbl/nsXBLPrototypeHandler.cpp +++ b/dom/xbl/nsXBLPrototypeHandler.cpp @@ -459,6 +459,10 @@ nsXBLPrototypeHandler::DispatchXBLCommand(EventTarget* aTarget, nsIDOMEvent* aEv else controller = GetController(aTarget); // We're attached to the receiver possibly. + // We are the default action for this command. + // Stop any other default action from executing. + aEvent->PreventDefault(); + if (mEventName == nsGkAtoms::keypress && mDetail == nsIDOMKeyEvent::DOM_VK_SPACE && mMisc == 1) { @@ -491,10 +495,6 @@ nsXBLPrototypeHandler::DispatchXBLCommand(EventTarget* aTarget, nsIDOMEvent* aEv } } } - - // We are the default action for this command. - // Stop any other default action from executing. - aEvent->PreventDefault(); if (controller) controller->DoCommand(command.get());