re-applying danm's changes after finding out they weren't cause for startup time regression. bug 124570. (patches originally from bugs 107937 and 77020)

This commit is contained in:
endico%mozilla.org 2002-02-10 07:12:16 +00:00
parent 1cc467d2ac
commit eb33259bdb
3 changed files with 21 additions and 24 deletions

View File

@ -499,16 +499,14 @@ nsAppShellService::JustCreateTopWindow(nsIXULWindow *aParent,
widgetInitData.mBorderStyle = NS_STATIC_CAST(enum nsBorderStyle, widgetInitData.mBorderStyle | eBorderStyle_close);
if (aChromeMask & nsIWebBrowserChrome::CHROME_WINDOW_RESIZE) {
widgetInitData.mBorderStyle = NS_STATIC_CAST(enum nsBorderStyle, widgetInitData.mBorderStyle | eBorderStyle_resizeh);
/* Associate the resize flag with min/max buttons and system menu.
but not for dialogs. This is logic better associated with the
platform implementation, and partially covered by the
eBorderStyle_default style. But since I know of no platform
that wants min/max buttons on dialogs, it works here, too.
If you have such a platform, this is where the fun starts: */
// only resizable windows get the maximize button (but not dialogs)
if (!(aChromeMask & nsIWebBrowserChrome::CHROME_OPENAS_DIALOG))
widgetInitData.mBorderStyle = NS_STATIC_CAST(enum nsBorderStyle, widgetInitData.mBorderStyle | eBorderStyle_minimize | eBorderStyle_maximize | eBorderStyle_menu);
widgetInitData.mBorderStyle = NS_STATIC_CAST(enum nsBorderStyle, widgetInitData.mBorderStyle | eBorderStyle_maximize);
}
// Min button only?
// all windows (except dialogs) get minimize buttons and the system menu
if (!(aChromeMask & nsIWebBrowserChrome::CHROME_OPENAS_DIALOG))
widgetInitData.mBorderStyle = NS_STATIC_CAST(enum nsBorderStyle, widgetInitData.mBorderStyle | eBorderStyle_minimize | eBorderStyle_menu);
// but anyone can explicitly ask for a minimize button
if (aChromeMask & nsIWebBrowserChrome::CHROME_WINDOW_MIN) {
widgetInitData.mBorderStyle = NS_STATIC_CAST(enum nsBorderStyle, widgetInitData.mBorderStyle | eBorderStyle_minimize );
}

View File

@ -422,7 +422,7 @@ nsWebShellWindow::HandleEvent(nsGUIEvent *aEvent)
case NS_MOVE: {
// persist position, but not immediately, in case this OS is firing
// repeated move events as the user drags the window
eventWindow->SetPersistenceTimer(PR_FALSE, PR_TRUE);
eventWindow->SetPersistenceTimer(PR_FALSE, PR_TRUE, PR_FALSE);
break;
}
case NS_SIZE: {
@ -432,14 +432,17 @@ nsWebShellWindow::HandleEvent(nsGUIEvent *aEvent)
sizeEvent->windowSize->height, PR_FALSE);
// persist size, but not immediately, in case this OS is firing
// repeated size events as the user drags the sizing handle
eventWindow->SetPersistenceTimer(PR_TRUE, PR_FALSE);
eventWindow->SetPersistenceTimer(PR_TRUE, PR_FALSE, PR_TRUE);
result = nsEventStatus_eConsumeNoDefault;
break;
}
case NS_SIZEMODE: {
nsSizeModeEvent* modeEvent = (nsSizeModeEvent*)aEvent;
aEvent->widget->SetSizeMode(modeEvent->mSizeMode);
eventWindow->StoreBoundsToXUL(PR_FALSE, PR_FALSE, PR_TRUE);
// persist mode, but not immediately, because in many (all?)
// cases this will merge with the similar call in NS_SIZE and
// write the attribute values only once.
eventWindow->SetPersistenceTimer(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
@ -592,7 +595,7 @@ nsWebShellWindow::HandleEvent(nsGUIEvent *aEvent)
// since the window has been activated, replace persistent size data
// with the newly activated window's
if (eventWindow->mChromeLoaded)
eventWindow->StoreBoundsToXUL(PR_TRUE, PR_TRUE, PR_TRUE);
eventWindow->PersistPositionAndSize(PR_TRUE, PR_TRUE, PR_TRUE);
break;
}
@ -1153,13 +1156,14 @@ nsWebShellWindow::DestroyModalDialogEvent(PLEvent *aEvent)
}
void
nsWebShellWindow::SetPersistenceTimer(PRBool aSize, PRBool aPosition)
nsWebShellWindow::SetPersistenceTimer(PRBool aSize, PRBool aPosition, PRBool aMode)
{
PR_Lock(mSPTimerLock);
if (mSPTimer) {
mSPTimer->SetDelay(SIZE_PERSISTENCE_TIMEOUT);
mSPTimerSize |= aSize;
mSPTimerPosition |= aPosition;
mSPTimerMode |= aMode;
} else {
nsresult rv;
mSPTimer = do_CreateInstance("@mozilla.org/timer;1", &rv);
@ -1168,6 +1172,7 @@ nsWebShellWindow::SetPersistenceTimer(PRBool aSize, PRBool aPosition)
SIZE_PERSISTENCE_TIMEOUT, NS_TYPE_ONE_SHOT);
mSPTimerSize = aSize;
mSPTimerPosition = aPosition;
mSPTimerMode = aMode;
}
}
PR_Unlock(mSPTimerLock);
@ -1180,7 +1185,8 @@ nsWebShellWindow::FirePersistenceTimer(nsITimer *aTimer, void *aClosure)
PR_Lock(win->mSPTimerLock);
win->mSPTimer = nsnull;
PR_Unlock(win->mSPTimerLock);
win->StoreBoundsToXUL(win->mSPTimerPosition, win->mSPTimerSize, PR_FALSE);
win->PersistPositionAndSize(win->mSPTimerPosition, win->mSPTimerSize,
win->mSPTimerMode);
}
@ -1379,12 +1385,6 @@ nsCOMPtr<nsIDOMDocument> nsWebShellWindow::GetNamedDOMDoc(const nsAString & aWeb
//----------------------------------------
/* copy the window's size and position to the window tag */
void nsWebShellWindow::StoreBoundsToXUL(PRBool aPosition, PRBool aSize, PRBool aSizeMode)
{
PersistPositionAndSize(aPosition, aSize, aSizeMode);
} // StoreBoundsToXUL
// if the main document URL specified URLs for any content areas, start them loading
void nsWebShellWindow::LoadContentAreas() {
@ -1737,7 +1737,7 @@ NS_IMETHODIMP nsWebShellWindow::Destroy()
if (mSPTimer) {
mSPTimer->Cancel();
mSPTimer = nsnull;
StoreBoundsToXUL(mSPTimerPosition, mSPTimerSize, PR_FALSE);
PersistPositionAndSize(mSPTimerPosition, mSPTimerSize, mSPTimerMode);
}
PR_Unlock(mSPTimerLock);

View File

@ -184,7 +184,6 @@ protected:
nsCOMPtr<nsIDOMNode> GetDOMNodeFromWebShell(nsIWebShell *aShell);
void ExecuteStartupCode();
void StoreBoundsToXUL(PRBool aPosition, PRBool aSize, PRBool aSizeMode);
void LoadContentAreas();
PRBool ExecuteCloseHandler();
@ -203,11 +202,11 @@ protected:
nsIDOMNode * contextMenuTest;
nsCOMPtr<nsITimer> mSPTimer;
PRBool mSPTimerSize, mSPTimerPosition;
PRBool mSPTimerSize, mSPTimerPosition, mSPTimerMode;
PRLock * mSPTimerLock;
nsCOMPtr<nsIPrompt> mPrompter;
void SetPersistenceTimer(PRBool aSize, PRBool aPosition);
void SetPersistenceTimer(PRBool aSize, PRBool aPosition, PRBool aMode);
static void FirePersistenceTimer(nsITimer *aTimer, void *aClosure);
private: