зеркало из https://github.com/mozilla/gecko-dev.git
persist size only when window is not minimized or maximized. bug 30116 r=scc a=jevering
This commit is contained in:
Родитель
89df8369bc
Коммит
0560402e53
|
@ -63,16 +63,18 @@ interface nsIXULWindow : nsISupports
|
||||||
nsIDocShellTreeItem getContentShellById(in wstring ID);
|
nsIDocShellTreeItem getContentShellById(in wstring ID);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Sets the persistence of different dimentions of the window.
|
Sets the persistence of different dimensions of the window.
|
||||||
*/
|
*/
|
||||||
void setPersistence(in boolean persistX, in boolean persistY,
|
void setPersistence(in boolean persistX, in boolean persistY,
|
||||||
in boolean persistCX, in boolean persistCY);
|
in boolean persistCX, in boolean persistCY,
|
||||||
|
in boolean persistSizeMode);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Gets the current persistence states of the window.
|
Gets the current persistence states of the window.
|
||||||
*/
|
*/
|
||||||
void getPersistence(out boolean persistX, out boolean persistY,
|
void getPersistence(out boolean persistX, out boolean persistY,
|
||||||
out boolean persistCX, out boolean persistCY);
|
out boolean persistCX, out boolean persistCY,
|
||||||
|
out boolean persistSizeMode);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Shows the window as a modal window
|
Shows the window as a modal window
|
||||||
|
|
|
@ -432,6 +432,22 @@ nsWebShellWindow::HandleEvent(nsGUIEvent *aEvent)
|
||||||
result = nsEventStatus_eConsumeNoDefault;
|
result = nsEventStatus_eConsumeNoDefault;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case NS_SIZEMODE: {
|
||||||
|
void* data;
|
||||||
|
nsWebShellWindow *win;
|
||||||
|
nsSizeModeEvent* modeEvent = (nsSizeModeEvent*)aEvent;
|
||||||
|
aEvent->widget->SetSizeMode(modeEvent->mSizeMode);
|
||||||
|
aEvent->widget->GetClientData(data);
|
||||||
|
win = NS_REINTERPRET_CAST(nsWebShellWindow *, data);
|
||||||
|
win->StoreBoundsToXUL(PR_FALSE, PR_FALSE, PR_TRUE);
|
||||||
|
result = nsEventStatus_eConsumeDoDefault;
|
||||||
|
// Note the current implementation of SetSizeMode just stores
|
||||||
|
// the new state; it doesn't actually resize. So here we store
|
||||||
|
// the state and pass the event on to the OS. The day is coming
|
||||||
|
// when we'll handle the event here, and the return result will
|
||||||
|
// then need to be different.
|
||||||
|
break;
|
||||||
|
}
|
||||||
case NS_XUL_CLOSE: {
|
case NS_XUL_CLOSE: {
|
||||||
void* data;
|
void* data;
|
||||||
nsWebShellWindow *win;
|
nsWebShellWindow *win;
|
||||||
|
@ -1209,7 +1225,7 @@ nsWebShellWindow::FirePersistenceTimer(nsITimer *aTimer, void *aClosure)
|
||||||
PR_Lock(win->mSPTimerLock);
|
PR_Lock(win->mSPTimerLock);
|
||||||
win->mSPTimer = nsnull;
|
win->mSPTimer = nsnull;
|
||||||
PR_Unlock(win->mSPTimerLock);
|
PR_Unlock(win->mSPTimerLock);
|
||||||
win->StoreBoundsToXUL(win->mSPTimerPosition, win->mSPTimerSize);
|
win->StoreBoundsToXUL(win->mSPTimerPosition, win->mSPTimerSize, PR_FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1434,9 +1450,9 @@ void nsWebShellWindow::ExecuteStartupCode()
|
||||||
}
|
}
|
||||||
|
|
||||||
/* copy the window's size and position to the window tag */
|
/* copy the window's size and position to the window tag */
|
||||||
void nsWebShellWindow::StoreBoundsToXUL(PRBool aPosition, PRBool aSize)
|
void nsWebShellWindow::StoreBoundsToXUL(PRBool aPosition, PRBool aSize, PRBool aSizeMode)
|
||||||
{
|
{
|
||||||
PersistPositionAndSize(aPosition, aSize);
|
PersistPositionAndSize(aPosition, aSize, aSizeMode);
|
||||||
} // StoreBoundsToXUL
|
} // StoreBoundsToXUL
|
||||||
|
|
||||||
|
|
||||||
|
@ -1444,8 +1460,8 @@ void nsWebShellWindow::KillPersistentSize()
|
||||||
{
|
{
|
||||||
PRBool persistX, persistY;
|
PRBool persistX, persistY;
|
||||||
|
|
||||||
GetPersistence(&persistX, &persistY, nsnull, nsnull);
|
GetPersistence(&persistX, &persistY, nsnull, nsnull, nsnull);
|
||||||
SetPersistence(persistX, persistY, PR_FALSE, PR_FALSE);
|
SetPersistence(persistX, persistY, PR_FALSE, PR_FALSE, PR_FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1774,7 +1790,7 @@ NS_IMETHODIMP nsWebShellWindow::Init(nsIAppShell* aAppShell,
|
||||||
NS_IMETHODIMP nsWebShellWindow::MoveTo(PRInt32 aX, PRInt32 aY)
|
NS_IMETHODIMP nsWebShellWindow::MoveTo(PRInt32 aX, PRInt32 aY)
|
||||||
{
|
{
|
||||||
mWindow->Move(aX, aY);
|
mWindow->Move(aX, aY);
|
||||||
StoreBoundsToXUL(PR_TRUE, PR_FALSE);
|
StoreBoundsToXUL(PR_TRUE, PR_FALSE, PR_FALSE);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1785,7 +1801,7 @@ NS_IMETHODIMP nsWebShellWindow::SizeWindowTo(PRInt32 aWidth, PRInt32 aHeight,
|
||||||
if (aWidthTransient || aHeightTransient)
|
if (aWidthTransient || aHeightTransient)
|
||||||
KillPersistentSize();
|
KillPersistentSize();
|
||||||
mWindow->Resize(aWidth, aHeight, PR_TRUE);
|
mWindow->Resize(aWidth, aHeight, PR_TRUE);
|
||||||
StoreBoundsToXUL(PR_FALSE, PR_TRUE);
|
StoreBoundsToXUL(PR_FALSE, PR_TRUE, PR_FALSE);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1810,7 +1826,7 @@ NS_IMETHODIMP nsWebShellWindow::SizeContentTo(PRInt32 aWidth, PRInt32 aHeight)
|
||||||
mWindow->Resize(windowBounds.width + widthDelta,
|
mWindow->Resize(windowBounds.width + widthDelta,
|
||||||
windowBounds.height + heightDelta,
|
windowBounds.height + heightDelta,
|
||||||
PR_TRUE);
|
PR_TRUE);
|
||||||
StoreBoundsToXUL(PR_FALSE, PR_TRUE);
|
StoreBoundsToXUL(PR_FALSE, PR_TRUE, PR_FALSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
|
@ -233,7 +233,7 @@ protected:
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMNode> GetDOMNodeFromWebShell(nsIWebShell *aShell);
|
nsCOMPtr<nsIDOMNode> GetDOMNodeFromWebShell(nsIWebShell *aShell);
|
||||||
void ExecuteStartupCode();
|
void ExecuteStartupCode();
|
||||||
void StoreBoundsToXUL(PRBool aPosition, PRBool aSize);
|
void StoreBoundsToXUL(PRBool aPosition, PRBool aSize, PRBool aSizeMode);
|
||||||
void KillPersistentSize();
|
void KillPersistentSize();
|
||||||
void LoadContentAreas();
|
void LoadContentAreas();
|
||||||
PRBool ExecuteCloseHandler();
|
PRBool ExecuteCloseHandler();
|
||||||
|
|
|
@ -177,7 +177,8 @@ NS_IMETHODIMP nsXULWindow::GetContentShellById(const PRUnichar* aID,
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP nsXULWindow::SetPersistence(PRBool aPersistX, PRBool aPersistY,
|
NS_IMETHODIMP nsXULWindow::SetPersistence(PRBool aPersistX, PRBool aPersistY,
|
||||||
PRBool aPersistCX, PRBool aPersistCY)
|
PRBool aPersistCX, PRBool aPersistCY,
|
||||||
|
PRBool aPersistSizeMode)
|
||||||
|
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIDOMElement> docShellElement;
|
nsCOMPtr<nsIDOMElement> docShellElement;
|
||||||
|
@ -240,6 +241,15 @@ NS_IMETHODIMP nsXULWindow::SetPersistence(PRBool aPersistX, PRBool aPersistY,
|
||||||
saveString = PR_TRUE;
|
saveString = PR_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
index = persistString.Find("sizemode");
|
||||||
|
if (!aPersistSizeMode && index >= 0) {
|
||||||
|
persistString.Append(" sizemode");
|
||||||
|
saveString = PR_TRUE;
|
||||||
|
} else if (aPersistSizeMode && index < 0) {
|
||||||
|
persistString.Cut(index, 8);
|
||||||
|
saveString = PR_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
if(saveString)
|
if(saveString)
|
||||||
docShellElement->SetAttribute("persist", persistString);
|
docShellElement->SetAttribute("persist", persistString);
|
||||||
|
|
||||||
|
@ -247,7 +257,8 @@ NS_IMETHODIMP nsXULWindow::SetPersistence(PRBool aPersistX, PRBool aPersistY,
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP nsXULWindow::GetPersistence(PRBool* aPersistX, PRBool* aPersistY,
|
NS_IMETHODIMP nsXULWindow::GetPersistence(PRBool* aPersistX, PRBool* aPersistY,
|
||||||
PRBool* aPersistCX, PRBool* aPersistCY)
|
PRBool* aPersistCX, PRBool* aPersistCY,
|
||||||
|
PRBool* aPersistSizeMode)
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIDOMElement> docShellElement;
|
nsCOMPtr<nsIDOMElement> docShellElement;
|
||||||
GetDOMElementFromDocShell(mDocShell, getter_AddRefs(docShellElement));
|
GetDOMElementFromDocShell(mDocShell, getter_AddRefs(docShellElement));
|
||||||
|
@ -265,6 +276,8 @@ NS_IMETHODIMP nsXULWindow::GetPersistence(PRBool* aPersistX, PRBool* aPersistY,
|
||||||
*aPersistCX = persistString.Find("width") >= 0 ? PR_TRUE : PR_FALSE;
|
*aPersistCX = persistString.Find("width") >= 0 ? PR_TRUE : PR_FALSE;
|
||||||
if(aPersistCY)
|
if(aPersistCY)
|
||||||
*aPersistCY = persistString.Find("height") >= 0 ? PR_TRUE : PR_FALSE;
|
*aPersistCY = persistString.Find("height") >= 0 ? PR_TRUE : PR_FALSE;
|
||||||
|
if(aPersistSizeMode)
|
||||||
|
*aPersistSizeMode = persistString.Find("sizemode") >= 0 ? PR_TRUE : PR_FALSE;
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
@ -418,7 +431,7 @@ NS_IMETHODIMP nsXULWindow::Destroy()
|
||||||
NS_IMETHODIMP nsXULWindow::SetPosition(PRInt32 aX, PRInt32 aY)
|
NS_IMETHODIMP nsXULWindow::SetPosition(PRInt32 aX, PRInt32 aY)
|
||||||
{
|
{
|
||||||
NS_ENSURE_SUCCESS(mWindow->Move(aX, aY), NS_ERROR_FAILURE);
|
NS_ENSURE_SUCCESS(mWindow->Move(aX, aY), NS_ERROR_FAILURE);
|
||||||
PersistPositionAndSize(PR_TRUE, PR_FALSE);
|
PersistPositionAndSize(PR_TRUE, PR_FALSE, PR_FALSE);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -431,7 +444,7 @@ NS_IMETHODIMP nsXULWindow::SetSize(PRInt32 aCX, PRInt32 aCY, PRBool aRepaint)
|
||||||
{
|
{
|
||||||
mIntrinsicallySized = PR_FALSE;
|
mIntrinsicallySized = PR_FALSE;
|
||||||
NS_ENSURE_SUCCESS(mWindow->Resize(aCX, aCY, aRepaint), NS_ERROR_FAILURE);
|
NS_ENSURE_SUCCESS(mWindow->Resize(aCX, aCY, aRepaint), NS_ERROR_FAILURE);
|
||||||
PersistPositionAndSize(PR_FALSE, PR_TRUE);
|
PersistPositionAndSize(PR_FALSE, PR_TRUE, PR_FALSE);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -445,7 +458,7 @@ NS_IMETHODIMP nsXULWindow::SetPositionAndSize(PRInt32 aX, PRInt32 aY,
|
||||||
{
|
{
|
||||||
mIntrinsicallySized = PR_FALSE;
|
mIntrinsicallySized = PR_FALSE;
|
||||||
NS_ENSURE_SUCCESS(mWindow->Resize(aX, aY, aCX, aCY, aRepaint), NS_ERROR_FAILURE);
|
NS_ENSURE_SUCCESS(mWindow->Resize(aX, aY, aCX, aCY, aRepaint), NS_ERROR_FAILURE);
|
||||||
PersistPositionAndSize(PR_TRUE, PR_TRUE);
|
PersistPositionAndSize(PR_TRUE, PR_TRUE, PR_FALSE);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -677,6 +690,10 @@ void nsXULWindow::OnChromeLoaded()
|
||||||
NS_IMETHODIMP nsXULWindow::LoadPositionAndSizeFromXUL(PRBool aPosition,
|
NS_IMETHODIMP nsXULWindow::LoadPositionAndSizeFromXUL(PRBool aPosition,
|
||||||
PRBool aSize)
|
PRBool aSize)
|
||||||
{
|
{
|
||||||
|
/* NB: we'll want to pay attention to the "sizemode" attribute (maximizing
|
||||||
|
the window if it asks) someday after the widget implementations know how
|
||||||
|
to do that.
|
||||||
|
*/
|
||||||
nsCOMPtr<nsIDOMElement> docShellElement;
|
nsCOMPtr<nsIDOMElement> docShellElement;
|
||||||
GetDOMElementFromDocShell(mDocShell, getter_AddRefs(docShellElement));
|
GetDOMElementFromDocShell(mDocShell, getter_AddRefs(docShellElement));
|
||||||
NS_ENSURE_TRUE(docShellElement, NS_ERROR_FAILURE);
|
NS_ENSURE_TRUE(docShellElement, NS_ERROR_FAILURE);
|
||||||
|
@ -763,7 +780,7 @@ NS_IMETHODIMP nsXULWindow::LoadTitleFromXUL()
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP nsXULWindow::PersistPositionAndSize(PRBool aPosition, PRBool aSize)
|
NS_IMETHODIMP nsXULWindow::PersistPositionAndSize(PRBool aPosition, PRBool aSize, PRBool aSizeMode)
|
||||||
{
|
{
|
||||||
// can happen when the persistence timer fires at an inopportune time
|
// can happen when the persistence timer fires at an inopportune time
|
||||||
// during window shutdown
|
// during window shutdown
|
||||||
|
@ -776,7 +793,10 @@ NS_IMETHODIMP nsXULWindow::PersistPositionAndSize(PRBool aPosition, PRBool aSize
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
PRInt32 x, y, cx, cy;
|
PRInt32 x, y, cx, cy;
|
||||||
|
PRInt32 sizeMode;
|
||||||
|
|
||||||
NS_ENSURE_SUCCESS(GetPositionAndSize(&x, &y, &cx, &cy), NS_ERROR_FAILURE);
|
NS_ENSURE_SUCCESS(GetPositionAndSize(&x, &y, &cx, &cy), NS_ERROR_FAILURE);
|
||||||
|
mWindow->GetSizeMode(&sizeMode);
|
||||||
|
|
||||||
// (But only for size elements which are persisted.)
|
// (But only for size elements which are persisted.)
|
||||||
/* Note we use the same cheesy way to determine that as in
|
/* Note we use the same cheesy way to determine that as in
|
||||||
|
@ -790,7 +810,7 @@ NS_IMETHODIMP nsXULWindow::PersistPositionAndSize(PRBool aPosition, PRBool aSize
|
||||||
|
|
||||||
char sizeBuf[10];
|
char sizeBuf[10];
|
||||||
nsAutoString sizeString;
|
nsAutoString sizeString;
|
||||||
if(aPosition)
|
if(aPosition && sizeMode == nsSizeMode_Normal)
|
||||||
{
|
{
|
||||||
if(persistString.Find("screenX") >= 0)
|
if(persistString.Find("screenX") >= 0)
|
||||||
{
|
{
|
||||||
|
@ -806,7 +826,7 @@ NS_IMETHODIMP nsXULWindow::PersistPositionAndSize(PRBool aPosition, PRBool aSize
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(aSize)
|
if(aSize && sizeMode == nsSizeMode_Normal)
|
||||||
{
|
{
|
||||||
if(persistString.Find("width") >= 0)
|
if(persistString.Find("width") >= 0)
|
||||||
{
|
{
|
||||||
|
@ -822,6 +842,18 @@ NS_IMETHODIMP nsXULWindow::PersistPositionAndSize(PRBool aPosition, PRBool aSize
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (aSizeMode && persistString.Find("sizemode") >= 0) {
|
||||||
|
PRInt32 sizemode;
|
||||||
|
if (NS_FAILED(mWindow->GetSizeMode(&sizemode)))
|
||||||
|
sizemode = nsSizeMode_Normal;
|
||||||
|
sizeString = "n";
|
||||||
|
if (sizemode == nsSizeMode_Minimized)
|
||||||
|
sizeString = "m";
|
||||||
|
else if (sizemode == nsSizeMode_Maximized)
|
||||||
|
sizeString = "M";
|
||||||
|
docShellElement->SetAttribute("sizemode", sizeString);
|
||||||
|
}
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -910,7 +942,7 @@ NS_IMETHODIMP nsXULWindow::SizeShellTo(nsIDocShellTreeItem* aShellItem,
|
||||||
|
|
||||||
GetSize(&winCX, &winCY);
|
GetSize(&winCX, &winCY);
|
||||||
SetSize(winCX + widthDelta, winCY + heightDelta, PR_TRUE);
|
SetSize(winCX + widthDelta, winCY + heightDelta, PR_TRUE);
|
||||||
PersistPositionAndSize(PR_FALSE, PR_TRUE);
|
PersistPositionAndSize(PR_FALSE, PR_TRUE, PR_FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
|
@ -69,7 +69,7 @@ protected:
|
||||||
void OnChromeLoaded();
|
void OnChromeLoaded();
|
||||||
NS_IMETHOD LoadPositionAndSizeFromXUL(PRBool aPosition, PRBool aSize);
|
NS_IMETHOD LoadPositionAndSizeFromXUL(PRBool aPosition, PRBool aSize);
|
||||||
NS_IMETHOD LoadTitleFromXUL();
|
NS_IMETHOD LoadTitleFromXUL();
|
||||||
NS_IMETHOD PersistPositionAndSize(PRBool aPosition, PRBool aSize);
|
NS_IMETHOD PersistPositionAndSize(PRBool aPosition, PRBool aSize, PRBool aSizeMode);
|
||||||
|
|
||||||
NS_IMETHOD GetDOMElementFromDocShell(nsIDocShell* aDocShell,
|
NS_IMETHOD GetDOMElementFromDocShell(nsIDocShell* aDocShell,
|
||||||
nsIDOMElement** aDOMElement);
|
nsIDOMElement** aDOMElement);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче