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 "ui/accessibility/ax_text_utils.h" | 5 #include "ui/accessibility/ax_text_utils.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 | 9 |
10 namespace ui { | 10 namespace ui { |
(...skipping 13 matching lines...) Expand all Loading... |
24 return start_offset; | 24 return start_offset; |
25 } else if (boundary == LINE_BOUNDARY) { | 25 } else if (boundary == LINE_BOUNDARY) { |
26 if (direction == FORWARDS_DIRECTION) { | 26 if (direction == FORWARDS_DIRECTION) { |
27 for (size_t j = 0; j < line_breaks.size(); ++j) { | 27 for (size_t j = 0; j < line_breaks.size(); ++j) { |
28 size_t line_break = line_breaks[j] >= 0 ? line_breaks[j] : 0; | 28 size_t line_break = line_breaks[j] >= 0 ? line_breaks[j] : 0; |
29 if (line_break > start_offset) | 29 if (line_break > start_offset) |
30 return line_break; | 30 return line_break; |
31 } | 31 } |
32 return text_size; | 32 return text_size; |
33 } else { | 33 } else { |
34 // Note: j is unsigned, so for loop continues until j wraps around | 34 for (size_t j = line_breaks.size(); j != 0; --j) { |
35 // and becomes greater than the starting value. | 35 size_t line_break = line_breaks[j - 1] >= 0 ? line_breaks[j - 1] : 0; |
36 for (size_t j = line_breaks.size() - 1; | |
37 j < line_breaks.size(); | |
38 --j) { | |
39 size_t line_break = line_breaks[j] >= 0 ? line_breaks[j] : 0; | |
40 if (line_break <= start_offset) | 36 if (line_break <= start_offset) |
41 return line_break; | 37 return line_break; |
42 } | 38 } |
43 return 0; | 39 return 0; |
44 } | 40 } |
45 } | 41 } |
46 | 42 |
47 size_t result = start_offset; | 43 size_t result = start_offset; |
48 for (;;) { | 44 for (;;) { |
49 size_t pos; | 45 size_t pos; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 | 79 |
84 if (direction == FORWARDS_DIRECTION) { | 80 if (direction == FORWARDS_DIRECTION) { |
85 result++; | 81 result++; |
86 } else { | 82 } else { |
87 result--; | 83 result--; |
88 } | 84 } |
89 } | 85 } |
90 } | 86 } |
91 | 87 |
92 } // Namespace ui | 88 } // Namespace ui |
OLD | NEW |