Bug 410337. Pass the parent window further down the window creation path so that its screen rect can be saved in nsXULWindow and used to determine what screen to open on in some cases. r=enndeakin
--HG-- extra : rebase_source : 889687a90625b8bb070ea015b93ffcc28570fb6a
This commit is contained in:
Родитель
e33126357c
Коммит
203decf4a6
|
@ -98,12 +98,15 @@ interface nsIXULWindow : nsISupports
|
|||
|
||||
/**
|
||||
* Move the window to a centered position.
|
||||
* @param aRelative the window relative to which the window is moved.
|
||||
* See screen parameter for details. if null, the
|
||||
* window is centered relative to the main screen.
|
||||
* @param aRelative If not null, the window relative to which the window is
|
||||
* moved. See aScreen parameter for details.
|
||||
* @param aScreen PR_TRUE to center the window relative to the screen
|
||||
* containing aRelative. PR_FALSE to center it relative
|
||||
* to aRelative itself.
|
||||
* containing aRelative if aRelative is not null. If
|
||||
* aRelative is null then relative to the screen of the
|
||||
* opener window if it was initialized by passing it to
|
||||
* nsWebShellWindow::Initialize. Failing that relative to
|
||||
* the main screen.
|
||||
* PR_FALSE to center it relative to aRelative itself.
|
||||
* @param aAlert PR_TRUE to move the window to an alert position,
|
||||
* generally centered horizontally and 1/3 down from the top.
|
||||
*/
|
||||
|
|
|
@ -238,7 +238,10 @@ nsAppShellService::CreateTopLevelWindow(nsIXULWindow *aParent,
|
|||
if (NS_SUCCEEDED(rv)) {
|
||||
// the addref resulting from this is the owning addref for this window
|
||||
RegisterTopLevelWindow(*aResult);
|
||||
(*aResult)->SetZLevel(CalculateWindowZLevel(aParent, aChromeMask));
|
||||
nsCOMPtr<nsIXULWindow> parent;
|
||||
if (aChromeMask & nsIWebBrowserChrome::CHROME_DEPENDENT)
|
||||
parent = aParent;
|
||||
(*aResult)->SetZLevel(CalculateWindowZLevel(parent, aChromeMask));
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
@ -295,6 +298,10 @@ nsAppShellService::JustCreateTopWindow(nsIXULWindow *aParent,
|
|||
{
|
||||
*aResult = nsnull;
|
||||
|
||||
nsCOMPtr<nsIXULWindow> parent;
|
||||
if (aChromeMask & nsIWebBrowserChrome::CHROME_DEPENDENT)
|
||||
parent = aParent;
|
||||
|
||||
nsRefPtr<nsWebShellWindow> window = new nsWebShellWindow(aChromeMask);
|
||||
NS_ENSURE_TRUE(window, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
|
@ -319,7 +326,7 @@ nsAppShellService::JustCreateTopWindow(nsIXULWindow *aParent,
|
|||
PRUint32 sheetMask = nsIWebBrowserChrome::CHROME_OPENAS_DIALOG |
|
||||
nsIWebBrowserChrome::CHROME_MODAL |
|
||||
nsIWebBrowserChrome::CHROME_OPENAS_CHROME;
|
||||
if (aParent && ((aChromeMask & sheetMask) == sheetMask))
|
||||
if (parent && ((aChromeMask & sheetMask) == sheetMask))
|
||||
widgetInitData.mWindowType = eWindowType_sheet;
|
||||
#endif
|
||||
|
||||
|
@ -361,18 +368,21 @@ nsAppShellService::JustCreateTopWindow(nsIXULWindow *aParent,
|
|||
window->SetIntrinsicallySized(PR_TRUE);
|
||||
}
|
||||
|
||||
nsresult rv = window->Initialize(aParent, aAppShell, aUrl,
|
||||
PRBool center = aChromeMask & nsIWebBrowserChrome::CHROME_CENTER_SCREEN;
|
||||
|
||||
nsresult rv = window->Initialize(parent, center ? aParent : nsnull,
|
||||
aAppShell, aUrl,
|
||||
aInitialWidth, aInitialHeight,
|
||||
aIsHiddenWindow, widgetInitData);
|
||||
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
window.swap(*aResult); // transfer reference
|
||||
if (aParent)
|
||||
aParent->AddChildWindow(*aResult);
|
||||
if (parent)
|
||||
parent->AddChildWindow(*aResult);
|
||||
|
||||
if (aChromeMask & nsIWebBrowserChrome::CHROME_CENTER_SCREEN)
|
||||
rv = (*aResult)->Center(aParent, aParent ? PR_FALSE : PR_TRUE, PR_FALSE);
|
||||
if (center)
|
||||
rv = (*aResult)->Center(parent, parent ? PR_FALSE : PR_TRUE, PR_FALSE);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
|
|
@ -150,7 +150,8 @@ NS_INTERFACE_MAP_BEGIN(nsWebShellWindow)
|
|||
NS_INTERFACE_MAP_END_INHERITING(nsXULWindow)
|
||||
|
||||
nsresult nsWebShellWindow::Initialize(nsIXULWindow* aParent,
|
||||
nsIAppShell* aShell, nsIURI* aUrl,
|
||||
nsIXULWindow* aOpener,
|
||||
nsIAppShell* aShell, nsIURI* aUrl,
|
||||
PRInt32 aInitialWidth,
|
||||
PRInt32 aInitialHeight,
|
||||
PRBool aIsHiddenWindow,
|
||||
|
@ -160,7 +161,18 @@ nsresult nsWebShellWindow::Initialize(nsIXULWindow* aParent,
|
|||
nsCOMPtr<nsIWidget> parentWidget;
|
||||
|
||||
mIsHiddenWindow = aIsHiddenWindow;
|
||||
|
||||
|
||||
nsCOMPtr<nsIBaseWindow> base(do_QueryInterface(aOpener));
|
||||
if (base) {
|
||||
rv = base->GetPositionAndSize(&mOpenerScreenRect.x,
|
||||
&mOpenerScreenRect.y,
|
||||
&mOpenerScreenRect.width,
|
||||
&mOpenerScreenRect.height);
|
||||
if (NS_FAILED(rv)) {
|
||||
mOpenerScreenRect.Empty();
|
||||
}
|
||||
}
|
||||
|
||||
// XXX: need to get the default window size from prefs...
|
||||
// Doesn't come from prefs... will come from CSS/XUL/RDF
|
||||
nsIntRect r(0, 0, aInitialWidth, aInitialHeight);
|
||||
|
|
|
@ -62,8 +62,8 @@ public:
|
|||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
// nsWebShellWindow methods...
|
||||
nsresult Initialize(nsIXULWindow * aParent, nsIAppShell* aShell,
|
||||
nsIURI* aUrl,
|
||||
nsresult Initialize(nsIXULWindow * aParent, nsIXULWindow * aOpener,
|
||||
nsIAppShell* aShell, nsIURI* aUrl,
|
||||
PRInt32 aInitialWidth, PRInt32 aInitialHeight,
|
||||
PRBool aIsHiddenWindow,
|
||||
nsWidgetInitData& widgetInitData);
|
||||
|
|
|
@ -685,8 +685,15 @@ NS_IMETHODIMP nsXULWindow::Center(nsIXULWindow *aRelative, PRBool aScreen, PRBoo
|
|||
}
|
||||
}
|
||||
}
|
||||
if (!aRelative)
|
||||
screenmgr->GetPrimaryScreen(getter_AddRefs(screen));
|
||||
if (!aRelative) {
|
||||
if (!mOpenerScreenRect.IsEmpty()) {
|
||||
screenmgr->ScreenForRect(mOpenerScreenRect.x, mOpenerScreenRect.y,
|
||||
mOpenerScreenRect.width, mOpenerScreenRect.height,
|
||||
getter_AddRefs(screen));
|
||||
} else {
|
||||
screenmgr->GetPrimaryScreen(getter_AddRefs(screen));
|
||||
}
|
||||
}
|
||||
|
||||
if (aScreen && screen) {
|
||||
screen->GetAvailRect(&left, &top, &width, &height);
|
||||
|
@ -1691,13 +1698,9 @@ NS_IMETHODIMP nsXULWindow::CreateNewChromeWindow(PRInt32 aChromeFlags,
|
|||
NS_ENSURE_TRUE(appShell, NS_ERROR_FAILURE);
|
||||
|
||||
// Just do a normal create of a window and return.
|
||||
//XXXTAB remove this when appshell talks in terms of nsIXULWindow
|
||||
nsCOMPtr<nsIXULWindow> parent;
|
||||
if (aChromeFlags & nsIWebBrowserChrome::CHROME_DEPENDENT)
|
||||
parent = this;
|
||||
|
||||
nsCOMPtr<nsIXULWindow> newWindow;
|
||||
appShell->CreateTopLevelWindow(parent, nsnull, aChromeFlags,
|
||||
appShell->CreateTopLevelWindow(this, nsnull, aChromeFlags,
|
||||
nsIAppShellService::SIZE_TO_CONTENT,
|
||||
nsIAppShellService::SIZE_TO_CONTENT,
|
||||
aAppShell, getter_AddRefs(newWindow));
|
||||
|
@ -1719,10 +1722,6 @@ NS_IMETHODIMP nsXULWindow::CreateNewContentWindow(PRInt32 aChromeFlags,
|
|||
nsCOMPtr<nsIAppShellService> appShell(do_GetService(NS_APPSHELLSERVICE_CONTRACTID));
|
||||
NS_ENSURE_TRUE(appShell, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIXULWindow> parent;
|
||||
if (aChromeFlags & nsIWebBrowserChrome::CHROME_DEPENDENT)
|
||||
parent = this;
|
||||
|
||||
// We need to create a new top level window and then enter a nested
|
||||
// loop. Eventually the new window will be told that it has loaded,
|
||||
// at which time we know it is safe to spin out of the nested loop
|
||||
|
@ -1747,9 +1746,9 @@ NS_IMETHODIMP nsXULWindow::CreateNewContentWindow(PRInt32 aChromeFlags,
|
|||
NS_ENSURE_TRUE(uri, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIXULWindow> newWindow;
|
||||
appShell->CreateTopLevelWindow(parent, uri,
|
||||
aChromeFlags, 615, 480, aAppShell,
|
||||
getter_AddRefs(newWindow));
|
||||
appShell->CreateTopLevelWindow(this, uri,
|
||||
aChromeFlags, 615, 480, aAppShell,
|
||||
getter_AddRefs(newWindow));
|
||||
|
||||
NS_ENSURE_TRUE(newWindow, NS_ERROR_FAILURE);
|
||||
|
||||
|
|
|
@ -68,11 +68,11 @@
|
|||
// nsXULWindow
|
||||
|
||||
#define NS_XULWINDOW_IMPL_CID \
|
||||
{ /* 2a38ef7e-3174-44ad-a785-b5a863cf5588 */ \
|
||||
0x2a38ef7e, \
|
||||
0x3174, \
|
||||
0x44ad, \
|
||||
{ 0xa7, 0x85, 0xb5, 0xa8, 0x63, 0xcf, 0x55, 0x88 } \
|
||||
{ /* 8eaec2f3-ed02-4be2-8e0f-342798477298 */ \
|
||||
0x8eaec2f3, \
|
||||
0xed02, \
|
||||
0x4be2, \
|
||||
{ 0x8e, 0x0f, 0x34, 0x27, 0x98, 0x47, 0x72, 0x98 } \
|
||||
}
|
||||
|
||||
class nsContentShellInfo;
|
||||
|
@ -177,6 +177,7 @@ protected:
|
|||
PRUint32 mAppPerDev; // sometimes needed when we can't get
|
||||
// it from the widget
|
||||
nsString mTitle;
|
||||
nsIntRect mOpenerScreenRect; // the screen rect of the opener
|
||||
|
||||
nsCOMArray<nsIWeakReference> mTargetableShells; // targetable shells only
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче