зеркало из https://github.com/mozilla/pjs.git
fix for bug #389003: sometimes favicons in url results are blank, need to use
the favicon service. r=mano
This commit is contained in:
Родитель
fb6c0b6a12
Коммит
8a4afdd7bf
|
@ -986,7 +986,6 @@ statusbarpanel#statusbar-display {
|
||||||
/* ----- AUTOCOMPLETE ----- */
|
/* ----- AUTOCOMPLETE ----- */
|
||||||
|
|
||||||
.autocomplete-treebody::-moz-tree-image(favicon, treecolAutoCompleteValue) {
|
.autocomplete-treebody::-moz-tree-image(favicon, treecolAutoCompleteValue) {
|
||||||
list-style-image: url("chrome://mozapps/skin/places/defaultFavicon.png");
|
|
||||||
width: 16px;
|
width: 16px;
|
||||||
height: 16px;
|
height: 16px;
|
||||||
}
|
}
|
||||||
|
|
|
@ -987,7 +987,6 @@ statusbarpanel#statusbar-display {
|
||||||
/* ::::: autocomplete ::::: */
|
/* ::::: autocomplete ::::: */
|
||||||
|
|
||||||
.autocomplete-treebody::-moz-tree-image(favicon, treecolAutoCompleteValue) {
|
.autocomplete-treebody::-moz-tree-image(favicon, treecolAutoCompleteValue) {
|
||||||
list-style-image: url("chrome://mozapps/skin/places/defaultFavicon.png");
|
|
||||||
width: 16px;
|
width: 16px;
|
||||||
height: 16px;
|
height: 16px;
|
||||||
}
|
}
|
||||||
|
|
|
@ -294,7 +294,7 @@ nsFaviconService::SetFaviconUrlForPageInternal(nsIURI* aPage, nsIURI* aFavicon,
|
||||||
|
|
||||||
// now link our entry with the history service
|
// now link our entry with the history service
|
||||||
nsNavHistory* historyService = nsNavHistory::GetHistoryService();
|
nsNavHistory* historyService = nsNavHistory::GetHistoryService();
|
||||||
NS_ENSURE_TRUE(historyService, NS_ERROR_NO_INTERFACE);
|
NS_ENSURE_TRUE(historyService, NS_ERROR_OUT_OF_MEMORY);
|
||||||
|
|
||||||
PRInt64 pageId;
|
PRInt64 pageId;
|
||||||
rv = historyService->GetUrlIdFor(aPage, &pageId, PR_TRUE);
|
rv = historyService->GetUrlIdFor(aPage, &pageId, PR_TRUE);
|
||||||
|
|
|
@ -106,6 +106,7 @@
|
||||||
#include "mozIStorageFunction.h"
|
#include "mozIStorageFunction.h"
|
||||||
#include "mozStorageCID.h"
|
#include "mozStorageCID.h"
|
||||||
#include "mozStorageHelper.h"
|
#include "mozStorageHelper.h"
|
||||||
|
#include "nsFaviconService.h"
|
||||||
|
|
||||||
#define NS_AUTOCOMPLETESIMPLERESULT_CONTRACTID \
|
#define NS_AUTOCOMPLETESIMPLERESULT_CONTRACTID \
|
||||||
"@mozilla.org/autocomplete/simple-result;1"
|
"@mozilla.org/autocomplete/simple-result;1"
|
||||||
|
@ -361,7 +362,6 @@ nsNavHistory::StopSearch()
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// nsNavHistory::AutoCompleteTypedSearch
|
// nsNavHistory::AutoCompleteTypedSearch
|
||||||
//
|
//
|
||||||
// Called when there is no search string. This happens when you press
|
// Called when there is no search string. This happens when you press
|
||||||
|
@ -390,6 +390,9 @@ nsresult nsNavHistory::AutoCompleteTypedSearch(
|
||||||
if (! urls.Init(500))
|
if (! urls.Init(500))
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
|
|
||||||
|
nsFaviconService* faviconService = nsFaviconService::GetFaviconService();
|
||||||
|
NS_ENSURE_TRUE(faviconService, NS_ERROR_OUT_OF_MEMORY);
|
||||||
|
|
||||||
PRInt32 dummy;
|
PRInt32 dummy;
|
||||||
PRInt32 count = 0;
|
PRInt32 count = 0;
|
||||||
PRBool hasMore = PR_FALSE;
|
PRBool hasMore = PR_FALSE;
|
||||||
|
@ -402,7 +405,11 @@ nsresult nsNavHistory::AutoCompleteTypedSearch(
|
||||||
|
|
||||||
if (! urls.Get(entryURL, &dummy)) {
|
if (! urls.Get(entryURL, &dummy)) {
|
||||||
// new item
|
// new item
|
||||||
rv = result->AppendMatch(entryURL, entryTitle, entryImage, NS_LITERAL_STRING("favicon"));
|
nsCAutoString faviconSpec;
|
||||||
|
faviconService->GetFaviconSpecForIconString(
|
||||||
|
NS_ConvertUTF16toUTF8(entryImage), faviconSpec);
|
||||||
|
rv = result->AppendMatch(entryURL, entryTitle,
|
||||||
|
NS_ConvertUTF8toUTF16(faviconSpec), NS_LITERAL_STRING("favicon"));
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
urls.Put(entryURL, 1);
|
urls.Put(entryURL, 1);
|
||||||
|
@ -497,19 +504,32 @@ nsNavHistory::AutoCompleteFullHistorySearch(const nsAString& aSearchString,
|
||||||
AUTOCOMPLETE_MATCHES_SCHEME_PENALTY, &matches);
|
AUTOCOMPLETE_MATCHES_SCHEME_PENALTY, &matches);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nsFaviconService* faviconService = nsFaviconService::GetFaviconService();
|
||||||
|
NS_ENSURE_TRUE(faviconService, NS_ERROR_OUT_OF_MEMORY);
|
||||||
|
|
||||||
// fill into result
|
// fill into result
|
||||||
if (matches.Length() > 0) {
|
if (matches.Length() > 0) {
|
||||||
// sort according to priorities
|
// sort according to priorities
|
||||||
AutoCompleteResultComparator comparator(this);
|
AutoCompleteResultComparator comparator(this);
|
||||||
matches.Sort(comparator);
|
matches.Sort(comparator);
|
||||||
|
|
||||||
rv = aResult->AppendMatch(matches[0].url, matches[0].title, matches[0].image, NS_LITERAL_STRING("favicon"));
|
nsCAutoString faviconSpec;
|
||||||
|
faviconService->GetFaviconSpecForIconString(
|
||||||
|
NS_ConvertUTF16toUTF8(matches[0].image), faviconSpec);
|
||||||
|
rv = aResult->AppendMatch(matches[0].url, matches[0].title,
|
||||||
|
NS_ConvertUTF8toUTF16(faviconSpec),
|
||||||
|
NS_LITERAL_STRING("favicon"));
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
for (i = 1; i < matches.Length(); i ++) {
|
for (i = 1; i < matches.Length(); i ++) {
|
||||||
// only add ones that are NOT the same as the previous one. It's possible
|
// only add ones that are NOT the same as the previous one. It's possible
|
||||||
// to get duplicates from the queries.
|
// to get duplicates from the queries.
|
||||||
if (!matches[i].url.Equals(matches[i-1].url)) {
|
if (!matches[i].url.Equals(matches[i-1].url)) {
|
||||||
rv = aResult->AppendMatch(matches[i].url, matches[i].title, matches[i].image, NS_LITERAL_STRING("favicon"));
|
faviconService->GetFaviconSpecForIconString(
|
||||||
|
NS_ConvertUTF16toUTF8(matches[i].image), faviconSpec);
|
||||||
|
rv = aResult->AppendMatch(matches[i].url, matches[i].title,
|
||||||
|
NS_ConvertUTF8toUTF16(faviconSpec),
|
||||||
|
NS_LITERAL_STRING("favicon"));
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,7 +127,7 @@ NS_IMETHODIMP
|
||||||
nsNavHistoryResultNode::GetIcon(nsIURI** aURI)
|
nsNavHistoryResultNode::GetIcon(nsIURI** aURI)
|
||||||
{
|
{
|
||||||
nsFaviconService* faviconService = nsFaviconService::GetFaviconService();
|
nsFaviconService* faviconService = nsFaviconService::GetFaviconService();
|
||||||
NS_ENSURE_TRUE(faviconService, NS_ERROR_NO_INTERFACE);
|
NS_ENSURE_TRUE(faviconService, NS_ERROR_OUT_OF_MEMORY);
|
||||||
if (mFaviconURI.IsEmpty()) {
|
if (mFaviconURI.IsEmpty()) {
|
||||||
*aURI = nsnull;
|
*aURI = nsnull;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче