forked from mirrors/gecko-dev
Backed out changeset da5a7c4478d9 (bug 1727815) for causing assertion failures on nsGlobalWindowOuter.cpp. CLOSED TREE
This commit is contained in:
parent
7b08264b23
commit
6c589aa7bd
3 changed files with 23 additions and 65 deletions
|
|
@ -7137,19 +7137,13 @@ nsresult nsWindow::MakeFullScreen(bool aFullScreen, nsIScreen* aTargetScreen) {
|
|||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
if (mWidgetListener) {
|
||||
// Signal a fullscreen state change request regardless of whether our widget
|
||||
// state already has the target value. This is necessary under e.g. wayland
|
||||
// where the compositor may refuse to let the widget enter xdg-shell
|
||||
// fullscreen mode but we're still toggling the internal fullscreen drawing
|
||||
// state.
|
||||
bool wasFullscreen = mSizeState == nsSizeMode_Fullscreen;
|
||||
if (aFullScreen != wasFullscreen && mWidgetListener) {
|
||||
mWidgetListener->FullscreenWillChange(aFullScreen);
|
||||
}
|
||||
|
||||
if (aFullScreen) {
|
||||
if (mSizeMode != nsSizeMode_Fullscreen) {
|
||||
mLastSizeMode = mSizeMode;
|
||||
}
|
||||
if (mSizeMode != nsSizeMode_Fullscreen) mLastSizeMode = mSizeMode;
|
||||
|
||||
mSizeMode = nsSizeMode_Fullscreen;
|
||||
|
||||
|
|
|
|||
|
|
@ -103,11 +103,6 @@
|
|||
|
||||
#define SIZE_PERSISTENCE_TIMEOUT 500 // msec
|
||||
|
||||
// Time to wait for window events that should trigger further actions but aren't
|
||||
// guaranteed to occur. Long enough for the desktop environment to act, but not
|
||||
// so long as to cause UI lag if it doesn't.
|
||||
#define NON_GUARANTEED_WINDOW_EVENT_TIMEOUT_MS 80
|
||||
|
||||
//*****************************************************************************
|
||||
//*** AppWindow: Object Management
|
||||
//*****************************************************************************
|
||||
|
|
@ -2175,19 +2170,6 @@ AppWindow::GetPrimaryContentSize(int32_t* aWidth, int32_t* aHeight) {
|
|||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
bool AppWindow::IsWaitingForFullscreenChange(
|
||||
FullscreenChangeState changeState) {
|
||||
switch (changeState) {
|
||||
case FullscreenChangeState::WillChange:
|
||||
case FullscreenChangeState::WidgetResized:
|
||||
return true;
|
||||
case FullscreenChangeState::NotChanging:
|
||||
case FullscreenChangeState::WidgetEnteredFullscreen:
|
||||
case FullscreenChangeState::WidgetExitedFullscreen:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
nsresult AppWindow::GetPrimaryRemoteTabSize(int32_t* aWidth, int32_t* aHeight) {
|
||||
BrowserHost* host = BrowserHost::GetFrom(mPrimaryBrowserParent.get());
|
||||
// Need strong ref, since Client* can run script.
|
||||
|
|
@ -2923,21 +2905,6 @@ void AppWindow::FullscreenWillChange(bool aInFullscreen) {
|
|||
}
|
||||
MOZ_ASSERT(mFullscreenChangeState == FullscreenChangeState::NotChanging);
|
||||
mFullscreenChangeState = FullscreenChangeState::WillChange;
|
||||
|
||||
// Wait for fullscreen state for a small amount of time: in some environments,
|
||||
// e.g. GTK running under wayland, a fullscreen request from the window widget
|
||||
// may be denied in which case no specific signal is received. In these cases
|
||||
// we have to trust the compositor/window-manager has placed us where it wants
|
||||
// and we can still finish setting the internal fullscreen state.
|
||||
NS_DelayedDispatchToCurrentThread(
|
||||
NS_NewRunnableFunction("AppWindow::FullscreenWillChange",
|
||||
[self = RefPtr<AppWindow>(this), aInFullscreen]() {
|
||||
if (self->IsWaitingForFullscreenChange(
|
||||
self->mFullscreenChangeState)) {
|
||||
self->FinishFullscreenChange(aInFullscreen);
|
||||
}
|
||||
}),
|
||||
NON_GUARANTEED_WINDOW_EVENT_TIMEOUT_MS);
|
||||
}
|
||||
|
||||
void AppWindow::FullscreenChanged(bool aInFullscreen) {
|
||||
|
|
@ -2952,9 +2919,10 @@ void AppWindow::FullscreenChanged(bool aInFullscreen) {
|
|||
: FullscreenChangeState::WidgetExitedFullscreen;
|
||||
mFullscreenChangeState = newState;
|
||||
nsCOMPtr<nsIAppWindow> kungFuDeathGrip(this);
|
||||
// Wait for resize but timeout if it looks like the widget resize is not
|
||||
// going to happen at all, which can be the case for some Linux window
|
||||
// managers and possibly Android.
|
||||
// Wait for resize for a small amount of time.
|
||||
// 80ms is actually picked arbitrarily. But it shouldn't be too large
|
||||
// in case the widget resize is not going to happen at all, which can
|
||||
// be the case for some Linux window managers and possibly Android.
|
||||
NS_DelayedDispatchToCurrentThread(
|
||||
NS_NewRunnableFunction(
|
||||
"AppWindow::FullscreenChanged",
|
||||
|
|
@ -2963,7 +2931,7 @@ void AppWindow::FullscreenChanged(bool aInFullscreen) {
|
|||
FinishFullscreenChange(aInFullscreen);
|
||||
}
|
||||
}),
|
||||
NON_GUARANTEED_WINDOW_EVENT_TIMEOUT_MS);
|
||||
80);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -265,35 +265,32 @@ class AppWindow final : public nsIBaseWindow,
|
|||
|
||||
// Enum for the current state of a fullscreen change.
|
||||
//
|
||||
// It is used to ensure that fullscreen change waits for both
|
||||
// It is used to ensure that fullscreen change is issued after both
|
||||
// the window state change and the window size change at best effort.
|
||||
// This is needed because some platforms can't guarantee the order
|
||||
// between such two events, or even that they occur at all.
|
||||
// between such two events.
|
||||
//
|
||||
// It's changed in the following way:
|
||||
// +--+------------------------+--------------------------------------+
|
||||
// | | | |
|
||||
// | | v |
|
||||
// | ^ delayed dispatch NotChanging |
|
||||
// | | (if no fullscreen) + |
|
||||
// | | | FullscreenWillChange |
|
||||
// | +-------------------+ v |
|
||||
// | | +-----------+ WillChange +------------------+ |
|
||||
// | | | WindowResized FullscreenChanged | |
|
||||
// | + v v |
|
||||
// +---------------------------+--------------------------------------+
|
||||
// | | |
|
||||
// | v |
|
||||
// | NotChanging |
|
||||
// | + |
|
||||
// | | FullscreenWillChange |
|
||||
// | v |
|
||||
// | +-----------+ WillChange +------------------+ |
|
||||
// | | WindowResized FullscreenChanged | |
|
||||
// | v v |
|
||||
// | WidgetResized WidgetEnteredFullscreen |
|
||||
// | + or WidgetExitedFullscreen |
|
||||
// | | FullscreenChanged + |
|
||||
// | v WindowResized or | |
|
||||
// +--------+ delayed dispatch | |
|
||||
// (if no resize) v |
|
||||
// v |
|
||||
// +-------------+
|
||||
//
|
||||
// The delayed dispatches serve as timeouts if expected widget state
|
||||
// changes never occur, which is necessary because it isn't guaranteed
|
||||
// that a widget will be made fullscreen when it wants (in some
|
||||
// environments), and it's not guaranteed that the widget will be resized
|
||||
// at all even if made fullscreen.
|
||||
// The delayed dispatch serves as timeout, which is necessary because it's
|
||||
// not even guaranteed that the widget will be resized at all.
|
||||
enum class FullscreenChangeState : uint8_t {
|
||||
// No current fullscreen change. Any previous change has finished.
|
||||
NotChanging,
|
||||
|
|
@ -351,7 +348,6 @@ class AppWindow final : public nsIBaseWindow,
|
|||
WidgetListenerDelegate mWidgetListenerDelegate;
|
||||
|
||||
private:
|
||||
static bool IsWaitingForFullscreenChange(FullscreenChangeState changeState);
|
||||
// GetPrimaryBrowserParentSize is called from xpidl methods and we don't have
|
||||
// a good way to annotate those with MOZ_CAN_RUN_SCRIPT yet. It takes no
|
||||
// refcounted args other than "this", and the "this" uses seem ok.
|
||||
|
|
|
|||
Loading…
Reference in a new issue