OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef UI_ACCESSIBILITY_AX_POSITION_H_ | 5 #ifndef UI_ACCESSIBILITY_AX_POSITION_H_ |
6 #define UI_ACCESSIBILITY_AX_POSITION_H_ | 6 #define UI_ACCESSIBILITY_AX_POSITION_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 } else { | 139 } else { |
140 str_text_offset = base::IntToString(text_offset_); | 140 str_text_offset = base::IntToString(text_offset_); |
141 } | 141 } |
142 str = "TextPosition tree_id=" + base::IntToString(tree_id_) + | 142 str = "TextPosition tree_id=" + base::IntToString(tree_id_) + |
143 " anchor_id=" + base::IntToString(anchor_id_) + " text_offset=" + | 143 " anchor_id=" + base::IntToString(anchor_id_) + " text_offset=" + |
144 str_text_offset + " affinity=" + | 144 str_text_offset + " affinity=" + |
145 ui::ToString(static_cast<AXTextAffinity>(affinity_)); | 145 ui::ToString(static_cast<AXTextAffinity>(affinity_)); |
146 } | 146 } |
147 } | 147 } |
148 | 148 |
149 if (!IsTextPosition() || text_offset() > MaxTextOffset()) | 149 if (!IsTextPosition() || text_offset_ > MaxTextOffset()) |
150 return str; | 150 return str; |
151 | 151 |
152 std::string text = base::UTF16ToUTF8(GetInnerText()); | 152 std::string text = base::UTF16ToUTF8(GetInnerText()); |
153 DCHECK_GE(text_offset_, 0); | 153 DCHECK_GE(text_offset_, 0); |
154 DCHECK_LE(text_offset_, static_cast<int>(text.length())); | 154 DCHECK_LE(text_offset_, static_cast<int>(text.length())); |
155 std::string annotated_text; | 155 std::string annotated_text; |
156 if (text_offset() == MaxTextOffset()) { | 156 if (text_offset_ == MaxTextOffset()) { |
157 annotated_text = text + "<>"; | 157 annotated_text = text + "<>"; |
158 } else { | 158 } else { |
159 annotated_text = text.substr(0, text_offset()) + "<" + | 159 annotated_text = text.substr(0, text_offset_) + "<" + text[text_offset_] + |
160 text[text_offset()] + ">" + | 160 ">" + text.substr(text_offset_ + 1); |
161 text.substr(text_offset() + 1); | |
162 } | 161 } |
163 | 162 |
164 return str + " annotated_text=" + annotated_text; | 163 return str + " annotated_text=" + annotated_text; |
165 } | 164 } |
166 | 165 |
167 int tree_id() const { return tree_id_; } | 166 int tree_id() const { return tree_id_; } |
168 int32_t anchor_id() const { return anchor_id_; } | 167 int32_t anchor_id() const { return anchor_id_; } |
169 | 168 |
170 AXNodeType* GetAnchor() const { | 169 AXNodeType* GetAnchor() const { |
171 if (tree_id_ == INVALID_TREE_ID || anchor_id_ == INVALID_ANCHOR_ID) | 170 if (tree_id_ == INVALID_TREE_ID || anchor_id_ == INVALID_ANCHOR_ID) |
(...skipping 963 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1135 | 1134 |
1136 template <class AXPositionType, class AXNodeType> | 1135 template <class AXPositionType, class AXNodeType> |
1137 bool operator>=(const AXPosition<AXPositionType, AXNodeType>& first, | 1136 bool operator>=(const AXPosition<AXPositionType, AXNodeType>& first, |
1138 const AXPosition<AXPositionType, AXNodeType>& second) { | 1137 const AXPosition<AXPositionType, AXNodeType>& second) { |
1139 return first == second || first > second; | 1138 return first == second || first > second; |
1140 } | 1139 } |
1141 | 1140 |
1142 } // namespace ui | 1141 } // namespace ui |
1143 | 1142 |
1144 #endif // UI_ACCESSIBILITY_AX_POSITION_H_ | 1143 #endif // UI_ACCESSIBILITY_AX_POSITION_H_ |
OLD | NEW |