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

Unified Diff: components/query_parser/query_parser.h

Issue 184663002: Omnibox: Make URLs of Bookmarks Searchable (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix ALL_MATCHES (in response to recent changes) Created 6 years, 8 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
« no previous file with comments | « components/bookmarks/core/browser/bookmark_title_match.cc ('k') | components/query_parser/query_parser.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/query_parser/query_parser.h
diff --git a/components/query_parser/query_parser.h b/components/query_parser/query_parser.h
index 46d0bd22cbdbd8c29ffb8da96743a86d3b931ad3..cc3f94b2cf3bc68f3353961b3bbe1c854dfa228d 100644
--- a/components/query_parser/query_parser.h
+++ b/components/query_parser/query_parser.h
@@ -24,6 +24,8 @@ struct QueryWord {
size_t position;
};
+typedef std::vector<query_parser::QueryWord> QueryWordVector;
+
// QueryNode is used by QueryParser to represent the elements that constitute a
// query. While QueryNode is exposed by way of ParseQuery, it really isn't meant
// for external usage.
@@ -45,16 +47,18 @@ class QueryNode {
// Returns true if this node matches at least one of the words in |words|. An
// entry is added to |match_positions| for all matching words giving the
// matching regions.
- virtual bool HasMatchIn(const std::vector<QueryWord>& words,
+ virtual bool HasMatchIn(const QueryWordVector& words,
Snippet::MatchPositions* match_positions) const = 0;
// Returns true if this node matches at least one of the words in |words|.
- virtual bool HasMatchIn(const std::vector<QueryWord>& words) const = 0;
+ virtual bool HasMatchIn(const QueryWordVector& words) const = 0;
// Appends the words that make up this node in |words|.
virtual void AppendWords(std::vector<base::string16>* words) const = 0;
};
+typedef std::vector<query_parser::QueryNode*> QueryNodeStarVector;
+
// This class is used to parse queries entered into the history search into more
// normalized queries that can be passed to the SQLite backend.
class QueryParser {
@@ -85,23 +89,27 @@ class QueryParser {
// query. This is intended for later usage with DoesQueryMatch. Ownership of
// the nodes passes to the caller.
void ParseQueryNodes(const base::string16& query,
- std::vector<QueryNode*>* nodes);
+ QueryNodeStarVector* nodes);
// Returns true if the string text matches the query nodes created by a call
// to ParseQuery. If the query does match, each of the matching positions in
// the text is added to |match_positions|.
bool DoesQueryMatch(const base::string16& text,
- const std::vector<QueryNode*>& nodes,
+ const QueryNodeStarVector& nodes,
Snippet::MatchPositions* match_positions);
// Returns true if all of the |words| match the query |nodes| created by a
// call to ParseQuery.
- bool DoesQueryMatch(const std::vector<QueryWord>& words,
- const std::vector<QueryNode*>& nodes);
+ bool DoesQueryMatch(const QueryWordVector& words,
+ const QueryNodeStarVector& nodes);
// Extracts the words from |text|, placing each word into |words|.
void ExtractQueryWords(const base::string16& text,
- std::vector<QueryWord>* words);
+ QueryWordVector* words);
+
+ // Sorts the match positions in |matches| by their first index, then
+ // coalesces any match positions that intersect each other.
+ static void SortAndCoalesceMatchPositions(Snippet::MatchPositions* matches);
private:
// Does the work of parsing |query|; creates nodes in |root| as appropriate.
« no previous file with comments | « components/bookmarks/core/browser/bookmark_title_match.cc ('k') | components/query_parser/query_parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698