mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 11:55:49 +00:00
fix for performance bug #107481 (reduce mail-toolbar command updating)
fix for bug #102180 (close std alone msg window on delete if no more messages in the folder). also, fix spelling mistake, "supress" -> "suppress" r=cavin, sr=bienvenu.
This commit is contained in:
parent
5bc2918bb4
commit
77e36b4a18
@ -285,7 +285,10 @@ interface nsIMsgDBView : nsISupports
|
||||
void selectMsgByKey(in nsMsgKey key);
|
||||
|
||||
// we'll suppress displaying messages if the message pane is collapsed
|
||||
attribute boolean supressMsgDisplay;
|
||||
attribute boolean suppressMsgDisplay;
|
||||
|
||||
// we'll suppress command updating during folder loading
|
||||
attribute boolean suppressCommandUpdating;
|
||||
|
||||
//to tell us if we are in the search view
|
||||
attribute boolean isSearchView;
|
||||
|
@ -150,6 +150,12 @@ function setTitleFromFolder(msgfolder, subject)
|
||||
window.title = title;
|
||||
}
|
||||
|
||||
function UpdateMailToolbar(caller)
|
||||
{
|
||||
//dump("XXX update mail-toolbar " + caller + "\n");
|
||||
document.commandDispatcher.updateCommands('mail-toolbar');
|
||||
}
|
||||
|
||||
function ChangeFolderByURI(uri, viewType, viewFlags, sortType, sortOrder)
|
||||
{
|
||||
//dump("In ChangeFolderByURI uri = " + uri + " sortType = " + sortType + "\n");
|
||||
@ -228,8 +234,6 @@ function ChangeFolderByURI(uri, viewType, viewFlags, sortType, sortOrder)
|
||||
//notification before folder has actually changed.
|
||||
msgfolder.updateFolder(msgWindow);
|
||||
}
|
||||
|
||||
document.commandDispatcher.updateCommands('mail-toolbar');
|
||||
}
|
||||
|
||||
function isNewsURI(uri)
|
||||
@ -574,8 +578,8 @@ function CreateDBView(msgFolder, viewType, viewFlags, sortType, sortOrder)
|
||||
// now do outliner specific work
|
||||
|
||||
// based on the collapsed state of the thread pane/message pane splitter,
|
||||
// supress message display if appropriate.
|
||||
gDBView.supressMsgDisplay = IsThreadAndMessagePaneSplitterCollapsed();
|
||||
// suppress message display if appropriate.
|
||||
gDBView.suppressMsgDisplay = IsThreadAndMessagePaneSplitterCollapsed();
|
||||
|
||||
UpdateSortIndicators(gCurSortType, sortOrder);
|
||||
}
|
||||
@ -638,7 +642,7 @@ function OnMouseUpThreadAndMessagePaneSplitter()
|
||||
if (gDBView) {
|
||||
// the collapsed state is the state after we released the mouse
|
||||
// so we take it as it is
|
||||
gDBView.supressMsgDisplay = IsThreadAndMessagePaneSplitterCollapsed();
|
||||
gDBView.suppressMsgDisplay = IsThreadAndMessagePaneSplitterCollapsed();
|
||||
}
|
||||
}
|
||||
|
||||
@ -647,7 +651,7 @@ function OnClickThreadAndMessagePaneSplitterGrippy()
|
||||
if (gDBView) {
|
||||
// the collapsed state is the state when we clicked on the grippy
|
||||
// not when afterwards, so we need to reverse this value
|
||||
gDBView.supressMsgDisplay = !IsThreadAndMessagePaneSplitterCollapsed();
|
||||
gDBView.suppressMsgDisplay = !IsThreadAndMessagePaneSplitterCollapsed();
|
||||
}
|
||||
}
|
||||
|
||||
@ -708,14 +712,15 @@ function FolderPaneSelectionChange()
|
||||
ClearThreadPane();
|
||||
}
|
||||
|
||||
if (! gAccountCentralLoaded)
|
||||
if (!gAccountCentralLoaded)
|
||||
ClearMessagePane();
|
||||
|
||||
if (gDisplayStartupPage)
|
||||
{
|
||||
loadStartPage();
|
||||
gDisplayStartupPage = false;
|
||||
}
|
||||
UpdateMailToolbar("gDisplayStartupPage");
|
||||
}
|
||||
}
|
||||
|
||||
function ClearThreadPane()
|
||||
|
@ -731,7 +731,7 @@ function FocusRingUpdate_Mail()
|
||||
gLastFocusedElement = currentFocusedElement;
|
||||
|
||||
// since we just changed the pane with focus we need to update the toolbar to reflect this
|
||||
document.commandDispatcher.updateCommands('mail-toolbar');
|
||||
UpdateMailToolbar("focus");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,7 @@ nsMsgDBViewCommandUpdater.prototype =
|
||||
{
|
||||
// the back end is smart and is only telling us to update command status
|
||||
// when the # of items in the selection has actually changed.
|
||||
document.commandDispatcher.updateCommands('mail-toolbar');
|
||||
UpdateMailToolbar("dbview, std alone window");
|
||||
},
|
||||
|
||||
displayMessageChanged : function(aFolder, aSubject)
|
||||
@ -93,6 +93,9 @@ nsMsgDBViewCommandUpdater.prototype =
|
||||
}
|
||||
}
|
||||
|
||||
// from MailNewsTypes.h
|
||||
const nsMsgKey_None = 0xFFFFFFFF;
|
||||
|
||||
function HandleDeleteOrMoveMsgCompleted(folder)
|
||||
{
|
||||
dump("In HandleDeleteOrMoveMsgCompleted\n");
|
||||
@ -104,10 +107,10 @@ function HandleDeleteOrMoveMsgCompleted(folder)
|
||||
if((folderUri == gCurrentFolderUri) && gCurrentMessageIsDeleted)
|
||||
{
|
||||
gCurrentMessageIsDeleted = false;
|
||||
if (gNextMessageViewIndexAfterDelete != -1)
|
||||
if (gNextMessageViewIndexAfterDelete != nsMsgViewIndex_None)
|
||||
{
|
||||
var nextMstKey = gDBView.getKeyAt(gNextMessageViewIndexAfterDelete);
|
||||
if (nextMstKey != -1) {
|
||||
if (nextMstKey != nsMsgKey_None) {
|
||||
gDBView.loadMessageByMsgKey(nextMstKey);
|
||||
}
|
||||
else {
|
||||
@ -355,7 +358,7 @@ function ClearMessageSelection()
|
||||
{
|
||||
gCurrentMessageUri = null;
|
||||
gCurrentFolderUri = null;
|
||||
document.commandDispatcher.updateCommands('mail-toolbar');
|
||||
UpdateMailToolbar("clear msg, std alone window");
|
||||
}
|
||||
|
||||
function GetCompositeDataSource(command)
|
||||
@ -705,7 +708,7 @@ function performNavigation(type)
|
||||
gDBView.viewNavigate(type, resultId, resultIndex, threadIndex, true /* wrap */);
|
||||
|
||||
// if we found something....display it.
|
||||
if ((resultId.value != nsMsgViewIndex_None) && (resultIndex.value != nsMsgViewIndex_None))
|
||||
if ((resultId.value != nsMsgKey_None) && (resultIndex.value != nsMsgViewIndex_None))
|
||||
{
|
||||
// load the message key
|
||||
gDBView.loadMessageByMsgKey(resultId.value);
|
||||
|
@ -103,7 +103,20 @@ var folderListener = {
|
||||
var msgFolder = folder.QueryInterface(Components.interfaces.nsIMsgFolder);
|
||||
if(msgFolder) {
|
||||
msgFolder.endFolderLoading();
|
||||
|
||||
// suppress command updating when rerooting the folder
|
||||
// when rerooting, we'll be clearing the selection
|
||||
// which will cause us to update commands.
|
||||
if (gDBView) {
|
||||
gDBView.suppressCommandUpdating = true;
|
||||
}
|
||||
|
||||
RerootFolder(uri, msgFolder, gCurrentLoadingFolderViewType, gCurrentLoadingFolderViewFlags, gCurrentLoadingFolderSortType, gCurrentLoadingFolderSortOrder);
|
||||
|
||||
if (gDBView) {
|
||||
gDBView.suppressCommandUpdating = false;
|
||||
}
|
||||
|
||||
gIsEditableMsgFolder = IsSpecialFolder(msgFolder, MSG_FOLDER_FLAG_DRAFTS);
|
||||
|
||||
gCurrentLoadingFolderSortType = 0;
|
||||
|
@ -72,7 +72,7 @@ nsMsgDBViewCommandUpdater.prototype =
|
||||
{
|
||||
// the back end is smart and is only telling us to update command status
|
||||
// when the # of items in the selection has actually changed.
|
||||
document.commandDispatcher.updateCommands('mail-toolbar');
|
||||
UpdateMailToolbar("dbview driven, thread pane");
|
||||
},
|
||||
|
||||
displayMessageChanged : function(aFolder, aSubject)
|
||||
|
@ -110,7 +110,8 @@ nsMsgDBView::nsMsgDBView()
|
||||
m_cachedMsgKey = nsMsgKey_None;
|
||||
m_currentlyDisplayedMsgKey = nsMsgKey_None;
|
||||
mNumSelectedRows = 0;
|
||||
mSupressMsgDisplay = PR_FALSE;
|
||||
mSuppressMsgDisplay = PR_FALSE;
|
||||
mSuppressCommandUpdating = PR_FALSE;
|
||||
mOfflineMsgSelected = PR_FALSE;
|
||||
mIsSpecialFolder = PR_FALSE;
|
||||
mIsNews = PR_FALSE;
|
||||
@ -568,7 +569,7 @@ NS_IMETHODIMP nsMsgDBView::SetSelection(nsIOutlinerSelection * aSelection)
|
||||
|
||||
NS_IMETHODIMP nsMsgDBView::ReloadMessage()
|
||||
{
|
||||
if (!mSupressMsgDisplay && m_currentlyDisplayedMsgKey != nsMsgKey_None)
|
||||
if (!mSuppressMsgDisplay && m_currentlyDisplayedMsgKey != nsMsgKey_None)
|
||||
{
|
||||
nsMsgKey currentMsgToReload = m_currentlyDisplayedMsgKey;
|
||||
m_currentlyDisplayedMsgKey = nsMsgKey_None;
|
||||
@ -605,7 +606,7 @@ NS_IMETHODIMP nsMsgDBView::LoadMessageByMsgKey(nsMsgKey aMsgKey)
|
||||
NS_ASSERTION(aMsgKey != nsMsgKey_None,"trying to load nsMsgKey_None");
|
||||
if (aMsgKey == nsMsgKey_None) return NS_ERROR_UNEXPECTED;
|
||||
|
||||
if (!mSupressMsgDisplay && (m_currentlyDisplayedMsgKey != aMsgKey))
|
||||
if (!mSuppressMsgDisplay && (m_currentlyDisplayedMsgKey != aMsgKey))
|
||||
{
|
||||
nsXPIDLCString uri;
|
||||
nsresult rv = GenerateURIForMsgKey(aMsgKey, m_folder, getter_Copies(uri));
|
||||
@ -644,7 +645,7 @@ NS_IMETHODIMP nsMsgDBView::SelectionChanged()
|
||||
nsMsgKey msgkey = m_keys.GetAt(startRange);
|
||||
if (!mRemovingRow)
|
||||
{
|
||||
if (!mSupressMsgDisplay)
|
||||
if (!mSuppressMsgDisplay)
|
||||
LoadMessageByMsgKey(msgkey);
|
||||
else
|
||||
UpdateDisplayMessage(msgkey);
|
||||
@ -666,9 +667,9 @@ NS_IMETHODIMP nsMsgDBView::SelectionChanged()
|
||||
if ((numSelected == mNumSelectedRows ||
|
||||
(numSelected > 1 && mNumSelectedRows > 1)) && mOfflineMsgSelected == offlineMsgSelected)
|
||||
{
|
||||
|
||||
} // don't update commands if we're removing rows, unless it was the last row.
|
||||
else if (mCommandUpdater && (!mRemovingRow || GetSize() == 0)) // o.t. push an updated
|
||||
}
|
||||
// don't update commands if we're suppressing them, or if we're removing rows, unless it was the last row.
|
||||
else if (!mSuppressCommandUpdating && mCommandUpdater && (!mRemovingRow || GetSize() == 0)) // o.t. push an updated
|
||||
{
|
||||
mCommandUpdater->UpdateCommandStatus();
|
||||
}
|
||||
@ -1216,13 +1217,25 @@ NS_IMETHODIMP nsMsgDBView::Init(nsIMessenger * aMessengerInstance, nsIMsgWindow
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgDBView::SetSupressMsgDisplay(PRBool aSupressDisplay)
|
||||
NS_IMETHODIMP nsMsgDBView::SetSuppressCommandUpdating(PRBool aSuppressCommandUpdating)
|
||||
{
|
||||
mSuppressCommandUpdating = aSuppressCommandUpdating;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgDBView::GetSuppressCommandUpdating(PRBool * aSuppressCommandUpdating)
|
||||
{
|
||||
*aSuppressCommandUpdating = mSuppressCommandUpdating;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgDBView::SetSuppressMsgDisplay(PRBool aSuppressDisplay)
|
||||
{
|
||||
PRBool forceDisplay = PR_FALSE;
|
||||
if (mSupressMsgDisplay && (mSupressMsgDisplay != aSupressDisplay))
|
||||
if (mSuppressMsgDisplay && (mSuppressMsgDisplay != aSuppressDisplay))
|
||||
forceDisplay = PR_TRUE;
|
||||
|
||||
mSupressMsgDisplay = aSupressDisplay;
|
||||
mSuppressMsgDisplay = aSuppressDisplay;
|
||||
if (forceDisplay)
|
||||
{
|
||||
// get the messae key for the currently selected message
|
||||
@ -1240,9 +1253,9 @@ NS_IMETHODIMP nsMsgDBView::SetSupressMsgDisplay(PRBool aSupressDisplay)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgDBView::GetSupressMsgDisplay(PRBool * aSupressDisplay)
|
||||
NS_IMETHODIMP nsMsgDBView::GetSuppressMsgDisplay(PRBool * aSuppressDisplay)
|
||||
{
|
||||
*aSupressDisplay = mSupressMsgDisplay;
|
||||
*aSuppressDisplay = mSuppressMsgDisplay;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -123,9 +123,10 @@ protected:
|
||||
nsCOMPtr<nsIOutlinerBoxObject> mOutliner;
|
||||
nsCOMPtr<nsIOutlinerSelection> mOutlinerSelection;
|
||||
PRUint32 mNumSelectedRows; // we cache this to determine when to push command status notifications.
|
||||
PRBool mSupressMsgDisplay; // set when the message pane is collapsed
|
||||
PRBool mSuppressMsgDisplay; // set when the message pane is collapsed
|
||||
PRBool mSuppressCommandUpdating;
|
||||
PRBool mIsSearchView; // tells if the search view is loaded.
|
||||
PRBool mRemovingRow; // set when we're telling the outline a row is being removed. used to supress msg loading.
|
||||
PRBool mRemovingRow; // set when we're telling the outline a row is being removed. used to suppress msg loading.
|
||||
// during delete/move operations.
|
||||
PRBool mOfflineMsgSelected;
|
||||
virtual const char * GetViewName(void) {return "MsgDBView"; }
|
||||
|
@ -53,7 +53,7 @@ nsMsgSearchDBView::nsMsgSearchDBView()
|
||||
{
|
||||
/* member initializers and constructor code */
|
||||
// don't try to display messages for the search pane.
|
||||
mSupressMsgDisplay = PR_TRUE;
|
||||
mSuppressMsgDisplay = PR_TRUE;
|
||||
}
|
||||
|
||||
nsMsgSearchDBView::~nsMsgSearchDBView()
|
||||
|
Loading…
Reference in New Issue
Block a user