OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/accessibility/browser_accessibility_win.h" | 5 #include "content/browser/accessibility/browser_accessibility_win.h" |
6 | 6 |
7 #include <UIAutomationClient.h> | 7 #include <UIAutomationClient.h> |
8 #include <UIAutomationCoreApi.h> | 8 #include <UIAutomationCoreApi.h> |
9 | 9 |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
168 for (long i = 0; i < count; ++i) { | 168 for (long i = 0; i < count; ++i) { |
169 HRESULT result = get_target(i, &targets[i]); | 169 HRESULT result = get_target(i, &targets[i]); |
170 if (result != S_OK) | 170 if (result != S_OK) |
171 return result; | 171 return result; |
172 } | 172 } |
173 | 173 |
174 return S_OK; | 174 return S_OK; |
175 } | 175 } |
176 | 176 |
177 // | 177 // |
178 // BrowserAccessibilityWin::WinAttributes | |
179 // | |
180 | |
181 BrowserAccessibilityWin::WinAttributes::WinAttributes() | |
182 : ia_role(0), | |
183 ia_state(0), | |
184 ia2_role(0), | |
185 ia2_state(0) { | |
186 } | |
187 | |
188 // | |
178 // BrowserAccessibilityWin | 189 // BrowserAccessibilityWin |
179 // | 190 // |
180 | 191 |
181 // static | 192 // static |
182 BrowserAccessibility* BrowserAccessibility::Create() { | 193 BrowserAccessibility* BrowserAccessibility::Create() { |
183 ui::win::CreateATLModuleIfNeeded(); | 194 ui::win::CreateATLModuleIfNeeded(); |
184 CComObject<BrowserAccessibilityWin>* instance; | 195 CComObject<BrowserAccessibilityWin>* instance; |
185 HRESULT hr = CComObject<BrowserAccessibilityWin>::CreateInstance(&instance); | 196 HRESULT hr = CComObject<BrowserAccessibilityWin>::CreateInstance(&instance); |
186 DCHECK(SUCCEEDED(hr)); | 197 DCHECK(SUCCEEDED(hr)); |
187 return instance->NewReference(); | 198 return instance->NewReference(); |
188 } | 199 } |
189 | 200 |
190 BrowserAccessibilityWin* BrowserAccessibility::ToBrowserAccessibilityWin() { | 201 BrowserAccessibilityWin* BrowserAccessibility::ToBrowserAccessibilityWin() { |
191 return static_cast<BrowserAccessibilityWin*>(this); | 202 return static_cast<BrowserAccessibilityWin*>(this); |
192 } | 203 } |
193 | 204 |
194 BrowserAccessibilityWin::BrowserAccessibilityWin() | 205 BrowserAccessibilityWin::BrowserAccessibilityWin() |
195 : ia_role_(0), | 206 : win_attributes_(new WinAttributes()), |
196 ia_state_(0), | |
197 ia2_role_(0), | |
198 ia2_state_(0), | |
199 first_time_(true), | |
200 old_ia_state_(0), | |
201 previous_scroll_x_(0), | 207 previous_scroll_x_(0), |
202 previous_scroll_y_(0) { | 208 previous_scroll_y_(0) { |
203 // Start unique IDs at -1 and decrement each time, because get_accChild | 209 // Start unique IDs at -1 and decrement each time, because get_accChild |
204 // uses positive IDs to enumerate children, so we use negative IDs to | 210 // uses positive IDs to enumerate children, so we use negative IDs to |
205 // clearly distinguish between indices and unique IDs. | 211 // clearly distinguish between indices and unique IDs. |
206 unique_id_win_ = next_unique_id_win_; | 212 unique_id_win_ = next_unique_id_win_; |
207 if (next_unique_id_win_ == | 213 if (next_unique_id_win_ == |
208 base::win::kLastBrowserAccessibilityManagerAccessibilityId) { | 214 base::win::kLastBrowserAccessibilityManagerAccessibilityId) { |
209 next_unique_id_win_ = | 215 next_unique_id_win_ = |
210 base::win::kFirstBrowserAccessibilityManagerAccessibilityId; | 216 base::win::kFirstBrowserAccessibilityManagerAccessibilityId; |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
390 if (!instance_active()) | 396 if (!instance_active()) |
391 return E_FAIL; | 397 return E_FAIL; |
392 | 398 |
393 if (!desc) | 399 if (!desc) |
394 return E_INVALIDARG; | 400 return E_INVALIDARG; |
395 | 401 |
396 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); | 402 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); |
397 if (!target) | 403 if (!target) |
398 return E_INVALIDARG; | 404 return E_INVALIDARG; |
399 | 405 |
400 return target->GetStringAttributeAsBstr( | 406 base::string16 description_str = target->description(); |
401 ui::AX_ATTR_DESCRIPTION, desc); | 407 if (description_str.empty()) |
408 return S_FALSE; | |
409 | |
410 *desc = SysAllocString(description_str.c_str()); | |
411 | |
412 DCHECK(*desc); | |
413 return S_OK; | |
402 } | 414 } |
403 | 415 |
404 STDMETHODIMP BrowserAccessibilityWin::get_accFocus(VARIANT* focus_child) { | 416 STDMETHODIMP BrowserAccessibilityWin::get_accFocus(VARIANT* focus_child) { |
405 if (!instance_active()) | 417 if (!instance_active()) |
406 return E_FAIL; | 418 return E_FAIL; |
407 | 419 |
408 if (!focus_child) | 420 if (!focus_child) |
409 return E_INVALIDARG; | 421 return E_INVALIDARG; |
410 | 422 |
411 BrowserAccessibilityWin* focus = static_cast<BrowserAccessibilityWin*>( | 423 BrowserAccessibilityWin* focus = static_cast<BrowserAccessibilityWin*>( |
(...skipping 15 matching lines...) Expand all Loading... | |
427 if (!instance_active()) | 439 if (!instance_active()) |
428 return E_FAIL; | 440 return E_FAIL; |
429 | 441 |
430 if (!help) | 442 if (!help) |
431 return E_INVALIDARG; | 443 return E_INVALIDARG; |
432 | 444 |
433 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); | 445 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); |
434 if (!target) | 446 if (!target) |
435 return E_INVALIDARG; | 447 return E_INVALIDARG; |
436 | 448 |
437 return target->GetStringAttributeAsBstr( | 449 base::string16 help_str = target->help(); |
438 ui::AX_ATTR_HELP, help); | 450 if (help_str.empty()) |
451 return S_FALSE; | |
452 | |
453 *help = SysAllocString(help_str.c_str()); | |
454 | |
455 DCHECK(*help); | |
456 return S_OK; | |
439 } | 457 } |
440 | 458 |
441 STDMETHODIMP BrowserAccessibilityWin::get_accKeyboardShortcut(VARIANT var_id, | 459 STDMETHODIMP BrowserAccessibilityWin::get_accKeyboardShortcut(VARIANT var_id, |
442 BSTR* acc_key) { | 460 BSTR* acc_key) { |
443 if (!instance_active()) | 461 if (!instance_active()) |
444 return E_FAIL; | 462 return E_FAIL; |
445 | 463 |
446 if (!acc_key) | 464 if (!acc_key) |
447 return E_INVALIDARG; | 465 return E_INVALIDARG; |
448 | 466 |
449 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); | 467 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); |
450 if (!target) | 468 if (!target) |
451 return E_INVALIDARG; | 469 return E_INVALIDARG; |
452 | 470 |
453 return target->GetStringAttributeAsBstr( | 471 return target->GetStringAttributeAsBstr( |
454 ui::AX_ATTR_SHORTCUT, acc_key); | 472 ui::AX_ATTR_SHORTCUT, acc_key); |
455 } | 473 } |
456 | 474 |
457 STDMETHODIMP BrowserAccessibilityWin::get_accName(VARIANT var_id, BSTR* name) { | 475 STDMETHODIMP BrowserAccessibilityWin::get_accName(VARIANT var_id, BSTR* name) { |
458 if (!instance_active()) | 476 if (!instance_active()) |
459 return E_FAIL; | 477 return E_FAIL; |
460 | 478 |
461 if (!name) | 479 if (!name) |
462 return E_INVALIDARG; | 480 return E_INVALIDARG; |
463 | 481 |
464 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); | 482 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); |
465 if (!target) | 483 if (!target) |
466 return E_INVALIDARG; | 484 return E_INVALIDARG; |
467 | 485 |
468 std::string name_str = target->name(); | 486 base::string16 name_str = target->name(); |
469 | 487 |
470 // If the name is empty, see if it's labeled by another element. | 488 // If the name is empty, see if it's labeled by another element. |
471 if (name_str.empty()) { | 489 if (name_str.empty()) { |
472 int title_elem_id; | 490 int title_elem_id; |
473 if (target->GetIntAttribute(ui::AX_ATTR_TITLE_UI_ELEMENT, | 491 if (target->GetIntAttribute(ui::AX_ATTR_TITLE_UI_ELEMENT, |
474 &title_elem_id)) { | 492 &title_elem_id)) { |
475 BrowserAccessibility* title_elem = | 493 BrowserAccessibilityWin* title_elem = |
476 manager()->GetFromID(title_elem_id); | 494 manager()->GetFromID(title_elem_id)->ToBrowserAccessibilityWin(); |
477 if (title_elem) | 495 if (title_elem) |
478 name_str = title_elem->GetTextRecursive(); | 496 name_str = title_elem->GetNameRecursive(); |
479 } | 497 } |
480 } | 498 } |
481 | 499 |
482 if (name_str.empty()) | 500 if (name_str.empty()) |
483 return S_FALSE; | 501 return S_FALSE; |
484 | 502 |
485 *name = SysAllocString(base::UTF8ToUTF16(name_str).c_str()); | 503 *name = SysAllocString(name_str.c_str()); |
486 | 504 |
487 DCHECK(*name); | 505 DCHECK(*name); |
488 return S_OK; | 506 return S_OK; |
489 } | 507 } |
490 | 508 |
491 STDMETHODIMP BrowserAccessibilityWin::get_accParent(IDispatch** disp_parent) { | 509 STDMETHODIMP BrowserAccessibilityWin::get_accParent(IDispatch** disp_parent) { |
492 if (!instance_active()) | 510 if (!instance_active()) |
493 return E_FAIL; | 511 return E_FAIL; |
494 | 512 |
495 if (!disp_parent) | 513 if (!disp_parent) |
(...skipping 27 matching lines...) Expand all Loading... | |
523 if (!instance_active()) | 541 if (!instance_active()) |
524 return E_FAIL; | 542 return E_FAIL; |
525 | 543 |
526 if (!role) | 544 if (!role) |
527 return E_INVALIDARG; | 545 return E_INVALIDARG; |
528 | 546 |
529 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); | 547 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); |
530 if (!target) | 548 if (!target) |
531 return E_INVALIDARG; | 549 return E_INVALIDARG; |
532 | 550 |
533 if (!target->role_name_.empty()) { | 551 if (!target->role_name().empty()) { |
534 role->vt = VT_BSTR; | 552 role->vt = VT_BSTR; |
535 role->bstrVal = SysAllocString(target->role_name_.c_str()); | 553 role->bstrVal = SysAllocString(target->role_name().c_str()); |
536 } else { | 554 } else { |
537 role->vt = VT_I4; | 555 role->vt = VT_I4; |
538 role->lVal = target->ia_role_; | 556 role->lVal = target->ia_role(); |
539 } | 557 } |
540 return S_OK; | 558 return S_OK; |
541 } | 559 } |
542 | 560 |
543 STDMETHODIMP BrowserAccessibilityWin::get_accState(VARIANT var_id, | 561 STDMETHODIMP BrowserAccessibilityWin::get_accState(VARIANT var_id, |
544 VARIANT* state) { | 562 VARIANT* state) { |
545 if (!instance_active()) | 563 if (!instance_active()) |
546 return E_FAIL; | 564 return E_FAIL; |
547 | 565 |
548 if (!state) | 566 if (!state) |
549 return E_INVALIDARG; | 567 return E_INVALIDARG; |
550 | 568 |
551 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); | 569 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); |
552 if (!target) | 570 if (!target) |
553 return E_INVALIDARG; | 571 return E_INVALIDARG; |
554 | 572 |
555 state->vt = VT_I4; | 573 state->vt = VT_I4; |
556 state->lVal = target->ia_state_; | 574 state->lVal = target->ia_state(); |
557 if (manager()->GetFocus(NULL) == this) | 575 if (manager()->GetFocus(NULL) == this) |
558 state->lVal |= STATE_SYSTEM_FOCUSED; | 576 state->lVal |= STATE_SYSTEM_FOCUSED; |
559 | 577 |
560 return S_OK; | 578 return S_OK; |
561 } | 579 } |
562 | 580 |
563 STDMETHODIMP BrowserAccessibilityWin::get_accValue(VARIANT var_id, | 581 STDMETHODIMP BrowserAccessibilityWin::get_accValue(VARIANT var_id, |
564 BSTR* value) { | 582 BSTR* value) { |
565 if (!instance_active()) | 583 if (!instance_active()) |
566 return E_FAIL; | 584 return E_FAIL; |
(...skipping 24 matching lines...) Expand all Loading... | |
591 ui::AX_ATTR_COLOR_VALUE_BLUE); | 609 ui::AX_ATTR_COLOR_VALUE_BLUE); |
592 base::string16 value_text; | 610 base::string16 value_text; |
593 value_text = base::IntToString16((r * 100) / 255) + L"% red " + | 611 value_text = base::IntToString16((r * 100) / 255) + L"% red " + |
594 base::IntToString16((g * 100) / 255) + L"% green " + | 612 base::IntToString16((g * 100) / 255) + L"% green " + |
595 base::IntToString16((b * 100) / 255) + L"% blue"; | 613 base::IntToString16((b * 100) / 255) + L"% blue"; |
596 *value = SysAllocString(value_text.c_str()); | 614 *value = SysAllocString(value_text.c_str()); |
597 DCHECK(*value); | 615 DCHECK(*value); |
598 return S_OK; | 616 return S_OK; |
599 } | 617 } |
600 | 618 |
601 *value = SysAllocString(base::UTF8ToUTF16(target->value()).c_str()); | 619 *value = SysAllocString(target->value().c_str()); |
602 DCHECK(*value); | 620 DCHECK(*value); |
603 return S_OK; | 621 return S_OK; |
604 } | 622 } |
605 | 623 |
606 STDMETHODIMP BrowserAccessibilityWin::get_accHelpTopic(BSTR* help_file, | 624 STDMETHODIMP BrowserAccessibilityWin::get_accHelpTopic(BSTR* help_file, |
607 VARIANT var_id, | 625 VARIANT var_id, |
608 LONG* topic_id) { | 626 LONG* topic_id) { |
609 return E_NOTIMPL; | 627 return E_NOTIMPL; |
610 } | 628 } |
611 | 629 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
674 // IAccessible2 methods. | 692 // IAccessible2 methods. |
675 // | 693 // |
676 | 694 |
677 STDMETHODIMP BrowserAccessibilityWin::role(LONG* role) { | 695 STDMETHODIMP BrowserAccessibilityWin::role(LONG* role) { |
678 if (!instance_active()) | 696 if (!instance_active()) |
679 return E_FAIL; | 697 return E_FAIL; |
680 | 698 |
681 if (!role) | 699 if (!role) |
682 return E_INVALIDARG; | 700 return E_INVALIDARG; |
683 | 701 |
684 *role = ia2_role_; | 702 *role = ia2_role(); |
685 | 703 |
686 return S_OK; | 704 return S_OK; |
687 } | 705 } |
688 | 706 |
689 STDMETHODIMP BrowserAccessibilityWin::get_attributes(BSTR* attributes) { | 707 STDMETHODIMP BrowserAccessibilityWin::get_attributes(BSTR* attributes) { |
690 if (!instance_active()) | 708 if (!instance_active()) |
691 return E_FAIL; | 709 return E_FAIL; |
692 | 710 |
693 if (!attributes) | 711 if (!attributes) |
694 return E_INVALIDARG; | 712 return E_INVALIDARG; |
(...skipping 14 matching lines...) Expand all Loading... | |
709 return S_OK; | 727 return S_OK; |
710 } | 728 } |
711 | 729 |
712 STDMETHODIMP BrowserAccessibilityWin::get_states(AccessibleStates* states) { | 730 STDMETHODIMP BrowserAccessibilityWin::get_states(AccessibleStates* states) { |
713 if (!instance_active()) | 731 if (!instance_active()) |
714 return E_FAIL; | 732 return E_FAIL; |
715 | 733 |
716 if (!states) | 734 if (!states) |
717 return E_INVALIDARG; | 735 return E_INVALIDARG; |
718 | 736 |
719 *states = ia2_state_; | 737 *states = ia2_state(); |
720 | 738 |
721 return S_OK; | 739 return S_OK; |
722 } | 740 } |
723 | 741 |
724 STDMETHODIMP BrowserAccessibilityWin::get_uniqueID(LONG* unique_id) { | 742 STDMETHODIMP BrowserAccessibilityWin::get_uniqueID(LONG* unique_id) { |
725 if (!instance_active()) | 743 if (!instance_active()) |
726 return E_FAIL; | 744 return E_FAIL; |
727 | 745 |
728 if (!unique_id) | 746 if (!unique_id) |
729 return E_INVALIDARG; | 747 return E_INVALIDARG; |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
973 // IAccessibleImage methods. | 991 // IAccessibleImage methods. |
974 // | 992 // |
975 | 993 |
976 STDMETHODIMP BrowserAccessibilityWin::get_description(BSTR* desc) { | 994 STDMETHODIMP BrowserAccessibilityWin::get_description(BSTR* desc) { |
977 if (!instance_active()) | 995 if (!instance_active()) |
978 return E_FAIL; | 996 return E_FAIL; |
979 | 997 |
980 if (!desc) | 998 if (!desc) |
981 return E_INVALIDARG; | 999 return E_INVALIDARG; |
982 | 1000 |
983 return GetStringAttributeAsBstr( | 1001 if (description().empty()) |
984 ui::AX_ATTR_DESCRIPTION, desc); | 1002 return S_FALSE; |
1003 | |
1004 *desc = SysAllocString(description().c_str()); | |
1005 | |
1006 DCHECK(*desc); | |
1007 return S_OK; | |
985 } | 1008 } |
986 | 1009 |
987 STDMETHODIMP BrowserAccessibilityWin::get_imagePosition( | 1010 STDMETHODIMP BrowserAccessibilityWin::get_imagePosition( |
988 enum IA2CoordinateType coordinate_type, | 1011 enum IA2CoordinateType coordinate_type, |
989 LONG* x, | 1012 LONG* x, |
990 LONG* y) { | 1013 LONG* y) { |
991 if (!instance_active()) | 1014 if (!instance_active()) |
992 return E_FAIL; | 1015 return E_FAIL; |
993 | 1016 |
994 if (!x || !y) | 1017 if (!x || !y) |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1150 BrowserAccessibilityWin* cell = static_cast<BrowserAccessibilityWin*>( | 1173 BrowserAccessibilityWin* cell = static_cast<BrowserAccessibilityWin*>( |
1151 manager()->GetFromID(cell_id)); | 1174 manager()->GetFromID(cell_id)); |
1152 if (cell && cell->GetRole() == ui::AX_ROLE_COLUMN_HEADER) { | 1175 if (cell && cell->GetRole() == ui::AX_ROLE_COLUMN_HEADER) { |
1153 base::string16 cell_name = cell->GetString16Attribute( | 1176 base::string16 cell_name = cell->GetString16Attribute( |
1154 ui::AX_ATTR_NAME); | 1177 ui::AX_ATTR_NAME); |
1155 if (cell_name.size() > 0) { | 1178 if (cell_name.size() > 0) { |
1156 *description = SysAllocString(cell_name.c_str()); | 1179 *description = SysAllocString(cell_name.c_str()); |
1157 return S_OK; | 1180 return S_OK; |
1158 } | 1181 } |
1159 | 1182 |
1160 return cell->GetStringAttributeAsBstr( | 1183 if (cell->description().size() > 0) { |
1161 ui::AX_ATTR_DESCRIPTION, description); | 1184 *description = SysAllocString(cell->description().c_str()); |
1185 return S_OK; | |
1186 } | |
1162 } | 1187 } |
1163 } | 1188 } |
1164 | 1189 |
1165 return S_FALSE; | 1190 return S_FALSE; |
1166 } | 1191 } |
1167 | 1192 |
1168 STDMETHODIMP BrowserAccessibilityWin::get_columnExtentAt( | 1193 STDMETHODIMP BrowserAccessibilityWin::get_columnExtentAt( |
1169 long row, | 1194 long row, |
1170 long column, | 1195 long column, |
1171 long* n_columns_spanned) { | 1196 long* n_columns_spanned) { |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1337 BrowserAccessibilityWin* cell = | 1362 BrowserAccessibilityWin* cell = |
1338 manager()->GetFromID(cell_id)->ToBrowserAccessibilityWin(); | 1363 manager()->GetFromID(cell_id)->ToBrowserAccessibilityWin(); |
1339 if (cell && cell->GetRole() == ui::AX_ROLE_ROW_HEADER) { | 1364 if (cell && cell->GetRole() == ui::AX_ROLE_ROW_HEADER) { |
1340 base::string16 cell_name = cell->GetString16Attribute( | 1365 base::string16 cell_name = cell->GetString16Attribute( |
1341 ui::AX_ATTR_NAME); | 1366 ui::AX_ATTR_NAME); |
1342 if (cell_name.size() > 0) { | 1367 if (cell_name.size() > 0) { |
1343 *description = SysAllocString(cell_name.c_str()); | 1368 *description = SysAllocString(cell_name.c_str()); |
1344 return S_OK; | 1369 return S_OK; |
1345 } | 1370 } |
1346 | 1371 |
1347 return cell->GetStringAttributeAsBstr( | 1372 if (cell->description().size() > 0) { |
1348 ui::AX_ATTR_DESCRIPTION, description); | 1373 *description = SysAllocString(cell->description().c_str()); |
1374 return S_OK; | |
1375 } | |
1349 } | 1376 } |
1350 } | 1377 } |
1351 | 1378 |
1352 return S_FALSE; | 1379 return S_FALSE; |
1353 } | 1380 } |
1354 | 1381 |
1355 STDMETHODIMP BrowserAccessibilityWin::get_rowExtentAt(long row, | 1382 STDMETHODIMP BrowserAccessibilityWin::get_rowExtentAt(long row, |
1356 long column, | 1383 long column, |
1357 long* n_rows_spanned) { | 1384 long* n_rows_spanned) { |
1358 if (!instance_active()) | 1385 if (!instance_active()) |
(...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2140 return get_text(*start_offset, *end_offset, text); | 2167 return get_text(*start_offset, *end_offset, text); |
2141 } | 2168 } |
2142 | 2169 |
2143 STDMETHODIMP BrowserAccessibilityWin::get_newText(IA2TextSegment* new_text) { | 2170 STDMETHODIMP BrowserAccessibilityWin::get_newText(IA2TextSegment* new_text) { |
2144 if (!instance_active()) | 2171 if (!instance_active()) |
2145 return E_FAIL; | 2172 return E_FAIL; |
2146 | 2173 |
2147 if (!new_text) | 2174 if (!new_text) |
2148 return E_INVALIDARG; | 2175 return E_INVALIDARG; |
2149 | 2176 |
2150 base::string16 text = TextForIAccessibleText(); | 2177 //if (!old_win_attributes_) |
aboxhall
2015/01/22 21:22:09
Lingering commented-out code
dmazzoni
2015/01/23 23:26:13
Done.
| |
2178 // return E_FAIL; | |
2151 | 2179 |
2152 new_text->text = SysAllocString(text.c_str()); | 2180 int start, old_len, new_len; |
2153 new_text->start = 0; | 2181 ComputeHypertextRemovedAndInserted(&start, &old_len, &new_len); |
2154 new_text->end = static_cast<long>(text.size()); | 2182 if (new_len == 0) |
2183 return E_FAIL; | |
2184 | |
2185 base::string16 substr = hypertext_.substr(start, new_len); | |
2186 new_text->text = SysAllocString(substr.c_str()); | |
2187 new_text->start = static_cast<long>(start); | |
2188 new_text->end = static_cast<long>(start + new_len); | |
2155 return S_OK; | 2189 return S_OK; |
2156 } | 2190 } |
2157 | 2191 |
2158 STDMETHODIMP BrowserAccessibilityWin::get_oldText(IA2TextSegment* old_text) { | 2192 STDMETHODIMP BrowserAccessibilityWin::get_oldText(IA2TextSegment* old_text) { |
2159 if (!instance_active()) | 2193 if (!instance_active()) |
2160 return E_FAIL; | 2194 return E_FAIL; |
2161 | 2195 |
2162 if (!old_text) | 2196 if (!old_text) |
2163 return E_INVALIDARG; | 2197 return E_INVALIDARG; |
2164 | 2198 |
2165 old_text->text = SysAllocString(old_text_.c_str()); | 2199 //if (!old_win_attributes_) |
2166 old_text->start = 0; | 2200 // return E_FAIL; |
2167 old_text->end = static_cast<long>(old_text_.size()); | 2201 |
2202 int start, old_len, new_len; | |
2203 ComputeHypertextRemovedAndInserted(&start, &old_len, &new_len); | |
2204 if (old_len == 0) | |
2205 return E_FAIL; | |
2206 | |
2207 base::string16 substr = old_hypertext_.substr(start, old_len); | |
2208 old_text->text = SysAllocString(substr.c_str()); | |
2209 old_text->start = static_cast<long>(start); | |
2210 old_text->end = static_cast<long>(start + old_len); | |
2168 return S_OK; | 2211 return S_OK; |
2169 } | 2212 } |
2170 | 2213 |
2171 STDMETHODIMP BrowserAccessibilityWin::get_offsetAtPoint( | 2214 STDMETHODIMP BrowserAccessibilityWin::get_offsetAtPoint( |
2172 LONG x, | 2215 LONG x, |
2173 LONG y, | 2216 LONG y, |
2174 enum IA2CoordinateType coord_type, | 2217 enum IA2CoordinateType coord_type, |
2175 LONG* offset) { | 2218 LONG* offset) { |
2176 if (!instance_active()) | 2219 if (!instance_active()) |
2177 return E_FAIL; | 2220 return E_FAIL; |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2291 long char_index, | 2334 long char_index, |
2292 long* hyperlink_index) { | 2335 long* hyperlink_index) { |
2293 if (!instance_active()) | 2336 if (!instance_active()) |
2294 return E_FAIL; | 2337 return E_FAIL; |
2295 | 2338 |
2296 if (!hyperlink_index) | 2339 if (!hyperlink_index) |
2297 return E_INVALIDARG; | 2340 return E_INVALIDARG; |
2298 | 2341 |
2299 *hyperlink_index = -1; | 2342 *hyperlink_index = -1; |
2300 | 2343 |
2301 if (char_index < 0 || char_index >= static_cast<long>(hypertext_.size())) | 2344 if (char_index < 0 || |
2345 char_index >= static_cast<long>(hypertext_.size())) { | |
2302 return E_INVALIDARG; | 2346 return E_INVALIDARG; |
2347 } | |
2303 | 2348 |
2304 std::map<int32, int32>::iterator it = | 2349 std::map<int32, int32>::iterator it = |
2305 hyperlink_offset_to_index_.find(char_index); | 2350 hyperlink_offset_to_index_.find(char_index); |
2306 if (it == hyperlink_offset_to_index_.end()) | 2351 if (it == hyperlink_offset_to_index_.end()) |
2307 return E_FAIL; | 2352 return E_FAIL; |
2308 | 2353 |
2309 *hyperlink_index = it->second; | 2354 *hyperlink_index = it->second; |
2310 return S_OK; | 2355 return S_OK; |
2311 } | 2356 } |
2312 | 2357 |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2441 return E_INVALIDARG; | 2486 return E_INVALIDARG; |
2442 } | 2487 } |
2443 | 2488 |
2444 base::string16 tag; | 2489 base::string16 tag; |
2445 if (GetString16Attribute(ui::AX_ATTR_HTML_TAG, &tag)) | 2490 if (GetString16Attribute(ui::AX_ATTR_HTML_TAG, &tag)) |
2446 *node_name = SysAllocString(tag.c_str()); | 2491 *node_name = SysAllocString(tag.c_str()); |
2447 else | 2492 else |
2448 *node_name = NULL; | 2493 *node_name = NULL; |
2449 | 2494 |
2450 *name_space_id = 0; | 2495 *name_space_id = 0; |
2451 *node_value = SysAllocString(base::UTF8ToUTF16(value()).c_str()); | 2496 *node_value = SysAllocString(value().c_str()); |
2452 *num_children = PlatformChildCount(); | 2497 *num_children = PlatformChildCount(); |
2453 *unique_id = unique_id_win_; | 2498 *unique_id = unique_id_win_; |
2454 | 2499 |
2455 if (ia_role_ == ROLE_SYSTEM_DOCUMENT) { | 2500 if (ia_role() == ROLE_SYSTEM_DOCUMENT) { |
2456 *node_type = NODETYPE_DOCUMENT; | 2501 *node_type = NODETYPE_DOCUMENT; |
2457 } else if (ia_role_ == ROLE_SYSTEM_TEXT && | 2502 } else if (ia_role() == ROLE_SYSTEM_TEXT && |
2458 ((ia2_state_ & IA2_STATE_EDITABLE) == 0)) { | 2503 ((ia2_state() & IA2_STATE_EDITABLE) == 0)) { |
2459 *node_type = NODETYPE_TEXT; | 2504 *node_type = NODETYPE_TEXT; |
2460 } else { | 2505 } else { |
2461 *node_type = NODETYPE_ELEMENT; | 2506 *node_type = NODETYPE_ELEMENT; |
2462 } | 2507 } |
2463 | 2508 |
2464 return S_OK; | 2509 return S_OK; |
2465 } | 2510 } |
2466 | 2511 |
2467 STDMETHODIMP BrowserAccessibilityWin::get_attributes( | 2512 STDMETHODIMP BrowserAccessibilityWin::get_attributes( |
2468 unsigned short max_attribs, | 2513 unsigned short max_attribs, |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2859 // | 2904 // |
2860 | 2905 |
2861 // static | 2906 // static |
2862 HRESULT WINAPI BrowserAccessibilityWin::InternalQueryInterface( | 2907 HRESULT WINAPI BrowserAccessibilityWin::InternalQueryInterface( |
2863 void* this_ptr, | 2908 void* this_ptr, |
2864 const _ATL_INTMAP_ENTRY* entries, | 2909 const _ATL_INTMAP_ENTRY* entries, |
2865 REFIID iid, | 2910 REFIID iid, |
2866 void** object) { | 2911 void** object) { |
2867 BrowserAccessibilityWin* accessibility = | 2912 BrowserAccessibilityWin* accessibility = |
2868 reinterpret_cast<BrowserAccessibilityWin*>(this_ptr); | 2913 reinterpret_cast<BrowserAccessibilityWin*>(this_ptr); |
2869 int32 ia_role = accessibility->ia_role_; | 2914 int32 ia_role = accessibility->ia_role(); |
2870 if (iid == IID_IAccessibleImage) { | 2915 if (iid == IID_IAccessibleImage) { |
2871 if (ia_role != ROLE_SYSTEM_GRAPHIC) { | 2916 if (ia_role != ROLE_SYSTEM_GRAPHIC) { |
2872 *object = NULL; | 2917 *object = NULL; |
2873 return E_NOINTERFACE; | 2918 return E_NOINTERFACE; |
2874 } | 2919 } |
2875 } else if (iid == IID_IAccessibleTable || iid == IID_IAccessibleTable2) { | 2920 } else if (iid == IID_IAccessibleTable || iid == IID_IAccessibleTable2) { |
2876 if (ia_role != ROLE_SYSTEM_TABLE) { | 2921 if (ia_role != ROLE_SYSTEM_TABLE) { |
2877 *object = NULL; | 2922 *object = NULL; |
2878 return E_NOINTERFACE; | 2923 return E_NOINTERFACE; |
2879 } | 2924 } |
(...skipping 17 matching lines...) Expand all Loading... | |
2897 } | 2942 } |
2898 | 2943 |
2899 return CComObjectRootBase::InternalQueryInterface( | 2944 return CComObjectRootBase::InternalQueryInterface( |
2900 this_ptr, entries, iid, object); | 2945 this_ptr, entries, iid, object); |
2901 } | 2946 } |
2902 | 2947 |
2903 // | 2948 // |
2904 // Private methods. | 2949 // Private methods. |
2905 // | 2950 // |
2906 | 2951 |
2907 // Called every time this node's data changes. | 2952 // Called every time this node's data changes, while the tree update is |
2953 // still in progress. | |
2908 void BrowserAccessibilityWin::OnDataChanged() { | 2954 void BrowserAccessibilityWin::OnDataChanged() { |
2909 BrowserAccessibility::OnDataChanged(); | 2955 BrowserAccessibility::OnDataChanged(); |
2956 } | |
2957 | |
2958 // Called every time this node's data changes, after an atomic tree update. | |
2959 void BrowserAccessibilityWin::OnUpdateFinished() { | |
2960 BrowserAccessibility::OnUpdateFinished(); | |
2961 | |
2962 if (PlatformIsChildOfLeaf()) | |
2963 return; | |
2964 | |
2965 bool is_new_object = ia_role() == 0 && role_name().empty(); | |
2966 | |
2967 old_win_attributes_.swap(win_attributes_); | |
2968 win_attributes_.reset(new WinAttributes()); | |
2910 | 2969 |
2911 InitRoleAndState(); | 2970 InitRoleAndState(); |
2912 | 2971 |
2972 win_attributes_->ia2_attributes.clear(); | |
2973 | |
2913 // Expose autocomplete attribute for combobox and textbox. | 2974 // Expose autocomplete attribute for combobox and textbox. |
2914 StringAttributeToIA2(ui::AX_ATTR_AUTO_COMPLETE, "autocomplete"); | 2975 StringAttributeToIA2(ui::AX_ATTR_AUTO_COMPLETE, "autocomplete"); |
2915 | 2976 |
2916 // Expose the "display" and "tag" attributes. | 2977 // Expose the "display" and "tag" attributes. |
2917 StringAttributeToIA2(ui::AX_ATTR_DISPLAY, "display"); | 2978 StringAttributeToIA2(ui::AX_ATTR_DISPLAY, "display"); |
2918 StringAttributeToIA2(ui::AX_ATTR_TEXT_INPUT_TYPE, "text-input-type"); | 2979 StringAttributeToIA2(ui::AX_ATTR_TEXT_INPUT_TYPE, "text-input-type"); |
2919 StringAttributeToIA2(ui::AX_ATTR_HTML_TAG, "tag"); | 2980 StringAttributeToIA2(ui::AX_ATTR_HTML_TAG, "tag"); |
2920 StringAttributeToIA2(ui::AX_ATTR_ROLE, "xml-roles"); | 2981 StringAttributeToIA2(ui::AX_ATTR_ROLE, "xml-roles"); |
2921 | 2982 |
2922 // Expose "level" attribute for headings, trees, etc. | 2983 // Expose "level" attribute for headings, trees, etc. |
2923 IntAttributeToIA2(ui::AX_ATTR_HIERARCHICAL_LEVEL, "level"); | 2984 IntAttributeToIA2(ui::AX_ATTR_HIERARCHICAL_LEVEL, "level"); |
2924 | 2985 |
2925 // Expose the set size and position in set for listbox options. | 2986 // Expose the set size and position in set for listbox options. |
2926 if (GetRole() == ui::AX_ROLE_LIST_BOX_OPTION && | 2987 if (GetRole() == ui::AX_ROLE_LIST_BOX_OPTION && |
2927 GetParent() && | 2988 GetParent() && |
2928 GetParent()->GetRole() == ui::AX_ROLE_LIST_BOX) { | 2989 GetParent()->GetRole() == ui::AX_ROLE_LIST_BOX) { |
2929 ia2_attributes_.push_back( | 2990 win_attributes_->ia2_attributes.push_back( |
2930 L"setsize:" + base::IntToString16(GetParent()->PlatformChildCount())); | 2991 L"setsize:" + base::IntToString16(GetParent()->PlatformChildCount())); |
2931 ia2_attributes_.push_back( | 2992 win_attributes_->ia2_attributes.push_back( |
2932 L"setsize:" + base::IntToString16(GetIndexInParent() + 1)); | 2993 L"setsize:" + base::IntToString16(GetIndexInParent() + 1)); |
2933 } | 2994 } |
2934 | 2995 |
2935 if (ia_role_ == ROLE_SYSTEM_CHECKBUTTON || | 2996 if (ia_role() == ROLE_SYSTEM_CHECKBUTTON || |
2936 ia_role_ == ROLE_SYSTEM_RADIOBUTTON || | 2997 ia_role() == ROLE_SYSTEM_RADIOBUTTON || |
2937 ia2_role_ == IA2_ROLE_CHECK_MENU_ITEM || | 2998 ia2_role() == IA2_ROLE_CHECK_MENU_ITEM || |
2938 ia2_role_ == IA2_ROLE_RADIO_MENU_ITEM || | 2999 ia2_role() == IA2_ROLE_RADIO_MENU_ITEM || |
2939 ia2_role_ == IA2_ROLE_TOGGLE_BUTTON) { | 3000 ia2_role() == IA2_ROLE_TOGGLE_BUTTON) { |
2940 ia2_attributes_.push_back(L"checkable:true"); | 3001 win_attributes_->ia2_attributes.push_back(L"checkable:true"); |
2941 } | 3002 } |
2942 | 3003 |
2943 // Expose live region attributes. | 3004 // Expose live region attributes. |
2944 StringAttributeToIA2(ui::AX_ATTR_LIVE_STATUS, "live"); | 3005 StringAttributeToIA2(ui::AX_ATTR_LIVE_STATUS, "live"); |
2945 StringAttributeToIA2(ui::AX_ATTR_LIVE_RELEVANT, "relevant"); | 3006 StringAttributeToIA2(ui::AX_ATTR_LIVE_RELEVANT, "relevant"); |
2946 BoolAttributeToIA2(ui::AX_ATTR_LIVE_ATOMIC, "atomic"); | 3007 BoolAttributeToIA2(ui::AX_ATTR_LIVE_ATOMIC, "atomic"); |
2947 BoolAttributeToIA2(ui::AX_ATTR_LIVE_BUSY, "busy"); | 3008 BoolAttributeToIA2(ui::AX_ATTR_LIVE_BUSY, "busy"); |
2948 | 3009 |
2949 // Expose container live region attributes. | 3010 // Expose container live region attributes. |
2950 StringAttributeToIA2(ui::AX_ATTR_CONTAINER_LIVE_STATUS, | 3011 StringAttributeToIA2(ui::AX_ATTR_CONTAINER_LIVE_STATUS, |
2951 "container-live"); | 3012 "container-live"); |
2952 StringAttributeToIA2(ui::AX_ATTR_CONTAINER_LIVE_RELEVANT, | 3013 StringAttributeToIA2(ui::AX_ATTR_CONTAINER_LIVE_RELEVANT, |
2953 "container-relevant"); | 3014 "container-relevant"); |
2954 BoolAttributeToIA2(ui::AX_ATTR_CONTAINER_LIVE_ATOMIC, | 3015 BoolAttributeToIA2(ui::AX_ATTR_CONTAINER_LIVE_ATOMIC, |
2955 "container-atomic"); | 3016 "container-atomic"); |
2956 BoolAttributeToIA2(ui::AX_ATTR_CONTAINER_LIVE_BUSY, | 3017 BoolAttributeToIA2(ui::AX_ATTR_CONTAINER_LIVE_BUSY, |
2957 "container-busy"); | 3018 "container-busy"); |
2958 | 3019 |
2959 // Expose slider value. | |
2960 if (ia_role_ == ROLE_SYSTEM_PROGRESSBAR || | |
2961 ia_role_ == ROLE_SYSTEM_SCROLLBAR || | |
2962 ia_role_ == ROLE_SYSTEM_SLIDER) { | |
2963 ia2_attributes_.push_back(L"valuetext:" + GetValueText()); | |
2964 } | |
2965 | |
2966 // Expose table cell index. | 3020 // Expose table cell index. |
2967 if (IsCellOrTableHeaderRole()) { | 3021 if (IsCellOrTableHeaderRole()) { |
2968 BrowserAccessibility* table = GetParent(); | 3022 BrowserAccessibility* table = GetParent(); |
2969 while (table && table->GetRole() != ui::AX_ROLE_TABLE) | 3023 while (table && table->GetRole() != ui::AX_ROLE_TABLE) |
2970 table = table->GetParent(); | 3024 table = table->GetParent(); |
2971 if (table) { | 3025 if (table) { |
2972 const std::vector<int32>& unique_cell_ids = table->GetIntListAttribute( | 3026 const std::vector<int32>& unique_cell_ids = table->GetIntListAttribute( |
2973 ui::AX_ATTR_UNIQUE_CELL_IDS); | 3027 ui::AX_ATTR_UNIQUE_CELL_IDS); |
2974 for (size_t i = 0; i < unique_cell_ids.size(); ++i) { | 3028 for (size_t i = 0; i < unique_cell_ids.size(); ++i) { |
2975 if (unique_cell_ids[i] == GetId()) { | 3029 if (unique_cell_ids[i] == GetId()) { |
2976 ia2_attributes_.push_back( | 3030 win_attributes_->ia2_attributes.push_back( |
2977 base::string16(L"table-cell-index:") + base::IntToString16(i)); | 3031 base::string16(L"table-cell-index:") + base::IntToString16(i)); |
2978 } | 3032 } |
2979 } | 3033 } |
2980 } | 3034 } |
2981 } | 3035 } |
2982 | 3036 |
2983 // Expose invalid state for form controls and elements with aria-invalid. | 3037 // Expose invalid state for form controls and elements with aria-invalid. |
2984 int invalid_state; | 3038 int invalid_state; |
2985 if (GetIntAttribute(ui::AX_ATTR_INVALID_STATE, &invalid_state)) { | 3039 if (GetIntAttribute(ui::AX_ATTR_INVALID_STATE, &invalid_state)) { |
2986 // TODO(nektar): Handle the possibility of having multiple aria-invalid | 3040 // TODO(nektar): Handle the possibility of having multiple aria-invalid |
2987 // attributes defined, e.g., "invalid:spelling,grammar". | 3041 // attributes defined, e.g., "invalid:spelling,grammar". |
2988 switch (invalid_state) { | 3042 switch (invalid_state) { |
2989 case ui::AX_INVALID_STATE_NONE: | 3043 case ui::AX_INVALID_STATE_NONE: |
2990 break; | 3044 break; |
2991 case ui::AX_INVALID_STATE_FALSE: | 3045 case ui::AX_INVALID_STATE_FALSE: |
2992 ia2_attributes_.push_back(L"invalid:false"); | 3046 win_attributes_->ia2_attributes.push_back(L"invalid:false"); |
2993 break; | 3047 break; |
2994 case ui::AX_INVALID_STATE_TRUE: | 3048 case ui::AX_INVALID_STATE_TRUE: |
2995 ia2_attributes_.push_back(L"invalid:true"); | 3049 win_attributes_->ia2_attributes.push_back(L"invalid:true"); |
2996 break; | 3050 break; |
2997 case ui::AX_INVALID_STATE_SPELLING: | 3051 case ui::AX_INVALID_STATE_SPELLING: |
2998 ia2_attributes_.push_back(L"invalid:spelling"); | 3052 win_attributes_->ia2_attributes.push_back(L"invalid:spelling"); |
2999 break; | 3053 break; |
3000 case ui::AX_INVALID_STATE_GRAMMAR: | 3054 case ui::AX_INVALID_STATE_GRAMMAR: |
3001 ia2_attributes_.push_back(L"invalid:grammar"); | 3055 win_attributes_->ia2_attributes.push_back(L"invalid:grammar"); |
3002 break; | 3056 break; |
3003 case ui::AX_INVALID_STATE_OTHER: | 3057 case ui::AX_INVALID_STATE_OTHER: |
3004 { | 3058 { |
3005 base::string16 aria_invalid_value; | 3059 base::string16 aria_invalid_value; |
3006 if (GetString16Attribute(ui::AX_ATTR_ARIA_INVALID_VALUE, | 3060 if (GetString16Attribute(ui::AX_ATTR_ARIA_INVALID_VALUE, |
3007 &aria_invalid_value)) { | 3061 &aria_invalid_value)) { |
3008 ia2_attributes_.push_back(L"invalid:" + aria_invalid_value); | 3062 win_attributes_->ia2_attributes.push_back( |
3063 L"invalid:" + aria_invalid_value); | |
3009 } else { | 3064 } else { |
3010 // Set the attribute to L"true", since we cannot be more specific. | 3065 // Set the attribute to L"true", since we cannot be more specific. |
3011 ia2_attributes_.push_back(L"invalid:true"); | 3066 win_attributes_->ia2_attributes.push_back(L"invalid:true"); |
3012 } | 3067 } |
3013 } | 3068 } |
3014 break; | 3069 break; |
3015 default: | 3070 default: |
3016 NOTREACHED(); | 3071 NOTREACHED(); |
3017 } | 3072 } |
3018 } | 3073 } |
3019 | 3074 |
3020 // The calculation of the accessible name of an element has been | 3075 // The calculation of the accessible name of an element has been |
3021 // standardized in the HTML to Platform Accessibility APIs Implementation | 3076 // standardized in the HTML to Platform Accessibility APIs Implementation |
3022 // Guide (http://www.w3.org/TR/html-aapi/). In order to return the | 3077 // Guide (http://www.w3.org/TR/html-aapi/). In order to return the |
3023 // appropriate accessible name on Windows, we need to apply some logic | 3078 // appropriate accessible name on Windows, we need to apply some logic |
3024 // to the fields we get from WebKit. | 3079 // to the fields we get from WebKit. |
3025 // | 3080 // |
3026 // TODO(dmazzoni): move most of this logic into WebKit. | 3081 // TODO(dmazzoni): move most of this logic into WebKit. |
3027 // | 3082 // |
3028 // WebKit gives us: | 3083 // WebKit gives us: |
3029 // | 3084 // |
3030 // name: the default name, e.g. inner text | 3085 // name: the default name, e.g. inner text |
3031 // title ui element: a reference to a <label> element on the same | 3086 // title ui element: a reference to a <label> element on the same |
3032 // page that labels this node. | 3087 // page that labels this node. |
3033 // description: accessible labels that override the default name: | 3088 // description: accessible labels that override the default name: |
3034 // aria-label or aria-labelledby or aria-describedby | 3089 // aria-label or aria-labelledby or aria-describedby |
3035 // help: the value of the "title" attribute | 3090 // help: the value of the "title" attribute |
3036 // | 3091 // |
3037 // On Windows, the logic we apply lets some fields take precedence and | 3092 // On Windows, the logic we apply lets some fields take precedence and |
3038 // always returns the primary name in "name" and the secondary name, | 3093 // always returns the primary name in "name" and the secondary name, |
3039 // if any, in "description". | 3094 // if any, in "description". |
3040 | 3095 |
3041 int title_elem_id = GetIntAttribute( | 3096 int title_elem_id = GetIntAttribute(ui::AX_ATTR_TITLE_UI_ELEMENT); |
3042 ui::AX_ATTR_TITLE_UI_ELEMENT); | 3097 base::string16 name = GetString16Attribute(ui::AX_ATTR_NAME); |
3043 std::string help = GetStringAttribute(ui::AX_ATTR_HELP); | 3098 base::string16 description = GetString16Attribute(ui::AX_ATTR_DESCRIPTION); |
3044 std::string description = GetStringAttribute( | 3099 base::string16 help = GetString16Attribute(ui::AX_ATTR_HELP); |
3045 ui::AX_ATTR_DESCRIPTION); | 3100 base::string16 value = GetString16Attribute(ui::AX_ATTR_VALUE); |
3046 | 3101 |
3047 // WebKit annoyingly puts the title in the description if there's no other | 3102 // WebKit annoyingly puts the title in the description if there's no other |
3048 // description, which just confuses the rest of the logic. Put it back. | 3103 // description, which just confuses the rest of the logic. Put it back. |
3049 // Now "help" is always the value of the "title" attribute, if present. | 3104 // Now "help" is always the value of the "title" attribute, if present. |
3050 std::string title_attr; | 3105 base::string16 title_attr; |
3051 if (GetHtmlAttribute("title", &title_attr) && | 3106 if (GetHtmlAttribute("title", &title_attr) && |
3052 description == title_attr && | 3107 description == title_attr && |
3053 help.empty()) { | 3108 help.empty()) { |
3054 help = description; | 3109 help = description; |
3055 description.clear(); | 3110 description.clear(); |
3056 } | 3111 } |
3057 | 3112 |
3058 // Now implement the main logic: the descripion should become the name if | 3113 // Now implement the main logic: the descripion should become the name if |
3059 // it's nonempty, and the help should become the description if | 3114 // it's nonempty, and the help should become the description if |
3060 // there's no description - or the name if there's no name or description. | 3115 // there's no description - or the name if there's no name or description. |
3061 if (!description.empty()) { | 3116 if (!description.empty()) { |
3062 set_name(description); | 3117 name = description; |
3063 description.clear(); | 3118 description.clear(); |
3064 } | 3119 } |
3065 if (!help.empty() && description.empty()) { | 3120 if (!help.empty() && description.empty()) { |
3066 description = help; | 3121 description = help; |
3067 help.clear(); | 3122 help.clear(); |
3068 } | 3123 } |
3069 if (!description.empty() && name().empty() && !title_elem_id) { | 3124 if (!description.empty() && name.empty() && !title_elem_id) { |
3070 set_name(description); | 3125 name = description; |
3071 description.clear(); | 3126 description.clear(); |
3072 } | 3127 } |
3073 | 3128 |
3074 // If it's a text field, also consider the placeholder. | 3129 // If it's a text field, also consider the placeholder. |
3075 std::string placeholder; | 3130 base::string16 placeholder; |
3076 if (GetRole() == ui::AX_ROLE_TEXT_FIELD && | 3131 if (GetRole() == ui::AX_ROLE_TEXT_FIELD && |
3077 HasState(ui::AX_STATE_FOCUSABLE) && | 3132 HasState(ui::AX_STATE_FOCUSABLE) && |
3078 GetHtmlAttribute("placeholder", &placeholder)) { | 3133 GetHtmlAttribute("placeholder", &placeholder)) { |
3079 if (name().empty() && !title_elem_id) { | 3134 if (name.empty() && !title_elem_id) { |
3080 set_name(placeholder); | 3135 name = placeholder; |
3081 } else if (description.empty()) { | 3136 } else if (description.empty()) { |
3082 description = placeholder; | 3137 description = placeholder; |
3083 } | 3138 } |
3084 } | 3139 } |
3085 | 3140 |
3086 SetStringAttribute(ui::AX_ATTR_DESCRIPTION, description); | |
3087 SetStringAttribute(ui::AX_ATTR_HELP, help); | |
3088 | |
3089 // On Windows, the value of a document should be its url. | 3141 // On Windows, the value of a document should be its url. |
3090 if (GetRole() == ui::AX_ROLE_ROOT_WEB_AREA || | 3142 if (GetRole() == ui::AX_ROLE_ROOT_WEB_AREA || |
3091 GetRole() == ui::AX_ROLE_WEB_AREA) { | 3143 GetRole() == ui::AX_ROLE_WEB_AREA) { |
3092 set_value(GetStringAttribute(ui::AX_ATTR_DOC_URL)); | 3144 value = GetString16Attribute(ui::AX_ATTR_DOC_URL); |
3093 } | 3145 } |
3094 | 3146 |
3095 // For certain roles (listbox option, static text, and list marker) | 3147 // For certain roles (listbox option, static text, and list marker) |
3096 // WebKit stores the main accessible text in the "value" - swap it so | 3148 // WebKit stores the main accessible text in the "value" - swap it so |
3097 // that it's the "name". | 3149 // that it's the "name". |
3098 if (name().empty() && | 3150 if (name.empty() && |
3099 (GetRole() == ui::AX_ROLE_LIST_BOX_OPTION || | 3151 (GetRole() == ui::AX_ROLE_LIST_BOX_OPTION || |
3100 GetRole() == ui::AX_ROLE_STATIC_TEXT || | 3152 GetRole() == ui::AX_ROLE_STATIC_TEXT || |
3101 GetRole() == ui::AX_ROLE_LIST_MARKER)) { | 3153 GetRole() == ui::AX_ROLE_LIST_MARKER)) { |
3102 std::string tmp = value(); | 3154 base::string16 tmp = value; |
3103 set_value(name()); | 3155 value = name; |
3104 set_name(tmp); | 3156 name = tmp; |
3105 } | 3157 } |
3106 | 3158 |
3107 // If this doesn't have a value and is linked then set its value to the url | 3159 // If this doesn't have a value and is linked then set its value to the url |
3108 // attribute. This allows screen readers to read an empty link's destination. | 3160 // attribute. This allows screen readers to read an empty link's destination. |
3109 if (value().empty() && (ia_state_ & STATE_SYSTEM_LINKED)) | 3161 if (value.empty() && (ia_state() & STATE_SYSTEM_LINKED)) |
3110 set_value(GetStringAttribute(ui::AX_ATTR_URL)); | 3162 value = GetString16Attribute(ui::AX_ATTR_URL); |
3163 | |
3164 win_attributes_->name = name; | |
3165 win_attributes_->description = description; | |
3166 win_attributes_->help = help; | |
3167 win_attributes_->value = value; | |
3111 | 3168 |
3112 // Clear any old relationships between this node and other nodes. | 3169 // Clear any old relationships between this node and other nodes. |
3113 for (size_t i = 0; i < relations_.size(); ++i) | 3170 for (size_t i = 0; i < relations_.size(); ++i) |
3114 relations_[i]->Release(); | 3171 relations_[i]->Release(); |
3115 relations_.clear(); | 3172 relations_.clear(); |
3116 | 3173 |
3117 // Handle title UI element. | 3174 // Handle title UI element. |
3118 if (title_elem_id) { | 3175 if (title_elem_id) { |
3119 // Add a labelled by relationship. | 3176 // Add a labelled by relationship. |
3120 CComObject<BrowserAccessibilityRelation>* relation; | 3177 CComObject<BrowserAccessibilityRelation>* relation; |
3121 HRESULT hr = CComObject<BrowserAccessibilityRelation>::CreateInstance( | 3178 HRESULT hr = CComObject<BrowserAccessibilityRelation>::CreateInstance( |
3122 &relation); | 3179 &relation); |
3123 DCHECK(SUCCEEDED(hr)); | 3180 DCHECK(SUCCEEDED(hr)); |
3124 relation->AddRef(); | 3181 relation->AddRef(); |
3125 relation->Initialize(this, IA2_RELATION_LABELLED_BY); | 3182 relation->Initialize(this, IA2_RELATION_LABELLED_BY); |
3126 relation->AddTarget(title_elem_id); | 3183 relation->AddTarget(title_elem_id); |
3127 relations_.push_back(relation); | 3184 relations_.push_back(relation); |
3128 } | 3185 } |
3129 | 3186 |
3187 // Expose slider value. | |
aboxhall
2015/01/22 21:22:09
The one feature I wish Rietveld had: move detectio
dmazzoni
2015/01/23 23:26:13
Acknowledged.
| |
3188 if (ia_role() == ROLE_SYSTEM_PROGRESSBAR || | |
3189 ia_role() == ROLE_SYSTEM_SCROLLBAR || | |
3190 ia_role() == ROLE_SYSTEM_SLIDER) { | |
3191 win_attributes_->ia2_attributes.push_back(L"valuetext:" + GetValueText()); | |
3192 } | |
3193 | |
3130 // If this is a web area for a presentational iframe, give it a role of | 3194 // If this is a web area for a presentational iframe, give it a role of |
3131 // something other than DOCUMENT so that the fact that it's a separate doc | 3195 // something other than DOCUMENT so that the fact that it's a separate doc |
3132 // is not exposed to AT. | 3196 // is not exposed to AT. |
3133 if (IsWebAreaForPresentationalIframe()) { | 3197 if (IsWebAreaForPresentationalIframe()) { |
3134 ia_role_ = ROLE_SYSTEM_GROUPING; | 3198 win_attributes_->ia_role = ROLE_SYSTEM_GROUPING; |
3135 ia2_role_ = ROLE_SYSTEM_GROUPING; | 3199 win_attributes_->ia2_role = ROLE_SYSTEM_GROUPING; |
3136 } | 3200 } |
3201 | |
3202 BrowserAccessibilityManagerWin* manager = | |
3203 this->manager()->ToBrowserAccessibilityManagerWin(); | |
3204 | |
3205 // Fire an event when an alert first appears. | |
3206 if (ia_role() == ROLE_SYSTEM_ALERT && | |
3207 old_win_attributes_->ia_role != ROLE_SYSTEM_ALERT) { | |
3208 manager->NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, this); | |
3209 } | |
3210 | |
3211 LOG(ERROR) << "id=" << GetId() | |
aboxhall
2015/01/22 21:22:09
logspam?
dmazzoni
2015/01/23 23:26:13
Done.
| |
3212 << " old_role=" << old_win_attributes_->ia_role | |
3213 << " role=" << ia_role() | |
3214 << " old_description=" << old_win_attributes_->description | |
3215 << " description=" << description; | |
3216 | |
3217 // Fire an event if the name, description, help, or value changes. | |
3218 if (!is_new_object) { | |
3219 if (name != old_win_attributes_->name) | |
3220 manager->MaybeCallNotifyWinEvent(EVENT_OBJECT_NAMECHANGE, this); | |
3221 if (description != old_win_attributes_->description) | |
3222 manager->MaybeCallNotifyWinEvent(EVENT_OBJECT_DESCRIPTIONCHANGE, this); | |
3223 if (help != old_win_attributes_->help) | |
3224 manager->MaybeCallNotifyWinEvent(EVENT_OBJECT_HELPCHANGE, this); | |
3225 if (value != old_win_attributes_->value) | |
3226 manager->MaybeCallNotifyWinEvent(EVENT_OBJECT_VALUECHANGE, this); | |
3227 if (ia_state() != old_win_attributes_->ia_state) | |
3228 manager->MaybeCallNotifyWinEvent(EVENT_OBJECT_STATECHANGE, this); | |
3229 | |
3230 // Normally focus events are handled elsewhere, however | |
3231 // focus for managed descendants is platform-specific. | |
3232 // Fire a focus event if the focused descendant in a multi-select | |
3233 // list box changes. | |
3234 if (GetRole() == ui::AX_ROLE_LIST_BOX_OPTION && | |
3235 (ia_state() & STATE_SYSTEM_FOCUSABLE) && | |
3236 (ia_state() & STATE_SYSTEM_SELECTABLE) && | |
3237 (ia_state() & STATE_SYSTEM_FOCUSED) && | |
3238 !(old_win_attributes_->ia_state & STATE_SYSTEM_FOCUSED)) { | |
3239 manager->MaybeCallNotifyWinEvent(EVENT_OBJECT_FOCUS, this); | |
3240 } | |
3241 | |
3242 // Handle selection being added or removed. | |
3243 if ((ia_state() & STATE_SYSTEM_SELECTED) && | |
aboxhall
2015/01/22 21:22:10
Suggestion: pull out (ia_state() & STATE_SYSTEM_SE
dmazzoni
2015/01/23 23:26:13
Good idea, done.
| |
3244 !(old_win_attributes_->ia_state & STATE_SYSTEM_SELECTED)) { | |
3245 manager->MaybeCallNotifyWinEvent(EVENT_OBJECT_SELECTIONADD, this); | |
3246 } else if (!(ia_state() & STATE_SYSTEM_SELECTED) && | |
3247 (old_win_attributes_->ia_state & STATE_SYSTEM_SELECTED)) { | |
3248 manager->MaybeCallNotifyWinEvent(EVENT_OBJECT_SELECTIONREMOVE, this); | |
3249 } | |
3250 | |
3251 // Fire an event if this container object has scrolled. | |
3252 int sx = 0; | |
3253 int sy = 0; | |
3254 if (GetIntAttribute(ui::AX_ATTR_SCROLL_X, &sx) && | |
3255 GetIntAttribute(ui::AX_ATTR_SCROLL_Y, &sy)) { | |
3256 if (sx != previous_scroll_x_ || sy != previous_scroll_y_) | |
3257 manager->MaybeCallNotifyWinEvent(EVENT_SYSTEM_SCROLLINGEND, this); | |
3258 previous_scroll_x_ = sx; | |
3259 previous_scroll_y_ = sy; | |
3260 } | |
3261 | |
3262 // Changing a static text node can affect the IAccessibleText hypertext | |
3263 // of the parent node, so force it to be recomputed here. | |
3264 if (GetParent() && | |
3265 GetRole() == ui::AX_ROLE_STATIC_TEXT && | |
3266 name != old_win_attributes_->name) { | |
3267 GetParent()->ToBrowserAccessibilityWin()->UpdateIAccessibleText(); | |
3268 } | |
3269 } | |
3270 | |
3271 old_win_attributes_.reset(nullptr); | |
3137 } | 3272 } |
3138 | 3273 |
3139 void BrowserAccessibilityWin::OnUpdateFinished() { | 3274 void BrowserAccessibilityWin::UpdateIAccessibleText() { |
3275 old_hypertext_ = hypertext_; | |
3276 hypertext_.clear(); | |
3277 | |
3140 // Construct the hypertext for this node. | 3278 // Construct the hypertext for this node. |
3141 hyperlink_offset_to_index_.clear(); | 3279 hyperlink_offset_to_index_.clear(); |
3142 hyperlinks_.clear(); | 3280 hyperlinks_.clear(); |
3143 hypertext_.clear(); | |
3144 for (unsigned int i = 0; i < PlatformChildCount(); ++i) { | 3281 for (unsigned int i = 0; i < PlatformChildCount(); ++i) { |
3145 BrowserAccessibility* child = PlatformGetChild(i); | 3282 BrowserAccessibilityWin* child = |
3283 PlatformGetChild(i)->ToBrowserAccessibilityWin(); | |
3146 if (child->GetRole() == ui::AX_ROLE_STATIC_TEXT) { | 3284 if (child->GetRole() == ui::AX_ROLE_STATIC_TEXT) { |
3147 hypertext_ += base::UTF8ToUTF16(child->name()); | 3285 hypertext_ += child->name(); |
3148 } else { | 3286 } else { |
3149 hyperlink_offset_to_index_[hypertext_.size()] = hyperlinks_.size(); | 3287 hyperlink_offset_to_index_[hypertext_.size()] = |
3288 hyperlinks_.size(); | |
3150 hypertext_ += kEmbeddedCharacter; | 3289 hypertext_ += kEmbeddedCharacter; |
3151 hyperlinks_.push_back(i); | 3290 hyperlinks_.push_back(i); |
3152 } | 3291 } |
3153 } | 3292 } |
3154 DCHECK_EQ(hyperlink_offset_to_index_.size(), hyperlinks_.size()); | 3293 DCHECK_EQ(hyperlink_offset_to_index_.size(), hyperlinks_.size()); |
3155 | 3294 |
3156 // Fire an event when an alert first appears. | 3295 if (hypertext_ != old_hypertext_) { |
aboxhall
2015/01/22 21:22:09
Maybe early-out instead?
dmazzoni
2015/01/23 23:26:13
Only reason I don't want to is because we need to
aboxhall
2015/01/23 23:39:13
Yeah, you could either write that line twice, or j
| |
3157 if (GetRole() == ui::AX_ROLE_ALERT && first_time_) | 3296 LOG(ERROR) << "Old hypertext: '" << old_hypertext_ |
3158 manager()->NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, this); | 3297 << "' new hypertext: '" << hypertext_ << "'"; |
3298 BrowserAccessibilityManagerWin* manager = | |
3299 this->manager()->ToBrowserAccessibilityManagerWin(); | |
3159 | 3300 |
3160 // Fire events if text has changed. | 3301 int start, old_len, new_len; |
3161 base::string16 text = TextForIAccessibleText(); | 3302 ComputeHypertextRemovedAndInserted(&start, &old_len, &new_len); |
3162 if (previous_text_ != text) { | 3303 if (old_len) { |
3163 if (!previous_text_.empty() && !text.empty()) { | 3304 // In-process screen readers may call IAccessibleText::get_oldText |
3164 manager()->NotifyAccessibilityEvent( | 3305 // to retrieve the text that was removed. |
3165 ui::AX_EVENT_SHOW, this); | 3306 manager->MaybeCallNotifyWinEvent(IA2_EVENT_TEXT_REMOVED, this); |
3166 } | 3307 } |
3167 | 3308 if (new_len) { |
3168 // TODO(dmazzoni): Look into HIDE events, too. | 3309 // In-process screen readers may call IAccessibleText::get_newText |
3169 | 3310 // to retrieve the text that was inserted. |
3170 old_text_ = previous_text_; | 3311 manager->MaybeCallNotifyWinEvent(IA2_EVENT_TEXT_INSERTED, this); |
3171 previous_text_ = text; | 3312 } |
3172 } | 3313 } |
3173 | 3314 |
3174 BrowserAccessibilityManagerWin* manager = | 3315 old_hypertext_.clear(); |
3175 this->manager()->ToBrowserAccessibilityManagerWin(); | 3316 } |
3176 | 3317 |
3177 // Fire events if the state has changed. | 3318 void BrowserAccessibilityWin::OnSubtreeWillBeDeleted() { |
3178 if (!first_time_ && ia_state_ != old_ia_state_) { | 3319 manager()->ToBrowserAccessibilityManagerWin()->MaybeCallNotifyWinEvent( |
3179 // Normally focus events are handled elsewhere, however | 3320 EVENT_OBJECT_HIDE, this); |
3180 // focus for managed descendants is platform-specific. | 3321 } |
3181 // Fire a focus event if the focused descendant in a multi-select | |
3182 // list box changes. | |
3183 if (GetRole() == ui::AX_ROLE_LIST_BOX_OPTION && | |
3184 (ia_state_ & STATE_SYSTEM_FOCUSABLE) && | |
3185 (ia_state_ & STATE_SYSTEM_SELECTABLE) && | |
3186 (ia_state_ & STATE_SYSTEM_FOCUSED) && | |
3187 !(old_ia_state_ & STATE_SYSTEM_FOCUSED)) { | |
3188 manager->MaybeCallNotifyWinEvent(EVENT_OBJECT_FOCUS, unique_id_win()); | |
3189 } | |
3190 | 3322 |
3191 if ((ia_state_ & STATE_SYSTEM_SELECTED) && | 3323 void BrowserAccessibilityWin::OnSubtreeCreationFinished() { |
3192 !(old_ia_state_ & STATE_SYSTEM_SELECTED)) { | 3324 manager()->ToBrowserAccessibilityManagerWin()->MaybeCallNotifyWinEvent( |
3193 manager->MaybeCallNotifyWinEvent(EVENT_OBJECT_SELECTIONADD, | 3325 EVENT_OBJECT_SHOW, this); |
3194 unique_id_win()); | |
3195 } else if (!(ia_state_ & STATE_SYSTEM_SELECTED) && | |
3196 (old_ia_state_ & STATE_SYSTEM_SELECTED)) { | |
3197 manager->MaybeCallNotifyWinEvent(EVENT_OBJECT_SELECTIONREMOVE, | |
3198 unique_id_win()); | |
3199 } | |
3200 | |
3201 old_ia_state_ = ia_state_; | |
3202 } | |
3203 | |
3204 // Fire an event if this container object has scrolled. | |
3205 int sx = 0; | |
3206 int sy = 0; | |
3207 if (GetIntAttribute(ui::AX_ATTR_SCROLL_X, &sx) && | |
3208 GetIntAttribute(ui::AX_ATTR_SCROLL_Y, &sy)) { | |
3209 if (!first_time_ && | |
3210 (sx != previous_scroll_x_ || sy != previous_scroll_y_)) { | |
3211 manager->MaybeCallNotifyWinEvent(EVENT_SYSTEM_SCROLLINGEND, | |
3212 unique_id_win()); | |
3213 } | |
3214 previous_scroll_x_ = sx; | |
3215 previous_scroll_y_ = sy; | |
3216 } | |
3217 | |
3218 first_time_ = false; | |
3219 } | 3326 } |
3220 | 3327 |
3221 void BrowserAccessibilityWin::NativeAddReference() { | 3328 void BrowserAccessibilityWin::NativeAddReference() { |
3222 AddRef(); | 3329 AddRef(); |
3223 } | 3330 } |
3224 | 3331 |
3225 void BrowserAccessibilityWin::NativeReleaseReference() { | 3332 void BrowserAccessibilityWin::NativeReleaseReference() { |
3226 Release(); | 3333 Release(); |
3227 } | 3334 } |
3228 | 3335 |
3229 bool BrowserAccessibilityWin::IsNative() const { | 3336 bool BrowserAccessibilityWin::IsNative() const { |
3230 return true; | 3337 return true; |
3231 } | 3338 } |
3232 | 3339 |
3233 void BrowserAccessibilityWin::OnLocationChanged() { | 3340 void BrowserAccessibilityWin::OnLocationChanged() { |
3234 manager()->ToBrowserAccessibilityManagerWin()->MaybeCallNotifyWinEvent( | 3341 manager()->ToBrowserAccessibilityManagerWin()->MaybeCallNotifyWinEvent( |
3235 EVENT_OBJECT_LOCATIONCHANGE, unique_id_win()); | 3342 EVENT_OBJECT_LOCATIONCHANGE, this); |
3236 } | 3343 } |
3237 | 3344 |
3238 BrowserAccessibilityWin* BrowserAccessibilityWin::NewReference() { | 3345 BrowserAccessibilityWin* BrowserAccessibilityWin::NewReference() { |
3239 AddRef(); | 3346 AddRef(); |
3240 return this; | 3347 return this; |
3241 } | 3348 } |
3242 | 3349 |
3243 BrowserAccessibilityWin* BrowserAccessibilityWin::GetTargetFromChildID( | 3350 BrowserAccessibilityWin* BrowserAccessibilityWin::GetTargetFromChildID( |
3244 const VARIANT& var_id) { | 3351 const VARIANT& var_id) { |
3245 if (var_id.vt != VT_I4) | 3352 if (var_id.vt != VT_I4) |
(...skipping 24 matching lines...) Expand all Loading... | |
3270 *value_bstr = SysAllocString(str.c_str()); | 3377 *value_bstr = SysAllocString(str.c_str()); |
3271 DCHECK(*value_bstr); | 3378 DCHECK(*value_bstr); |
3272 | 3379 |
3273 return S_OK; | 3380 return S_OK; |
3274 } | 3381 } |
3275 | 3382 |
3276 void BrowserAccessibilityWin::StringAttributeToIA2( | 3383 void BrowserAccessibilityWin::StringAttributeToIA2( |
3277 ui::AXStringAttribute attribute, | 3384 ui::AXStringAttribute attribute, |
3278 const char* ia2_attr) { | 3385 const char* ia2_attr) { |
3279 base::string16 value; | 3386 base::string16 value; |
3280 if (GetString16Attribute(attribute, &value)) | 3387 if (GetString16Attribute(attribute, &value)) { |
3281 ia2_attributes_.push_back(base::ASCIIToUTF16(ia2_attr) + L":" + value); | 3388 win_attributes_->ia2_attributes.push_back( |
3389 base::ASCIIToUTF16(ia2_attr) + L":" + value); | |
3390 } | |
3282 } | 3391 } |
3283 | 3392 |
3284 void BrowserAccessibilityWin::BoolAttributeToIA2( | 3393 void BrowserAccessibilityWin::BoolAttributeToIA2( |
3285 ui::AXBoolAttribute attribute, | 3394 ui::AXBoolAttribute attribute, |
3286 const char* ia2_attr) { | 3395 const char* ia2_attr) { |
3287 bool value; | 3396 bool value; |
3288 if (GetBoolAttribute(attribute, &value)) { | 3397 if (GetBoolAttribute(attribute, &value)) { |
3289 ia2_attributes_.push_back((base::ASCIIToUTF16(ia2_attr) + L":") + | 3398 win_attributes_->ia2_attributes.push_back( |
3290 (value ? L"true" : L"false")); | 3399 (base::ASCIIToUTF16(ia2_attr) + L":") + |
3400 (value ? L"true" : L"false")); | |
3291 } | 3401 } |
3292 } | 3402 } |
3293 | 3403 |
3294 void BrowserAccessibilityWin::IntAttributeToIA2( | 3404 void BrowserAccessibilityWin::IntAttributeToIA2( |
3295 ui::AXIntAttribute attribute, | 3405 ui::AXIntAttribute attribute, |
3296 const char* ia2_attr) { | 3406 const char* ia2_attr) { |
3297 int value; | 3407 int value; |
3298 if (GetIntAttribute(attribute, &value)) { | 3408 if (GetIntAttribute(attribute, &value)) { |
3299 ia2_attributes_.push_back(base::ASCIIToUTF16(ia2_attr) + L":" + | 3409 win_attributes_->ia2_attributes.push_back( |
3300 base::IntToString16(value)); | 3410 base::ASCIIToUTF16(ia2_attr) + L":" + |
3411 base::IntToString16(value)); | |
3301 } | 3412 } |
3302 } | 3413 } |
3303 | 3414 |
3415 base::string16 BrowserAccessibilityWin::GetNameRecursive() const { | |
3416 if (!name().empty()) { | |
3417 return name(); | |
3418 } | |
3419 | |
3420 base::string16 result; | |
3421 for (uint32 i = 0; i < PlatformChildCount(); ++i) { | |
3422 result += PlatformGetChild(i)->ToBrowserAccessibilityWin()-> | |
3423 GetNameRecursive(); | |
3424 } | |
3425 return result; | |
3426 } | |
3427 | |
3304 base::string16 BrowserAccessibilityWin::GetValueText() { | 3428 base::string16 BrowserAccessibilityWin::GetValueText() { |
3305 float fval; | 3429 float fval; |
3306 base::string16 value = base::UTF8ToUTF16(this->value()); | 3430 base::string16 value = this->value(); |
3307 | 3431 |
3308 if (value.empty() && | 3432 if (value.empty() && |
3309 GetFloatAttribute(ui::AX_ATTR_VALUE_FOR_RANGE, &fval)) { | 3433 GetFloatAttribute(ui::AX_ATTR_VALUE_FOR_RANGE, &fval)) { |
3310 value = base::UTF8ToUTF16(base::DoubleToString(fval)); | 3434 value = base::UTF8ToUTF16(base::DoubleToString(fval)); |
3311 } | 3435 } |
3312 return value; | 3436 return value; |
3313 } | 3437 } |
3314 | 3438 |
3315 base::string16 BrowserAccessibilityWin::TextForIAccessibleText() { | 3439 base::string16 BrowserAccessibilityWin::TextForIAccessibleText() { |
3316 if (IsEditableText()) | 3440 if (IsEditableText()) |
3317 return base::UTF8ToUTF16(value()); | 3441 return value(); |
3318 return (GetRole() == ui::AX_ROLE_STATIC_TEXT) ? | 3442 return (GetRole() == ui::AX_ROLE_STATIC_TEXT) ? name() : hypertext_; |
3319 base::UTF8ToUTF16(name()) : hypertext_; | 3443 } |
3444 | |
3445 void BrowserAccessibilityWin::ComputeHypertextRemovedAndInserted( | |
3446 int* start, int* old_len, int* new_len) { | |
3447 *start = 0; | |
3448 *old_len = 0; | |
3449 *new_len = 0; | |
3450 | |
3451 const base::string16& old_text = old_hypertext_; | |
3452 const base::string16& new_text = hypertext_; | |
3453 | |
3454 size_t common_prefix = 0; | |
3455 while (common_prefix < old_text.size() && | |
3456 common_prefix < new_text.size() && | |
3457 old_text[common_prefix] == new_text[common_prefix]) { | |
3458 ++common_prefix; | |
3459 } | |
3460 | |
3461 size_t common_suffix = 0; | |
3462 while (common_prefix + common_suffix < old_text.size() && | |
3463 common_prefix + common_suffix < new_text.size() && | |
3464 old_text[old_text.size() - common_suffix - 1] == | |
3465 new_text[new_text.size() - common_suffix - 1]) { | |
3466 ++common_suffix; | |
3467 } | |
3468 | |
3469 *start = common_prefix; | |
3470 *old_len = old_text.size() - common_prefix - common_suffix; | |
3471 *new_len = new_text.size() - common_prefix - common_suffix; | |
3320 } | 3472 } |
3321 | 3473 |
3322 void BrowserAccessibilityWin::HandleSpecialTextOffset( | 3474 void BrowserAccessibilityWin::HandleSpecialTextOffset( |
3323 const base::string16& text, | 3475 const base::string16& text, |
3324 LONG* offset) { | 3476 LONG* offset) { |
3325 if (*offset == IA2_TEXT_OFFSET_LENGTH) | 3477 if (*offset == IA2_TEXT_OFFSET_LENGTH) |
3326 *offset = static_cast<LONG>(text.size()); | 3478 *offset = static_cast<LONG>(text.size()); |
3327 else if (*offset == IA2_TEXT_OFFSET_CARET) | 3479 else if (*offset == IA2_TEXT_OFFSET_CARET) |
3328 get_caretOffset(offset); | 3480 get_caretOffset(offset); |
3329 } | 3481 } |
(...skipping 30 matching lines...) Expand all Loading... | |
3360 ui::AX_ATTR_LINE_BREAKS); | 3512 ui::AX_ATTR_LINE_BREAKS); |
3361 return ui::FindAccessibleTextBoundary( | 3513 return ui::FindAccessibleTextBoundary( |
3362 text, line_breaks, boundary, start_offset, direction); | 3514 text, line_breaks, boundary, start_offset, direction); |
3363 } | 3515 } |
3364 | 3516 |
3365 BrowserAccessibilityWin* BrowserAccessibilityWin::GetFromID(int32 id) { | 3517 BrowserAccessibilityWin* BrowserAccessibilityWin::GetFromID(int32 id) { |
3366 return manager()->GetFromID(id)->ToBrowserAccessibilityWin(); | 3518 return manager()->GetFromID(id)->ToBrowserAccessibilityWin(); |
3367 } | 3519 } |
3368 | 3520 |
3369 void BrowserAccessibilityWin::InitRoleAndState() { | 3521 void BrowserAccessibilityWin::InitRoleAndState() { |
3370 ia_state_ = 0; | 3522 int32 ia_role = 0; |
3371 ia2_state_ = IA2_STATE_OPAQUE; | 3523 int32 ia_state = 0; |
3372 ia2_attributes_.clear(); | 3524 base::string16 role_name; |
3525 int32 ia2_role = 0; | |
3526 int32 ia2_state = IA2_STATE_OPAQUE; | |
3373 | 3527 |
3374 if (HasState(ui::AX_STATE_BUSY)) | 3528 if (HasState(ui::AX_STATE_BUSY)) |
3375 ia_state_ |= STATE_SYSTEM_BUSY; | 3529 ia_state |= STATE_SYSTEM_BUSY; |
3376 if (HasState(ui::AX_STATE_CHECKED)) | 3530 if (HasState(ui::AX_STATE_CHECKED)) |
3377 ia_state_ |= STATE_SYSTEM_CHECKED; | 3531 ia_state |= STATE_SYSTEM_CHECKED; |
3378 if (HasState(ui::AX_STATE_COLLAPSED)) | 3532 if (HasState(ui::AX_STATE_COLLAPSED)) |
3379 ia_state_ |= STATE_SYSTEM_COLLAPSED; | 3533 ia_state |= STATE_SYSTEM_COLLAPSED; |
3380 if (HasState(ui::AX_STATE_EXPANDED)) | 3534 if (HasState(ui::AX_STATE_EXPANDED)) |
3381 ia_state_ |= STATE_SYSTEM_EXPANDED; | 3535 ia_state |= STATE_SYSTEM_EXPANDED; |
3382 if (HasState(ui::AX_STATE_FOCUSABLE)) | 3536 if (HasState(ui::AX_STATE_FOCUSABLE)) |
3383 ia_state_ |= STATE_SYSTEM_FOCUSABLE; | 3537 ia_state |= STATE_SYSTEM_FOCUSABLE; |
3384 if (HasState(ui::AX_STATE_HASPOPUP)) | 3538 if (HasState(ui::AX_STATE_HASPOPUP)) |
3385 ia_state_ |= STATE_SYSTEM_HASPOPUP; | 3539 ia_state |= STATE_SYSTEM_HASPOPUP; |
3386 if (HasState(ui::AX_STATE_HOVERED)) | 3540 if (HasState(ui::AX_STATE_HOVERED)) |
3387 ia_state_ |= STATE_SYSTEM_HOTTRACKED; | 3541 ia_state |= STATE_SYSTEM_HOTTRACKED; |
3388 if (HasState(ui::AX_STATE_INDETERMINATE)) | 3542 if (HasState(ui::AX_STATE_INDETERMINATE)) |
3389 ia_state_ |= STATE_SYSTEM_INDETERMINATE; | 3543 ia_state |= STATE_SYSTEM_INDETERMINATE; |
3390 if (HasIntAttribute(ui::AX_ATTR_INVALID_STATE) && | 3544 if (HasIntAttribute(ui::AX_ATTR_INVALID_STATE) && |
3391 GetIntAttribute(ui::AX_ATTR_INVALID_STATE) != ui::AX_INVALID_STATE_FALSE) | 3545 GetIntAttribute(ui::AX_ATTR_INVALID_STATE) != ui::AX_INVALID_STATE_FALSE) |
3392 ia2_state_ |= IA2_STATE_INVALID_ENTRY; | 3546 ia2_state |= IA2_STATE_INVALID_ENTRY; |
3393 if (HasState(ui::AX_STATE_INVISIBLE)) | 3547 if (HasState(ui::AX_STATE_INVISIBLE)) |
3394 ia_state_ |= STATE_SYSTEM_INVISIBLE; | 3548 ia_state |= STATE_SYSTEM_INVISIBLE; |
3395 if (HasState(ui::AX_STATE_LINKED)) | 3549 if (HasState(ui::AX_STATE_LINKED)) |
3396 ia_state_ |= STATE_SYSTEM_LINKED; | 3550 ia_state |= STATE_SYSTEM_LINKED; |
3397 if (HasState(ui::AX_STATE_MULTISELECTABLE)) { | 3551 if (HasState(ui::AX_STATE_MULTISELECTABLE)) { |
3398 ia_state_ |= STATE_SYSTEM_EXTSELECTABLE; | 3552 ia_state |= STATE_SYSTEM_EXTSELECTABLE; |
3399 ia_state_ |= STATE_SYSTEM_MULTISELECTABLE; | 3553 ia_state |= STATE_SYSTEM_MULTISELECTABLE; |
3400 } | 3554 } |
3401 // TODO(ctguil): Support STATE_SYSTEM_EXTSELECTABLE/accSelect. | 3555 // TODO(ctguil): Support STATE_SYSTEM_EXTSELECTABLE/accSelect. |
3402 if (HasState(ui::AX_STATE_OFFSCREEN)) | 3556 if (HasState(ui::AX_STATE_OFFSCREEN)) |
3403 ia_state_ |= STATE_SYSTEM_OFFSCREEN; | 3557 ia_state |= STATE_SYSTEM_OFFSCREEN; |
3404 if (HasState(ui::AX_STATE_PRESSED)) | 3558 if (HasState(ui::AX_STATE_PRESSED)) |
3405 ia_state_ |= STATE_SYSTEM_PRESSED; | 3559 ia_state |= STATE_SYSTEM_PRESSED; |
3406 if (HasState(ui::AX_STATE_PROTECTED)) | 3560 if (HasState(ui::AX_STATE_PROTECTED)) |
3407 ia_state_ |= STATE_SYSTEM_PROTECTED; | 3561 ia_state |= STATE_SYSTEM_PROTECTED; |
3408 if (HasState(ui::AX_STATE_REQUIRED)) | 3562 if (HasState(ui::AX_STATE_REQUIRED)) |
3409 ia2_state_ |= IA2_STATE_REQUIRED; | 3563 ia2_state |= IA2_STATE_REQUIRED; |
3410 if (HasState(ui::AX_STATE_SELECTABLE)) | 3564 if (HasState(ui::AX_STATE_SELECTABLE)) |
3411 ia_state_ |= STATE_SYSTEM_SELECTABLE; | 3565 ia_state |= STATE_SYSTEM_SELECTABLE; |
3412 if (HasState(ui::AX_STATE_SELECTED)) | 3566 if (HasState(ui::AX_STATE_SELECTED)) |
3413 ia_state_ |= STATE_SYSTEM_SELECTED; | 3567 ia_state |= STATE_SYSTEM_SELECTED; |
3414 if (HasState(ui::AX_STATE_VISITED)) | 3568 if (HasState(ui::AX_STATE_VISITED)) |
3415 ia_state_ |= STATE_SYSTEM_TRAVERSED; | 3569 ia_state |= STATE_SYSTEM_TRAVERSED; |
3416 if (!HasState(ui::AX_STATE_ENABLED)) | 3570 if (!HasState(ui::AX_STATE_ENABLED)) |
3417 ia_state_ |= STATE_SYSTEM_UNAVAILABLE; | 3571 ia_state |= STATE_SYSTEM_UNAVAILABLE; |
3418 if (HasState(ui::AX_STATE_VERTICAL)) | 3572 if (HasState(ui::AX_STATE_VERTICAL)) |
3419 ia2_state_ |= IA2_STATE_VERTICAL; | 3573 ia2_state |= IA2_STATE_VERTICAL; |
3420 if (HasState(ui::AX_STATE_HORIZONTAL)) | 3574 if (HasState(ui::AX_STATE_HORIZONTAL)) |
3421 ia2_state_ |= IA2_STATE_HORIZONTAL; | 3575 ia2_state |= IA2_STATE_HORIZONTAL; |
3422 if (HasState(ui::AX_STATE_VISITED)) | 3576 if (HasState(ui::AX_STATE_VISITED)) |
3423 ia_state_ |= STATE_SYSTEM_TRAVERSED; | 3577 ia_state |= STATE_SYSTEM_TRAVERSED; |
3424 | 3578 |
3425 // WebKit marks everything as readonly unless it's editable text, so if it's | 3579 // WebKit marks everything as readonly unless it's editable text, so if it's |
3426 // not readonly, mark it as editable now. The final computation of the | 3580 // not readonly, mark it as editable now. The final computation of the |
3427 // READONLY state for MSAA is below, after the switch. | 3581 // READONLY state for MSAA is below, after the switch. |
3428 if (!HasState(ui::AX_STATE_READ_ONLY)) | 3582 if (!HasState(ui::AX_STATE_READ_ONLY)) |
3429 ia2_state_ |= IA2_STATE_EDITABLE; | 3583 ia2_state |= IA2_STATE_EDITABLE; |
3430 | 3584 |
3431 if (GetBoolAttribute(ui::AX_ATTR_BUTTON_MIXED)) | 3585 if (GetBoolAttribute(ui::AX_ATTR_BUTTON_MIXED)) |
3432 ia_state_ |= STATE_SYSTEM_MIXED; | 3586 ia_state |= STATE_SYSTEM_MIXED; |
3433 | 3587 |
3434 if (GetBoolAttribute(ui::AX_ATTR_CAN_SET_VALUE)) | 3588 if (GetBoolAttribute(ui::AX_ATTR_CAN_SET_VALUE)) |
3435 ia2_state_ |= IA2_STATE_EDITABLE; | 3589 ia2_state |= IA2_STATE_EDITABLE; |
3436 | 3590 |
3437 if (!GetStringAttribute(ui::AX_ATTR_AUTO_COMPLETE).empty()) | 3591 if (!GetStringAttribute(ui::AX_ATTR_AUTO_COMPLETE).empty()) |
3438 ia2_state_ |= IA2_STATE_SUPPORTS_AUTOCOMPLETION; | 3592 ia2_state |= IA2_STATE_SUPPORTS_AUTOCOMPLETION; |
3439 | 3593 |
3440 base::string16 html_tag = GetString16Attribute( | 3594 base::string16 html_tag = GetString16Attribute( |
3441 ui::AX_ATTR_HTML_TAG); | 3595 ui::AX_ATTR_HTML_TAG); |
3442 ia_role_ = 0; | |
3443 ia2_role_ = 0; | |
3444 switch (GetRole()) { | 3596 switch (GetRole()) { |
3445 case ui::AX_ROLE_ALERT: | 3597 case ui::AX_ROLE_ALERT: |
3446 ia_role_ = ROLE_SYSTEM_ALERT; | 3598 ia_role = ROLE_SYSTEM_ALERT; |
3447 break; | 3599 break; |
3448 case ui::AX_ROLE_ALERT_DIALOG: | 3600 case ui::AX_ROLE_ALERT_DIALOG: |
3449 ia_role_ = ROLE_SYSTEM_DIALOG; | 3601 ia_role = ROLE_SYSTEM_DIALOG; |
3450 break; | 3602 break; |
3451 case ui::AX_ROLE_APPLICATION: | 3603 case ui::AX_ROLE_APPLICATION: |
3452 ia_role_ = ROLE_SYSTEM_APPLICATION; | 3604 ia_role = ROLE_SYSTEM_APPLICATION; |
3453 break; | 3605 break; |
3454 case ui::AX_ROLE_ARTICLE: | 3606 case ui::AX_ROLE_ARTICLE: |
3455 ia_role_ = ROLE_SYSTEM_DOCUMENT; | 3607 ia_role = ROLE_SYSTEM_DOCUMENT; |
3456 ia_state_ |= STATE_SYSTEM_READONLY; | 3608 ia_state |= STATE_SYSTEM_READONLY; |
3457 break; | 3609 break; |
3458 case ui::AX_ROLE_BANNER: | 3610 case ui::AX_ROLE_BANNER: |
3459 ia_role_ = ROLE_SYSTEM_GROUPING; | 3611 ia_role = ROLE_SYSTEM_GROUPING; |
3460 ia2_role_ = IA2_ROLE_HEADER; | 3612 ia2_role = IA2_ROLE_HEADER; |
3461 break; | 3613 break; |
3462 case ui::AX_ROLE_BLOCKQUOTE: | 3614 case ui::AX_ROLE_BLOCKQUOTE: |
3463 role_name_ = html_tag; | 3615 role_name = html_tag; |
3464 ia2_role_ = IA2_ROLE_SECTION; | 3616 ia2_role = IA2_ROLE_SECTION; |
3465 break; | 3617 break; |
3466 case ui::AX_ROLE_BUSY_INDICATOR: | 3618 case ui::AX_ROLE_BUSY_INDICATOR: |
3467 ia_role_ = ROLE_SYSTEM_ANIMATION; | 3619 ia_role = ROLE_SYSTEM_ANIMATION; |
3468 ia_state_ |= STATE_SYSTEM_READONLY; | 3620 ia_state |= STATE_SYSTEM_READONLY; |
3469 break; | 3621 break; |
3470 case ui::AX_ROLE_BUTTON: | 3622 case ui::AX_ROLE_BUTTON: |
3471 ia_role_ = ROLE_SYSTEM_PUSHBUTTON; | 3623 ia_role = ROLE_SYSTEM_PUSHBUTTON; |
3472 break; | 3624 break; |
3473 case ui::AX_ROLE_CANVAS: | 3625 case ui::AX_ROLE_CANVAS: |
3474 if (GetBoolAttribute(ui::AX_ATTR_CANVAS_HAS_FALLBACK)) { | 3626 if (GetBoolAttribute(ui::AX_ATTR_CANVAS_HAS_FALLBACK)) { |
3475 role_name_ = L"canvas"; | 3627 role_name = L"canvas"; |
3476 ia2_role_ = IA2_ROLE_CANVAS; | 3628 ia2_role = IA2_ROLE_CANVAS; |
3477 } else { | 3629 } else { |
3478 ia_role_ = ROLE_SYSTEM_GRAPHIC; | 3630 ia_role = ROLE_SYSTEM_GRAPHIC; |
3479 } | 3631 } |
3480 break; | 3632 break; |
3481 case ui::AX_ROLE_CAPTION: | 3633 case ui::AX_ROLE_CAPTION: |
3482 ia_role_ = ROLE_SYSTEM_TEXT; | 3634 ia_role = ROLE_SYSTEM_TEXT; |
3483 ia2_role_ = IA2_ROLE_CAPTION; | 3635 ia2_role = IA2_ROLE_CAPTION; |
3484 break; | 3636 break; |
3485 case ui::AX_ROLE_CELL: | 3637 case ui::AX_ROLE_CELL: |
3486 ia_role_ = ROLE_SYSTEM_CELL; | 3638 ia_role = ROLE_SYSTEM_CELL; |
3487 break; | 3639 break; |
3488 case ui::AX_ROLE_CHECK_BOX: | 3640 case ui::AX_ROLE_CHECK_BOX: |
3489 ia_role_ = ROLE_SYSTEM_CHECKBUTTON; | 3641 ia_role = ROLE_SYSTEM_CHECKBUTTON; |
3490 ia2_state_ |= IA2_STATE_CHECKABLE; | 3642 ia2_state |= IA2_STATE_CHECKABLE; |
3491 break; | 3643 break; |
3492 case ui::AX_ROLE_COLOR_WELL: | 3644 case ui::AX_ROLE_COLOR_WELL: |
3493 ia_role_ = ROLE_SYSTEM_TEXT; | 3645 ia_role = ROLE_SYSTEM_TEXT; |
3494 ia2_role_ = IA2_ROLE_COLOR_CHOOSER; | 3646 ia2_role = IA2_ROLE_COLOR_CHOOSER; |
3495 break; | 3647 break; |
3496 case ui::AX_ROLE_COLUMN: | 3648 case ui::AX_ROLE_COLUMN: |
3497 ia_role_ = ROLE_SYSTEM_COLUMN; | 3649 ia_role = ROLE_SYSTEM_COLUMN; |
3498 break; | 3650 break; |
3499 case ui::AX_ROLE_COLUMN_HEADER: | 3651 case ui::AX_ROLE_COLUMN_HEADER: |
3500 ia_role_ = ROLE_SYSTEM_COLUMNHEADER; | 3652 ia_role = ROLE_SYSTEM_COLUMNHEADER; |
3501 break; | 3653 break; |
3502 case ui::AX_ROLE_COMBO_BOX: | 3654 case ui::AX_ROLE_COMBO_BOX: |
3503 ia_role_ = ROLE_SYSTEM_COMBOBOX; | 3655 ia_role = ROLE_SYSTEM_COMBOBOX; |
3504 break; | 3656 break; |
3505 case ui::AX_ROLE_COMPLEMENTARY: | 3657 case ui::AX_ROLE_COMPLEMENTARY: |
3506 ia_role_ = ROLE_SYSTEM_GROUPING; | 3658 ia_role = ROLE_SYSTEM_GROUPING; |
3507 ia2_role_ = IA2_ROLE_NOTE; | 3659 ia2_role = IA2_ROLE_NOTE; |
3508 break; | 3660 break; |
3509 case ui::AX_ROLE_CONTENT_INFO: | 3661 case ui::AX_ROLE_CONTENT_INFO: |
3510 ia_role_ = ROLE_SYSTEM_TEXT; | 3662 ia_role = ROLE_SYSTEM_TEXT; |
3511 ia2_role_ = IA2_ROLE_PARAGRAPH; | 3663 ia2_role = IA2_ROLE_PARAGRAPH; |
3512 break; | 3664 break; |
3513 case ui::AX_ROLE_DATE: | 3665 case ui::AX_ROLE_DATE: |
3514 case ui::AX_ROLE_DATE_TIME: | 3666 case ui::AX_ROLE_DATE_TIME: |
3515 ia_role_ = ROLE_SYSTEM_DROPLIST; | 3667 ia_role = ROLE_SYSTEM_DROPLIST; |
3516 ia2_role_ = IA2_ROLE_DATE_EDITOR; | 3668 ia2_role = IA2_ROLE_DATE_EDITOR; |
3517 break; | 3669 break; |
3518 case ui::AX_ROLE_DIV: | 3670 case ui::AX_ROLE_DIV: |
3519 role_name_ = L"div"; | 3671 role_name = L"div"; |
3520 ia_role_ = ROLE_SYSTEM_GROUPING; | 3672 ia_role = ROLE_SYSTEM_GROUPING; |
3521 ia2_role_ = IA2_ROLE_SECTION; | 3673 ia2_role = IA2_ROLE_SECTION; |
3522 break; | 3674 break; |
3523 case ui::AX_ROLE_DEFINITION: | 3675 case ui::AX_ROLE_DEFINITION: |
3524 role_name_ = html_tag; | 3676 role_name = html_tag; |
3525 ia2_role_ = IA2_ROLE_PARAGRAPH; | 3677 ia2_role = IA2_ROLE_PARAGRAPH; |
3526 ia_state_ |= STATE_SYSTEM_READONLY; | 3678 ia_state |= STATE_SYSTEM_READONLY; |
3527 break; | 3679 break; |
3528 case ui::AX_ROLE_DESCRIPTION_LIST_DETAIL: | 3680 case ui::AX_ROLE_DESCRIPTION_LIST_DETAIL: |
3529 role_name_ = html_tag; | 3681 role_name = html_tag; |
3530 ia_role_ = ROLE_SYSTEM_TEXT; | 3682 ia_role = ROLE_SYSTEM_TEXT; |
3531 ia2_role_ = IA2_ROLE_PARAGRAPH; | 3683 ia2_role = IA2_ROLE_PARAGRAPH; |
3532 break; | 3684 break; |
3533 case ui::AX_ROLE_DESCRIPTION_LIST: | 3685 case ui::AX_ROLE_DESCRIPTION_LIST: |
3534 role_name_ = html_tag; | 3686 role_name = html_tag; |
3535 ia_role_ = ROLE_SYSTEM_LIST; | 3687 ia_role = ROLE_SYSTEM_LIST; |
3536 ia_state_ |= STATE_SYSTEM_READONLY; | 3688 ia_state |= STATE_SYSTEM_READONLY; |
3537 break; | 3689 break; |
3538 case ui::AX_ROLE_DESCRIPTION_LIST_TERM: | 3690 case ui::AX_ROLE_DESCRIPTION_LIST_TERM: |
3539 ia_role_ = ROLE_SYSTEM_LISTITEM; | 3691 ia_role = ROLE_SYSTEM_LISTITEM; |
3540 ia_state_ |= STATE_SYSTEM_READONLY; | 3692 ia_state |= STATE_SYSTEM_READONLY; |
3541 break; | 3693 break; |
3542 case ui::AX_ROLE_DETAILS: | 3694 case ui::AX_ROLE_DETAILS: |
3543 role_name_ = html_tag; | 3695 role_name = html_tag; |
3544 ia_role_ = ROLE_SYSTEM_GROUPING; | 3696 ia_role = ROLE_SYSTEM_GROUPING; |
3545 break; | 3697 break; |
3546 case ui::AX_ROLE_DIALOG: | 3698 case ui::AX_ROLE_DIALOG: |
3547 ia_role_ = ROLE_SYSTEM_DIALOG; | 3699 ia_role = ROLE_SYSTEM_DIALOG; |
3548 break; | 3700 break; |
3549 case ui::AX_ROLE_DISCLOSURE_TRIANGLE: | 3701 case ui::AX_ROLE_DISCLOSURE_TRIANGLE: |
3550 ia_role_ = ROLE_SYSTEM_PUSHBUTTON; | 3702 ia_role = ROLE_SYSTEM_PUSHBUTTON; |
3551 break; | 3703 break; |
3552 case ui::AX_ROLE_DOCUMENT: | 3704 case ui::AX_ROLE_DOCUMENT: |
3553 case ui::AX_ROLE_ROOT_WEB_AREA: | 3705 case ui::AX_ROLE_ROOT_WEB_AREA: |
3554 case ui::AX_ROLE_WEB_AREA: | 3706 case ui::AX_ROLE_WEB_AREA: |
3555 ia_role_ = ROLE_SYSTEM_DOCUMENT; | 3707 ia_role = ROLE_SYSTEM_DOCUMENT; |
3556 ia_state_ |= STATE_SYSTEM_READONLY; | 3708 ia_state |= STATE_SYSTEM_READONLY; |
3557 ia_state_ |= STATE_SYSTEM_FOCUSABLE; | 3709 ia_state |= STATE_SYSTEM_FOCUSABLE; |
3558 break; | 3710 break; |
3559 case ui::AX_ROLE_EMBEDDED_OBJECT: | 3711 case ui::AX_ROLE_EMBEDDED_OBJECT: |
3560 ia_role_ = ROLE_SYSTEM_CLIENT; | 3712 ia_role = ROLE_SYSTEM_CLIENT; |
3561 ia2_role_ = IA2_ROLE_EMBEDDED_OBJECT; | 3713 ia2_role = IA2_ROLE_EMBEDDED_OBJECT; |
3562 break; | 3714 break; |
3563 case ui::AX_ROLE_FIGCAPTION: | 3715 case ui::AX_ROLE_FIGCAPTION: |
3564 role_name_ = html_tag; | 3716 role_name = html_tag; |
3565 ia2_role_ = IA2_ROLE_CAPTION; | 3717 ia2_role = IA2_ROLE_CAPTION; |
3566 break; | 3718 break; |
3567 case ui::AX_ROLE_FIGURE: | 3719 case ui::AX_ROLE_FIGURE: |
3568 ia_role_ = ROLE_SYSTEM_GROUPING; | 3720 ia_role = ROLE_SYSTEM_GROUPING; |
3569 break; | 3721 break; |
3570 case ui::AX_ROLE_FORM: | 3722 case ui::AX_ROLE_FORM: |
3571 role_name_ = L"form"; | 3723 role_name = L"form"; |
3572 ia2_role_ = IA2_ROLE_FORM; | 3724 ia2_role = IA2_ROLE_FORM; |
3573 break; | 3725 break; |
3574 case ui::AX_ROLE_FOOTER: | 3726 case ui::AX_ROLE_FOOTER: |
3575 ia_role_ = ROLE_SYSTEM_GROUPING; | 3727 ia_role = ROLE_SYSTEM_GROUPING; |
3576 ia2_role_ = IA2_ROLE_FOOTER; | 3728 ia2_role = IA2_ROLE_FOOTER; |
3577 break; | 3729 break; |
3578 case ui::AX_ROLE_GRID: | 3730 case ui::AX_ROLE_GRID: |
3579 ia_role_ = ROLE_SYSTEM_TABLE; | 3731 ia_role = ROLE_SYSTEM_TABLE; |
3580 ia_state_ |= STATE_SYSTEM_READONLY; | 3732 ia_state |= STATE_SYSTEM_READONLY; |
3581 break; | 3733 break; |
3582 case ui::AX_ROLE_GROUP: { | 3734 case ui::AX_ROLE_GROUP: { |
3583 base::string16 aria_role = GetString16Attribute( | 3735 base::string16 aria_role = GetString16Attribute( |
3584 ui::AX_ATTR_ROLE); | 3736 ui::AX_ATTR_ROLE); |
3585 if (aria_role == L"group" || html_tag == L"fieldset") { | 3737 if (aria_role == L"group" || html_tag == L"fieldset") { |
3586 ia_role_ = ROLE_SYSTEM_GROUPING; | 3738 ia_role = ROLE_SYSTEM_GROUPING; |
3587 } else if (html_tag == L"li") { | 3739 } else if (html_tag == L"li") { |
3588 ia_role_ = ROLE_SYSTEM_LISTITEM; | 3740 ia_role = ROLE_SYSTEM_LISTITEM; |
3589 ia_state_ |= STATE_SYSTEM_READONLY; | 3741 ia_state |= STATE_SYSTEM_READONLY; |
3590 } else { | 3742 } else { |
3591 if (html_tag.empty()) | 3743 if (html_tag.empty()) |
3592 role_name_ = L"div"; | 3744 role_name = L"div"; |
3593 else | 3745 else |
3594 role_name_ = html_tag; | 3746 role_name = html_tag; |
3595 ia2_role_ = IA2_ROLE_SECTION; | 3747 ia2_role = IA2_ROLE_SECTION; |
3596 } | 3748 } |
3597 break; | 3749 break; |
3598 } | 3750 } |
3599 case ui::AX_ROLE_HEADING: | 3751 case ui::AX_ROLE_HEADING: |
3600 role_name_ = html_tag; | 3752 role_name = html_tag; |
3601 ia2_role_ = IA2_ROLE_HEADING; | 3753 ia2_role = IA2_ROLE_HEADING; |
3602 break; | 3754 break; |
3603 case ui::AX_ROLE_IFRAME: | 3755 case ui::AX_ROLE_IFRAME: |
3604 ia_role_ = ROLE_SYSTEM_DOCUMENT; | 3756 ia_role = ROLE_SYSTEM_DOCUMENT; |
3605 ia2_role_ = IA2_ROLE_INTERNAL_FRAME; | 3757 ia2_role = IA2_ROLE_INTERNAL_FRAME; |
3606 ia_state_ = STATE_SYSTEM_READONLY; | 3758 ia_state = STATE_SYSTEM_READONLY; |
3607 break; | 3759 break; |
3608 case ui::AX_ROLE_IFRAME_PRESENTATIONAL: | 3760 case ui::AX_ROLE_IFRAME_PRESENTATIONAL: |
3609 ia_role_ = ROLE_SYSTEM_GROUPING; | 3761 ia_role = ROLE_SYSTEM_GROUPING; |
3610 break; | 3762 break; |
3611 case ui::AX_ROLE_IMAGE: | 3763 case ui::AX_ROLE_IMAGE: |
3612 ia_role_ = ROLE_SYSTEM_GRAPHIC; | 3764 ia_role = ROLE_SYSTEM_GRAPHIC; |
3613 ia_state_ |= STATE_SYSTEM_READONLY; | 3765 ia_state |= STATE_SYSTEM_READONLY; |
3614 break; | 3766 break; |
3615 case ui::AX_ROLE_IMAGE_MAP: | 3767 case ui::AX_ROLE_IMAGE_MAP: |
3616 role_name_ = html_tag; | 3768 role_name = html_tag; |
3617 ia2_role_ = IA2_ROLE_IMAGE_MAP; | 3769 ia2_role = IA2_ROLE_IMAGE_MAP; |
3618 ia_state_ |= STATE_SYSTEM_READONLY; | 3770 ia_state |= STATE_SYSTEM_READONLY; |
3619 break; | 3771 break; |
3620 case ui::AX_ROLE_IMAGE_MAP_LINK: | 3772 case ui::AX_ROLE_IMAGE_MAP_LINK: |
3621 ia_role_ = ROLE_SYSTEM_LINK; | 3773 ia_role = ROLE_SYSTEM_LINK; |
3622 ia_state_ |= STATE_SYSTEM_LINKED; | 3774 ia_state |= STATE_SYSTEM_LINKED; |
3623 ia_state_ |= STATE_SYSTEM_READONLY; | 3775 ia_state |= STATE_SYSTEM_READONLY; |
3624 break; | 3776 break; |
3625 case ui::AX_ROLE_LABEL_TEXT: | 3777 case ui::AX_ROLE_LABEL_TEXT: |
3626 case ui::AX_ROLE_LEGEND: | 3778 case ui::AX_ROLE_LEGEND: |
3627 ia_role_ = ROLE_SYSTEM_TEXT; | 3779 ia_role = ROLE_SYSTEM_TEXT; |
3628 ia2_role_ = IA2_ROLE_LABEL; | 3780 ia2_role = IA2_ROLE_LABEL; |
3629 break; | 3781 break; |
3630 case ui::AX_ROLE_SEARCH: | 3782 case ui::AX_ROLE_SEARCH: |
3631 ia_role_ = ROLE_SYSTEM_GROUPING; | 3783 ia_role = ROLE_SYSTEM_GROUPING; |
3632 ia2_role_ = IA2_ROLE_SECTION; | 3784 ia2_role = IA2_ROLE_SECTION; |
3633 break; | 3785 break; |
3634 case ui::AX_ROLE_LINK: | 3786 case ui::AX_ROLE_LINK: |
3635 ia_role_ = ROLE_SYSTEM_LINK; | 3787 ia_role = ROLE_SYSTEM_LINK; |
3636 ia_state_ |= STATE_SYSTEM_LINKED; | 3788 ia_state |= STATE_SYSTEM_LINKED; |
3637 break; | 3789 break; |
3638 case ui::AX_ROLE_LIST: | 3790 case ui::AX_ROLE_LIST: |
3639 ia_role_ = ROLE_SYSTEM_LIST; | 3791 ia_role = ROLE_SYSTEM_LIST; |
3640 ia_state_ |= STATE_SYSTEM_READONLY; | 3792 ia_state |= STATE_SYSTEM_READONLY; |
3641 break; | 3793 break; |
3642 case ui::AX_ROLE_LIST_BOX: | 3794 case ui::AX_ROLE_LIST_BOX: |
3643 ia_role_ = ROLE_SYSTEM_LIST; | 3795 ia_role = ROLE_SYSTEM_LIST; |
3644 break; | 3796 break; |
3645 case ui::AX_ROLE_LIST_BOX_OPTION: | 3797 case ui::AX_ROLE_LIST_BOX_OPTION: |
3646 ia_role_ = ROLE_SYSTEM_LISTITEM; | 3798 ia_role = ROLE_SYSTEM_LISTITEM; |
3647 if (ia_state_ & STATE_SYSTEM_SELECTABLE) { | 3799 if (ia_state & STATE_SYSTEM_SELECTABLE) { |
3648 ia_state_ |= STATE_SYSTEM_FOCUSABLE; | 3800 ia_state |= STATE_SYSTEM_FOCUSABLE; |
3649 if (HasState(ui::AX_STATE_FOCUSED)) | 3801 if (HasState(ui::AX_STATE_FOCUSED)) |
3650 ia_state_ |= STATE_SYSTEM_FOCUSED; | 3802 ia_state |= STATE_SYSTEM_FOCUSED; |
3651 } | 3803 } |
3652 break; | 3804 break; |
3653 case ui::AX_ROLE_LIST_ITEM: | 3805 case ui::AX_ROLE_LIST_ITEM: |
3654 ia_role_ = ROLE_SYSTEM_LISTITEM; | 3806 ia_role = ROLE_SYSTEM_LISTITEM; |
3655 ia_state_ |= STATE_SYSTEM_READONLY; | 3807 ia_state |= STATE_SYSTEM_READONLY; |
3656 break; | 3808 break; |
3657 case ui::AX_ROLE_MAIN: | 3809 case ui::AX_ROLE_MAIN: |
3658 ia_role_ = ROLE_SYSTEM_GROUPING; | 3810 ia_role = ROLE_SYSTEM_GROUPING; |
3659 ia2_role_ = IA2_ROLE_PARAGRAPH; | 3811 ia2_role = IA2_ROLE_PARAGRAPH; |
3660 break; | 3812 break; |
3661 case ui::AX_ROLE_MARQUEE: | 3813 case ui::AX_ROLE_MARQUEE: |
3662 ia_role_ = ROLE_SYSTEM_ANIMATION; | 3814 ia_role = ROLE_SYSTEM_ANIMATION; |
3663 break; | 3815 break; |
3664 case ui::AX_ROLE_MATH: | 3816 case ui::AX_ROLE_MATH: |
3665 ia_role_ = ROLE_SYSTEM_EQUATION; | 3817 ia_role = ROLE_SYSTEM_EQUATION; |
3666 break; | 3818 break; |
3667 case ui::AX_ROLE_MENU: | 3819 case ui::AX_ROLE_MENU: |
3668 case ui::AX_ROLE_MENU_BUTTON: | 3820 case ui::AX_ROLE_MENU_BUTTON: |
3669 ia_role_ = ROLE_SYSTEM_MENUPOPUP; | 3821 ia_role = ROLE_SYSTEM_MENUPOPUP; |
3670 break; | 3822 break; |
3671 case ui::AX_ROLE_MENU_BAR: | 3823 case ui::AX_ROLE_MENU_BAR: |
3672 ia_role_ = ROLE_SYSTEM_MENUBAR; | 3824 ia_role = ROLE_SYSTEM_MENUBAR; |
3673 break; | 3825 break; |
3674 case ui::AX_ROLE_MENU_ITEM: | 3826 case ui::AX_ROLE_MENU_ITEM: |
3675 ia_role_ = ROLE_SYSTEM_MENUITEM; | 3827 ia_role = ROLE_SYSTEM_MENUITEM; |
3676 break; | 3828 break; |
3677 case ui::AX_ROLE_MENU_ITEM_CHECK_BOX: | 3829 case ui::AX_ROLE_MENU_ITEM_CHECK_BOX: |
3678 ia_role_ = ROLE_SYSTEM_MENUITEM; | 3830 ia_role = ROLE_SYSTEM_MENUITEM; |
3679 ia2_role_ = IA2_ROLE_CHECK_MENU_ITEM; | 3831 ia2_role = IA2_ROLE_CHECK_MENU_ITEM; |
3680 ia2_state_ |= IA2_STATE_CHECKABLE; | 3832 ia2_state |= IA2_STATE_CHECKABLE; |
3681 break; | 3833 break; |
3682 case ui::AX_ROLE_MENU_ITEM_RADIO: | 3834 case ui::AX_ROLE_MENU_ITEM_RADIO: |
3683 ia_role_ = ROLE_SYSTEM_MENUITEM; | 3835 ia_role = ROLE_SYSTEM_MENUITEM; |
3684 ia2_role_ = IA2_ROLE_RADIO_MENU_ITEM; | 3836 ia2_role = IA2_ROLE_RADIO_MENU_ITEM; |
3685 break; | 3837 break; |
3686 case ui::AX_ROLE_MENU_LIST_POPUP: | 3838 case ui::AX_ROLE_MENU_LIST_POPUP: |
3687 ia_role_ = ROLE_SYSTEM_CLIENT; | 3839 ia_role = ROLE_SYSTEM_CLIENT; |
3688 break; | 3840 break; |
3689 case ui::AX_ROLE_MENU_LIST_OPTION: | 3841 case ui::AX_ROLE_MENU_LIST_OPTION: |
3690 ia_role_ = ROLE_SYSTEM_LISTITEM; | 3842 ia_role = ROLE_SYSTEM_LISTITEM; |
3691 if (ia_state_ & STATE_SYSTEM_SELECTABLE) { | 3843 if (ia_state & STATE_SYSTEM_SELECTABLE) { |
3692 ia_state_ |= STATE_SYSTEM_FOCUSABLE; | 3844 ia_state |= STATE_SYSTEM_FOCUSABLE; |
3693 if (HasState(ui::AX_STATE_FOCUSED)) | 3845 if (HasState(ui::AX_STATE_FOCUSED)) |
3694 ia_state_ |= STATE_SYSTEM_FOCUSED; | 3846 ia_state |= STATE_SYSTEM_FOCUSED; |
3695 } | 3847 } |
3696 break; | 3848 break; |
3697 case ui::AX_ROLE_METER: | 3849 case ui::AX_ROLE_METER: |
3698 role_name_ = html_tag; | 3850 role_name = html_tag; |
3699 ia_role_ = ROLE_SYSTEM_PROGRESSBAR; | 3851 ia_role = ROLE_SYSTEM_PROGRESSBAR; |
3700 break; | 3852 break; |
3701 case ui::AX_ROLE_NAVIGATION: | 3853 case ui::AX_ROLE_NAVIGATION: |
3702 ia_role_ = ROLE_SYSTEM_GROUPING; | 3854 ia_role = ROLE_SYSTEM_GROUPING; |
3703 ia2_role_ = IA2_ROLE_SECTION; | 3855 ia2_role = IA2_ROLE_SECTION; |
3704 break; | 3856 break; |
3705 case ui::AX_ROLE_NOTE: | 3857 case ui::AX_ROLE_NOTE: |
3706 ia_role_ = ROLE_SYSTEM_GROUPING; | 3858 ia_role = ROLE_SYSTEM_GROUPING; |
3707 ia2_role_ = IA2_ROLE_NOTE; | 3859 ia2_role = IA2_ROLE_NOTE; |
3708 ia_state_ |= STATE_SYSTEM_READONLY; | 3860 ia_state |= STATE_SYSTEM_READONLY; |
3709 break; | 3861 break; |
3710 case ui::AX_ROLE_OUTLINE: | 3862 case ui::AX_ROLE_OUTLINE: |
3711 ia_role_ = ROLE_SYSTEM_OUTLINE; | 3863 ia_role = ROLE_SYSTEM_OUTLINE; |
3712 break; | 3864 break; |
3713 case ui::AX_ROLE_PARAGRAPH: | 3865 case ui::AX_ROLE_PARAGRAPH: |
3714 role_name_ = L"P"; | 3866 role_name = L"P"; |
3715 ia2_role_ = IA2_ROLE_PARAGRAPH; | 3867 ia2_role = IA2_ROLE_PARAGRAPH; |
3716 break; | 3868 break; |
3717 case ui::AX_ROLE_POP_UP_BUTTON: | 3869 case ui::AX_ROLE_POP_UP_BUTTON: |
3718 if (html_tag == L"select") { | 3870 if (html_tag == L"select") { |
3719 ia_role_ = ROLE_SYSTEM_COMBOBOX; | 3871 ia_role = ROLE_SYSTEM_COMBOBOX; |
3720 } else { | 3872 } else { |
3721 ia_role_ = ROLE_SYSTEM_BUTTONMENU; | 3873 ia_role = ROLE_SYSTEM_BUTTONMENU; |
3722 } | 3874 } |
3723 break; | 3875 break; |
3724 case ui::AX_ROLE_PRE: | 3876 case ui::AX_ROLE_PRE: |
3725 role_name_ = html_tag; | 3877 role_name = html_tag; |
3726 ia_role_ = ROLE_SYSTEM_TEXT; | 3878 ia_role = ROLE_SYSTEM_TEXT; |
3727 ia2_role_ = IA2_ROLE_PARAGRAPH; | 3879 ia2_role = IA2_ROLE_PARAGRAPH; |
3728 break; | 3880 break; |
3729 case ui::AX_ROLE_PROGRESS_INDICATOR: | 3881 case ui::AX_ROLE_PROGRESS_INDICATOR: |
3730 ia_role_ = ROLE_SYSTEM_PROGRESSBAR; | 3882 ia_role = ROLE_SYSTEM_PROGRESSBAR; |
3731 ia_state_ |= STATE_SYSTEM_READONLY; | 3883 ia_state |= STATE_SYSTEM_READONLY; |
3732 break; | 3884 break; |
3733 case ui::AX_ROLE_RADIO_BUTTON: | 3885 case ui::AX_ROLE_RADIO_BUTTON: |
3734 ia_role_ = ROLE_SYSTEM_RADIOBUTTON; | 3886 ia_role = ROLE_SYSTEM_RADIOBUTTON; |
3735 ia2_state_ = IA2_STATE_CHECKABLE; | 3887 ia2_state = IA2_STATE_CHECKABLE; |
3736 break; | 3888 break; |
3737 case ui::AX_ROLE_RADIO_GROUP: | 3889 case ui::AX_ROLE_RADIO_GROUP: |
3738 ia_role_ = ROLE_SYSTEM_GROUPING; | 3890 ia_role = ROLE_SYSTEM_GROUPING; |
3739 break; | 3891 break; |
3740 case ui::AX_ROLE_REGION: | 3892 case ui::AX_ROLE_REGION: |
3741 if (html_tag == L"section") { | 3893 if (html_tag == L"section") { |
3742 ia_role_ = ROLE_SYSTEM_GROUPING; | 3894 ia_role = ROLE_SYSTEM_GROUPING; |
3743 ia2_role_ = IA2_ROLE_SECTION; | 3895 ia2_role = IA2_ROLE_SECTION; |
3744 } else { | 3896 } else { |
3745 ia_role_ = ROLE_SYSTEM_PANE; | 3897 ia_role = ROLE_SYSTEM_PANE; |
3746 } | 3898 } |
3747 break; | 3899 break; |
3748 case ui::AX_ROLE_ROW: | 3900 case ui::AX_ROLE_ROW: |
3749 ia_role_ = ROLE_SYSTEM_ROW; | 3901 ia_role = ROLE_SYSTEM_ROW; |
3750 break; | 3902 break; |
3751 case ui::AX_ROLE_ROW_HEADER: | 3903 case ui::AX_ROLE_ROW_HEADER: |
3752 ia_role_ = ROLE_SYSTEM_ROWHEADER; | 3904 ia_role = ROLE_SYSTEM_ROWHEADER; |
3753 break; | 3905 break; |
3754 case ui::AX_ROLE_RUBY: | 3906 case ui::AX_ROLE_RUBY: |
3755 ia_role_ = ROLE_SYSTEM_TEXT; | 3907 ia_role = ROLE_SYSTEM_TEXT; |
3756 ia2_role_ = IA2_ROLE_TEXT_FRAME; | 3908 ia2_role = IA2_ROLE_TEXT_FRAME; |
3757 break; | 3909 break; |
3758 case ui::AX_ROLE_RULER: | 3910 case ui::AX_ROLE_RULER: |
3759 ia_role_ = ROLE_SYSTEM_CLIENT; | 3911 ia_role = ROLE_SYSTEM_CLIENT; |
3760 ia2_role_ = IA2_ROLE_RULER; | 3912 ia2_role = IA2_ROLE_RULER; |
3761 ia_state_ |= STATE_SYSTEM_READONLY; | 3913 ia_state |= STATE_SYSTEM_READONLY; |
3762 break; | 3914 break; |
3763 case ui::AX_ROLE_SCROLL_AREA: | 3915 case ui::AX_ROLE_SCROLL_AREA: |
3764 ia_role_ = ROLE_SYSTEM_CLIENT; | 3916 ia_role = ROLE_SYSTEM_CLIENT; |
3765 ia2_role_ = IA2_ROLE_SCROLL_PANE; | 3917 ia2_role = IA2_ROLE_SCROLL_PANE; |
3766 ia_state_ |= STATE_SYSTEM_READONLY; | 3918 ia_state |= STATE_SYSTEM_READONLY; |
3767 ia2_state_ &= ~(IA2_STATE_EDITABLE); | 3919 ia2_state &= ~(IA2_STATE_EDITABLE); |
3768 break; | 3920 break; |
3769 case ui::AX_ROLE_SCROLL_BAR: | 3921 case ui::AX_ROLE_SCROLL_BAR: |
3770 ia_role_ = ROLE_SYSTEM_SCROLLBAR; | 3922 ia_role = ROLE_SYSTEM_SCROLLBAR; |
3771 break; | 3923 break; |
3772 case ui::AX_ROLE_SLIDER: | 3924 case ui::AX_ROLE_SLIDER: |
3773 ia_role_ = ROLE_SYSTEM_SLIDER; | 3925 ia_role = ROLE_SYSTEM_SLIDER; |
3774 break; | 3926 break; |
3775 case ui::AX_ROLE_SPIN_BUTTON: | 3927 case ui::AX_ROLE_SPIN_BUTTON: |
3776 ia_role_ = ROLE_SYSTEM_SPINBUTTON; | 3928 ia_role = ROLE_SYSTEM_SPINBUTTON; |
3777 break; | 3929 break; |
3778 case ui::AX_ROLE_SPIN_BUTTON_PART: | 3930 case ui::AX_ROLE_SPIN_BUTTON_PART: |
3779 ia_role_ = ROLE_SYSTEM_PUSHBUTTON; | 3931 ia_role = ROLE_SYSTEM_PUSHBUTTON; |
3780 break; | 3932 break; |
3781 case ui::AX_ROLE_ANNOTATION: | 3933 case ui::AX_ROLE_ANNOTATION: |
3782 case ui::AX_ROLE_LIST_MARKER: | 3934 case ui::AX_ROLE_LIST_MARKER: |
3783 case ui::AX_ROLE_STATIC_TEXT: | 3935 case ui::AX_ROLE_STATIC_TEXT: |
3784 ia_role_ = ROLE_SYSTEM_STATICTEXT; | 3936 ia_role = ROLE_SYSTEM_STATICTEXT; |
3785 break; | 3937 break; |
3786 case ui::AX_ROLE_STATUS: | 3938 case ui::AX_ROLE_STATUS: |
3787 ia_role_ = ROLE_SYSTEM_STATUSBAR; | 3939 ia_role = ROLE_SYSTEM_STATUSBAR; |
3788 break; | 3940 break; |
3789 case ui::AX_ROLE_SPLITTER: | 3941 case ui::AX_ROLE_SPLITTER: |
3790 ia_role_ = ROLE_SYSTEM_SEPARATOR; | 3942 ia_role = ROLE_SYSTEM_SEPARATOR; |
3791 break; | 3943 break; |
3792 case ui::AX_ROLE_SVG_ROOT: | 3944 case ui::AX_ROLE_SVG_ROOT: |
3793 ia_role_ = ROLE_SYSTEM_GRAPHIC; | 3945 ia_role = ROLE_SYSTEM_GRAPHIC; |
3794 break; | 3946 break; |
3795 case ui::AX_ROLE_TAB: | 3947 case ui::AX_ROLE_TAB: |
3796 ia_role_ = ROLE_SYSTEM_PAGETAB; | 3948 ia_role = ROLE_SYSTEM_PAGETAB; |
3797 break; | 3949 break; |
3798 case ui::AX_ROLE_TABLE: { | 3950 case ui::AX_ROLE_TABLE: { |
3799 base::string16 aria_role = GetString16Attribute( | 3951 base::string16 aria_role = GetString16Attribute( |
3800 ui::AX_ATTR_ROLE); | 3952 ui::AX_ATTR_ROLE); |
3801 if (aria_role == L"treegrid") { | 3953 if (aria_role == L"treegrid") { |
3802 ia_role_ = ROLE_SYSTEM_OUTLINE; | 3954 ia_role = ROLE_SYSTEM_OUTLINE; |
3803 } else { | 3955 } else { |
3804 ia_role_ = ROLE_SYSTEM_TABLE; | 3956 ia_role = ROLE_SYSTEM_TABLE; |
3805 } | 3957 } |
3806 break; | 3958 break; |
3807 } | 3959 } |
3808 case ui::AX_ROLE_TABLE_HEADER_CONTAINER: | 3960 case ui::AX_ROLE_TABLE_HEADER_CONTAINER: |
3809 ia_role_ = ROLE_SYSTEM_GROUPING; | 3961 ia_role = ROLE_SYSTEM_GROUPING; |
3810 ia2_role_ = IA2_ROLE_SECTION; | 3962 ia2_role = IA2_ROLE_SECTION; |
3811 ia_state_ |= STATE_SYSTEM_READONLY; | 3963 ia_state |= STATE_SYSTEM_READONLY; |
3812 break; | 3964 break; |
3813 case ui::AX_ROLE_TAB_LIST: | 3965 case ui::AX_ROLE_TAB_LIST: |
3814 ia_role_ = ROLE_SYSTEM_PAGETABLIST; | 3966 ia_role = ROLE_SYSTEM_PAGETABLIST; |
3815 break; | 3967 break; |
3816 case ui::AX_ROLE_TAB_PANEL: | 3968 case ui::AX_ROLE_TAB_PANEL: |
3817 ia_role_ = ROLE_SYSTEM_PROPERTYPAGE; | 3969 ia_role = ROLE_SYSTEM_PROPERTYPAGE; |
3818 break; | 3970 break; |
3819 case ui::AX_ROLE_TOGGLE_BUTTON: | 3971 case ui::AX_ROLE_TOGGLE_BUTTON: |
3820 ia_role_ = ROLE_SYSTEM_PUSHBUTTON; | 3972 ia_role = ROLE_SYSTEM_PUSHBUTTON; |
3821 ia2_role_ = IA2_ROLE_TOGGLE_BUTTON; | 3973 ia2_role = IA2_ROLE_TOGGLE_BUTTON; |
3822 break; | 3974 break; |
3823 case ui::AX_ROLE_TEXT_AREA: | 3975 case ui::AX_ROLE_TEXT_AREA: |
3824 ia_role_ = ROLE_SYSTEM_TEXT; | 3976 ia_role = ROLE_SYSTEM_TEXT; |
3825 ia2_state_ |= IA2_STATE_MULTI_LINE; | 3977 ia2_state |= IA2_STATE_MULTI_LINE; |
3826 ia2_state_ |= IA2_STATE_EDITABLE; | 3978 ia2_state |= IA2_STATE_EDITABLE; |
3827 ia2_state_ |= IA2_STATE_SELECTABLE_TEXT; | 3979 ia2_state |= IA2_STATE_SELECTABLE_TEXT; |
3828 break; | 3980 break; |
3829 case ui::AX_ROLE_TEXT_FIELD: | 3981 case ui::AX_ROLE_TEXT_FIELD: |
3830 ia_role_ = ROLE_SYSTEM_TEXT; | 3982 ia_role = ROLE_SYSTEM_TEXT; |
3831 ia2_state_ |= IA2_STATE_SINGLE_LINE; | 3983 ia2_state |= IA2_STATE_SINGLE_LINE; |
3832 ia2_state_ |= IA2_STATE_EDITABLE; | 3984 ia2_state |= IA2_STATE_EDITABLE; |
3833 ia2_state_ |= IA2_STATE_SELECTABLE_TEXT; | 3985 ia2_state |= IA2_STATE_SELECTABLE_TEXT; |
3834 break; | 3986 break; |
3835 case ui::AX_ROLE_TIME: | 3987 case ui::AX_ROLE_TIME: |
3836 ia_role_ = ROLE_SYSTEM_SPINBUTTON; | 3988 ia_role = ROLE_SYSTEM_SPINBUTTON; |
3837 break; | 3989 break; |
3838 case ui::AX_ROLE_TIMER: | 3990 case ui::AX_ROLE_TIMER: |
3839 ia_role_ = ROLE_SYSTEM_CLOCK; | 3991 ia_role = ROLE_SYSTEM_CLOCK; |
3840 ia_state_ |= STATE_SYSTEM_READONLY; | 3992 ia_state |= STATE_SYSTEM_READONLY; |
3841 break; | 3993 break; |
3842 case ui::AX_ROLE_TOOLBAR: | 3994 case ui::AX_ROLE_TOOLBAR: |
3843 ia_role_ = ROLE_SYSTEM_TOOLBAR; | 3995 ia_role = ROLE_SYSTEM_TOOLBAR; |
3844 ia_state_ |= STATE_SYSTEM_READONLY; | 3996 ia_state |= STATE_SYSTEM_READONLY; |
3845 break; | 3997 break; |
3846 case ui::AX_ROLE_TOOLTIP: | 3998 case ui::AX_ROLE_TOOLTIP: |
3847 ia_role_ = ROLE_SYSTEM_TOOLTIP; | 3999 ia_role = ROLE_SYSTEM_TOOLTIP; |
3848 ia_state_ |= STATE_SYSTEM_READONLY; | 4000 ia_state |= STATE_SYSTEM_READONLY; |
3849 break; | 4001 break; |
3850 case ui::AX_ROLE_TREE: | 4002 case ui::AX_ROLE_TREE: |
3851 ia_role_ = ROLE_SYSTEM_OUTLINE; | 4003 ia_role = ROLE_SYSTEM_OUTLINE; |
3852 break; | 4004 break; |
3853 case ui::AX_ROLE_TREE_GRID: | 4005 case ui::AX_ROLE_TREE_GRID: |
3854 ia_role_ = ROLE_SYSTEM_OUTLINE; | 4006 ia_role = ROLE_SYSTEM_OUTLINE; |
3855 break; | 4007 break; |
3856 case ui::AX_ROLE_TREE_ITEM: | 4008 case ui::AX_ROLE_TREE_ITEM: |
3857 ia_role_ = ROLE_SYSTEM_OUTLINEITEM; | 4009 ia_role = ROLE_SYSTEM_OUTLINEITEM; |
3858 break; | 4010 break; |
3859 case ui::AX_ROLE_LINE_BREAK: | 4011 case ui::AX_ROLE_LINE_BREAK: |
3860 ia_role_ = ROLE_SYSTEM_WHITESPACE; | 4012 ia_role = ROLE_SYSTEM_WHITESPACE; |
3861 break; | 4013 break; |
3862 case ui::AX_ROLE_WINDOW: | 4014 case ui::AX_ROLE_WINDOW: |
3863 ia_role_ = ROLE_SYSTEM_WINDOW; | 4015 ia_role = ROLE_SYSTEM_WINDOW; |
3864 break; | 4016 break; |
3865 | 4017 |
3866 // TODO(dmazzoni): figure out the proper MSAA role for all of these. | 4018 // TODO(dmazzoni): figure out the proper MSAA role for all of these. |
3867 case ui::AX_ROLE_DIRECTORY: | 4019 case ui::AX_ROLE_DIRECTORY: |
3868 case ui::AX_ROLE_IGNORED: | 4020 case ui::AX_ROLE_IGNORED: |
3869 case ui::AX_ROLE_LOG: | 4021 case ui::AX_ROLE_LOG: |
3870 case ui::AX_ROLE_NONE: | 4022 case ui::AX_ROLE_NONE: |
3871 case ui::AX_ROLE_PRESENTATIONAL: | 4023 case ui::AX_ROLE_PRESENTATIONAL: |
3872 case ui::AX_ROLE_SLIDER_THUMB: | 4024 case ui::AX_ROLE_SLIDER_THUMB: |
3873 default: | 4025 default: |
3874 ia_role_ = ROLE_SYSTEM_CLIENT; | 4026 ia_role = ROLE_SYSTEM_CLIENT; |
3875 break; | 4027 break; |
3876 } | 4028 } |
3877 | 4029 |
3878 // Compute the final value of READONLY for MSAA. | 4030 // Compute the final value of READONLY for MSAA. |
3879 // | 4031 // |
3880 // We always set the READONLY state for elements that have the | 4032 // We always set the READONLY state for elements that have the |
3881 // aria-readonly attribute and for a few roles (in the switch above). | 4033 // aria-readonly attribute and for a few roles (in the switch above). |
3882 // We clear the READONLY state on focusable controls and on a document. | 4034 // We clear the READONLY state on focusable controls and on a document. |
3883 // Everything else, the majority of objects, do not have this state set. | 4035 // Everything else, the majority of objects, do not have this state set. |
3884 if (HasState(ui::AX_STATE_FOCUSABLE) && | 4036 if (HasState(ui::AX_STATE_FOCUSABLE) && |
3885 ia_role_ != ROLE_SYSTEM_DOCUMENT) { | 4037 ia_role != ROLE_SYSTEM_DOCUMENT) { |
3886 ia_state_ &= ~(STATE_SYSTEM_READONLY); | 4038 ia_state &= ~(STATE_SYSTEM_READONLY); |
3887 } | 4039 } |
3888 if (!HasState(ui::AX_STATE_READ_ONLY)) | 4040 if (!HasState(ui::AX_STATE_READ_ONLY)) |
3889 ia_state_ &= ~(STATE_SYSTEM_READONLY); | 4041 ia_state &= ~(STATE_SYSTEM_READONLY); |
3890 if (GetBoolAttribute(ui::AX_ATTR_ARIA_READONLY)) | 4042 if (GetBoolAttribute(ui::AX_ATTR_ARIA_READONLY)) |
3891 ia_state_ |= STATE_SYSTEM_READONLY; | 4043 ia_state |= STATE_SYSTEM_READONLY; |
3892 | 4044 |
3893 // The role should always be set. | 4045 // The role should always be set. |
3894 DCHECK(!role_name_.empty() || ia_role_); | 4046 DCHECK(!role_name.empty() || ia_role); |
3895 | 4047 |
3896 // If we didn't explicitly set the IAccessible2 role, make it the same | 4048 // If we didn't explicitly set the IAccessible2 role, make it the same |
3897 // as the MSAA role. | 4049 // as the MSAA role. |
3898 if (!ia2_role_) | 4050 if (!ia2_role) |
3899 ia2_role_ = ia_role_; | 4051 ia2_role = ia_role; |
4052 | |
4053 win_attributes_->ia_role = ia_role; | |
4054 win_attributes_->ia_state = ia_state; | |
4055 win_attributes_->role_name = role_name; | |
4056 win_attributes_->ia2_role = ia2_role; | |
4057 win_attributes_->ia2_state = ia2_state; | |
3900 } | 4058 } |
3901 | 4059 |
3902 } // namespace content | 4060 } // namespace content |
OLD | NEW |