fix for bug #397527: append folder and all ancestors to the include / exclude folder array in nsNavHistory::FilterResultSet(), to save repeated queries

r=dietrich, a=mconnor
This commit is contained in:
sspitzer%mozilla.org 2007-09-27 17:08:15 +00:00
Родитель b0ff1c9bc0
Коммит 44a135fe70
1 изменённых файлов: 8 добавлений и 2 удалений

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

@ -4199,22 +4199,28 @@ nsNavHistory::FilterResultSet(nsNavHistoryQueryResultNode* aQueryNode,
// check ancestors
PRInt64 ancestor = parentId, lastAncestor;
PRBool belongs = PR_FALSE;
nsTArray<PRInt64> ancestorFolders;
while (!belongs) {
// Avoid using |ancestor| itself if GetFolderIdForItem failed.
lastAncestor = ancestor;
ancestorFolders.AppendElement(ancestor);
// GetFolderIdForItems throws when called for the places-root
if (NS_FAILED(bookmarks->GetFolderIdForItem(ancestor,&ancestor))) {
break;
} else if (excludeFolders[queryIndex]->IndexOf(ancestor) != -1) {
break;
} else if (includeFolders[queryIndex]->IndexOf(ancestor) != -1) {
belongs = PR_TRUE;
}
}
// if the parentId or any of its ancestors "belong",
// include all of them. otherwise, exclude all of them.
if (belongs) {
includeFolders[queryIndex]->AppendElement(lastAncestor);
includeFolders[queryIndex]->AppendElements(ancestorFolders);
} else {
excludeFolders[queryIndex]->AppendElement(lastAncestor);
excludeFolders[queryIndex]->AppendElements(ancestorFolders);
continue;
}
}