OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/query_parser/snippet.h" | 5 #include "components/query_parser/snippet.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 &utf8_pos, &utf16_pos); | 201 &utf8_pos, &utf16_pos); |
202 i->second = AdvanceAndReturnUTF16Pos(utf8_cstring, utf8_length, | 202 i->second = AdvanceAndReturnUTF16Pos(utf8_cstring, utf8_length, |
203 static_cast<int32_t>(i->second), | 203 static_cast<int32_t>(i->second), |
204 &utf8_pos, &utf16_pos); | 204 &utf8_pos, &utf16_pos); |
205 } | 205 } |
206 } | 206 } |
207 | 207 |
208 Snippet::Snippet() { | 208 Snippet::Snippet() { |
209 } | 209 } |
210 | 210 |
| 211 Snippet::Snippet(const Snippet& other) = default; |
| 212 |
211 Snippet::~Snippet() { | 213 Snippet::~Snippet() { |
212 } | 214 } |
213 | 215 |
214 void Snippet::ComputeSnippet(const MatchPositions& match_positions, | 216 void Snippet::ComputeSnippet(const MatchPositions& match_positions, |
215 const std::string& document) { | 217 const std::string& document) { |
216 // The length of snippets we try to produce. | 218 // The length of snippets we try to produce. |
217 // We can generate longer snippets but stop once we cross kSnippetMaxLength. | 219 // We can generate longer snippets but stop once we cross kSnippetMaxLength. |
218 const size_t kSnippetMaxLength = 200; | 220 const size_t kSnippetMaxLength = 200; |
219 const base::string16 kEllipsis = base::ASCIIToUTF16(" ... "); | 221 const base::string16 kEllipsis = base::ASCIIToUTF16(" ... "); |
220 | 222 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 utext_close(document_utext); | 297 utext_close(document_utext); |
296 swap(text_, snippet); | 298 swap(text_, snippet); |
297 } | 299 } |
298 | 300 |
299 void Snippet::Swap(Snippet* other) { | 301 void Snippet::Swap(Snippet* other) { |
300 text_.swap(other->text_); | 302 text_.swap(other->text_); |
301 matches_.swap(other->matches_); | 303 matches_.swap(other->matches_); |
302 } | 304 } |
303 | 305 |
304 } // namespace query_parser | 306 } // namespace query_parser |
OLD | NEW |