зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1530220 - part1 : allow some non-printalble keys as supported user gesture inputs to activate document. r=masayuki,cpearce
`carriage return` and `space` are common keys which user might use to start media, so we should take account them as supported user gesture inputs. As their pseudo char code are zero, we have to check their key code in order to distinguish them from other controls keys such as shift, alt... Differential Revision: https://phabricator.services.mozilla.com/D21253 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
616caf8ad0
Коммит
b89fda8a6d
|
@ -829,12 +829,9 @@ void EventStateManager::NotifyTargetUserActivation(WidgetEvent* aEvent,
|
|||
}
|
||||
|
||||
// Don't gesture activate for key events for keys which are likely
|
||||
// to be interaction with the browser, OS, or likely to be scrolling.
|
||||
// to be interaction with the browser, OS.
|
||||
WidgetKeyboardEvent* keyEvent = aEvent->AsKeyboardEvent();
|
||||
if (keyEvent && (!keyEvent->PseudoCharCode() ||
|
||||
(keyEvent->IsControl() && !keyEvent->IsAltGraph()) ||
|
||||
(keyEvent->IsAlt() && !keyEvent->IsAltGraph()) ||
|
||||
keyEvent->IsMeta() || keyEvent->IsOS())) {
|
||||
if (keyEvent && !keyEvent->CanUserGestureActivateTarget()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -300,6 +300,22 @@ class WidgetKeyboardEvent : public WidgetInputEvent {
|
|||
return result;
|
||||
}
|
||||
|
||||
bool CanUserGestureActivateTarget() const {
|
||||
// Printable keys, 'carriage return' and 'space' are supported user gestures
|
||||
// for activating the document. However, if supported key is being pressed
|
||||
// combining with other operation keys, such like alt, control ..etc., we
|
||||
// won't activate the target for them because at that time user might
|
||||
// interact with browser or window manager which doesn't necessarily
|
||||
// demonstrate user's intent to play media.
|
||||
const bool isCombiningWithOperationKeys = (IsControl() && !IsAltGraph()) ||
|
||||
(IsAlt() && !IsAltGraph()) ||
|
||||
IsMeta() || IsOS();
|
||||
const bool isEnterOrSpaceKey =
|
||||
mKeyNameIndex == KEY_NAME_INDEX_Enter || mKeyCode == NS_VK_SPACE;
|
||||
return (PseudoCharCode() || isEnterOrSpaceKey) &&
|
||||
!isCombiningWithOperationKeys;
|
||||
}
|
||||
|
||||
// OS translated Unicode chars which are used for accesskey and accelkey
|
||||
// handling. The handlers will try from first character to last character.
|
||||
nsTArray<AlternativeCharCode> mAlternativeCharCodes;
|
||||
|
|
Загрузка…
Ссылка в новой задаче