forked from mirrors/gecko-dev
Backed out 2 changesets (bug 1823284) for causing failures on element-request-fullscreen-timing.html, test_fullscreen-api.html CLOSED TREE
Backed out changeset 54bce7b5d558 (bug 1823284) Backed out changeset 65747f283949 (bug 1823284)
This commit is contained in:
parent
abe65e2661
commit
e14b74864b
12 changed files with 83 additions and 265 deletions
|
|
@ -36,4 +36,3 @@ support-files =
|
|||
file_fullscreen-bug-1798219.html
|
||||
file_fullscreen-bug-1798219-2.html
|
||||
[browser_fullscreen-window-open-race.js]
|
||||
[browser_fullscreen-sizemode.js]
|
||||
|
|
|
|||
|
|
@ -1,225 +0,0 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
const isMac = AppConstants.platform == "macosx";
|
||||
const isWin = AppConstants.platform == "win";
|
||||
|
||||
async function waitForSizeMode(aWindow, aSizeMode) {
|
||||
await BrowserTestUtils.waitForEvent(aWindow, "sizemodechange", false, () => {
|
||||
return aWindow.windowState === aSizeMode;
|
||||
});
|
||||
const expectedHidden =
|
||||
aSizeMode == aWindow.STATE_MINIMIZED || aWindow.isFullyOccluded;
|
||||
if (aWindow.document.hidden != expectedHidden) {
|
||||
await BrowserTestUtils.waitForEvent(aWindow, "visibilitychange");
|
||||
}
|
||||
is(
|
||||
aWindow.document.hidden,
|
||||
expectedHidden,
|
||||
"Should be inactive if minimized or occluded"
|
||||
);
|
||||
}
|
||||
|
||||
async function checkSizeModeAndFullscreenState(
|
||||
aWindow,
|
||||
aSizeMode,
|
||||
aFullscreen,
|
||||
aFullscreenEventShouldHaveFired,
|
||||
aStepFun
|
||||
) {
|
||||
let promises = [];
|
||||
if (aWindow.windowState != aSizeMode) {
|
||||
promises.push(waitForSizeMode(aWindow, aSizeMode));
|
||||
}
|
||||
if (aFullscreenEventShouldHaveFired) {
|
||||
promises.push(
|
||||
BrowserTestUtils.waitForEvent(
|
||||
aWindow,
|
||||
aFullscreen ? "willenterfullscreen" : "willexitfullscreen"
|
||||
)
|
||||
);
|
||||
promises.push(BrowserTestUtils.waitForEvent(aWindow, "fullscreen"));
|
||||
}
|
||||
|
||||
// Add listener for unexpected event.
|
||||
let unexpectedEventListener = aEvent => {
|
||||
ok(false, `should not receive ${aEvent.type} event`);
|
||||
};
|
||||
if (aFullscreenEventShouldHaveFired) {
|
||||
aWindow.addEventListener(
|
||||
aFullscreen ? "willexitfullscreen" : "willenterfullscreen",
|
||||
unexpectedEventListener
|
||||
);
|
||||
} else {
|
||||
aWindow.addEventListener("willenterfullscreen", unexpectedEventListener);
|
||||
aWindow.addEventListener("willexitfullscreen", unexpectedEventListener);
|
||||
aWindow.addEventListener("fullscreen", unexpectedEventListener);
|
||||
}
|
||||
|
||||
let eventPromise = Promise.all(promises);
|
||||
aStepFun();
|
||||
await eventPromise;
|
||||
|
||||
// Check SizeMode.
|
||||
is(
|
||||
aWindow.windowState,
|
||||
aSizeMode,
|
||||
"The new sizemode should have the expected value"
|
||||
);
|
||||
// Check Fullscreen state.
|
||||
is(
|
||||
aWindow.fullScreen,
|
||||
aFullscreen,
|
||||
`chrome window should ${aFullscreen ? "be" : "not be"} in fullscreen`
|
||||
);
|
||||
is(
|
||||
aWindow.document.documentElement.hasAttribute("inFullscreen"),
|
||||
aFullscreen,
|
||||
`chrome documentElement should ${
|
||||
aFullscreen ? "have" : "not have"
|
||||
} inFullscreen attribute`
|
||||
);
|
||||
|
||||
// Remove listener for unexpected event.
|
||||
if (aFullscreenEventShouldHaveFired) {
|
||||
aWindow.removeEventListener(
|
||||
aFullscreen ? "willexitfullscreen" : "willenterfullscreen",
|
||||
unexpectedEventListener
|
||||
);
|
||||
} else {
|
||||
aWindow.removeEventListener("willenterfullscreen", unexpectedEventListener);
|
||||
aWindow.removeEventListener("willexitfullscreen", unexpectedEventListener);
|
||||
aWindow.removeEventListener("fullscreen", unexpectedEventListener);
|
||||
}
|
||||
}
|
||||
|
||||
async function restoreWindowToNormal(aWindow) {
|
||||
while (aWindow.windowState != aWindow.STATE_NORMAL) {
|
||||
info(`Try to restore window with state ${aWindow.windowState} to normal`);
|
||||
let eventPromise = BrowserTestUtils.waitForEvent(aWindow, "sizemodechange");
|
||||
aWindow.restore();
|
||||
await eventPromise;
|
||||
info(`Window is now in state ${aWindow.windowState}`);
|
||||
}
|
||||
}
|
||||
|
||||
add_task(async function test_fullscreen_restore() {
|
||||
let win = await BrowserTestUtils.openNewBrowserWindow();
|
||||
await restoreWindowToNormal(win);
|
||||
|
||||
info("Enter fullscreen");
|
||||
await checkSizeModeAndFullscreenState(
|
||||
win,
|
||||
win.STATE_FULLSCREEN,
|
||||
true,
|
||||
true,
|
||||
() => {
|
||||
win.fullScreen = true;
|
||||
}
|
||||
);
|
||||
|
||||
info("Restore window");
|
||||
await checkSizeModeAndFullscreenState(
|
||||
win,
|
||||
win.STATE_NORMAL,
|
||||
false,
|
||||
true,
|
||||
() => {
|
||||
win.restore();
|
||||
}
|
||||
);
|
||||
|
||||
await BrowserTestUtils.closeWindow(win);
|
||||
});
|
||||
|
||||
// This test only enable on Windows because:
|
||||
// - Test gets intermittent timeout on macOS, see bug 1828848.
|
||||
// - Restoring a fullscreen window on GTK doesn't return it to the previous
|
||||
// sizemode, see bug 1828837.
|
||||
if (isWin) {
|
||||
add_task(async function test_maximize_fullscreen_restore() {
|
||||
let win = await BrowserTestUtils.openNewBrowserWindow();
|
||||
await restoreWindowToNormal(win);
|
||||
|
||||
info("Maximize window");
|
||||
await checkSizeModeAndFullscreenState(
|
||||
win,
|
||||
win.STATE_MAXIMIZED,
|
||||
false,
|
||||
false,
|
||||
() => {
|
||||
win.maximize();
|
||||
}
|
||||
);
|
||||
|
||||
info("Enter fullscreen");
|
||||
await checkSizeModeAndFullscreenState(
|
||||
win,
|
||||
win.STATE_FULLSCREEN,
|
||||
true,
|
||||
true,
|
||||
() => {
|
||||
win.fullScreen = true;
|
||||
}
|
||||
);
|
||||
|
||||
info("Restore window");
|
||||
await checkSizeModeAndFullscreenState(
|
||||
win,
|
||||
win.STATE_MAXIMIZED,
|
||||
false,
|
||||
true,
|
||||
() => {
|
||||
win.restore();
|
||||
}
|
||||
);
|
||||
|
||||
await BrowserTestUtils.closeWindow(win);
|
||||
});
|
||||
}
|
||||
|
||||
// Restoring a minimized window on macOS doesn't return it to the previous
|
||||
// sizemode, see bug 1828706.
|
||||
if (!isMac) {
|
||||
add_task(async function test_fullscreen_minimize_restore() {
|
||||
let win = await BrowserTestUtils.openNewBrowserWindow();
|
||||
await restoreWindowToNormal(win);
|
||||
|
||||
info("Enter fullscreen");
|
||||
await checkSizeModeAndFullscreenState(
|
||||
win,
|
||||
win.STATE_FULLSCREEN,
|
||||
true,
|
||||
true,
|
||||
() => {
|
||||
win.fullScreen = true;
|
||||
}
|
||||
);
|
||||
|
||||
info("Minimize window");
|
||||
await checkSizeModeAndFullscreenState(
|
||||
win,
|
||||
win.STATE_MINIMIZED,
|
||||
true,
|
||||
false,
|
||||
() => {
|
||||
win.minimize();
|
||||
}
|
||||
);
|
||||
|
||||
info("Restore window");
|
||||
await checkSizeModeAndFullscreenState(
|
||||
win,
|
||||
win.STATE_FULLSCREEN,
|
||||
true,
|
||||
false,
|
||||
() => {
|
||||
win.restore();
|
||||
}
|
||||
);
|
||||
|
||||
await BrowserTestUtils.closeWindow(win);
|
||||
});
|
||||
}
|
||||
|
|
@ -2426,14 +2426,19 @@ nsresult nsWindow::MakeFullScreen(bool aFullScreen) {
|
|||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
nsIWidgetListener* listener = GetWidgetListener();
|
||||
if (listener) {
|
||||
listener->FullscreenWillChange(aFullScreen);
|
||||
}
|
||||
|
||||
mIsFullScreen = aFullScreen;
|
||||
mAndroidView->mEventDispatcher->Dispatch(
|
||||
aFullScreen ? u"GeckoView:FullScreenEnter" : u"GeckoView:FullScreenExit");
|
||||
|
||||
nsIWidgetListener* listener = GetWidgetListener();
|
||||
if (listener) {
|
||||
mSizeMode = mIsFullScreen ? nsSizeMode_Fullscreen : nsSizeMode_Normal;
|
||||
listener->SizeModeChanged(mSizeMode);
|
||||
listener->FullscreenChanged(mIsFullScreen);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1634,9 +1634,17 @@ void nsCocoaWindow::CocoaWindowWillEnterFullscreen(bool aFullscreen) {
|
|||
// happens.
|
||||
mUpdateFullscreenOnResize =
|
||||
Some(aFullscreen ? TransitionType::Fullscreen : TransitionType::Windowed);
|
||||
|
||||
if (mWidgetListener) {
|
||||
mWidgetListener->FullscreenWillChange(aFullscreen);
|
||||
}
|
||||
}
|
||||
|
||||
void nsCocoaWindow::CocoaWindowDidFailFullscreen(bool aAttemptedFullscreen) {
|
||||
if (mWidgetListener) {
|
||||
mWidgetListener->FullscreenWillChange(!aAttemptedFullscreen);
|
||||
}
|
||||
|
||||
// If we already updated our fullscreen state due to a resize, we need to update it again.
|
||||
if (mUpdateFullscreenOnResize.isNothing()) {
|
||||
UpdateFullscreenState(!aAttemptedFullscreen, true);
|
||||
|
|
@ -1661,6 +1669,10 @@ void nsCocoaWindow::UpdateFullscreenState(bool aFullScreen, bool aNativeMode) {
|
|||
|
||||
DispatchSizeModeEvent();
|
||||
|
||||
if (mWidgetListener) {
|
||||
mWidgetListener->FullscreenChanged(aFullScreen);
|
||||
}
|
||||
|
||||
// Notify the mainChildView with our new fullscreen state.
|
||||
nsChildView* mainChildView = static_cast<nsChildView*>([[mWindow mainChildView] widget]);
|
||||
if (mainChildView) {
|
||||
|
|
@ -1761,6 +1773,10 @@ void nsCocoaWindow::ProcessTransitions() {
|
|||
|
||||
case TransitionType::EmulatedFullscreen: {
|
||||
if (!mInFullScreenMode) {
|
||||
// This can be done synchronously.
|
||||
if (mWidgetListener) {
|
||||
mWidgetListener->FullscreenWillChange(true);
|
||||
}
|
||||
NSDisableScreenUpdates();
|
||||
mSuppressSizeModeEvents = true;
|
||||
// The order here matters. When we exit full screen mode, we need to show the
|
||||
|
|
@ -1782,6 +1798,10 @@ void nsCocoaWindow::ProcessTransitions() {
|
|||
[mWindow toggleFullScreen:nil];
|
||||
continue;
|
||||
} else {
|
||||
// This can be done synchronously.
|
||||
if (mWidgetListener) {
|
||||
mWidgetListener->FullscreenWillChange(false);
|
||||
}
|
||||
NSDisableScreenUpdates();
|
||||
mSuppressSizeModeEvents = true;
|
||||
// The order here matters. When we exit full screen mode, we need to show the
|
||||
|
|
|
|||
|
|
@ -5240,7 +5240,15 @@ void nsWindow::OnWindowStateEvent(GtkWidget* aWidget,
|
|||
LOG("\tTiled: %d\n", int(mIsTiled));
|
||||
|
||||
if (mWidgetListener && mSizeMode != oldSizeMode) {
|
||||
if (mSizeMode == nsSizeMode_Fullscreen ||
|
||||
oldSizeMode == nsSizeMode_Fullscreen) {
|
||||
bool isFullscreen = mSizeMode == nsSizeMode_Fullscreen;
|
||||
mWidgetListener->FullscreenWillChange(isFullscreen);
|
||||
mWidgetListener->SizeModeChanged(mSizeMode);
|
||||
mWidgetListener->FullscreenChanged(isFullscreen);
|
||||
} else {
|
||||
mWidgetListener->SizeModeChanged(mSizeMode);
|
||||
}
|
||||
}
|
||||
|
||||
if (mDrawInTitlebar && mTransparencyBitmapForTitlebar) {
|
||||
|
|
|
|||
|
|
@ -390,6 +390,7 @@ nsresult HeadlessWidget::MakeFullScreen(bool aFullScreen) {
|
|||
// resize events.
|
||||
if (mWidgetListener) {
|
||||
mWidgetListener->SizeModeChanged(mSizeMode);
|
||||
mWidgetListener->FullscreenChanged(aFullScreen);
|
||||
}
|
||||
|
||||
// Real widget backends don't seem to follow a common approach for
|
||||
|
|
|
|||
|
|
@ -44,6 +44,10 @@ void nsIWidgetListener::DynamicToolbarMaxHeightChanged(ScreenIntCoord aHeight) {
|
|||
void nsIWidgetListener::DynamicToolbarOffsetChanged(ScreenIntCoord aOffset) {}
|
||||
#endif
|
||||
|
||||
void nsIWidgetListener::FullscreenWillChange(bool aInFullscreen) {}
|
||||
|
||||
void nsIWidgetListener::FullscreenChanged(bool aInFullscreen) {}
|
||||
|
||||
void nsIWidgetListener::MacFullscreenMenubarOverlapChanged(
|
||||
mozilla::DesktopCoord aOverlapAmount) {}
|
||||
|
||||
|
|
|
|||
|
|
@ -103,6 +103,16 @@ class nsIWidgetListener {
|
|||
nsIWidget* aRequestBelow,
|
||||
nsIWidget** aActualBelow);
|
||||
|
||||
/**
|
||||
* Called when the window will enter or leave the fullscreen state.
|
||||
*/
|
||||
virtual void FullscreenWillChange(bool aInFullscreen);
|
||||
|
||||
/**
|
||||
* Called when the window entered or left the fullscreen state.
|
||||
*/
|
||||
virtual void FullscreenChanged(bool aInFullscreen);
|
||||
|
||||
/**
|
||||
* Called when the macOS titlebar is shown while in fullscreen.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -3652,6 +3652,12 @@ void nsWindow::CleanupFullscreenTransition() {
|
|||
mTransitionWnd = nullptr;
|
||||
}
|
||||
|
||||
void nsWindow::OnFullscreenWillChange(bool aFullScreen) {
|
||||
if (mWidgetListener) {
|
||||
mWidgetListener->FullscreenWillChange(aFullScreen);
|
||||
}
|
||||
}
|
||||
|
||||
void nsWindow::OnFullscreenChanged(nsSizeMode aOldSizeMode, bool aFullScreen) {
|
||||
// Hide chrome and reposition window. Note this will also cache dimensions for
|
||||
// restoration, so it should only be called once per fullscreen request.
|
||||
|
|
@ -3665,6 +3671,10 @@ void nsWindow::OnFullscreenChanged(nsSizeMode aOldSizeMode, bool aFullScreen) {
|
|||
InfallibleMakeFullScreen(aFullScreen);
|
||||
}
|
||||
|
||||
if (mWidgetListener) {
|
||||
mWidgetListener->FullscreenChanged(aFullScreen);
|
||||
}
|
||||
|
||||
// Possibly notify the taskbar that we have changed our fullscreen mode.
|
||||
TaskbarConcealer::OnFullscreenChanged(this, aFullScreen);
|
||||
}
|
||||
|
|
@ -9364,6 +9374,10 @@ void nsWindow::FrameState::SetSizeModeInternal(nsSizeMode aMode,
|
|||
mSizeMode == nsSizeMode_Fullscreen || aMode == nsSizeMode_Fullscreen;
|
||||
const bool fullscreen = aMode == nsSizeMode_Fullscreen;
|
||||
|
||||
if (fullscreenChange) {
|
||||
mWindow->OnFullscreenWillChange(fullscreen);
|
||||
}
|
||||
|
||||
mLastSizeMode = mSizeMode;
|
||||
mSizeMode = aMode;
|
||||
|
||||
|
|
@ -9373,11 +9387,11 @@ void nsWindow::FrameState::SetSizeModeInternal(nsSizeMode aMode,
|
|||
ShowWindowWithMode(mWindow->mWnd, aMode);
|
||||
}
|
||||
|
||||
mWindow->OnSizeModeChange();
|
||||
|
||||
if (fullscreenChange) {
|
||||
mWindow->OnFullscreenChanged(oldSizeMode, fullscreen);
|
||||
}
|
||||
|
||||
mWindow->OnSizeModeChange();
|
||||
}
|
||||
|
||||
void nsWindow::ContextMenuPreventer::Update(
|
||||
|
|
|
|||
|
|
@ -702,6 +702,7 @@ class nsWindow final : public nsBaseWidget {
|
|||
POINTER_FLAGS aFlags, uint32_t aPressure = 1024,
|
||||
uint32_t aOrientation = 90);
|
||||
|
||||
void OnFullscreenWillChange(bool aFullScreen);
|
||||
void OnFullscreenChanged(nsSizeMode aOldSizeMode, bool aFullScreen);
|
||||
|
||||
static void OnCloakEvent(HWND aWnd, bool aCloaked);
|
||||
|
|
|
|||
|
|
@ -2897,20 +2897,6 @@ bool AppWindow::RequestWindowClose(nsIWidget* aWidget) {
|
|||
}
|
||||
|
||||
void AppWindow::SizeModeChanged(nsSizeMode aSizeMode) {
|
||||
const bool wasWidgetInFullscreen = mIsWidgetInFullscreen;
|
||||
// Fullscreen and minimized states are usually compatible, and the widget
|
||||
// typically returns to fullscreen after restoration. By not updating the
|
||||
// widget's fullscreen state while it is minimized, we can avoid unnecessary
|
||||
// fullscreen exits, such as those encountered in bug 1823284.
|
||||
if (aSizeMode != nsSizeMode_Minimized) {
|
||||
mIsWidgetInFullscreen = aSizeMode == nsSizeMode_Fullscreen;
|
||||
}
|
||||
|
||||
const bool fullscreenChanged = wasWidgetInFullscreen != mIsWidgetInFullscreen;
|
||||
if (fullscreenChanged) {
|
||||
FullscreenWillChange(mIsWidgetInFullscreen);
|
||||
}
|
||||
|
||||
// An alwaysRaised (or higher) window will hide any newly opened normal
|
||||
// browser windows, so here we just drop a raised window to the normal
|
||||
// zlevel if it's maximized. We make no provision for automatically
|
||||
|
|
@ -2937,10 +2923,6 @@ void AppWindow::SizeModeChanged(nsSizeMode aSizeMode) {
|
|||
presShell->GetPresContext()->SizeModeChanged(aSizeMode);
|
||||
}
|
||||
|
||||
if (fullscreenChanged) {
|
||||
FullscreenChanged(mIsWidgetInFullscreen);
|
||||
}
|
||||
|
||||
// Note the current implementation of SetSizeMode just stores
|
||||
// the new state; it doesn't actually resize. So here we store
|
||||
// the state and pass the event on to the OS. The day is coming
|
||||
|
|
@ -2964,22 +2946,7 @@ void AppWindow::FullscreenWillChange(bool aInFullscreen) {
|
|||
}
|
||||
}
|
||||
MOZ_ASSERT(mFullscreenChangeState == FullscreenChangeState::NotChanging);
|
||||
|
||||
int32_t winWidth = 0;
|
||||
int32_t winHeight = 0;
|
||||
GetSize(&winWidth, &winHeight);
|
||||
|
||||
int32_t screenWidth = 0;
|
||||
int32_t screenHeight = 0;
|
||||
GetAvailScreenSize(&screenWidth, &screenHeight);
|
||||
|
||||
// Check if the window is already at the expected dimensions. If it is, set
|
||||
// the fullscreen change state to WidgetResized to avoid waiting for a resize
|
||||
// event.
|
||||
mFullscreenChangeState =
|
||||
(aInFullscreen == (winWidth == screenWidth && winHeight == screenHeight))
|
||||
? FullscreenChangeState::WidgetResized
|
||||
: FullscreenChangeState::WillChange;
|
||||
mFullscreenChangeState = FullscreenChangeState::WillChange;
|
||||
}
|
||||
|
||||
void AppWindow::FullscreenChanged(bool aInFullscreen) {
|
||||
|
|
@ -3454,6 +3421,17 @@ void AppWindow::WidgetListenerDelegate::UIResolutionChanged() {
|
|||
holder->UIResolutionChanged();
|
||||
}
|
||||
|
||||
void AppWindow::WidgetListenerDelegate::FullscreenWillChange(
|
||||
bool aInFullscreen) {
|
||||
RefPtr<AppWindow> holder = mAppWindow;
|
||||
holder->FullscreenWillChange(aInFullscreen);
|
||||
}
|
||||
|
||||
void AppWindow::WidgetListenerDelegate::FullscreenChanged(bool aInFullscreen) {
|
||||
RefPtr<AppWindow> holder = mAppWindow;
|
||||
holder->FullscreenChanged(aInFullscreen);
|
||||
}
|
||||
|
||||
void AppWindow::WidgetListenerDelegate::MacFullscreenMenubarOverlapChanged(
|
||||
DesktopCoord aOverlapAmount) {
|
||||
RefPtr<AppWindow> holder = mAppWindow;
|
||||
|
|
|
|||
|
|
@ -100,6 +100,10 @@ class AppWindow final : public nsIBaseWindow,
|
|||
MOZ_CAN_RUN_SCRIPT_BOUNDARY
|
||||
virtual void UIResolutionChanged() override;
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY
|
||||
virtual void FullscreenWillChange(bool aInFullscreen) override;
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY
|
||||
virtual void FullscreenChanged(bool aInFullscreen) override;
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY
|
||||
virtual void MacFullscreenMenubarOverlapChanged(
|
||||
mozilla::DesktopCoord aOverlapAmount) override;
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY
|
||||
|
|
@ -388,7 +392,6 @@ class AppWindow final : public nsIBaseWindow,
|
|||
nsresult MoveResize(const Maybe<DesktopPoint>& aPosition,
|
||||
const Maybe<DesktopSize>& aSize, bool aRepaint);
|
||||
nsCOMPtr<nsIXULStore> mLocalStore;
|
||||
bool mIsWidgetInFullscreen = false;
|
||||
};
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(AppWindow, NS_APPWINDOW_IMPL_CID)
|
||||
|
|
|
|||
Loading…
Reference in a new issue