Verified Commit bd3926cf authored by Edgar Chen's avatar Edgar Chen Committed by Pier Angelo Vendrame
Browse files

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

parent c77de97d
Loading
Loading
Loading
Loading
+13 −9
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) {