Bug 1452536 - Don't gesture activate documents on non-printable key events. r=masayuki
authorChris Pearce <cpearce@mozilla.com>
Mon, 23 Apr 2018 15:53:50 +1200
changeset 416234 006f976d79630f70ea5e921a22ab266c2d08479f
parent 416233 4252c770699c81f0da958cafc313a37a9a4ac1ae
child 416235 c454505cc025bdcfcf1a4e1c17c02570262cddbb
push id33920
push usertoros@mozilla.com
push dateMon, 30 Apr 2018 09:50:56 +0000
treeherdermozilla-central@f01311ae4951 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmasayuki
bugs1452536
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1452536 - Don't gesture activate documents on non-printable key events. r=masayuki We don't want key presses of keys which are likely to be intended to be interaction with the browser or OS to gesture activate documents and unblock autoplay videos. So don't gesture activate for key events which are modifier keys, or which don't have a pseudo char code. MozReview-Commit-ID: 6uyPmlzbAvg
dom/events/EventStateManager.cpp
--- a/dom/events/EventStateManager.cpp
+++ b/dom/events/EventStateManager.cpp
@@ -924,16 +924,26 @@ EventStateManager::NotifyTargetUserActiv
     return;
   }
 
   nsIDocument* doc = node->OwnerDoc();
   if (!doc || doc->HasBeenUserActivated()) {
     return;
   }
 
+  // Don't gesture activate for key events for keys which are likely
+  // to be interaction with the browser, OS, or likely to be scrolling.
+  WidgetKeyboardEvent* keyEvent = aEvent->AsKeyboardEvent();
+  if (keyEvent && (!keyEvent->PseudoCharCode() ||
+                   (keyEvent->IsControl() && !keyEvent->IsAltGraph()) ||
+                   (keyEvent->IsAlt() && !keyEvent->IsAltGraph()) ||
+                   keyEvent->IsMeta() || keyEvent->IsOS())) {
+    return;
+  }
+
   MOZ_ASSERT(aEvent->mMessage == eKeyDown   ||
              aEvent->mMessage == eMouseDown ||
              aEvent->mMessage == ePointerDown ||
              aEvent->mMessage == eTouchEnd);
   doc->NotifyUserActivation();
 }
 
 already_AddRefed<EventStateManager>