Backing about 484488.

This commit is contained in:
Doug Turner 2009-07-05 22:24:56 -07:00
parent 882aebc361
commit 55fdfb6010
14 changed files with 108 additions and 147 deletions

View File

@ -2582,7 +2582,6 @@ 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:

View File

@ -149,6 +149,7 @@
#include "nsIContentViewer.h"
#include "nsDOMClassInfo.h"
#include "nsIJSNativeInitializer.h"
#include "nsIFullScreen.h"
#include "nsIScriptError.h"
#include "nsIScriptEventManager.h" // For GetInterface()
#include "nsIConsoleService.h"
@ -603,6 +604,7 @@ nsGlobalWindow::nsGlobalWindow(nsGlobalWindow *aOuterWindow)
: nsPIDOMWindow(aOuterWindow),
mIsFrozen(PR_FALSE),
mDidInitJavaProperties(PR_FALSE),
mFullScreen(PR_FALSE),
mIsClosed(PR_FALSE),
mInClose(PR_FALSE),
mHavePendingClose(PR_FALSE),
@ -2112,6 +2114,29 @@ 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<nsIDOMWindow> activeWindow;
fm->GetActiveWindow(getter_AddRefs(activeWindow));
nsCOMPtr<nsIDocShellTreeItem> treeItem = do_QueryInterface(mDocShell);
nsCOMPtr<nsIDocShellTreeItem> rootItem;
treeItem->GetRootTreeItem(getter_AddRefs(rootItem));
nsCOMPtr<nsIDOMWindow> rootWin = do_GetInterface(rootItem);
if (rootWin == activeWindow) {
nsCOMPtr<nsIFullScreen> fullScreen =
do_GetService("@mozilla.org/browser/fullscreen;1");
if (fullScreen)
fullScreen->ShowAllOSChrome();
}
}
}
ClearControllers();
mChromeEventHandler = nsnull; // force release now
@ -3820,6 +3845,8 @@ nsGlobalWindow::SetFullScreen(PRBool aFullScreen)
if (widget)
widget->MakeFullScreen(aFullScreen);
mFullScreen = aFullScreen;
return NS_OK;
}
@ -3841,13 +3868,8 @@ nsGlobalWindow::GetFullScreen(PRBool* aFullScreen)
}
}
nsCOMPtr<nsIWidget> widget = GetMainWidget();
PRInt32 mode;
if (!widget)
return NS_ERROR_UNEXPECTED;
widget->GetSizeMode(&mode);
*aFullScreen = mode == nsSizeMode_Fullscreen;
// We are the root window, or something went wrong. Return our internal value.
*aFullScreen = mFullScreen;
return NS_OK;
}
@ -6570,6 +6592,20 @@ 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<nsIFullScreen> 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<nsIWidget> mainWidget = GetMainWidget();
@ -8765,9 +8801,6 @@ 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;
@ -8798,8 +8831,16 @@ nsGlobalChromeWindow::Minimize()
nsCOMPtr<nsIWidget> widget = GetMainWidget();
nsresult rv = NS_OK;
if (widget)
if (widget) {
// minimize doesn't send deactivate events on windows,
// so we need to forcefully restore the os chrome
nsCOMPtr<nsIFullScreen> fullScreen =
do_GetService("@mozilla.org/browser/fullscreen;1");
if (fullScreen)
fullScreen->ShowAllOSChrome();
rv = widget->SetSizeMode(nsSizeMode_Minimized);
}
return rv;
}

View File

@ -676,6 +676,7 @@ 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

View File

@ -40,13 +40,12 @@
interface nsIBrowserDOMWindow;
[scriptable, uuid(09A5E148-2A77-4739-9DD9-3D552F5390EE)]
[scriptable, uuid(77a20f5a-68ad-41d3-97ac-6ff721512908)]
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;

View File

@ -44,12 +44,7 @@ relativesrcdir = dom/tests/mochitest/chrome
include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/rules.mk
_TEST_FILES = \
test_fullscreen.xul \
fullscreen.xul \
test_fullscreen_preventdefault.xul \
fullscreen_preventdefault.xul \
test_domstorage.xul \
_TEST_FILES = test_domstorage.xul \
domstorage_global.xul \
domstorage_global.js \
test_focus.xul \

View File

@ -97,6 +97,7 @@ XPIDLSRCS = \
nsIRollupListener.idl \
nsIBaseWindow.idl \
nsIBidiKeyboard.idl \
nsIFullScreen.idl \
nsIScreen.idl \
nsIScreenManager.idl \
nsIPrintSession.idl \

View File

@ -63,8 +63,7 @@ enum nsEventStatus {
enum nsSizeMode {
nsSizeMode_Normal = 0,
nsSizeMode_Minimized,
nsSizeMode_Maximized,
nsSizeMode_Fullscreen
nsSizeMode_Maximized
};
class nsEvent;

View File

@ -1140,22 +1140,12 @@ NS_METHOD nsWindow::Show(PRBool bState)
if (!wasVisible && mWindowType == eWindowType_toplevel) {
switch (mSizeMode) {
#ifdef WINCE
case nsSizeMode_Fullscreen:
::SetForegroundWindow(mWnd);
::ShowWindow(mWnd, SW_SHOWMAXIMIZED);
MakeFullScreen(TRUE);
break;
case nsSizeMode_Maximized :
::SetForegroundWindow(mWnd);
::ShowWindow(mWnd, SW_SHOWMAXIMIZED);
break;
// use default for nsSizeMode_Minimized on Windows CE
#else
case nsSizeMode_Fullscreen:
::ShowWindow(mWnd, SW_SHOWMAXIMIZED);
break;
case nsSizeMode_Maximized :
::ShowWindow(mWnd, SW_SHOWMAXIMIZED);
break;
@ -1507,10 +1497,6 @@ NS_IMETHODIMP nsWindow::SetSizeMode(PRInt32 aMode) {
int mode;
switch (aMode) {
case nsSizeMode_Fullscreen :
mode = SW_MAXIMIZE;
break;
case nsSizeMode_Maximized :
mode = SW_MAXIMIZE;
break;
@ -2317,27 +2303,6 @@ NS_METHOD nsWindow::Invalidate(const nsIntRect & aRect, PRBool aIsSynchronous)
return NS_OK;
}
NS_IMETHODIMP
nsWindow::MakeFullScreen(PRBool aFullScreen)
{
#if WINCE
RECT rc;
if (aFullScreen) {
SetForegroundWindow(mWnd);
SHFullScreen(mWnd, SHFS_HIDETASKBAR | SHFS_HIDESTARTICON);
SetRect(&rc, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
}
else {
SHFullScreen(mWnd, SHFS_SHOWTASKBAR | SHFS_SHOWSTARTICON);
SystemParametersInfo(SPI_GETWORKAREA, 0, &rc, FALSE);
}
MoveWindow(mWnd, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, TRUE);
return NS_OK;
#else
return nsBaseWidget::MakeFullScreen(aFullScreen);
#endif
}
/**************************************************************
*
* SECTION: nsIWidget::Update
@ -4159,8 +4124,6 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM &wParam, LPARAM &lParam,
#else
*aRetValue = 0;
#endif
if (mSizeMode == nsSizeMode_Fullscreen)
MakeFullScreen(TRUE);
}
}
break;
@ -4320,7 +4283,7 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM &wParam, LPARAM &lParam,
else
event.mSizeMode = nsSizeMode_Normal;
#else
event.mSizeMode = mSizeMode;
event.mSizeMode = nsSizeMode_Normal;
#endif
InitEvent(event);
@ -6493,4 +6456,4 @@ DWORD ChildWindow::WindowStyle()
style |= WS_CHILD; // WS_POPUP and WS_CHILD are mutually exclusive.
VERIFY_WINDOW_STYLE(style);
return style;
}
}

View File

@ -140,7 +140,6 @@ public:
NS_IMETHOD SetCursor(imgIContainer* aCursor,
PRUint32 aHotspotX, PRUint32 aHotspotY);
NS_IMETHOD SetCursor(nsCursor aCursor);
NS_IMETHOD MakeFullScreen(PRBool aFullScreen);
NS_IMETHOD HideWindowChrome(PRBool aShouldHide);
NS_IMETHOD Validate();
NS_IMETHOD Invalidate(PRBool aIsSynchronous);
@ -520,4 +519,4 @@ protected:
virtual DWORD WindowStyle();
};
#endif // Window_h__
#endif // Window_h__

View File

@ -343,8 +343,7 @@ NS_IMETHODIMP nsWindow::SetSizeMode(PRInt32 aMode)
// on windows mobile, dialogs and top level windows are full screen
// This is partly due to the lack of a GetWindowPlacement.
if (mWindowType == eWindowType_dialog || mWindowType == eWindowType_toplevel) {
if (aMode == nsSizeMode_Normal)
aMode = nsSizeMode_Maximized;
aMode = nsSizeMode_Maximized;
}
#endif
@ -354,7 +353,6 @@ NS_IMETHODIMP nsWindow::SetSizeMode(PRInt32 aMode)
int mode;
switch (aMode) {
case nsSizeMode_Fullscreen :
case nsSizeMode_Maximized :
mode = SW_MAXIMIZE;
break;
@ -463,4 +461,4 @@ PRBool nsWindow::OnHotKey(WPARAM wParam, LPARAM lParam)
break;
}
return PR_FALSE;
}
}

View File

@ -41,6 +41,7 @@
#include "nsCOMPtr.h"
#include "nsGfxCIID.h"
#include "nsWidgetsCID.h"
#include "nsIFullScreen.h"
#include "nsServiceManagerUtils.h"
#include "nsIScreenManager.h"
#include "nsAppDirectoryServiceDefs.h"
@ -441,11 +442,8 @@ NS_IMETHODIMP nsBaseWidget::PlaceBehind(nsTopLevelWidgetZPlacement aPlacement,
//-------------------------------------------------------------------------
NS_IMETHODIMP nsBaseWidget::SetSizeMode(PRInt32 aMode) {
if (aMode == nsSizeMode_Normal ||
aMode == nsSizeMode_Minimized ||
aMode == nsSizeMode_Maximized ||
aMode == nsSizeMode_Fullscreen) {
if (aMode == nsSizeMode_Normal || aMode == nsSizeMode_Minimized ||
aMode == nsSizeMode_Maximized) {
mSizeMode = (nsSizeMode) aMode;
return NS_OK;
@ -588,10 +586,10 @@ NS_IMETHODIMP nsBaseWidget::HideWindowChrome(PRBool aShouldHide)
//-------------------------------------------------------------------------
NS_IMETHODIMP nsBaseWidget::MakeFullScreen(PRBool aFullScreen)
{
SetSizeMode(aFullScreen ? nsSizeMode_Fullscreen : nsSizeMode_Normal);
HideWindowChrome(aFullScreen);
nsCOMPtr<nsIFullScreen> fullScreen = do_GetService("@mozilla.org/browser/fullscreen;1");
if (aFullScreen) {
if (!mOriginalBounds)
mOriginalBounds = new nsIntRect();
@ -609,7 +607,12 @@ NS_IMETHODIMP nsBaseWidget::MakeFullScreen(PRBool aFullScreen)
if (screen) {
PRInt32 left, top, width, height;
if (NS_SUCCEEDED(screen->GetRect(&left, &top, &width, &height))) {
SetSizeMode(nsSizeMode_Normal);
Resize(left, top, width, height, PR_TRUE);
// Hide all of the OS chrome
if (fullScreen)
fullScreen->HideAllOSChrome();
}
}
}
@ -617,6 +620,10 @@ NS_IMETHODIMP nsBaseWidget::MakeFullScreen(PRBool aFullScreen)
} else if (mOriginalBounds) {
Resize(mOriginalBounds->x, mOriginalBounds->y, mOriginalBounds->width,
mOriginalBounds->height, PR_TRUE);
// Show all of the OS chrome
if (fullScreen)
fullScreen->ShowAllOSChrome();
}
return NS_OK;

View File

@ -347,8 +347,7 @@ nsWebShellWindow::HandleEvent(nsGUIEvent *aEvent)
// normal browser windows. here we just drop a raised window
// to the normal zlevel if it's maximized. we make no provision
// for automatically re-raising it when restored.
if (modeEvent->mSizeMode == nsSizeMode_Maximized ||
modeEvent->mSizeMode == nsSizeMode_Fullscreen) {
if (modeEvent->mSizeMode == nsSizeMode_Maximized) {
PRUint32 zLevel;
eventWindow->GetZLevel(&zLevel);
if (zLevel > nsIXULWindow::normalZ)

View File

@ -95,10 +95,9 @@
#include "nsWebShellWindow.h" // get rid of this one, too...
#define SIZEMODE_NORMAL NS_LITERAL_STRING("normal")
#define SIZEMODE_MAXIMIZED NS_LITERAL_STRING("maximized")
#define SIZEMODE_MINIMIZED NS_LITERAL_STRING("minimized")
#define SIZEMODE_FULLSCREEN NS_LITERAL_STRING("fullscreen")
#define SIZEMODE_NORMAL NS_LITERAL_STRING("normal")
#define SIZEMODE_MAXIMIZED NS_LITERAL_STRING("maximized")
#define SIZEMODE_MINIMIZED NS_LITERAL_STRING("minimized")
#define WINDOWTYPE_ATTRIBUTE NS_LITERAL_STRING("windowtype")
@ -256,7 +255,7 @@ NS_IMETHODIMP nsXULWindow::SetZLevel(PRUint32 aLevel)
PRInt32 sizeMode;
if (mWindow) {
mWindow->GetSizeMode(&sizeMode);
if (sizeMode == nsSizeMode_Maximized || sizeMode == nsSizeMode_Fullscreen)
if (sizeMode == nsSizeMode_Maximized)
return NS_ERROR_FAILURE;
}
}
@ -276,7 +275,30 @@ NS_IMETHODIMP nsXULWindow::SetZLevel(PRUint32 aLevel)
SavePersistentAttributes();
// finally, send a notification DOM event
DispatchCustomEvent(NS_LITERAL_STRING("windowZLevel"));
nsCOMPtr<nsIContentViewer> cv;
mDocShell->GetContentViewer(getter_AddRefs(cv));
nsCOMPtr<nsIDocumentViewer> dv(do_QueryInterface(cv));
if (dv) {
nsCOMPtr<nsIDocument> doc;
dv->GetDocument(getter_AddRefs(doc));
nsCOMPtr<nsIDOMDocumentEvent> docEvent(do_QueryInterface(doc));
if (docEvent) {
nsCOMPtr<nsIDOMEvent> event;
docEvent->CreateEvent(NS_LITERAL_STRING("Events"), getter_AddRefs(event));
if (event) {
event->InitEvent(NS_LITERAL_STRING("windowZLevel"), PR_TRUE, PR_FALSE);
nsCOMPtr<nsIPrivateDOMEvent> privateEvent(do_QueryInterface(event));
privateEvent->SetTrusted(PR_TRUE);
nsCOMPtr<nsIDOMEventTarget> targ(do_QueryInterface(doc));
if (targ) {
PRBool defaultActionEnabled;
targ->DispatchEvent(event, &defaultActionEnabled);
}
}
}
}
return NS_OK;
}
@ -1180,34 +1202,17 @@ PRBool nsXULWindow::LoadMiscPersistentAttributesFromXUL()
if (stateString.Equals(SIZEMODE_MINIMIZED))
sizeMode = nsSizeMode_Minimized;
*/
if (stateString.Equals(SIZEMODE_MAXIMIZED) || stateString.Equals(SIZEMODE_FULLSCREEN)) {
if (stateString.Equals(SIZEMODE_MAXIMIZED)) {
/* Honor request to maximize only if the window is sizable.
An unsizable, unmaximizable, yet maximized window confuses
Windows OS and is something of a travesty, anyway. */
if (mChromeFlags & nsIWebBrowserChrome::CHROME_WINDOW_RESIZE) {
mIntrinsicallySized = PR_FALSE;
if (stateString.Equals(SIZEMODE_MAXIMIZED))
sizeMode = nsSizeMode_Maximized;
else
sizeMode = nsSizeMode_Fullscreen;
sizeMode = nsSizeMode_Maximized;
}
}
// the widget had better be able to deal with not becoming visible yet.
// also, we set this before the dispatchcustomevent so that window.fullScreen
// is already set to true.
// the widget had better be able to deal with not becoming visible yet
mWindow->SetSizeMode(sizeMode);
// Dispatch fullscreen event
if (sizeMode == nsSizeMode_Fullscreen) {
if (!DispatchCustomEvent(NS_LITERAL_STRING("fullscreen"), PR_TRUE, PR_FALSE)) {
// fullscreen event prevented the default, set the window to
// maximized instead of fullscreen.
mWindow->SetSizeMode(nsSizeMode_Maximized);
}
}
gotState = PR_TRUE;
}
@ -1517,8 +1522,6 @@ NS_IMETHODIMP nsXULWindow::SavePersistentAttributes()
persistString.Find("sizemode") >= 0) {
if (sizeMode == nsSizeMode_Maximized)
sizeString.Assign(SIZEMODE_MAXIMIZED);
else if (sizeMode == nsSizeMode_Fullscreen)
sizeString.Assign(SIZEMODE_FULLSCREEN);
else
sizeString.Assign(SIZEMODE_NORMAL);
docShellElement->SetAttribute(MODE_ATTRIBUTE, sizeString);
@ -2136,48 +2139,6 @@ PRInt32 nsXULWindow::AppUnitsPerDevPixel()
return mAppPerDev;
}
PRBool nsXULWindow::DispatchCustomEvent(const nsAString& eventName, PRBool cancelable, PRBool toDocument)
{
nsCOMPtr<nsIContentViewer> cv;
mDocShell->GetContentViewer(getter_AddRefs(cv));
nsCOMPtr<nsIDocumentViewer> dv(do_QueryInterface(cv));
if (dv) {
nsCOMPtr<nsIDocument> doc;
dv->GetDocument(getter_AddRefs(doc));
nsCOMPtr<nsIDOMDocumentEvent> docEvent(do_QueryInterface(doc));
if (docEvent) {
nsCOMPtr<nsIDOMEvent> event;
docEvent->CreateEvent(NS_LITERAL_STRING("Events"), getter_AddRefs(event));
if (event) {
event->InitEvent(eventName, PR_TRUE, cancelable);
nsCOMPtr<nsIPrivateDOMEvent> privateEvent(do_QueryInterface(event));
privateEvent->SetTrusted(PR_TRUE);
if (toDocument) {
nsCOMPtr<nsIDOMEventTarget> targ(do_QueryInterface(doc));
if (targ) {
PRBool defaultActionEnabled;
targ->DispatchEvent(event, &defaultActionEnabled);
return defaultActionEnabled;
}
} else {
nsCOMPtr<nsIDOMWindowInternal> ourWindow;
GetWindowDOMWindow(getter_AddRefs(ourWindow));
nsCOMPtr<nsIDOMEventTarget> targ(do_QueryInterface(ourWindow));
if (targ) {
PRBool defaultActionEnabled;
targ->DispatchEvent(event, &defaultActionEnabled);
return defaultActionEnabled;
}
}
}
}
}
return PR_TRUE;
}
//*****************************************************************************
//*** nsContentShellInfo: Object Management
//*****************************************************************************

View File

@ -150,7 +150,6 @@ protected:
PRBool GetContentScrollbarVisibility();
void PersistentAttributesDirty(PRUint32 aDirtyFlags);
PRInt32 AppUnitsPerDevPixel();
PRBool DispatchCustomEvent(const nsAString& eventName, PRBool cancelable = PR_FALSE, PRBool toDocument = PR_TRUE);
nsChromeTreeOwner* mChromeTreeOwner;
nsContentTreeOwner* mContentTreeOwner;