OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_node_data.h" | 5 #include "ui/accessibility/ax_node_data.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| 11 #include "base/strings/stringprintf.h" |
11 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
12 | 13 |
13 using base::DoubleToString; | 14 using base::DoubleToString; |
14 using base::IntToString; | 15 using base::IntToString; |
15 | 16 |
16 namespace ui { | 17 namespace ui { |
17 | 18 |
18 namespace { | 19 namespace { |
19 | 20 |
20 std::string IntVectorToString(const std::vector<int>& items) { | 21 std::string IntVectorToString(const std::vector<int>& items) { |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 result += " sort_direction=other"; | 204 result += " sort_direction=other"; |
204 break; | 205 break; |
205 } | 206 } |
206 break; | 207 break; |
207 case AX_ATTR_TITLE_UI_ELEMENT: | 208 case AX_ATTR_TITLE_UI_ELEMENT: |
208 result += " title_elem=" + value; | 209 result += " title_elem=" + value; |
209 break; | 210 break; |
210 case AX_ATTR_ACTIVEDESCENDANT_ID: | 211 case AX_ATTR_ACTIVEDESCENDANT_ID: |
211 result += " activedescendant=" + value; | 212 result += " activedescendant=" + value; |
212 break; | 213 break; |
213 case AX_ATTR_COLOR_VALUE_RED: | |
214 result += " color_value_red=" + value; | |
215 break; | |
216 case AX_ATTR_COLOR_VALUE_GREEN: | |
217 result += " color_value_green=" + value; | |
218 break; | |
219 case AX_ATTR_COLOR_VALUE_BLUE: | |
220 result += " color_value_blue=" + value; | |
221 break; | |
222 case AX_ATTR_TREE_ID: | 214 case AX_ATTR_TREE_ID: |
223 result += " tree_id=" + value; | 215 result += " tree_id=" + value; |
224 break; | 216 break; |
225 case AX_ATTR_CHILD_TREE_ID: | 217 case AX_ATTR_CHILD_TREE_ID: |
226 result += " child_tree_id=" + value; | 218 result += " child_tree_id=" + value; |
227 break; | 219 break; |
| 220 case AX_ATTR_COLOR_VALUE: |
| 221 result += base::StringPrintf(" color_value=&%X", |
| 222 int_attributes[i].second); |
| 223 break; |
| 224 case AX_ATTR_BACKGROUND_COLOR: |
| 225 result += base::StringPrintf(" background_color=&%X", |
| 226 int_attributes[i].second); |
| 227 break; |
| 228 case AX_ATTR_COLOR: |
| 229 result += base::StringPrintf(" color=&%X", int_attributes[i].second); |
| 230 break; |
228 case AX_ATTR_TEXT_DIRECTION: | 231 case AX_ATTR_TEXT_DIRECTION: |
229 switch (int_attributes[i].second) { | 232 switch (int_attributes[i].second) { |
230 case AX_TEXT_DIRECTION_LR: | 233 case AX_TEXT_DIRECTION_LTR: |
231 default: | 234 result += " text_direction=ltr"; |
232 result += " text_direction=lr"; | |
233 break; | 235 break; |
234 case AX_TEXT_DIRECTION_RL: | 236 case AX_TEXT_DIRECTION_RTL: |
235 result += " text_direction=rl"; | 237 result += " text_direction=rtl"; |
236 break; | 238 break; |
237 case AX_TEXT_DIRECTION_TB: | 239 case AX_TEXT_DIRECTION_TTB: |
238 result += " text_direction=tb"; | 240 result += " text_direction=ttb"; |
239 break; | 241 break; |
240 case AX_TEXT_DIRECTION_BT: | 242 case AX_TEXT_DIRECTION_BTT: |
241 result += " text_direction=bt"; | 243 result += " text_direction=btt"; |
242 break; | 244 break; |
243 } | 245 } |
| 246 case AX_ATTR_TEXT_STYLE: { |
| 247 unsigned int text_style = int_attributes[i].second; |
| 248 if (text_style == AX_TEXT_STYLE_NONE) |
| 249 break; |
| 250 std::string text_style_value(" text_style="); |
| 251 if (text_style & AX_TEXT_STYLE_BOLD) |
| 252 text_style_value += "bold,"; |
| 253 if (text_style & AX_TEXT_STYLE_ITALIC) |
| 254 text_style_value += "italic,"; |
| 255 if (text_style & AX_TEXT_STYLE_UNDERLINE) |
| 256 text_style_value += "underline,"; |
| 257 if (text_style & AX_TEXT_STYLE_LINE_THROUGH) |
| 258 text_style_value += "line-through,"; |
| 259 result += text_style_value.substr(0, text_style_value.size() - 1);; |
| 260 } |
244 break; | 261 break; |
245 case AX_ATTR_SET_SIZE: | 262 case AX_ATTR_SET_SIZE: |
246 result += " setsize=" + value; | 263 result += " setsize=" + value; |
247 break; | 264 break; |
248 case AX_ATTR_POS_IN_SET: | 265 case AX_ATTR_POS_IN_SET: |
249 result += " posinset=" + value; | 266 result += " posinset=" + value; |
250 break; | 267 break; |
251 case AX_ATTR_INVALID_STATE: | 268 case AX_ATTR_INVALID_STATE: |
252 switch (int_attributes[i].second) { | 269 switch (int_attributes[i].second) { |
253 case AX_INVALID_STATE_FALSE: | 270 case AX_INVALID_STATE_FALSE: |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 break; | 377 break; |
361 case AX_ATTR_VALUE_FOR_RANGE: | 378 case AX_ATTR_VALUE_FOR_RANGE: |
362 result += " value_for_range=" + value; | 379 result += " value_for_range=" + value; |
363 break; | 380 break; |
364 case AX_ATTR_MAX_VALUE_FOR_RANGE: | 381 case AX_ATTR_MAX_VALUE_FOR_RANGE: |
365 result += " max_value=" + value; | 382 result += " max_value=" + value; |
366 break; | 383 break; |
367 case AX_ATTR_MIN_VALUE_FOR_RANGE: | 384 case AX_ATTR_MIN_VALUE_FOR_RANGE: |
368 result += " min_value=" + value; | 385 result += " min_value=" + value; |
369 break; | 386 break; |
| 387 case AX_ATTR_FONT_SIZE: |
| 388 result += " font_size=" + value; |
| 389 break; |
370 case AX_FLOAT_ATTRIBUTE_NONE: | 390 case AX_FLOAT_ATTRIBUTE_NONE: |
371 break; | 391 break; |
372 } | 392 } |
373 } | 393 } |
374 | 394 |
375 for (size_t i = 0; i < bool_attributes.size(); ++i) { | 395 for (size_t i = 0; i < bool_attributes.size(); ++i) { |
376 std::string value = bool_attributes[i].second ? "true" : "false"; | 396 std::string value = bool_attributes[i].second ? "true" : "false"; |
377 switch (bool_attributes[i].first) { | 397 switch (bool_attributes[i].first) { |
378 case AX_ATTR_DOC_LOADED: | 398 case AX_ATTR_DOC_LOADED: |
379 result += " doc_loaded=" + value; | 399 result += " doc_loaded=" + value; |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 } | 480 } |
461 } | 481 } |
462 | 482 |
463 if (!child_ids.empty()) | 483 if (!child_ids.empty()) |
464 result += " child_ids=" + IntVectorToString(child_ids); | 484 result += " child_ids=" + IntVectorToString(child_ids); |
465 | 485 |
466 return result; | 486 return result; |
467 } | 487 } |
468 | 488 |
469 } // namespace ui | 489 } // namespace ui |
OLD | NEW |