Bug 1804185 - remove useless nsIMsgThread getRootHdr out param. r=benc

Differential Revision: https://phabricator.services.mozilla.com/D163897

--HG--
extra : rebase_source : 0d3de29d61752b02988fd9abe98f1a489624f7e8
extra : amend_source : 9c7732c53f65c3b11a629f8bb0aac3927f33137c
This commit is contained in:
Magnus Melin 2022-12-06 21:20:41 +11:00
Родитель 4df1d667c7
Коммит 48111906b3
11 изменённых файлов: 23 добавлений и 36 удалений

Просмотреть файл

@ -439,8 +439,7 @@ async function displayMessages(messages = []) {
clearMessage();
let getThreadId = function(message) {
return gDBView.getThreadContainingMsgHdr(message).getChildHdrAt(0)
.messageKey;
return gDBView.getThreadContainingMsgHdr(message).getRootHdr().messageKey;
};
let oneThread = true;

Просмотреть файл

@ -2592,9 +2592,7 @@ FolderDisplayWidget.prototype = {
let dbView = this.view.dbView;
for (let index of selectedIndices) {
let thread = dbView.getThreadContainingIndex(index);
// We use getChildHdrAt instead of getRootHdr because getRootHdr has
// a useless out-param and just calls getChildHdrAt anyways.
newSelectedMessages.push(thread.getChildHdrAt(0));
newSelectedMessages.push(thread.getRootHdr());
}
this.selectMessages(newSelectedMessages);
},

Просмотреть файл

@ -22,7 +22,7 @@ function summarizeSelection(aMessageDisplay) {
let dbView = folderDisplay.view.dbView;
let getThreadId = function(index) {
return dbView.getThreadContainingIndex(index).getChildHdrAt(0).messageKey;
return dbView.getThreadContainingIndex(index).getRootHdr().messageKey;
};
let firstThreadId = getThreadId(selectedIndices[0]);

Просмотреть файл

@ -23,7 +23,7 @@ interface nsIMsgThread : nsISupports {
nsMsgKey getChildKeyAt(in unsigned long index);
nsIMsgDBHdr getChild(in nsMsgKey msgKey);
nsIMsgDBHdr getChildHdrAt(in unsigned long index);
nsIMsgDBHdr getRootHdr(out long index);
nsIMsgDBHdr getRootHdr();
void removeChildAt(in unsigned long index);
void removeChildHdr(in nsIMsgDBHdr child, in nsIDBChangeAnnouncer announcer);

Просмотреть файл

@ -328,7 +328,7 @@ nsMsgGroupThreadEnumerator::nsMsgGroupThreadEnumerator(
mNeedToPrefetch = true;
mFirstMsgKey = nsMsgKey_None;
nsresult rv = mThread->GetRootHdr(nullptr, getter_AddRefs(mResultHdr));
nsresult rv = mThread->GetRootHdr(getter_AddRefs(mResultHdr));
if (NS_SUCCEEDED(rv) && mResultHdr) mResultHdr->GetMessageKey(&mFirstMsgKey);
uint32_t numChildren;
@ -421,7 +421,7 @@ nsresult nsMsgGroupThreadEnumerator::Prefetch() {
nsresult rv = NS_OK; // XXX or should this default to an error?
mResultHdr = nullptr;
if (mThreadParentKey == nsMsgKey_None) {
rv = mThread->GetRootHdr(&mChildIndex, getter_AddRefs(mResultHdr));
rv = mThread->GetRootHdr(getter_AddRefs(mResultHdr));
NS_ASSERTION(NS_SUCCEEDED(rv) && mResultHdr,
"better be able to get root hdr");
mChildIndex = 0; // since root can be anywhere, set mChildIndex to 0.
@ -521,14 +521,14 @@ nsresult nsMsgGroupThread::ReparentMsgsWithInvalidParent(uint32_t numChildren, n
}
#endif
NS_IMETHODIMP nsMsgGroupThread::GetRootHdr(int32_t* resultIndex,
nsIMsgDBHdr** result) {
NS_IMETHODIMP nsMsgGroupThread::GetRootHdr(nsIMsgDBHdr** result) {
NS_ENSURE_ARG_POINTER(result);
*result = nullptr;
int32_t resultIndex = -1;
if (m_threadRootKey != nsMsgKey_None) {
nsresult ret = GetChildHdrForKey(m_threadRootKey, result, resultIndex);
nsresult ret = GetChildHdrForKey(m_threadRootKey, result, &resultIndex);
if (NS_SUCCEEDED(ret) && *result)
return ret;
else {
@ -548,7 +548,6 @@ NS_IMETHODIMP nsMsgGroupThread::GetRootHdr(int32_t* resultIndex,
NS_ASSERTION(!(*result), "two top level msgs, not good");
curChild->GetMessageKey(&threadParentKey);
m_threadRootKey = threadParentKey;
if (resultIndex) *resultIndex = childIndex;
curChild.forget(result);
}
}
@ -561,7 +560,6 @@ NS_IMETHODIMP nsMsgGroupThread::GetRootHdr(int32_t* resultIndex,
// there's a bug where sometimes we weren't resetting the thread root key
// when removing the thread root key.
}
if (resultIndex) *resultIndex = 0;
return GetChildHdrAt(0, result);
}

Просмотреть файл

@ -395,8 +395,7 @@ nsresult nsMsgQuickSearchDBView::GetFirstMessageHdrToDisplayInThread(
threadHdr->GetNumChildren(&numChildren);
nsMsgKey threadRootKey;
nsCOMPtr<nsIMsgDBHdr> rootParent;
int32_t rootIndex;
threadHdr->GetRootHdr(&rootIndex, getter_AddRefs(rootParent));
threadHdr->GetRootHdr(getter_AddRefs(rootParent));
if (rootParent)
rootParent->GetMessageKey(&threadRootKey);
else
@ -682,8 +681,7 @@ nsresult nsMsgQuickSearchDBView::ListIdsInThreadOrder(nsIMsgThread* threadHdr,
nsCOMPtr<nsIMsgDBHdr> root;
nsCOMPtr<nsIMsgDBHdr> rootParent;
nsMsgKey rootKey;
int32_t rootIndex;
threadHdr->GetRootHdr(&rootIndex, getter_AddRefs(rootParent));
threadHdr->GetRootHdr(getter_AddRefs(rootParent));
if (rootParent) {
rootParent->GetMessageKey(&rootKey);
if (rootKey != parentKey)

Просмотреть файл

@ -210,7 +210,7 @@ nsMsgSearchDBView::OnHdrDeleted(nsIMsgDBHdr* aHdrDeleted, nsMsgKey aParentKey,
// Remove the last child of a collapsed thread. Need to find the root,
// and remove the thread flags on it.
nsCOMPtr<nsIMsgDBHdr> rootHdr;
thread->GetRootHdr(nullptr, getter_AddRefs(rootHdr));
thread->GetRootHdr(getter_AddRefs(rootHdr));
if (rootHdr) {
nsMsgViewIndex threadIndex = GetThreadRootIndex(rootHdr);
if (IsValidIndex(threadIndex))
@ -221,7 +221,7 @@ nsMsgSearchDBView::OnHdrDeleted(nsIMsgDBHdr* aHdrDeleted, nsMsgKey aParentKey,
} else if (savedFlags & MSG_VIEW_FLAG_HASCHILDREN) {
if (savedFlags & nsMsgMessageFlags::Elided) {
nsCOMPtr<nsIMsgDBHdr> rootHdr;
nsresult rv = thread->GetRootHdr(nullptr, getter_AddRefs(rootHdr));
nsresult rv = thread->GetRootHdr(getter_AddRefs(rootHdr));
NS_ENSURE_SUCCESS(rv, rv);
nsMsgKey msgKey;
uint32_t msgFlags;

Просмотреть файл

@ -124,8 +124,7 @@ nsresult nsMsgThreadedDBView::InitThreadedView(int32_t& count) {
if (unreadOnly) {
rv = threadHdr->GetFirstUnreadChild(getter_AddRefs(msgHdr));
} else {
int32_t unusedRootIndex;
rv = threadHdr->GetRootHdr(&unusedRootIndex, getter_AddRefs(msgHdr));
rv = threadHdr->GetRootHdr(getter_AddRefs(msgHdr));
}
NS_ENSURE_SUCCESS(rv, rv);

Просмотреть файл

@ -235,7 +235,7 @@ nsresult nsMsgXFViewThread::AddHdr(nsIMsgDBHdr* newHdr, bool reparentChildren,
// if (numChildren > 0 && !(newHdrFlags & nsMsgMessageFlags::HasRe)) {
// PRTime topLevelHdrDate;
// nsCOMPtr<nsIMsgDBHdr> topLevelHdr;
// rv = GetRootHdr(nullptr, getter_AddRefs(topLevelHdr));
// rv = GetRootHdr(getter_AddRefs(topLevelHdr));
// if (NS_SUCCEEDED(rv) && topLevelHdr) {
// topLevelHdr->GetDate(&topLevelHdrDate);
// if (newHdrDate < topLevelHdrDate) ?? and now ??
@ -304,10 +304,8 @@ nsMsgXFViewThread::RemoveChildHdr(nsIMsgDBHdr* child,
}
NS_IMETHODIMP
nsMsgXFViewThread::GetRootHdr(int32_t* aResultIndex, nsIMsgDBHdr** aResult) {
nsMsgXFViewThread::GetRootHdr(nsIMsgDBHdr** aResult) {
NS_ENSURE_ARG_POINTER(aResult);
if (aResultIndex) *aResultIndex = 0;
return GetChildHdrAt(0, aResult);
}

Просмотреть файл

@ -741,9 +741,8 @@ void nsMsgHdr::ReparentInThread(nsIMsgThread* thread) {
}
// we didn't find it. So either the root header is our parent,
// or we're the root.
int32_t rootIndex;
nsCOMPtr<nsIMsgDBHdr> rootHdr;
thread->GetRootHdr(&rootIndex, getter_AddRefs(rootHdr));
thread->GetRootHdr(getter_AddRefs(rootHdr));
NS_ASSERTION(rootHdr, "thread has no root hdr - shouldn't happen");
if (rootHdr) {
nsMsgKey rootKey;

Просмотреть файл

@ -323,7 +323,7 @@ NS_IMETHODIMP nsMsgThread::AddChild(nsIMsgDBHdr* child, nsIMsgDBHdr* inReplyTo,
PRTime topLevelHdrDate;
nsCOMPtr<nsIMsgDBHdr> topLevelHdr;
rv = GetRootHdr(nullptr, getter_AddRefs(topLevelHdr));
rv = GetRootHdr(getter_AddRefs(topLevelHdr));
if (NS_SUCCEEDED(rv) && topLevelHdr) {
topLevelHdr->GetDate(&topLevelHdrDate);
if (newHdrDate < topLevelHdrDate) {
@ -597,7 +597,7 @@ nsMsgThreadEnumerator::nsMsgThreadEnumerator(nsMsgThread* thread,
mNeedToPrefetch = true;
mFirstMsgKey = nsMsgKey_None;
nsresult rv = mThread->GetRootHdr(nullptr, getter_AddRefs(mResultHdr));
nsresult rv = mThread->GetRootHdr(getter_AddRefs(mResultHdr));
if (NS_SUCCEEDED(rv) && mResultHdr) mResultHdr->GetMessageKey(&mFirstMsgKey);
@ -700,7 +700,7 @@ nsresult nsMsgThreadEnumerator::Prefetch() {
nsresult rv = NS_OK; // XXX or should this default to an error?
mResultHdr = nullptr;
if (mThreadParentKey == nsMsgKey_None) {
rv = mThread->GetRootHdr(&mChildIndex, getter_AddRefs(mResultHdr));
rv = mThread->GetRootHdr(getter_AddRefs(mResultHdr));
NS_ASSERTION(NS_SUCCEEDED(rv) && mResultHdr,
"better be able to get root hdr");
mChildIndex = 0; // since root can be anywhere, set mChildIndex to 0.
@ -803,15 +803,15 @@ nsresult nsMsgThread::ReparentMsgsWithInvalidParent(uint32_t numChildren,
return rv;
}
NS_IMETHODIMP nsMsgThread::GetRootHdr(int32_t* resultIndex,
nsIMsgDBHdr** result) {
NS_IMETHODIMP nsMsgThread::GetRootHdr(nsIMsgDBHdr** result) {
NS_ENSURE_ARG_POINTER(result);
*result = nullptr;
int32_t resultIndex = -1;
nsresult rv = NS_OK;
if (m_threadRootKey != nsMsgKey_None) {
rv = GetChildHdrForKey(m_threadRootKey, result, resultIndex);
rv = GetChildHdrForKey(m_threadRootKey, result, &resultIndex);
if (NS_SUCCEEDED(rv) && *result) {
// check that we're really the root key.
nsMsgKey parentKey;
@ -842,7 +842,6 @@ NS_IMETHODIMP nsMsgThread::GetRootHdr(int32_t* resultIndex,
continue;
}
SetThreadRootKey(threadParentKey);
if (resultIndex) *resultIndex = childIndex;
curChild.forget(result);
ReparentMsgsWithInvalidParent(numChildren, threadParentKey);
}
@ -853,7 +852,6 @@ NS_IMETHODIMP nsMsgThread::GetRootHdr(int32_t* resultIndex,
// if we can't get the thread root key, we'll just get the first hdr.
// there's a bug where sometimes we weren't resetting the thread root key
// when removing the thread root key.
if (resultIndex) *resultIndex = 0;
rv = GetChildHdrAt(0, result);
}
if (!*result) return rv;