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 473202 46471bf78ee81cb9454f36b8adf05e9fccf294bc
parent 473197 881670154df07ef8253a9597c5826d30ffe0c00d
child 473203 2f2a7a27a90f45558b26f39b83e9b83c28d3f0fe
push id1728
push userjlund@mozilla.com
push dateMon, 18 Jun 2018 21:12:27 +0000
treeherdermozilla-release@c296fde26f5f [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>