From bf145b9c316cdad4b89c8c65748b845af0636b05 Mon Sep 17 00:00:00 2001 From: "edward.lee%engineering.uiuc.edu" Date: Sun, 27 Jan 2008 22:52:28 +0000 Subject: [PATCH] Bug 414257 - Stop searching for autocomplete results that won't be displayed. r=sspitzer, a1.9=beltzner --- toolkit/components/places/src/nsNavHistory.cpp | 5 +++++ toolkit/components/places/src/nsNavHistory.h | 1 + toolkit/components/places/src/nsNavHistoryAutoComplete.cpp | 5 +++++ 3 files changed, 11 insertions(+) diff --git a/toolkit/components/places/src/nsNavHistory.cpp b/toolkit/components/places/src/nsNavHistory.cpp index a7daf24097b..f9e788f668c 100644 --- a/toolkit/components/places/src/nsNavHistory.cpp +++ b/toolkit/components/places/src/nsNavHistory.cpp @@ -112,6 +112,7 @@ #define PREF_BROWSER_HISTORY_EXPIRE_SITES "history_expire_sites" #define PREF_AUTOCOMPLETE_ONLY_TYPED "urlbar.matchOnlyTyped" #define PREF_AUTOCOMPLETE_ENABLED "urlbar.autocomplete.enabled" +#define PREF_AUTOCOMPLETE_MAX_RICH_RESULTS "urlbar.maxRichResults" #define PREF_DB_CACHE_PERCENTAGE "history_cache_percentage" #define PREF_FRECENCY_NUM_VISITS "places.frecency.numVisits" #define PREF_FRECENCY_UPDATE_IDLE_TIME "places.frecency.updateIdleTime" @@ -309,6 +310,7 @@ nsNavHistory::nsNavHistory() : mNowValid(PR_FALSE), mExpireDaysMax(0), mExpireSites(0), mAutoCompleteOnlyTyped(PR_FALSE), + mAutoCompleteMaxResults(25), mBatchLevel(0), mLock(nsnull), mBatchHasTransaction(PR_FALSE), @@ -450,6 +452,7 @@ nsNavHistory::Init() nsCOMPtr pbi = do_QueryInterface(mPrefBranch); if (pbi) { pbi->AddObserver(PREF_AUTOCOMPLETE_ONLY_TYPED, this, PR_FALSE); + pbi->AddObserver(PREF_AUTOCOMPLETE_MAX_RICH_RESULTS, this, PR_FALSE); pbi->AddObserver(PREF_BROWSER_HISTORY_EXPIRE_DAYS_MAX, this, PR_FALSE); pbi->AddObserver(PREF_BROWSER_HISTORY_EXPIRE_DAYS_MIN, this, PR_FALSE); pbi->AddObserver(PREF_BROWSER_HISTORY_EXPIRE_SITES, this, PR_FALSE); @@ -1663,6 +1666,8 @@ nsNavHistory::LoadPrefs(PRBool aInitializing) PRBool oldCompleteOnlyTyped = mAutoCompleteOnlyTyped; mPrefBranch->GetBoolPref(PREF_AUTOCOMPLETE_ONLY_TYPED, &mAutoCompleteOnlyTyped); + mPrefBranch->GetBoolPref(PREF_AUTOCOMPLETE_MAX_RICH_RESULTS, + &mAutoCompleteMaxResults); if (!aInitializing && oldCompleteOnlyTyped != mAutoCompleteOnlyTyped) { // update the autocomplete statements if the option has changed. nsresult rv = CreateAutoCompleteQueries(); diff --git a/toolkit/components/places/src/nsNavHistory.h b/toolkit/components/places/src/nsNavHistory.h index 165bcc678ed..f53ebb9b550 100644 --- a/toolkit/components/places/src/nsNavHistory.h +++ b/toolkit/components/places/src/nsNavHistory.h @@ -615,6 +615,7 @@ protected: nsresult InitAutoComplete(); nsresult CreateAutoCompleteQueries(); PRBool mAutoCompleteOnlyTyped; + PRInt32 mAutoCompleteMaxResults; nsCOMPtr mAutoCompleteTimer; nsString mCurrentSearchString; diff --git a/toolkit/components/places/src/nsNavHistoryAutoComplete.cpp b/toolkit/components/places/src/nsNavHistoryAutoComplete.cpp index 5e028f775cc..7d29ee127f9 100644 --- a/toolkit/components/places/src/nsNavHistoryAutoComplete.cpp +++ b/toolkit/components/places/src/nsNavHistoryAutoComplete.cpp @@ -637,6 +637,11 @@ nsNavHistory::AutoCompleteFullHistorySearch(PRBool* aHasMoreResults) NS_ENSURE_SUCCESS(rv, rv); mCurrentResultURLs.Put(entryURL, PR_TRUE); + + if (mCurrentResultURLs.Count() >= mAutoCompleteMaxResults) { + *aHasMoreResults = PR_FALSE; + break; + } } }