From b2937b55f1dfd8e638960bacd7a4f117e22c5501 Mon Sep 17 00:00:00 2001 From: "edward.lee@engineering.uiuc.edu" Date: Thu, 27 Mar 2008 09:38:40 -0700 Subject: [PATCH] Bug 424216 - displaying filename/path instead of title for (unvisited?) bookmarks. r=dietrich, b-ff3=beltzner --- .../places/src/nsNavHistoryAutoComplete.cpp | 54 +++++++------------ 1 file changed, 18 insertions(+), 36 deletions(-) diff --git a/toolkit/components/places/src/nsNavHistoryAutoComplete.cpp b/toolkit/components/places/src/nsNavHistoryAutoComplete.cpp index a7ac96d4b78f..e4488d0751f5 100644 --- a/toolkit/components/places/src/nsNavHistoryAutoComplete.cpp +++ b/toolkit/components/places/src/nsNavHistoryAutoComplete.cpp @@ -706,8 +706,10 @@ nsNavHistory::AutoCompleteProcessSearch(mozIStorageStatement* aQuery, rv = aQuery->GetString(kAutoCompleteIndex_Tags, entryTags); NS_ENSURE_SUCCESS(rv, rv); - PRBool useBookmark = PR_FALSE; - PRBool showTags = PR_FALSE; + // Always prefer the bookmark title unless it's empty + nsAutoString title = + entryBookmarkTitle.IsEmpty() ? entryTitle : entryBookmarkTitle; + nsString style; switch (aType) { case QUERY_FULL: { @@ -721,21 +723,15 @@ nsNavHistory::AutoCompleteProcessSearch(mozIStorageStatement* aQuery, for (PRInt32 i = 0; i < mCurrentSearchTokens.Count() && matchAll; i++) { const nsString *token = mCurrentSearchTokens.StringAt(i); - // Check if the current token matches the bookmark - PRBool bookmarkMatch = parentId && - (*tokenMatchesTarget)(*token, entryBookmarkTitle); - // If any part of the search string is in the bookmark title, show - // that in the result instead of the page title - useBookmark |= bookmarkMatch; - - // If the token is in any of the tags, remember to show tags - PRBool tagsMatch = (*tokenMatchesTarget)(*token, entryTags); - showTags |= tagsMatch; + // Check if the tags match the search term + PRBool matchTags = (*tokenMatchesTarget)(*token, entryTags); + // Check if the title matches the search term + PRBool matchTitle = (*tokenMatchesTarget)(*token, title); + // Check if the url matches the search term + PRBool matchUrl = (*tokenMatchesTarget)(*token, entryURL); // True if any of them match; false makes us quit the loop - matchAll = bookmarkMatch || tagsMatch || - (*tokenMatchesTarget)(*token, entryTitle) || - (*tokenMatchesTarget)(*token, entryURL); + matchAll = matchTags || matchTitle || matchUrl; } // Skip if we don't match all terms in the bookmark, tag, title or url @@ -744,27 +740,16 @@ nsNavHistory::AutoCompleteProcessSearch(mozIStorageStatement* aQuery, break; } - default: { - // Always prefer to show tags if we have them; otherwise, prefer the - // bookmark title if we have it - if (!entryTags.IsEmpty()) - showTags = PR_TRUE; - else - useBookmark = !entryBookmarkTitle.IsEmpty(); - - break; - } } + // Always prefer to show tags if we have them + PRBool showTags = !entryTags.IsEmpty(); + // Add the tags to the title if necessary - if (showTags) { - // Always show the bookmark if possible when we have tags - useBookmark = !entryBookmarkTitle.IsEmpty(); - /* XXX bug 418257 to look at RTL issues of appending tags - (useBookmark ? entryBookmarkTitle : entryTitle) - += NS_LITERAL_STRING(" (") + entryTags + NS_LITERAL_STRING(")"); - */ - } + /* XXX bug 418257 to look at RTL issues of appending tags + if (showTags) + title += kTitleTagsSeparator + entryTags; + */ // Tags have a special style to show a tag icon; otherwise, style the // bookmarks that aren't feed items and feed URIs as bookmark @@ -773,9 +758,6 @@ nsNavHistory::AutoCompleteProcessSearch(mozIStorageStatement* aQuery, mLivemarkFeedURIs.Get(escapedEntryURL, &dummy) ? NS_LITERAL_STRING("bookmark") : NS_LITERAL_STRING("favicon"); - // Pick the right title to show based on the result of the query type - const nsAString &title = useBookmark ? entryBookmarkTitle : entryTitle; - // Get the URI for the favicon nsCAutoString faviconSpec; faviconService->GetFaviconSpecForIconString(