From d210ca62c4de2b03ff725ffba8552872f2008361 Mon Sep 17 00:00:00 2001 From: Doug Turner Date: Wed, 1 Jul 2009 12:01:11 -0700 Subject: [PATCH] Bug 484488 - MakeFullWindow support for windows mobile. r=olli.pettay, sr=vlad --- .../sessionstore/src/nsSessionStore.js | 1 + dom/base/nsGlobalWindow.cpp | 63 +++--------- dom/base/nsGlobalWindow.h | 1 - dom/interfaces/base/nsIDOMChromeWindow.idl | 3 +- dom/tests/mochitest/chrome/Makefile.in | 7 +- dom/tests/mochitest/chrome/fullscreen.xul | 29 ++++++ .../chrome/fullscreen_preventdefault.xul | 30 ++++++ .../mochitest/chrome/test_fullscreen.xul | 37 +++++++ .../chrome/test_fullscreen_preventdefault.xul | 39 ++++++++ widget/public/Makefile.in | 1 - widget/public/nsEvent.h | 3 +- widget/src/windows/nsWindow.cpp | 41 +++++++- widget/src/windows/nsWindow.h | 3 +- widget/src/windows/nsWindowCE.cpp | 6 +- widget/src/xpwidgets/nsBaseWidget.cpp | 21 ++-- xpfe/appshell/src/nsWebShellWindow.cpp | 3 +- xpfe/appshell/src/nsXULWindow.cpp | 98 +++++++++++++------ xpfe/appshell/src/nsXULWindow.h | 1 + 18 files changed, 280 insertions(+), 107 deletions(-) create mode 100644 dom/tests/mochitest/chrome/fullscreen.xul create mode 100644 dom/tests/mochitest/chrome/fullscreen_preventdefault.xul create mode 100644 dom/tests/mochitest/chrome/test_fullscreen.xul create mode 100644 dom/tests/mochitest/chrome/test_fullscreen_preventdefault.xul diff --git a/browser/components/sessionstore/src/nsSessionStore.js b/browser/components/sessionstore/src/nsSessionStore.js index 56b6eab05a05..6cf4753df36c 100644 --- a/browser/components/sessionstore/src/nsSessionStore.js +++ b/browser/components/sessionstore/src/nsSessionStore.js @@ -2582,6 +2582,7 @@ SessionStoreService.prototype = { _getWindowDimension: function sss_getWindowDimension(aWindow, aAttribute) { if (aAttribute == "sizemode") { switch (aWindow.windowState) { + case aWindow.STATE_FULLSCREEN: case aWindow.STATE_MAXIMIZED: return "maximized"; case aWindow.STATE_MINIMIZED: diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index 9c267154a932..f6651b3487c1 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -148,7 +148,6 @@ #include "nsIContentViewer.h" #include "nsDOMClassInfo.h" #include "nsIJSNativeInitializer.h" -#include "nsIFullScreen.h" #include "nsIScriptError.h" #include "nsIScriptEventManager.h" // For GetInterface() #include "nsIConsoleService.h" @@ -603,7 +602,6 @@ nsGlobalWindow::nsGlobalWindow(nsGlobalWindow *aOuterWindow) : nsPIDOMWindow(aOuterWindow), mIsFrozen(PR_FALSE), mDidInitJavaProperties(PR_FALSE), - mFullScreen(PR_FALSE), mIsClosed(PR_FALSE), mInClose(PR_FALSE), mHavePendingClose(PR_FALSE), @@ -2113,29 +2111,6 @@ nsGlobalWindow::SetDocShell(nsIDocShell* aDocShell) langCtx->ClearScope(mScriptGlobals[NS_STID_INDEX(lang_id)], PR_TRUE); } - // if we are closing the window while in full screen mode, be sure - // to restore os chrome - if (mFullScreen) { - // only restore OS chrome if the closing window was active - nsIFocusManager* fm = nsFocusManager::GetFocusManager(); - if (fm) { - nsCOMPtr activeWindow; - fm->GetActiveWindow(getter_AddRefs(activeWindow)); - - nsCOMPtr treeItem = do_QueryInterface(mDocShell); - nsCOMPtr rootItem; - treeItem->GetRootTreeItem(getter_AddRefs(rootItem)); - nsCOMPtr rootWin = do_GetInterface(rootItem); - if (rootWin == activeWindow) { - nsCOMPtr fullScreen = - do_GetService("@mozilla.org/browser/fullscreen;1"); - - if (fullScreen) - fullScreen->ShowAllOSChrome(); - } - } - } - ClearControllers(); mChromeEventHandler = nsnull; // force release now @@ -3844,8 +3819,6 @@ nsGlobalWindow::SetFullScreen(PRBool aFullScreen) if (widget) widget->MakeFullScreen(aFullScreen); - mFullScreen = aFullScreen; - return NS_OK; } @@ -3867,8 +3840,13 @@ nsGlobalWindow::GetFullScreen(PRBool* aFullScreen) } } - // We are the root window, or something went wrong. Return our internal value. - *aFullScreen = mFullScreen; + nsCOMPtr widget = GetMainWidget(); + PRInt32 mode; + if (!widget) + return NS_ERROR_UNEXPECTED; + + widget->GetSizeMode(&mode); + *aFullScreen = mode == nsSizeMode_Fullscreen; return NS_OK; } @@ -6591,20 +6569,6 @@ nsGlobalWindow::GetLocation(nsIDOMLocation ** aLocation) void nsGlobalWindow::ActivateOrDeactivate(PRBool aActivate) { - // if the window is deactivated while in full screen mode, - // restore OS chrome, and hide it again upon re-activation - nsGlobalWindow* outer = GetOuterWindowInternal(); - if (outer && outer->mFullScreen) { - nsCOMPtr fullScreen = - do_GetService("@mozilla.org/browser/fullscreen;1"); - if (fullScreen) { - if (aActivate) - fullScreen->HideAllOSChrome(); - else - fullScreen->ShowAllOSChrome(); - } - } - // Set / unset the "active" attribute on the documentElement // of the top level window nsCOMPtr mainWidget = GetMainWidget(); @@ -8767,6 +8731,9 @@ nsGlobalChromeWindow::GetWindowState(PRUint16* aWindowState) case nsSizeMode_Maximized: *aWindowState = nsIDOMChromeWindow::STATE_MAXIMIZED; break; + case nsSizeMode_Fullscreen: + *aWindowState = nsIDOMChromeWindow::STATE_FULLSCREEN; + break; case nsSizeMode_Normal: *aWindowState = nsIDOMChromeWindow::STATE_NORMAL; break; @@ -8797,16 +8764,8 @@ nsGlobalChromeWindow::Minimize() nsCOMPtr widget = GetMainWidget(); nsresult rv = NS_OK; - if (widget) { - // minimize doesn't send deactivate events on windows, - // so we need to forcefully restore the os chrome - nsCOMPtr fullScreen = - do_GetService("@mozilla.org/browser/fullscreen;1"); - if (fullScreen) - fullScreen->ShowAllOSChrome(); - + if (widget) rv = widget->SetSizeMode(nsSizeMode_Minimized); - } return rv; } diff --git a/dom/base/nsGlobalWindow.h b/dom/base/nsGlobalWindow.h index 183d8bc2c75a..97180b4ffd6b 100644 --- a/dom/base/nsGlobalWindow.h +++ b/dom/base/nsGlobalWindow.h @@ -670,7 +670,6 @@ protected: // These members are only used on outer window objects. Make sure // you never set any of these on an inner object! - PRPackedBool mFullScreen : 1; PRPackedBool mIsClosed : 1; PRPackedBool mInClose : 1; // mHavePendingClose means we've got a termination function set to diff --git a/dom/interfaces/base/nsIDOMChromeWindow.idl b/dom/interfaces/base/nsIDOMChromeWindow.idl index f7372abafa63..a5366ef25fa4 100644 --- a/dom/interfaces/base/nsIDOMChromeWindow.idl +++ b/dom/interfaces/base/nsIDOMChromeWindow.idl @@ -40,12 +40,13 @@ interface nsIBrowserDOMWindow; -[scriptable, uuid(77a20f5a-68ad-41d3-97ac-6ff721512908)] +[scriptable, uuid(09A5E148-2A77-4739-9DD9-3D552F5390EE)] interface nsIDOMChromeWindow : nsISupports { const unsigned short STATE_MAXIMIZED = 1; const unsigned short STATE_MINIMIZED = 2; const unsigned short STATE_NORMAL = 3; + const unsigned short STATE_FULLSCREEN = 4; readonly attribute unsigned short windowState; diff --git a/dom/tests/mochitest/chrome/Makefile.in b/dom/tests/mochitest/chrome/Makefile.in index 74f3eff1f428..8490bb82a16e 100644 --- a/dom/tests/mochitest/chrome/Makefile.in +++ b/dom/tests/mochitest/chrome/Makefile.in @@ -44,7 +44,12 @@ relativesrcdir = dom/tests/mochitest/chrome include $(DEPTH)/config/autoconf.mk include $(topsrcdir)/config/rules.mk -_TEST_FILES = test_domstorage.xul \ +_TEST_FILES = \ + test_fullscreen.xul \ + fullscreen.xul \ + test_fullscreen_preventdefault.xul \ + fullscreen_preventdefault.xul \ + test_domstorage.xul \ domstorage_global.xul \ domstorage_global.js \ test_focus.xul \ diff --git a/dom/tests/mochitest/chrome/fullscreen.xul b/dom/tests/mochitest/chrome/fullscreen.xul new file mode 100644 index 000000000000..ea8c5773a3fb --- /dev/null +++ b/dom/tests/mochitest/chrome/fullscreen.xul @@ -0,0 +1,29 @@ + + + + + + + + + + + +