From 38dcba8fbb5b8d13809703dd8dcbb6763be14a05 Mon Sep 17 00:00:00 2001 From: Edgar Chen Date: Thu, 28 May 2020 21:56:30 +0000 Subject: [PATCH] Bug 1640883 - Treat ctrl-c, ctrl-x and ctrl-v as user activation; r=smaug ctrl-c and ctrl-x is quite common shortcut for clipboard operation, we should treat it as user activation. Differential Revision: https://phabricator.services.mozilla.com/D77046 --- dom/base/test/useractivation/mochitest.ini | 1 + .../test_useractivation_key_events.html | 91 +++++++++++++++++++ widget/TextEvents.h | 11 ++- 3 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 dom/base/test/useractivation/test_useractivation_key_events.html diff --git a/dom/base/test/useractivation/mochitest.ini b/dom/base/test/useractivation/mochitest.ini index 9d2ec7daade5..fc1630e7174d 100644 --- a/dom/base/test/useractivation/mochitest.ini +++ b/dom/base/test/useractivation/mochitest.ini @@ -9,6 +9,7 @@ prefs = apz.zoom-to-focused-input.enabled=false [test_useractivation_has_been_activated.html] +[test_useractivation_key_events.html] [test_useractivation_transient.html] [test_useractivation_transient_consuming.html] [test_clipboard_editor.html] diff --git a/dom/base/test/useractivation/test_useractivation_key_events.html b/dom/base/test/useractivation/test_useractivation_key_events.html new file mode 100644 index 000000000000..d97906c22bcf --- /dev/null +++ b/dom/base/test/useractivation/test_useractivation_key_events.html @@ -0,0 +1,91 @@ + + + + User activation test: key events + + + + + + + diff --git a/widget/TextEvents.h b/widget/TextEvents.h index b4c4b9e95c39..4882bc2babd4 100644 --- a/widget/TextEvents.h +++ b/widget/TextEvents.h @@ -317,7 +317,16 @@ class WidgetKeyboardEvent : public WidgetInputEvent { const bool isEnterOrSpaceKey = mKeyNameIndex == KEY_NAME_INDEX_Enter || mKeyCode == NS_VK_SPACE; return (PseudoCharCode() || isEnterOrSpaceKey) && - !isCombiningWithOperationKeys; + (!isCombiningWithOperationKeys || + // ctrl-c/ctrl-x/ctrl-v is quite common shortcut for clipboard + // operation. + // XXXedgar, we have to find a better way to handle browser keyboard + // shortcut for user activation, instead of just ignoring all + // combinations, see bug 1641171. + ((mKeyCode == dom::KeyboardEvent_Binding::DOM_VK_C || + mKeyCode == dom::KeyboardEvent_Binding::DOM_VK_V || + mKeyCode == dom::KeyboardEvent_Binding::DOM_VK_X) && + IsAccel())); } /**