Chromium Code Reviews| Index: chrome/browser/autocomplete/autocomplete_match.cc |
| diff --git a/chrome/browser/autocomplete/autocomplete_match.cc b/chrome/browser/autocomplete/autocomplete_match.cc |
| index d00ac976fcfb01120c87c6f359721bc80a857831..c13139f4000ef28bca769c4e812c54e1e6e99a8c 100644 |
| --- a/chrome/browser/autocomplete/autocomplete_match.cc |
| +++ b/chrome/browser/autocomplete/autocomplete_match.cc |
| @@ -233,6 +233,29 @@ void AutocompleteMatch::ClassifyLocationInString( |
| } |
| // static |
| +AutocompleteMatch::ACMatchClassifications |
| +AutocompleteMatch::MergeClassifications( |
|
Peter Kasting
2012/09/10 18:56:11
Nit: Style guide is vague here; I usually suggest
Daniel Erat
2012/09/10 19:36:17
Done.
|
| + const ACMatchClassifications& classifications1, |
| + const ACMatchClassifications& classifications2) { |
| + ACMatchClassifications output; |
| + for (ACMatchClassifications::const_iterator i = classifications1.begin(), |
|
Peter Kasting
2012/09/10 18:56:11
This is not quite safe. If someone passes in an e
Daniel Erat
2012/09/10 19:36:17
Done.
|
| + j = classifications2.begin(); i != classifications1.end();) { |
| + AutocompleteMatch::AddLastClassificationIfNecessary(&output, |
| + std::max(i->offset, j->offset), i->style | j->style); |
| + const size_t next_i_offset = (i + 1) == classifications1.end() ? |
| + static_cast<size_t>(-1) : (i + 1)->offset; |
| + const size_t next_j_offset = (j + 1) == classifications2.end() ? |
| + static_cast<size_t>(-1) : (j + 1)->offset; |
| + if (next_i_offset >= next_j_offset) |
| + ++j; |
| + if (next_j_offset >= next_i_offset) |
| + ++i; |
| + } |
| + |
| + return output; |
| +} |
| + |
| +// static |
| std::string AutocompleteMatch::ClassificationsToString( |
| const ACMatchClassifications& classifications) { |
| std::string serialized_classifications; |