Bug 1743329 - Handle ESC key to release pointer lock in parent process; r=smaug

Differential Revision: https://phabricator.services.mozilla.com/D211621
This commit is contained in:
Edgar Chen
2024-05-31 11:13:47 +00:00
parent d67110bf57
commit b6e9002fbf

View File

@@ -8682,15 +8682,19 @@ void PresShell::EventHandler::MaybeHandleKeyboardEventBeforeDispatch(
}
}
nsCOMPtr<Document> pointerLockedDoc = PointerLockManager::GetLockedDocument();
if (!mPresShell->mIsLastChromeOnlyEscapeKeyConsumed && pointerLockedDoc) {
// XXX See above comment to understand the reason why this needs
// to claim that the Escape key event is consumed by content
// even though it will be dispatched only into chrome.
aKeyboardEvent->PreventDefaultBeforeDispatch(CrossProcessForwarding::eStop);
aKeyboardEvent->mFlags.mOnlyChromeDispatch = true;
if (aKeyboardEvent->mMessage == eKeyUp) {
PointerLockManager::Unlock();
if (XRE_IsParentProcess() &&
!mPresShell->mIsLastChromeOnlyEscapeKeyConsumed) {
if (PointerLockManager::GetLockedRemoteTarget() ||
PointerLockManager::IsLocked()) {
// XXX See above comment to understand the reason why this needs
// to claim that the Escape key event is consumed by content
// even though it will be dispatched only into chrome.
aKeyboardEvent->PreventDefaultBeforeDispatch(
CrossProcessForwarding::eStop);
aKeyboardEvent->mFlags.mOnlyChromeDispatch = true;
if (aKeyboardEvent->mMessage == eKeyUp) {
PointerLockManager::Unlock();
}
}
}
}