зеркало из https://github.com/mozilla/pjs.git
Replace some uses of nsUInt32Array with nsTArray b=258018 r=dwitte sr=bienvenu
This commit is contained in:
Родитель
e091a75168
Коммит
57c48a66ff
|
@ -760,16 +760,16 @@ nsresult nsMsgDBView::SaveAndClearSelection(nsMsgKey *aCurrentMsgKey, nsMsgKeyAr
|
||||||
}
|
}
|
||||||
|
|
||||||
// third, get an array of view indices for the selection.
|
// third, get an array of view indices for the selection.
|
||||||
nsUInt32Array selection;
|
nsMsgViewIndexArray selection;
|
||||||
GetSelectedIndices(&selection);
|
GetSelectedIndices(selection);
|
||||||
PRInt32 numIndices = selection.GetSize();
|
PRInt32 numIndices = selection.Length();
|
||||||
aMsgKeyArray->SetSize(numIndices);
|
aMsgKeyArray->SetSize(numIndices);
|
||||||
|
|
||||||
// now store the msg key for each selected item.
|
// now store the msg key for each selected item.
|
||||||
nsMsgKey msgKey;
|
nsMsgKey msgKey;
|
||||||
for (PRInt32 index = 0; index < numIndices; index++)
|
for (PRInt32 index = 0; index < numIndices; index++)
|
||||||
{
|
{
|
||||||
msgKey = m_keys.GetAt(selection.GetAt(index));
|
msgKey = m_keys.GetAt(selection[index]);
|
||||||
aMsgKeyArray->SetAt(index, msgKey);
|
aMsgKeyArray->SetAt(index, msgKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1013,10 +1013,10 @@ NS_IMETHODIMP nsMsgDBView::SelectionChanged()
|
||||||
PRUint32 numSelected = 0;
|
PRUint32 numSelected = 0;
|
||||||
|
|
||||||
GetNumSelected(&numSelected);
|
GetNumSelected(&numSelected);
|
||||||
nsUInt32Array selection;
|
nsMsgViewIndexArray selection;
|
||||||
GetSelectedIndices(&selection);
|
GetSelectedIndices(selection);
|
||||||
nsMsgViewIndex *indices = selection.GetData();
|
nsMsgViewIndex *indices = selection.Elements();
|
||||||
NS_ASSERTION(numSelected == selection.GetSize(), "selected indices is not equal to num of msg selected!!!");
|
NS_ASSERTION(numSelected == selection.Length(), "selected indices is not equal to num of msg selected!!!");
|
||||||
|
|
||||||
PRBool commandsNeedDisablingBecauseOfSelection = PR_FALSE;
|
PRBool commandsNeedDisablingBecauseOfSelection = PR_FALSE;
|
||||||
|
|
||||||
|
@ -1100,14 +1100,14 @@ NS_IMETHODIMP nsMsgDBView::SelectionChanged()
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult nsMsgDBView::GetSelectedIndices(nsUInt32Array *selection)
|
nsresult nsMsgDBView::GetSelectedIndices(nsMsgViewIndexArray& selection)
|
||||||
{
|
{
|
||||||
if (mTreeSelection)
|
if (mTreeSelection)
|
||||||
{
|
{
|
||||||
PRInt32 viewSize = GetSize();
|
PRInt32 viewSize = GetSize();
|
||||||
PRInt32 count;
|
PRInt32 count;
|
||||||
mTreeSelection->GetCount(&count);
|
mTreeSelection->GetCount(&count);
|
||||||
selection->SetSize(count);
|
selection.SetLength(count);
|
||||||
count = 0;
|
count = 0;
|
||||||
PRInt32 selectionCount;
|
PRInt32 selectionCount;
|
||||||
nsresult rv = mTreeSelection->GetRangeCount(&selectionCount);
|
nsresult rv = mTreeSelection->GetRangeCount(&selectionCount);
|
||||||
|
@ -1119,11 +1119,11 @@ nsresult nsMsgDBView::GetSelectedIndices(nsUInt32Array *selection)
|
||||||
if (startRange >= 0 && startRange < viewSize)
|
if (startRange >= 0 && startRange < viewSize)
|
||||||
{
|
{
|
||||||
for (PRInt32 rangeIndex = startRange; rangeIndex <= endRange && rangeIndex < viewSize; rangeIndex++)
|
for (PRInt32 rangeIndex = startRange; rangeIndex <= endRange && rangeIndex < viewSize; rangeIndex++)
|
||||||
selection->SetAt(count++, rangeIndex);
|
selection[count++] = rangeIndex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
NS_ASSERTION(selection->GetSize() == count, "selection count is wrong");
|
NS_ASSERTION(selection.Length() == count, "selection count is wrong");
|
||||||
selection->SetSize(count);
|
selection.SetLength(count);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1131,7 +1131,7 @@ nsresult nsMsgDBView::GetSelectedIndices(nsUInt32Array *selection)
|
||||||
// in that case the selected indices are really just the current message key.
|
// in that case the selected indices are really just the current message key.
|
||||||
nsMsgViewIndex viewIndex = FindViewIndex(m_currentlyDisplayedMsgKey);
|
nsMsgViewIndex viewIndex = FindViewIndex(m_currentlyDisplayedMsgKey);
|
||||||
if (viewIndex != nsMsgViewIndex_None)
|
if (viewIndex != nsMsgViewIndex_None)
|
||||||
selection->Add(viewIndex);
|
selection.AppendElement(viewIndex);
|
||||||
}
|
}
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
@ -2132,17 +2132,16 @@ NS_IMETHODIMP nsMsgDBView::GetIndicesForSelection(nsMsgViewIndex **indices, PRU
|
||||||
NS_ENSURE_ARG_POINTER(indices);
|
NS_ENSURE_ARG_POINTER(indices);
|
||||||
*indices = nsnull;
|
*indices = nsnull;
|
||||||
|
|
||||||
nsUInt32Array selection;
|
nsMsgViewIndexArray selection;
|
||||||
GetSelectedIndices(&selection);
|
GetSelectedIndices(selection);
|
||||||
*length = selection.GetSize();
|
PRUint32 numIndices = selection.Length();
|
||||||
PRUint32 numIndicies = *length;
|
if (!numIndices) return NS_OK;
|
||||||
if (!numIndicies) return NS_OK;
|
*length = numIndices;
|
||||||
|
|
||||||
*indices = (nsMsgViewIndex *)nsMemory::Alloc(numIndicies * sizeof(nsMsgViewIndex));
|
PRUint32 datalen = numIndices * sizeof(nsMsgViewIndex);
|
||||||
|
*indices = (nsMsgViewIndex *)NS_Alloc(datalen);
|
||||||
if (!*indices) return NS_ERROR_OUT_OF_MEMORY;
|
if (!*indices) return NS_ERROR_OUT_OF_MEMORY;
|
||||||
for (PRUint32 i=0;i<numIndicies;i++) {
|
memcpy(*indices, selection.Elements(), datalen);
|
||||||
(*indices)[i] = selection.GetAt(i);
|
|
||||||
}
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2155,9 +2154,9 @@ NS_IMETHODIMP nsMsgDBView::GetURIsForSelection(char ***uris, PRUint32 *length)
|
||||||
NS_ENSURE_ARG_POINTER(uris);
|
NS_ENSURE_ARG_POINTER(uris);
|
||||||
*uris = nsnull;
|
*uris = nsnull;
|
||||||
|
|
||||||
nsUInt32Array selection;
|
nsMsgViewIndexArray selection;
|
||||||
GetSelectedIndices(&selection);
|
GetSelectedIndices(selection);
|
||||||
*length = selection.GetSize();
|
*length = selection.Length();
|
||||||
PRUint32 numIndicies = *length;
|
PRUint32 numIndicies = *length;
|
||||||
if (!numIndicies) return NS_OK;
|
if (!numIndicies) return NS_OK;
|
||||||
|
|
||||||
|
@ -2167,7 +2166,7 @@ NS_IMETHODIMP nsMsgDBView::GetURIsForSelection(char ***uris, PRUint32 *length)
|
||||||
if (!outArray) return NS_ERROR_OUT_OF_MEMORY;
|
if (!outArray) return NS_ERROR_OUT_OF_MEMORY;
|
||||||
for (PRUint32 i=0;i<numIndicies;i++)
|
for (PRUint32 i=0;i<numIndicies;i++)
|
||||||
{
|
{
|
||||||
nsMsgViewIndex selectedIndex = selection.GetAt(i);
|
nsMsgViewIndex selectedIndex = selection[i];
|
||||||
nsCString tmpUri;
|
nsCString tmpUri;
|
||||||
if (!m_folder) // must be a cross folder view, like search results
|
if (!m_folder) // must be a cross folder view, like search results
|
||||||
GetFolderForViewIndex(selectedIndex, getter_AddRefs(folder));
|
GetFolderForViewIndex(selectedIndex, getter_AddRefs(folder));
|
||||||
|
@ -2199,25 +2198,19 @@ NS_IMETHODIMP nsMsgDBView::GetURIForViewIndex(nsMsgViewIndex index, nsACString &
|
||||||
|
|
||||||
NS_IMETHODIMP nsMsgDBView::DoCommandWithFolder(nsMsgViewCommandTypeValue command, nsIMsgFolder *destFolder)
|
NS_IMETHODIMP nsMsgDBView::DoCommandWithFolder(nsMsgViewCommandTypeValue command, nsIMsgFolder *destFolder)
|
||||||
{
|
{
|
||||||
nsUInt32Array selection;
|
|
||||||
|
|
||||||
NS_ENSURE_ARG_POINTER(destFolder);
|
NS_ENSURE_ARG_POINTER(destFolder);
|
||||||
|
|
||||||
GetSelectedIndices(&selection);
|
nsMsgViewIndexArray selection;
|
||||||
|
|
||||||
nsMsgViewIndex *indices = selection.GetData();
|
GetSelectedIndices(selection);
|
||||||
PRInt32 numIndices = selection.GetSize();
|
|
||||||
|
nsMsgViewIndex *indices = selection.Elements();
|
||||||
|
PRInt32 numIndices = selection.Length();
|
||||||
|
|
||||||
nsresult rv = NS_OK;
|
nsresult rv = NS_OK;
|
||||||
switch (command) {
|
switch (command) {
|
||||||
case nsMsgViewCommandType::copyMessages:
|
case nsMsgViewCommandType::copyMessages:
|
||||||
case nsMsgViewCommandType::moveMessages:
|
case nsMsgViewCommandType::moveMessages:
|
||||||
// since the FE could have constructed the list of indices in
|
|
||||||
// any order (e.g. order of discontiguous selection), we have to
|
|
||||||
// sort the indices in order to find out which nsMsgViewIndex will
|
|
||||||
// be deleted first.
|
|
||||||
if (numIndices > 1)
|
|
||||||
NS_QuickSort(indices, numIndices, sizeof(nsMsgViewIndex), CompareViewIndices, nsnull);
|
|
||||||
NoteStartChange(nsMsgViewNotificationCode::none, 0, 0);
|
NoteStartChange(nsMsgViewNotificationCode::none, 0, 0);
|
||||||
rv = ApplyCommandToIndicesWithFolder(command, indices, numIndices, destFolder);
|
rv = ApplyCommandToIndicesWithFolder(command, indices, numIndices, destFolder);
|
||||||
NoteEndChange(nsMsgViewNotificationCode::none, 0, 0);
|
NoteEndChange(nsMsgViewNotificationCode::none, 0, 0);
|
||||||
|
@ -2233,12 +2226,12 @@ NS_IMETHODIMP nsMsgDBView::DoCommandWithFolder(nsMsgViewCommandTypeValue command
|
||||||
|
|
||||||
NS_IMETHODIMP nsMsgDBView::DoCommand(nsMsgViewCommandTypeValue command)
|
NS_IMETHODIMP nsMsgDBView::DoCommand(nsMsgViewCommandTypeValue command)
|
||||||
{
|
{
|
||||||
nsUInt32Array selection;
|
nsMsgViewIndexArray selection;
|
||||||
|
|
||||||
GetSelectedIndices(&selection);
|
GetSelectedIndices(selection);
|
||||||
|
|
||||||
nsMsgViewIndex *indices = selection.GetData();
|
nsMsgViewIndex *indices = selection.Elements();
|
||||||
PRInt32 numIndices = selection.GetSize();
|
PRInt32 numIndices = selection.Length();
|
||||||
nsCOMPtr<nsIMsgWindow> msgWindow(do_QueryReferent(mMsgWindowWeak));
|
nsCOMPtr<nsIMsgWindow> msgWindow(do_QueryReferent(mMsgWindowWeak));
|
||||||
|
|
||||||
nsresult rv = NS_OK;
|
nsresult rv = NS_OK;
|
||||||
|
@ -2259,12 +2252,6 @@ NS_IMETHODIMP nsMsgDBView::DoCommand(nsMsgViewCommandTypeValue command)
|
||||||
case nsMsgViewCommandType::markThreadRead:
|
case nsMsgViewCommandType::markThreadRead:
|
||||||
case nsMsgViewCommandType::junk:
|
case nsMsgViewCommandType::junk:
|
||||||
case nsMsgViewCommandType::unjunk:
|
case nsMsgViewCommandType::unjunk:
|
||||||
// since the FE could have constructed the list of indices in
|
|
||||||
// any order (e.g. order of discontiguous selection), we have to
|
|
||||||
// sort the indices in order to find out which nsMsgViewIndex will
|
|
||||||
// be deleted first.
|
|
||||||
if (numIndices > 1)
|
|
||||||
NS_QuickSort (indices, numIndices, sizeof(nsMsgViewIndex), CompareViewIndices, nsnull);
|
|
||||||
NoteStartChange(nsMsgViewNotificationCode::none, 0, 0);
|
NoteStartChange(nsMsgViewNotificationCode::none, 0, 0);
|
||||||
rv = ApplyCommandToIndices(command, indices, numIndices);
|
rv = ApplyCommandToIndices(command, indices, numIndices);
|
||||||
NoteEndChange(nsMsgViewNotificationCode::none, 0, 0);
|
NoteEndChange(nsMsgViewNotificationCode::none, 0, 0);
|
||||||
|
@ -2360,10 +2347,10 @@ NS_IMETHODIMP nsMsgDBView::GetCommandStatus(nsMsgViewCommandTypeValue command, P
|
||||||
|
|
||||||
PRBool haveSelection;
|
PRBool haveSelection;
|
||||||
PRInt32 rangeCount;
|
PRInt32 rangeCount;
|
||||||
nsUInt32Array selection;
|
nsMsgViewIndexArray selection;
|
||||||
GetSelectedIndices(&selection);
|
GetSelectedIndices(selection);
|
||||||
PRInt32 numIndices = selection.GetSize();
|
PRInt32 numIndices = selection.Length();
|
||||||
nsMsgViewIndex *indices = selection.GetData();
|
nsMsgViewIndex *indices = selection.Elements();
|
||||||
// if range count is non-zero, we have at least one item selected, so we have a selection
|
// if range count is non-zero, we have at least one item selected, so we have a selection
|
||||||
if (mTreeSelection && NS_SUCCEEDED(mTreeSelection->GetRangeCount(&rangeCount)) && rangeCount > 0)
|
if (mTreeSelection && NS_SUCCEEDED(mTreeSelection->GetRangeCount(&rangeCount)) && rangeCount > 0)
|
||||||
haveSelection = NonDummyMsgSelected(indices, numIndices);
|
haveSelection = NonDummyMsgSelected(indices, numIndices);
|
||||||
|
@ -5482,9 +5469,9 @@ nsresult nsMsgDBView::NavigateFromPos(nsMsgNavigationTypeValue motion, nsMsgView
|
||||||
case nsMsgNavigationType::toggleThreadKilled:
|
case nsMsgNavigationType::toggleThreadKilled:
|
||||||
{
|
{
|
||||||
PRBool resultKilled;
|
PRBool resultKilled;
|
||||||
nsUInt32Array selection;
|
nsMsgViewIndexArray selection;
|
||||||
GetSelectedIndices(&selection);
|
GetSelectedIndices(selection);
|
||||||
ToggleIgnored(selection.GetData(), selection.GetSize(), &threadIndex, &resultKilled);
|
ToggleIgnored(selection.Elements(), selection.Length(), &threadIndex, &resultKilled);
|
||||||
if (resultKilled)
|
if (resultKilled)
|
||||||
{
|
{
|
||||||
return NavigateFromPos(nsMsgNavigationType::nextUnreadThread, threadIndex, pResultKey, pResultIndex, pThreadIndex, PR_TRUE);
|
return NavigateFromPos(nsMsgNavigationType::nextUnreadThread, threadIndex, pResultKey, pResultIndex, pThreadIndex, PR_TRUE);
|
||||||
|
@ -5789,8 +5776,6 @@ nsresult nsMsgDBView::ToggleIgnored(nsMsgViewIndex * indices, PRInt32 numIndices
|
||||||
nsCOMPtr <nsIMsgThread> thread;
|
nsCOMPtr <nsIMsgThread> thread;
|
||||||
|
|
||||||
// Ignored state is toggled based on the first selected thread
|
// Ignored state is toggled based on the first selected thread
|
||||||
if (numIndices > 1)
|
|
||||||
NS_QuickSort(indices, numIndices, sizeof(nsMsgViewIndex), CompareViewIndices, nsnull);
|
|
||||||
nsMsgViewIndex threadIndex = GetThreadFromMsgIndex(indices[0], getter_AddRefs(thread));
|
nsMsgViewIndex threadIndex = GetThreadFromMsgIndex(indices[0], getter_AddRefs(thread));
|
||||||
PRUint32 threadFlags;
|
PRUint32 threadFlags;
|
||||||
thread->GetFlags(&threadFlags);
|
thread->GetFlags(&threadFlags);
|
||||||
|
@ -5846,8 +5831,6 @@ nsresult nsMsgDBView::ToggleWatched( nsMsgViewIndex* indices, PRInt32 numIndice
|
||||||
nsCOMPtr <nsIMsgThread> thread;
|
nsCOMPtr <nsIMsgThread> thread;
|
||||||
|
|
||||||
// Watched state is toggled based on the first selected thread
|
// Watched state is toggled based on the first selected thread
|
||||||
if (numIndices > 1)
|
|
||||||
NS_QuickSort(indices, numIndices, sizeof(nsMsgViewIndex), CompareViewIndices, nsnull);
|
|
||||||
nsMsgViewIndex threadIndex = GetThreadFromMsgIndex(indices[0], getter_AddRefs(thread));
|
nsMsgViewIndex threadIndex = GetThreadFromMsgIndex(indices[0], getter_AddRefs(thread));
|
||||||
PRUint32 threadFlags;
|
PRUint32 threadFlags;
|
||||||
thread->GetFlags(&threadFlags);
|
thread->GetFlags(&threadFlags);
|
||||||
|
|
|
@ -69,6 +69,8 @@
|
||||||
|
|
||||||
#define MESSENGER_STRING_URL "chrome://messenger/locale/messenger.properties"
|
#define MESSENGER_STRING_URL "chrome://messenger/locale/messenger.properties"
|
||||||
|
|
||||||
|
typedef nsAutoTArray<nsMsgViewIndex, 1> nsMsgViewIndexArray;
|
||||||
|
|
||||||
enum eFieldType {
|
enum eFieldType {
|
||||||
kCollationKey,
|
kCollationKey,
|
||||||
kU32
|
kU32
|
||||||
|
@ -212,7 +214,7 @@ protected:
|
||||||
// RestoreSelection()
|
// RestoreSelection()
|
||||||
nsresult AdjustRowCount(PRInt32 rowCountBeforeSort, PRInt32 rowCountAfterSort);
|
nsresult AdjustRowCount(PRInt32 rowCountBeforeSort, PRInt32 rowCountAfterSort);
|
||||||
|
|
||||||
nsresult GetSelectedIndices(nsUInt32Array *selection);
|
nsresult GetSelectedIndices(nsMsgViewIndexArray& selection);
|
||||||
nsresult GenerateURIForMsgKey(nsMsgKey aMsgKey, nsIMsgFolder *folder, nsACString &aURI);
|
nsresult GenerateURIForMsgKey(nsMsgKey aMsgKey, nsIMsgFolder *folder, nsACString &aURI);
|
||||||
// routines used in building up view
|
// routines used in building up view
|
||||||
virtual PRBool WantsThisThread(nsIMsgThread * thread);
|
virtual PRBool WantsThisThread(nsIMsgThread * thread);
|
||||||
|
|
|
@ -307,11 +307,11 @@ NS_IMETHODIMP nsMsgSearchDBView::DoCommand(nsMsgViewCommandTypeValue command)
|
||||||
|| command == nsMsgViewCommandType::selectAll)
|
|| command == nsMsgViewCommandType::selectAll)
|
||||||
return nsMsgDBView::DoCommand(command);
|
return nsMsgDBView::DoCommand(command);
|
||||||
nsresult rv = NS_OK;
|
nsresult rv = NS_OK;
|
||||||
nsUInt32Array selection;
|
nsMsgViewIndexArray selection;
|
||||||
GetSelectedIndices(&selection);
|
GetSelectedIndices(selection);
|
||||||
|
|
||||||
nsMsgViewIndex *indices = selection.GetData();
|
nsMsgViewIndex *indices = selection.Elements();
|
||||||
PRInt32 numIndices = selection.GetSize();
|
PRInt32 numIndices = selection.Length();
|
||||||
|
|
||||||
// we need to break apart the selection by folders, and then call
|
// we need to break apart the selection by folders, and then call
|
||||||
// ApplyCommandToIndices with the command and the indices in the
|
// ApplyCommandToIndices with the command and the indices in the
|
||||||
|
|
Загрузка…
Ссылка в новой задаче