Verified Commit b9ef0ae2 authored by Edgar Chen's avatar Edgar Chen Committed by ma1
Browse files

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

parent f0dd2fef
Loading
Loading
Loading
Loading
+7 −3
Changes for layout/base/PresShell.cpp: 7 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -8472,18 +8472,22 @@ void PresShell::EventHandler::MaybeHandleKeyboardEventBeforeDispatch(
    }
  }

  nsCOMPtr<Document> pointerLockedDoc = PointerLockManager::GetLockedDocument();
  if (!mPresShell->mIsLastChromeOnlyEscapeKeyConsumed && pointerLockedDoc) {
  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->PreventDefaultBeforeDispatch(
          CrossProcessForwarding::eStop);
      aKeyboardEvent->mFlags.mOnlyChromeDispatch = true;
      if (aKeyboardEvent->mMessage == eKeyUp) {
        PointerLockManager::Unlock();
      }
    }
  }
}

void PresShell::EventHandler::RecordEventPreparationPerformance(
    const WidgetEvent* aEvent) {