Bug 1456037 - Gesture activate documents on key/mouse down not up. r=masayuki

We should gesture activate documents in key/mouse down instead of up because
if a web app wants to play a video inside a key/mouse handler, the document
needs to be activated before the handler runs.

Also, Chrome activates on key/mouse down, so we may have compat issues if
we have different behaviour.

MozReview-Commit-ID: JgGaQcNQfzz

--HG--
extra : rebase_source : de4269db9538e9c8aa5ff686c215bd619cf0c573
This commit is contained in:
Chris Pearce 2018-04-23 15:56:29 +12:00
parent 0296ae6c8e
commit a2d85597fe

View File

@ -643,6 +643,7 @@ EventStateManager::PreHandleEvent(nsPresContext* aPresContext,
SetClickCount(mouseEvent, aStatus);
break;
}
NotifyTargetUserActivation(aEvent, aTargetContent);
break;
}
case eMouseUp: {
@ -659,7 +660,6 @@ EventStateManager::PreHandleEvent(nsPresContext* aPresContext,
case WidgetMouseEvent::eMiddleButton:
RefPtr<EventStateManager> esm = ESMFromContentOrThis(aOverrideClickTarget);
esm->SetClickCount(mouseEvent, aStatus, aOverrideClickTarget);
NotifyTargetUserActivation(aEvent, aTargetContent);
break;
}
break;
@ -714,6 +714,13 @@ EventStateManager::PreHandleEvent(nsPresContext* aPresContext,
case ePointerDown:
if (aEvent->mMessage == ePointerDown) {
PointerEventHandler::ImplicitlyCapturePointer(aTargetFrame, aEvent);
#ifndef MOZ_WIDGET_ANDROID
// Pointer events aren't enabled on Android yet, but when they
// are enabled, we should not activate on pointerdown, as that
// fires for touches that turn into moves on Android, and we don't
// want to gesture activate for scroll actions.
NotifyTargetUserActivation(aEvent, aTargetContent);
#endif
}
MOZ_FALLTHROUGH;
case ePointerMove: {
@ -794,6 +801,10 @@ EventStateManager::PreHandleEvent(nsPresContext* aPresContext,
// then fall through...
MOZ_FALLTHROUGH;
case eKeyDown:
if (aEvent->mMessage == eKeyDown) {
NotifyTargetUserActivation(aEvent, aTargetContent);
}
MOZ_FALLTHROUGH;
case eKeyUp:
{
nsIContent* content = GetFocusedContent();
@ -823,9 +834,6 @@ EventStateManager::PreHandleEvent(nsPresContext* aPresContext,
!IsRemoteTarget(content)) {
aEvent->ResetWaitingReplyFromRemoteProcessState();
}
if (aEvent->mMessage == eKeyUp) {
NotifyTargetUserActivation(aEvent, aTargetContent);
}
}
break;
case eWheel:
@ -921,8 +929,11 @@ EventStateManager::NotifyTargetUserActivation(WidgetEvent* aEvent,
return;
}
MOZ_ASSERT(aEvent->mMessage == eKeyUp ||
aEvent->mMessage == eMouseUp ||
MOZ_ASSERT(aEvent->mMessage == eKeyDown ||
aEvent->mMessage == eMouseDown ||
#ifndef MOZ_WIDGET_ANDROID
aEvent->mMessage == ePointerDown ||
#endif
aEvent->mMessage == eTouchEnd);
doc->NotifyUserActivation();
}