Bug
1879816: Make nsCocoaWindow::Destroy close the window and let destruction happen later. r=mstange
This allows mWindow to stay alive as long as there are still references
to the nsCocoaWindow that owns it. This was the original intent before
the landing of Bug
1865372, which instead destroyed mWindow as soon as
possible. The important behavior in Destroy() is that the native window
becomes not visible. There are at least two ways to hide the window:
orderOut, which merely hides the window, and close (used here) which has
some additional semantic meaning and posts NSWindowWillCloseNotification.
That notification is detected by our window state save/restore code, so
closing the window is a trigger to update the window state. It's
appropriate to update this state during Destroy().
The alternative of hiding the window with orderOut also seems to confuse
the window manager when closing a fullscreen window (which was the
issue addressed by Bug
1865372). So we use close. In order to make this
work, we have to ensure that all new native windows have the property
releaseWhenClosed set to NO, and that we explicitly release mWindow in
DestroyNativeWindow().
Differential Revision: https://phabricator.services.mozilla.com/
D202363