Skip to content
This repository has been archived by the owner on Aug 4, 2022. It is now read-only.

Commit

Permalink
Bug 1160014 part 0 - Avoid explicitly mentioning DOM Fullscreen conce…
Browse files Browse the repository at this point in the history
…pt in widget part. r=roc
  • Loading branch information
upsuper committed Jul 13, 2015
1 parent bfafeb8 commit 0115a8a
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 45 deletions.
9 changes: 6 additions & 3 deletions dom/base/nsGlobalWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
17 changes: 10 additions & 7 deletions widget/cocoa/nsCocoaWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<nsIWidget>
AllocateChildPopupWidget() override
{
Expand Down Expand Up @@ -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.
Expand Down
42 changes: 23 additions & 19 deletions widget/cocoa/nsCocoaWindow.mm
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ static void RollUpPopups()
, mSheetNeedsShow(false)
, mInFullScreenMode(false)
, mInFullScreenTransition(false)
, mInDOMFullscreenTransition(false)
, mModal(false)
, mSupportsNativeFullScreen(false)
, mInNativeFullScreenMode(false)
Expand Down Expand Up @@ -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;
Expand All @@ -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.
Expand All @@ -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;

Expand All @@ -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:]
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion widget/nsBaseWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
29 changes: 14 additions & 15 deletions widget/nsIWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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.
Expand Down

0 comments on commit 0115a8a

Please sign in to comment.