Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(311)

Unified Diff: chrome/browser/autocomplete/search_provider.h

Issue 23164011: Omnibox: Reduce Bolding Flicker in SearchProvider (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/autocomplete/search_provider.h
diff --git a/chrome/browser/autocomplete/search_provider.h b/chrome/browser/autocomplete/search_provider.h
index 281684d22f54d0565b215ae9bb2f9a81f303be50..9c1823632aafdc1c0a99fee27d714556cf7a9cad 100644
--- a/chrome/browser/autocomplete/search_provider.h
+++ b/chrome/browser/autocomplete/search_provider.h
@@ -60,36 +60,6 @@ class SearchProvider : public AutocompleteProvider,
SearchProvider(AutocompleteProviderListener* listener, Profile* profile);
- // Returns an AutocompleteMatch with the given |autocomplete_provider|,
- // |relevance|, and |type|, which represents a search via |template_url| for
- // |query_string|. If |template_url| is NULL, returns a match with an invalid
- // destination URL.
- //
- // |input_text| is the original user input, which may differ from
- // |query_string|; e.g. the user typed "foo" and got a search suggestion of
- // "food", which we're now marking up. This is used to highlight portions of
- // the match contents to distinguish locally-typed text from suggested text.
- //
- // |input| and |is_keyword| are necessary for various other details, like
- // whether we should allow inline autocompletion and what the transition type
- // should be. |accepted_suggestion| and |omnibox_start_margin| are used along
- // with |input_text| to generate Assisted Query Stats.
- // |append_extra_query_params| should be set if |template_url| is the default
- // search engine, so the destination URL will contain any
- // command-line-specified query params.
- static AutocompleteMatch CreateSearchSuggestion(
- AutocompleteProvider* autocomplete_provider,
- int relevance,
- AutocompleteMatch::Type type,
- const TemplateURL* template_url,
- const string16& query_string,
- const string16& input_text,
- const AutocompleteInput& input,
- bool is_keyword,
- int accepted_suggestion,
- int omnibox_start_margin,
- bool append_extra_query_params);
-
// AutocompleteProvider:
virtual void AddProviderInfo(ProvidersInfo* provider_info) const OVERRIDE;
virtual void ResetSession() OVERRIDE;
@@ -181,6 +151,11 @@ class SearchProvider : public AutocompleteProvider,
relevance_from_server_ = relevance_from_server;
}
+ const string16& contents() const { return contents_; }
+ const ACMatchClassifications& contents_class() const {
+ return contents_class_;
+ }
+
// Returns if this result is inlineable against the current input |input|.
// Non-inlineable results are stale.
virtual bool IsInlineable(const string16& input) const = 0;
@@ -199,6 +174,15 @@ class SearchProvider : public AutocompleteProvider,
// The relevance score.
int relevance_;
+ // The string is loaded into the location bar when the item is selected
+ // by pressing the arrow keys. This may be different than a URL. For
+ // example, for search suggestions this would just be the search terms.
+ // string16 fill_into_edit_;
Mark P 2013/08/15 18:34:23 I abandoned this part, sorry that the lines are st
+
+ // The main text displayed in the address bar dropdown.
+ string16 contents_;
+ ACMatchClassifications contents_class_;
+
private:
// Whether this result's relevance score was fully or partly calculated
// based on server information, and thus is assumed to be more accurate.
@@ -210,10 +194,16 @@ class SearchProvider : public AutocompleteProvider,
class SuggestResult : public Result {
public:
+ // Most parameters are self-explanatory. |input_text| is used to
+ // determine highlighting (i.e., populate |contents_| and
+ // |contents_class_|). We determine highlighting at the time
+ // the SuggestResult is created in order to reduce flicker as
+ // additional characters are typed or deleted.
SuggestResult(const string16& suggestion,
bool from_keyword_provider,
int relevance,
- bool relevance_from_server);
+ bool relevance_from_server,
+ const string16& input_text);
virtual ~SuggestResult();
const string16& suggestion() const { return suggestion_; }
@@ -233,12 +223,19 @@ class SearchProvider : public AutocompleteProvider,
public:
// |provider| is necessary to use StringForURLDisplay() in order to
// compute |formatted_url_|.
+ // |input_text| and |languages| are used to determine
+ // highlighting (i.e., populate |contents_| and |contents_class_|).
+ // We determine highlighting at the time the NavigationResult is
+ // created in order to reduce flicker as additional characters are
+ // typed or deleted.
NavigationResult(const AutocompleteProvider& provider,
const GURL& url,
const string16& description,
bool from_keyword_provider,
int relevance,
- bool relevance_from_server);
+ bool relevance_from_server,
+ const string16& input_text,
+ const std::string& languages);
virtual ~NavigationResult();
const GURL& url() const { return url_; }
@@ -304,6 +301,34 @@ class SearchProvider : public AutocompleteProvider,
virtual ~SearchProvider();
+ // Returns an AutocompleteMatch with the given |autocomplete_provider|,
+ // |relevance|, and |type|, which represents a search via |template_url| for
+ // |query_string|. If |template_url| is NULL, returns a match with an invalid
+ // destination URL.
+ //
+ // |input_text| is the original user input, which may differ from
+ // |query_string|; e.g. the user typed "foo" and got a search suggestion of
+ // "food", which we're now marking up. This is used to highlight portions of
+ // the match contents to distinguish locally-typed text from suggested text.
+ //
+ // |input| and |is_keyword| are necessary for various other details, like
+ // whether we should allow inline autocompletion and what the transition type
+ // should be. |accepted_suggestion| and |omnibox_start_margin| are used along
+ // with |input_text| to generate Assisted Query Stats.
+ // |append_extra_query_params| should be set if |template_url| is the default
+ // search engine, so the destination URL will contain any
+ // command-line-specified query params.
+ static AutocompleteMatch CreateSearchSuggestion(
Mark P 2013/08/15 18:34:23 FYI, this is an exact move except I changed some o
+ AutocompleteProvider* autocomplete_provider,
+ const SuggestResult& result,
+ AutocompleteMatch::Type type,
+ const TemplateURL* template_url,
+ const string16& input_text,
+ const AutocompleteInput& input,
+ int accepted_suggestion,
+ int omnibox_start_margin,
+ bool append_extra_query_params);
+
// Removes non-inlineable results until either the top result can inline
// autocomplete the current input or verbatim outscores the top result.
static void RemoveStaleResults(const string16& input,
@@ -445,13 +470,10 @@ class SearchProvider : public AutocompleteProvider,
// Creates an AutocompleteMatch for "Search <engine> for |query_string|" with
// the supplied relevance. Adds this match to |map|; if such a match already
// exists, whichever one has lower relevance is eliminated.
- void AddMatchToMap(const string16& query_string,
+ void AddMatchToMap(const SuggestResult& result,
const string16& input_text,
- int relevance,
- bool relevance_from_server,
AutocompleteMatch::Type type,
int accepted_suggestion,
- bool is_keyword,
MatchMap* map);
// Returns an AutocompleteMatch for a navigational suggestion.
« no previous file with comments | « no previous file | chrome/browser/autocomplete/search_provider.cc » ('j') | chrome/browser/autocomplete/search_provider.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698