forked from mirrors/gecko-dev
Bug 1883396 - Exit fullscreen when two Escape keyup events occur in a short time; r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D209667
This commit is contained in:
parent
61d3478f4a
commit
6f4b15e60d
3 changed files with 35 additions and 6 deletions
|
|
@ -8669,12 +8669,30 @@ void PresShell::EventHandler::MaybeHandleKeyboardEventBeforeDispatch(
|
|||
|
||||
// The event listeners in chrome can prevent this ESC behavior by
|
||||
// calling prevent default on the preceding keydown/press events.
|
||||
if (!mPresShell->mIsLastChromeOnlyEscapeKeyConsumed &&
|
||||
aKeyboardEvent->mMessage == eKeyUp) {
|
||||
// ESC key released while in DOM fullscreen mode.
|
||||
// Fully exit all browser windows and documents from
|
||||
// fullscreen mode.
|
||||
Document::AsyncExitFullscreen(nullptr);
|
||||
if (aKeyboardEvent->mMessage == eKeyUp) {
|
||||
bool shouldExitFullscreen =
|
||||
!mPresShell->mIsLastChromeOnlyEscapeKeyConsumed;
|
||||
if (!shouldExitFullscreen) {
|
||||
if (mPresShell->mLastConsumedEscapeKeyUpForFullscreen &&
|
||||
(aKeyboardEvent->mTimeStamp -
|
||||
mPresShell->mLastConsumedEscapeKeyUpForFullscreen) <=
|
||||
TimeDuration::FromMilliseconds(
|
||||
StaticPrefs::
|
||||
dom_fullscreen_force_exit_on_multiple_escape_interval())) {
|
||||
shouldExitFullscreen = true;
|
||||
mPresShell->mLastConsumedEscapeKeyUpForFullscreen = TimeStamp();
|
||||
} else {
|
||||
mPresShell->mLastConsumedEscapeKeyUpForFullscreen =
|
||||
aKeyboardEvent->mTimeStamp;
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldExitFullscreen) {
|
||||
// ESC key released while in DOM fullscreen mode.
|
||||
// Fully exit all browser windows and documents from
|
||||
// fullscreen mode.
|
||||
Document::AsyncExitFullscreen(nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3221,6 +3221,10 @@ class PresShell final : public nsStubDocumentObserver,
|
|||
bool mProcessingReflowCommands : 1;
|
||||
bool mPendingDidDoReflow : 1;
|
||||
|
||||
// The last TimeStamp when the keyup event did not exit fullscreen because it
|
||||
// was consumed.
|
||||
TimeStamp mLastConsumedEscapeKeyUpForFullscreen;
|
||||
|
||||
struct CapturingContentInfo final {
|
||||
CapturingContentInfo()
|
||||
: mRemoteTarget(nullptr),
|
||||
|
|
|
|||
|
|
@ -2703,6 +2703,13 @@
|
|||
value: false
|
||||
mirror: always
|
||||
|
||||
# The interval in milliseconds between two Escape key events where the second
|
||||
# key event will exit fullscreen, even if it is consumed.
|
||||
- name: dom.fullscreen.force_exit_on_multiple_escape_interval
|
||||
type: uint32_t
|
||||
value: 500
|
||||
mirror: always
|
||||
|
||||
# Whether the Gamepad API is enabled
|
||||
- name: dom.gamepad.enabled
|
||||
type: bool
|
||||
|
|
|
|||
Loading…
Reference in a new issue