| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/logging.h" | 5 #include "base/logging.h" |
| 6 #include "chrome/browser/autocomplete/autocomplete_match.h" | 6 #include "chrome/browser/autocomplete/autocomplete_match.h" |
| 7 #include "grit/theme_resources.h" | 7 #include "grit/theme_resources.h" |
| 8 | 8 |
| 9 // AutocompleteMatch ---------------------------------------------------------- | 9 // AutocompleteMatch ---------------------------------------------------------- |
| 10 | 10 |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 // static | 110 // static |
| 111 void AutocompleteMatch::ClassifyMatchInString( | 111 void AutocompleteMatch::ClassifyMatchInString( |
| 112 const string16& find_text, | 112 const string16& find_text, |
| 113 const string16& text, | 113 const string16& text, |
| 114 int style, | 114 int style, |
| 115 ACMatchClassifications* classification) { | 115 ACMatchClassifications* classification) { |
| 116 ClassifyLocationInString(text.find(find_text), find_text.length(), | 116 ClassifyLocationInString(text.find(find_text), find_text.length(), |
| 117 text.length(), style, classification); | 117 text.length(), style, classification); |
| 118 } | 118 } |
| 119 | 119 |
| 120 // static |
| 120 void AutocompleteMatch::ClassifyLocationInString( | 121 void AutocompleteMatch::ClassifyLocationInString( |
| 121 size_t match_location, | 122 size_t match_location, |
| 122 size_t match_length, | 123 size_t match_length, |
| 123 size_t overall_length, | 124 size_t overall_length, |
| 124 int style, | 125 int style, |
| 125 ACMatchClassifications* classification) { | 126 ACMatchClassifications* classification) { |
| 126 classification->clear(); | 127 classification->clear(); |
| 127 | 128 |
| 128 // Don't classify anything about an empty string | 129 // Don't classify anything about an empty string |
| 129 // (AutocompleteMatch::Validate() checks this). | 130 // (AutocompleteMatch::Validate() checks this). |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 // The classifications should always be sorted. | 177 // The classifications should always be sorted. |
| 177 size_t last_offset = classifications[0].offset; | 178 size_t last_offset = classifications[0].offset; |
| 178 for (ACMatchClassifications::const_iterator i(classifications.begin() + 1); | 179 for (ACMatchClassifications::const_iterator i(classifications.begin() + 1); |
| 179 i != classifications.end(); ++i) { | 180 i != classifications.end(); ++i) { |
| 180 DCHECK(i->offset > last_offset) << "Classification unsorted"; | 181 DCHECK(i->offset > last_offset) << "Classification unsorted"; |
| 181 DCHECK(i->offset < text.length()) << "Classification out of bounds"; | 182 DCHECK(i->offset < text.length()) << "Classification out of bounds"; |
| 182 last_offset = i->offset; | 183 last_offset = i->offset; |
| 183 } | 184 } |
| 184 } | 185 } |
| 185 #endif | 186 #endif |
| OLD | NEW |