Bug 422177 - Awesome bar interrupts typing, so continue from where it left off. r=dietrich, a1.9b5=mconnor, b-ff3=beltzner. Bug 424388 - Autocomplete results keep disappearing and reappearing when typing more letters.

git-svn-id: svn://10.0.0.236/trunk@248442 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
edward.lee%engineering.uiuc.edu 2008-03-23 06:38:28 +00:00
parent 2a4ed127f6
commit d85903112e
4 changed files with 26 additions and 13 deletions

View File

@ -222,7 +222,7 @@ pref("browser.urlbar.maxRichResults", 12);
// timeout (ms). Too big and the UI will be unresponsive; too small and we'll
// be waiting on the timeout too often without many results.
pref("browser.urlbar.search.chunkSize", 1000);
pref("browser.urlbar.search.timeout", 50);
pref("browser.urlbar.search.timeout", 100);
pref("browser.download.useDownloadDir", true);
pref("browser.download.folderList", 0);

View File

@ -329,6 +329,7 @@ nsNavHistory::nsNavHistory() : mBatchLevel(0),
mAutoCompleteMaxResults(25),
mAutoCompleteSearchChunkSize(100),
mAutoCompleteSearchTimeout(100),
mPreviousChunkOffset(-1),
mAutoCompleteFinishedSearch(PR_FALSE),
mExpireDaysMin(0),
mExpireDaysMax(0),

View File

@ -681,6 +681,7 @@ protected:
nsDataHashtable<nsStringHashKey, PRBool> mCurrentResultURLs;
PRInt32 mCurrentChunkOffset;
PRInt32 mPreviousChunkOffset;
nsDataHashtable<nsTrimInt64HashKey, PRBool> mLivemarkFeedItemIds;
nsDataHashtable<nsStringHashKey, PRBool> mLivemarkFeedURIs;

View File

@ -343,11 +343,21 @@ nsNavHistory::PerformAutoComplete()
if (mDBPreviousQuery) {
rv = AutoCompletePreviousSearch();
NS_ENSURE_SUCCESS(rv, rv);
// We want to continue searching if we didn't finish last time, so move to
// one before the previous chunk so that we move up to the previous chunk
if (moreChunksToSearch = mPreviousChunkOffset != -1)
mCurrentChunkOffset = mPreviousChunkOffset - mAutoCompleteSearchChunkSize;
} else {
rv = AutoCompleteFullHistorySearch(&moreChunksToSearch);
NS_ENSURE_SUCCESS(rv, rv);
}
// If we ran out of pages to search, set offset to -1, so we can tell the
// difference between completing and stopping because we have enough results
if (!moreChunksToSearch)
mCurrentChunkOffset = -1;
// Only search more chunks if there are more and we need more results
moreChunksToSearch &= !AutoCompleteHasEnoughResults();
@ -387,6 +397,7 @@ nsNavHistory::PerformAutoComplete()
void
nsNavHistory::DoneSearching(PRBool aFinished)
{
mPreviousChunkOffset = mCurrentChunkOffset;
mAutoCompleteFinishedSearch = aFinished;
mCurrentResult = nsnull;
mCurrentListener = nsnull;
@ -422,20 +433,17 @@ nsNavHistory::StartSearch(const nsAString & aSearchString,
mCurrentResult = do_CreateInstance(NS_AUTOCOMPLETESIMPLERESULT_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
// We can optimize by reusing the last search if it finished and has strictly
// less than maxResults number of results as well as making sure the new
// search begins with the old one and both aren't empty. Without these
// checks, could cause problems mixing up old and new results. (bug 412730)
// Use the previous in-progress search by looking at which urls it found if
// the new search begins with the old one and both aren't empty. We don't run
// into bug 412730 because we only specify urls and not titles to look at.
// Also, only reuse the search if the previous and new search both start with
// javascript: or both don't. (bug 417798)
if (mAutoCompleteFinishedSearch &&
prevMatchCount < (PRUint32)mAutoCompleteMaxResults &&
!prevSearchString.IsEmpty() &&
if (!prevSearchString.IsEmpty() &&
StringBeginsWith(mCurrentSearchString, prevSearchString) &&
(StartsWithJS(prevSearchString) == StartsWithJS(mCurrentSearchString))) {
// Got nothing before? We won't get anything new, so stop now
if (prevMatchCount == 0) {
if (mAutoCompleteFinishedSearch && prevMatchCount == 0) {
// Set up the result to let the listener know that there's nothing
mCurrentResult->SetSearchString(mCurrentSearchString);
mCurrentResult->SetSearchResult(nsIAutoCompleteResult::RESULT_NOMATCH);
@ -449,8 +457,10 @@ nsNavHistory::StartSearch(const nsAString & aSearchString,
return NS_OK;
} else {
// We must have more than 0 but fewer than the max results, so create an
// optimized query that only looks at these urls
// We either have a previous in-progress search or a finished search that
// has more than 0 results. We can continue from where the previous
// search left off, but first we want to create an optimized query that
// only searches through the urls that were previously found
nsCString sql = NS_LITERAL_CSTRING(
"SELECT h.url, h.title, f.url") + kBookTagSQL + NS_LITERAL_CSTRING(" "
"FROM moz_places h "
@ -637,8 +647,9 @@ nsNavHistory::AutoCompleteProcessSearch(mozIStorageStatement* aQuery,
const QueryType aType,
PRBool *aHasMoreResults)
{
// Don't bother processing results if we already have enough results
if (AutoCompleteHasEnoughResults())
// Unless we're checking if there are any results for the query, don't bother
// processing results if we already have enough results
if (!aHasMoreResults && AutoCompleteHasEnoughResults())
return NS_OK;
nsFaviconService* faviconService = nsFaviconService::GetFaviconService();