diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index 25679f0e7965..95989abed8b0 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -6104,10 +6104,13 @@ nsGlobalWindow::SetFullscreenInternal(FullscreenReason aReason, if (aHMD) { screen = aHMD->GetScreen(); } - if (aReason == eForFullscreenAPI) { - widget->PrepareForDOMFullscreenTransition(); + if (aReason == eForFullscreenMode) { + // If we enter fullscreen for fullscreen mode, we want + // the native system behavior. + widget->MakeFullScreenWithNativeTransition(aFullScreen, screen); + } else { + widget->MakeFullScreen(aFullScreen, screen); } - widget->MakeFullScreen(aFullScreen, screen); // The rest of code for switching fullscreen is in nsGlobalWindow:: // FinishFullscreenChange() which will be called after sizemodechange // event is dispatched. diff --git a/widget/cocoa/nsCocoaWindow.h b/widget/cocoa/nsCocoaWindow.h index 182d2c6dc6ab..8c049d3c8976 100644 --- a/widget/cocoa/nsCocoaWindow.h +++ b/widget/cocoa/nsCocoaWindow.h @@ -285,10 +285,13 @@ class nsCocoaWindow : public nsBaseWidget, public nsPIWidgetCocoa nsIWidget *aWidget, bool aActivate) override; NS_IMETHOD SetSizeMode(int32_t aMode) override; NS_IMETHOD HideWindowChrome(bool aShouldHide) override; - virtual void PrepareForDOMFullscreenTransition() override; + void EnteredFullScreen(bool aFullScreen, bool aNativeMode = true); - inline bool ShouldToggleNativeFullscreen(bool aFullScreen); - NS_IMETHOD MakeFullScreen(bool aFullScreen, nsIScreen* aTargetScreen = nullptr) override; + NS_IMETHOD MakeFullScreen( + bool aFullScreen, nsIScreen* aTargetScreen = nullptr) override final; + NS_IMETHOD MakeFullScreenWithNativeTransition( + bool aFullScreen, nsIScreen* aTargetScreen = nullptr) override final; + NS_IMETHOD Resize(double aWidth, double aHeight, bool aRepaint) override; NS_IMETHOD Resize(double aX, double aY, double aWidth, double aHeight, bool aRepaint) override; NS_IMETHOD GetClientBounds(nsIntRect &aRect) override; @@ -385,6 +388,10 @@ class nsCocoaWindow : public nsBaseWidget, public nsPIWidgetCocoa nsresult DoResize(double aX, double aY, double aWidth, double aHeight, bool aRepaint, bool aConstrainToCurrentScreen); + inline bool ShouldToggleNativeFullscreen(bool aFullScreen, + bool aUseSystemTransition); + nsresult DoMakeFullScreen(bool aFullScreen, bool aUseSystemTransition); + virtual already_AddRefed AllocateChildPopupWidget() override { @@ -414,10 +421,6 @@ class nsCocoaWindow : public nsBaseWidget, public nsPIWidgetCocoa bool mInFullScreenMode; bool mInFullScreenTransition; // true from the request to enter/exit fullscreen // (MakeFullScreen() call) to EnteredFullScreen() - // We are in transition to/from DOM Fullscreen. - // XXX The transition is not implemented yet. This is currently only - // used to distinguish between DOM fullscreen and fullscreen mode. - bool mInDOMFullscreenTransition; bool mModal; // Only true on 10.7+ if SetShowsFullScreenButton(true) is called. diff --git a/widget/cocoa/nsCocoaWindow.mm b/widget/cocoa/nsCocoaWindow.mm index eb9626fa3626..2dbb22779773 100644 --- a/widget/cocoa/nsCocoaWindow.mm +++ b/widget/cocoa/nsCocoaWindow.mm @@ -108,7 +108,6 @@ static void RollUpPopups() , mSheetNeedsShow(false) , mInFullScreenMode(false) , mInFullScreenTransition(false) -, mInDOMFullscreenTransition(false) , mModal(false) , mSupportsNativeFullScreen(false) , mInNativeFullScreenMode(false) @@ -1266,11 +1265,6 @@ static unsigned int WindowMaskForBorderStyle(nsBorderStyle aBorderStyle) NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT; } -void nsCocoaWindow::PrepareForDOMFullscreenTransition() -{ - mInDOMFullscreenTransition = true; -} - void nsCocoaWindow::EnteredFullScreen(bool aFullScreen, bool aNativeMode) { mInFullScreenTransition = false; @@ -1284,7 +1278,9 @@ static unsigned int WindowMaskForBorderStyle(nsBorderStyle aBorderStyle) } } -inline bool nsCocoaWindow::ShouldToggleNativeFullscreen(bool aFullScreen) +inline bool +nsCocoaWindow::ShouldToggleNativeFullscreen(bool aFullScreen, + bool aUseSystemTransition) { if (!mSupportsNativeFullScreen) { // If we cannot use native fullscreen, don't touch it. @@ -1294,17 +1290,30 @@ static unsigned int WindowMaskForBorderStyle(nsBorderStyle aBorderStyle) // If we are using native fullscreen, go ahead to exit it. return true; } - if (mInDOMFullscreenTransition) { - // We shouldn't use native fullscreen for DOM fullscreen. + if (!aUseSystemTransition) { + // If we do not want the system fullscreen transition, + // don't use the native fullscreen. return false; } - // If we are using native fullscreen, we should have returned earlier, - // which means if we reach here for exiting fullscreen, we must be - // exiting from DOM fullscreen, not native fullscreen. + // If we are using native fullscreen, we should have returned earlier. return aFullScreen; } -NS_METHOD nsCocoaWindow::MakeFullScreen(bool aFullScreen, nsIScreen* aTargetScreen) +NS_IMETHODIMP +nsCocoaWindow::MakeFullScreen(bool aFullScreen, nsIScreen* aTargetScreen) +{ + return DoMakeFullScreen(aFullScreen, false); +} + +NS_IMETHODIMP +nsCocoaWindow::MakeFullScreenWithNativeTransition(bool aFullScreen, + nsIScreen* aTargetScreen) +{ + return DoMakeFullScreen(aFullScreen, true); +} + +nsresult +nsCocoaWindow::DoMakeFullScreen(bool aFullScreen, bool aUseSystemTransition) { NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT; @@ -1322,7 +1331,7 @@ static unsigned int WindowMaskForBorderStyle(nsBorderStyle aBorderStyle) mInFullScreenTransition = true; - if (ShouldToggleNativeFullscreen(aFullScreen)) { + if (ShouldToggleNativeFullscreen(aFullScreen, aUseSystemTransition)) { // If we're using native fullscreen mode and our native window is invisible, // our attempt to go into fullscreen mode will fail with an assertion in // system code, without [WindowDelegate windowDidFailToEnterFullScreen:] @@ -1350,11 +1359,6 @@ static unsigned int WindowMaskForBorderStyle(nsBorderStyle aBorderStyle) EnteredFullScreen(aFullScreen, /* aNativeMode */ false); } - if (mInDOMFullscreenTransition) { - // Clear the flag about DOM fullscreen. - mInDOMFullscreenTransition = false; - } - return NS_OK; NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT; diff --git a/widget/nsBaseWidget.h b/widget/nsBaseWidget.h index dfb4a184b703..12838e0b043b 100644 --- a/widget/nsBaseWidget.h +++ b/widget/nsBaseWidget.h @@ -143,8 +143,8 @@ class nsBaseWidget : public nsIWidget, public nsSupportsWeakReference virtual void SetShowsFullScreenButton(bool aShow) override {} virtual void SetWindowAnimationType(WindowAnimationType aType) override {} NS_IMETHOD HideWindowChrome(bool aShouldHide) override; - virtual void PrepareForDOMFullscreenTransition() override {} NS_IMETHOD MakeFullScreen(bool aFullScreen, nsIScreen* aScreen = nullptr) override; + virtual LayerManager* GetLayerManager(PLayerTransactionChild* aShadowManager = nullptr, LayersBackend aBackendHint = mozilla::layers::LayersBackend::LAYERS_NONE, LayerManagerPersistence aPersistence = LAYER_MANAGER_CURRENT, diff --git a/widget/nsIWidget.h b/widget/nsIWidget.h index cb3aa50d7fba..7eaa4889a8d1 100644 --- a/widget/nsIWidget.h +++ b/widget/nsIWidget.h @@ -119,8 +119,8 @@ typedef void* nsNativeWidget; #define NS_NATIVE_PLUGIN_ID 105 #define NS_IWIDGET_IID \ -{ 0x53376F57, 0xF081, 0x4949, \ - { 0xB5, 0x5E, 0x87, 0xEF, 0x6A, 0xE9, 0xE3, 0x5A } }; +{ 0xb81e1264, 0x9f79, 0x4962, \ + { 0x8d, 0x9a, 0x64, 0xdd, 0x21, 0x5d, 0x6a, 0x01 } } /* * Window shadow styles @@ -1696,19 +1696,6 @@ class nsIWidget : public nsISupports { */ NS_IMETHOD HideWindowChrome(bool aShouldHide) = 0; - /** - * Ask the widget to start the transition for entering or exiting - * DOM Fullscreen. - * - * XXX This method is currently not actually implemented by any - * widget. The only function of this method is to notify cocoa - * window that it should not use the native fullscreen mode. This - * method is reserved for bug 1160014 where a transition will be - * added for DOM fullscreen. Hence, this function is likely to - * be further changed then. - */ - virtual void PrepareForDOMFullscreenTransition() = 0; - /** * Put the toplevel window into or out of fullscreen mode. * If aTargetScreen is given, attempt to go fullscreen on that screen, @@ -1718,6 +1705,18 @@ class nsIWidget : public nsISupports { */ NS_IMETHOD MakeFullScreen(bool aFullScreen, nsIScreen* aTargetScreen = nullptr) = 0; + /** + * Same as MakeFullScreen, except that, on systems which natively + * support fullscreen transition, calling this method explicitly + * requests that behavior. + * It is currently only supported on OS X 10.7+. + */ + NS_IMETHOD MakeFullScreenWithNativeTransition( + bool aFullScreen, nsIScreen* aTargetScreen = nullptr) + { + return MakeFullScreen(aFullScreen, aTargetScreen); + } + /** * Invalidate a specified rect for a widget so that it will be repainted * later.