Bug 1435530 - part 2: Make nsXBLWindowKeyHandler treat eAccessKeyNotFound as eKeyPress event r=enndeakin+6102

Modifiers of shortcut keys may be same as modifier of content access keys.

When focus is in the main process, such eKeyPress event is sent to remote
content first.  Then, and if it's not handled in the remote content,
eAccessKeyNotFound is dispatched into the DOM tree in the main process.
However, nsXBLWindowKeyHandler doesn't handle it as eKeyPress event.  So,
it causes that shortcut keys whose modifier conflicts with content access key
won't be handled.

This patch just makes nsXBLWindowKeyHandler treat eAccessKeyNotFound as
eKeyPress event even though other shortcut keys which are handled by JS
won't be executed.  Perhaps, we should stop using eAccessKeyNotFound but
it's too risky change for now.

MozReview-Commit-ID: IJltg5gwBc5

--HG--
extra : rebase_source : f456eade18cd4fefd2eab6e06f5b00156ac8ad59
This commit is contained in:
Masayuki Nakano 2018-02-05 18:27:30 +09:00
Родитель 8f3e9a2be7
Коммит cb5853d299
2 изменённых файлов: 17 добавлений и 1 удалений

Просмотреть файл

@ -2244,6 +2244,7 @@ TabParent::RecvAccessKeyNotHandled(const WidgetKeyboardEvent& aEvent)
// twice or more for a keyboard event, that must be a bug. But how to
// detect if received event has already been handled?
MOZ_ASSERT(aEvent.mMessage == eKeyPress);
WidgetKeyboardEvent localEvent(aEvent);
localEvent.MarkAsHandledInRemoteProcess();
localEvent.mMessage = eAccessKeyNotFound;

Просмотреть файл

@ -356,6 +356,12 @@ nsXBLWindowKeyHandler::InstallKeyboardEventListenersTo(
aEventListenerManager->AddEventListenerByType(
this, NS_LITERAL_STRING("keypress"),
TrustedEventsAtSystemGroupBubble());
// mozaccesskeynotfound event is fired when modifiers of keypress event
// matches with modifier of content access key but it's not consumed by
// remote content.
aEventListenerManager->AddEventListenerByType(
this, NS_LITERAL_STRING("mozaccesskeynotfound"),
TrustedEventsAtSystemGroupBubble());
aEventListenerManager->AddEventListenerByType(
this, NS_LITERAL_STRING("mozkeydownonplugin"),
TrustedEventsAtSystemGroupBubble());
@ -409,6 +415,9 @@ nsXBLWindowKeyHandler::RemoveKeyboardEventListenersFrom(
aEventListenerManager->RemoveEventListenerByType(
this, NS_LITERAL_STRING("keypress"),
TrustedEventsAtSystemGroupBubble());
aEventListenerManager->RemoveEventListenerByType(
this, NS_LITERAL_STRING("mozaccesskeynotfound"),
TrustedEventsAtSystemGroupBubble());
aEventListenerManager->RemoveEventListenerByType(
this, NS_LITERAL_STRING("mozkeydownonplugin"),
TrustedEventsAtSystemGroupBubble());
@ -465,7 +474,13 @@ nsXBLWindowKeyHandler::ConvertEventToDOMEventType(
if (aWidgetKeyboardEvent.IsKeyUpOrKeyUpOnPlugin()) {
return nsGkAtoms::keyup;
}
if (aWidgetKeyboardEvent.mMessage == eKeyPress) {
// eAccessKeyNotFound event is always created from eKeyPress event and
// the original eKeyPress event has stopped its propagation before dispatched
// into the DOM tree in this process and not matched with remote content's
// access keys. So, we should treat it as an eKeyPress event and execute
// a command if it's registered as a shortcut key.
if (aWidgetKeyboardEvent.mMessage == eKeyPress ||
aWidgetKeyboardEvent.mMessage == eAccessKeyNotFound) {
return nsGkAtoms::keypress;
}
MOZ_ASSERT_UNREACHABLE(