Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(289)

Side by Side Diff: content/browser/accessibility/browser_accessibility_win.cc

Issue 224803005: Refactor BrowserAccessibility to prepare for AXNode (re-land) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix gtk Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 return S_OK; 486 return S_OK;
487 } 487 }
488 488
489 STDMETHODIMP BrowserAccessibilityWin::get_accParent(IDispatch** disp_parent) { 489 STDMETHODIMP BrowserAccessibilityWin::get_accParent(IDispatch** disp_parent) {
490 if (!instance_active()) 490 if (!instance_active())
491 return E_FAIL; 491 return E_FAIL;
492 492
493 if (!disp_parent) 493 if (!disp_parent)
494 return E_INVALIDARG; 494 return E_INVALIDARG;
495 495
496 IAccessible* parent_obj = parent()->ToBrowserAccessibilityWin(); 496 IAccessible* parent_obj = GetParent()->ToBrowserAccessibilityWin();
497 if (parent_obj == NULL) { 497 if (parent_obj == NULL) {
498 // This happens if we're the root of the tree; 498 // This happens if we're the root of the tree;
499 // return the IAccessible for the window. 499 // return the IAccessible for the window.
500 parent_obj = 500 parent_obj =
501 manager()->ToBrowserAccessibilityManagerWin()->parent_iaccessible(); 501 manager()->ToBrowserAccessibilityManagerWin()->parent_iaccessible();
502 // |parent| can only be NULL if the manager was created before the parent 502 // |parent| can only be NULL if the manager was created before the parent
503 // IAccessible was known and it wasn't subsequently set before a client 503 // IAccessible was known and it wasn't subsequently set before a client
504 // requested it. This has been fixed. |parent| may also be NULL during 504 // requested it. This has been fixed. |parent| may also be NULL during
505 // destruction. Possible cases where this could occur include tabs being 505 // destruction. Possible cases where this could occur include tabs being
506 // dragged to a new window, etc. 506 // dragged to a new window, etc.
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 STDMETHODIMP BrowserAccessibilityWin::get_accHelpTopic(BSTR* help_file, 604 STDMETHODIMP BrowserAccessibilityWin::get_accHelpTopic(BSTR* help_file,
605 VARIANT var_id, 605 VARIANT var_id,
606 LONG* topic_id) { 606 LONG* topic_id) {
607 return E_NOTIMPL; 607 return E_NOTIMPL;
608 } 608 }
609 609
610 STDMETHODIMP BrowserAccessibilityWin::get_accSelection(VARIANT* selected) { 610 STDMETHODIMP BrowserAccessibilityWin::get_accSelection(VARIANT* selected) {
611 if (!instance_active()) 611 if (!instance_active())
612 return E_FAIL; 612 return E_FAIL;
613 613
614 if (blink_role() != ui::AX_ROLE_LIST_BOX) 614 if (GetRole() != ui::AX_ROLE_LIST_BOX)
615 return E_NOTIMPL; 615 return E_NOTIMPL;
616 616
617 unsigned long selected_count = 0; 617 unsigned long selected_count = 0;
618 for (size_t i = 0; i < children().size(); ++i) { 618 for (size_t i = 0; i < InternalChildCount(); ++i) {
619 if (children()[i]->HasState(ui::AX_STATE_SELECTED)) 619 if (InternalGetChild(i)->HasState(ui::AX_STATE_SELECTED))
620 ++selected_count; 620 ++selected_count;
621 } 621 }
622 622
623 if (selected_count == 0) { 623 if (selected_count == 0) {
624 selected->vt = VT_EMPTY; 624 selected->vt = VT_EMPTY;
625 return S_OK; 625 return S_OK;
626 } 626 }
627 627
628 if (selected_count == 1) { 628 if (selected_count == 1) {
629 for (size_t i = 0; i < children().size(); ++i) { 629 for (size_t i = 0; i < InternalChildCount(); ++i) {
630 if (children()[i]->HasState(ui::AX_STATE_SELECTED)) { 630 if (InternalGetChild(i)->HasState(ui::AX_STATE_SELECTED)) {
631 selected->vt = VT_DISPATCH; 631 selected->vt = VT_DISPATCH;
632 selected->pdispVal = 632 selected->pdispVal =
633 children()[i]->ToBrowserAccessibilityWin()->NewReference(); 633 InternalGetChild(i)->ToBrowserAccessibilityWin()->NewReference();
634 return S_OK; 634 return S_OK;
635 } 635 }
636 } 636 }
637 } 637 }
638 638
639 // Multiple items are selected. 639 // Multiple items are selected.
640 base::win::EnumVariant* enum_variant = 640 base::win::EnumVariant* enum_variant =
641 new base::win::EnumVariant(selected_count); 641 new base::win::EnumVariant(selected_count);
642 enum_variant->AddRef(); 642 enum_variant->AddRef();
643 unsigned long index = 0; 643 unsigned long index = 0;
644 for (size_t i = 0; i < children().size(); ++i) { 644 for (size_t i = 0; i < InternalChildCount(); ++i) {
645 if (children()[i]->HasState(ui::AX_STATE_SELECTED)) { 645 if (InternalGetChild(i)->HasState(ui::AX_STATE_SELECTED)) {
646 enum_variant->ItemAt(index)->vt = VT_DISPATCH; 646 enum_variant->ItemAt(index)->vt = VT_DISPATCH;
647 enum_variant->ItemAt(index)->pdispVal = 647 enum_variant->ItemAt(index)->pdispVal =
648 children()[i]->ToBrowserAccessibilityWin()->NewReference(); 648 InternalGetChild(i)->ToBrowserAccessibilityWin()->NewReference();
649 ++index; 649 ++index;
650 } 650 }
651 } 651 }
652 selected->vt = VT_UNKNOWN; 652 selected->vt = VT_UNKNOWN;
653 selected->punkVal = static_cast<IUnknown*>( 653 selected->punkVal = static_cast<IUnknown*>(
654 static_cast<base::win::IUnknownImpl*>(enum_variant)); 654 static_cast<base::win::IUnknownImpl*>(enum_variant));
655 return S_OK; 655 return S_OK;
656 } 656 }
657 657
658 STDMETHODIMP BrowserAccessibilityWin::accSelect( 658 STDMETHODIMP BrowserAccessibilityWin::accSelect(
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 return S_OK; 742 return S_OK;
743 } 743 }
744 744
745 STDMETHODIMP BrowserAccessibilityWin::get_indexInParent(LONG* index_in_parent) { 745 STDMETHODIMP BrowserAccessibilityWin::get_indexInParent(LONG* index_in_parent) {
746 if (!instance_active()) 746 if (!instance_active())
747 return E_FAIL; 747 return E_FAIL;
748 748
749 if (!index_in_parent) 749 if (!index_in_parent)
750 return E_INVALIDARG; 750 return E_INVALIDARG;
751 751
752 *index_in_parent = this->index_in_parent(); 752 *index_in_parent = this->GetIndexInParent();
753 return S_OK; 753 return S_OK;
754 } 754 }
755 755
756 STDMETHODIMP BrowserAccessibilityWin::get_nRelations(LONG* n_relations) { 756 STDMETHODIMP BrowserAccessibilityWin::get_nRelations(LONG* n_relations) {
757 if (!instance_active()) 757 if (!instance_active())
758 return E_FAIL; 758 return E_FAIL;
759 759
760 if (!n_relations) 760 if (!n_relations)
761 return E_INVALIDARG; 761 return E_INVALIDARG;
762 762
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
803 relations[i] = relations_[i]; 803 relations[i] = relations_[i];
804 } 804 }
805 805
806 return S_OK; 806 return S_OK;
807 } 807 }
808 808
809 STDMETHODIMP BrowserAccessibilityWin::scrollTo(enum IA2ScrollType scroll_type) { 809 STDMETHODIMP BrowserAccessibilityWin::scrollTo(enum IA2ScrollType scroll_type) {
810 if (!instance_active()) 810 if (!instance_active())
811 return E_FAIL; 811 return E_FAIL;
812 812
813 gfx::Rect r = location(); 813 gfx::Rect r = GetLocation();
814 switch(scroll_type) { 814 switch(scroll_type) {
815 case IA2_SCROLL_TYPE_TOP_LEFT: 815 case IA2_SCROLL_TYPE_TOP_LEFT:
816 manager()->ScrollToMakeVisible(*this, gfx::Rect(r.x(), r.y(), 0, 0)); 816 manager()->ScrollToMakeVisible(*this, gfx::Rect(r.x(), r.y(), 0, 0));
817 break; 817 break;
818 case IA2_SCROLL_TYPE_BOTTOM_RIGHT: 818 case IA2_SCROLL_TYPE_BOTTOM_RIGHT:
819 manager()->ScrollToMakeVisible( 819 manager()->ScrollToMakeVisible(
820 *this, gfx::Rect(r.right(), r.bottom(), 0, 0)); 820 *this, gfx::Rect(r.right(), r.bottom(), 0, 0));
821 break; 821 break;
822 case IA2_SCROLL_TYPE_TOP_EDGE: 822 case IA2_SCROLL_TYPE_TOP_EDGE:
823 manager()->ScrollToMakeVisible( 823 manager()->ScrollToMakeVisible(
(...skipping 27 matching lines...) Expand all
851 LONG x, 851 LONG x,
852 LONG y) { 852 LONG y) {
853 if (!instance_active()) 853 if (!instance_active())
854 return E_FAIL; 854 return E_FAIL;
855 855
856 gfx::Point scroll_to(x, y); 856 gfx::Point scroll_to(x, y);
857 857
858 if (coordinate_type == IA2_COORDTYPE_SCREEN_RELATIVE) { 858 if (coordinate_type == IA2_COORDTYPE_SCREEN_RELATIVE) {
859 scroll_to -= manager()->GetViewBounds().OffsetFromOrigin(); 859 scroll_to -= manager()->GetViewBounds().OffsetFromOrigin();
860 } else if (coordinate_type == IA2_COORDTYPE_PARENT_RELATIVE) { 860 } else if (coordinate_type == IA2_COORDTYPE_PARENT_RELATIVE) {
861 if (parent()) 861 if (GetParent())
862 scroll_to += parent()->location().OffsetFromOrigin(); 862 scroll_to += GetParent()->GetLocation().OffsetFromOrigin();
863 } else { 863 } else {
864 return E_INVALIDARG; 864 return E_INVALIDARG;
865 } 865 }
866 866
867 manager()->ScrollToPoint(*this, scroll_to); 867 manager()->ScrollToPoint(*this, scroll_to);
868 manager()->ToBrowserAccessibilityManagerWin()->TrackScrollingObject(this); 868 manager()->ToBrowserAccessibilityManagerWin()->TrackScrollingObject(this);
869 869
870 return S_OK; 870 return S_OK;
871 } 871 }
872 872
873 STDMETHODIMP BrowserAccessibilityWin::get_groupPosition( 873 STDMETHODIMP BrowserAccessibilityWin::get_groupPosition(
874 LONG* group_level, 874 LONG* group_level,
875 LONG* similar_items_in_group, 875 LONG* similar_items_in_group,
876 LONG* position_in_group) { 876 LONG* position_in_group) {
877 if (!instance_active()) 877 if (!instance_active())
878 return E_FAIL; 878 return E_FAIL;
879 879
880 if (!group_level || !similar_items_in_group || !position_in_group) 880 if (!group_level || !similar_items_in_group || !position_in_group)
881 return E_INVALIDARG; 881 return E_INVALIDARG;
882 882
883 if (blink_role() == ui::AX_ROLE_LIST_BOX_OPTION && 883 if (GetRole() == ui::AX_ROLE_LIST_BOX_OPTION &&
884 parent() && 884 GetParent() &&
885 parent()->role() == ui::AX_ROLE_LIST_BOX) { 885 GetParent()->GetRole() == ui::AX_ROLE_LIST_BOX) {
886 *group_level = 0; 886 *group_level = 0;
887 *similar_items_in_group = parent()->PlatformChildCount(); 887 *similar_items_in_group = GetParent()->PlatformChildCount();
888 *position_in_group = index_in_parent() + 1; 888 *position_in_group = GetIndexInParent() + 1;
889 return S_OK; 889 return S_OK;
890 } 890 }
891 891
892 return E_NOTIMPL; 892 return E_NOTIMPL;
893 } 893 }
894 894
895 // 895 //
896 // IAccessibleApplication methods. 896 // IAccessibleApplication methods.
897 // 897 //
898 898
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
987 return E_FAIL; 987 return E_FAIL;
988 988
989 if (!x || !y) 989 if (!x || !y)
990 return E_INVALIDARG; 990 return E_INVALIDARG;
991 991
992 if (coordinate_type == IA2_COORDTYPE_SCREEN_RELATIVE) { 992 if (coordinate_type == IA2_COORDTYPE_SCREEN_RELATIVE) {
993 HWND parent_hwnd = 993 HWND parent_hwnd =
994 manager()->ToBrowserAccessibilityManagerWin()->parent_hwnd(); 994 manager()->ToBrowserAccessibilityManagerWin()->parent_hwnd();
995 POINT top_left = {0, 0}; 995 POINT top_left = {0, 0};
996 ::ClientToScreen(parent_hwnd, &top_left); 996 ::ClientToScreen(parent_hwnd, &top_left);
997 *x = location().x() + top_left.x; 997 *x = GetLocation().x() + top_left.x;
998 *y = location().y() + top_left.y; 998 *y = GetLocation().y() + top_left.y;
999 } else if (coordinate_type == IA2_COORDTYPE_PARENT_RELATIVE) { 999 } else if (coordinate_type == IA2_COORDTYPE_PARENT_RELATIVE) {
1000 *x = location().x(); 1000 *x = GetLocation().x();
1001 *y = location().y(); 1001 *y = GetLocation().y();
1002 if (parent()) { 1002 if (GetParent()) {
1003 *x -= parent()->location().x(); 1003 *x -= GetParent()->GetLocation().x();
1004 *y -= parent()->location().y(); 1004 *y -= GetParent()->GetLocation().y();
1005 } 1005 }
1006 } else { 1006 } else {
1007 return E_INVALIDARG; 1007 return E_INVALIDARG;
1008 } 1008 }
1009 1009
1010 return S_OK; 1010 return S_OK;
1011 } 1011 }
1012 1012
1013 STDMETHODIMP BrowserAccessibilityWin::get_imageSize(LONG* height, LONG* width) { 1013 STDMETHODIMP BrowserAccessibilityWin::get_imageSize(LONG* height, LONG* width) {
1014 if (!instance_active()) 1014 if (!instance_active())
1015 return E_FAIL; 1015 return E_FAIL;
1016 1016
1017 if (!height || !width) 1017 if (!height || !width)
1018 return E_INVALIDARG; 1018 return E_INVALIDARG;
1019 1019
1020 *height = location().height(); 1020 *height = GetLocation().height();
1021 *width = location().width(); 1021 *width = GetLocation().width();
1022 return S_OK; 1022 return S_OK;
1023 } 1023 }
1024 1024
1025 // 1025 //
1026 // IAccessibleTable methods. 1026 // IAccessibleTable methods.
1027 // 1027 //
1028 1028
1029 STDMETHODIMP BrowserAccessibilityWin::get_accessibleAt( 1029 STDMETHODIMP BrowserAccessibilityWin::get_accessibleAt(
1030 long row, 1030 long row,
1031 long column, 1031 long column,
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1135 1135
1136 if (column < 0 || column >= columns) 1136 if (column < 0 || column >= columns)
1137 return E_INVALIDARG; 1137 return E_INVALIDARG;
1138 1138
1139 const std::vector<int32>& cell_ids = GetIntListAttribute( 1139 const std::vector<int32>& cell_ids = GetIntListAttribute(
1140 ui::AX_ATTR_CELL_IDS); 1140 ui::AX_ATTR_CELL_IDS);
1141 for (int i = 0; i < rows; ++i) { 1141 for (int i = 0; i < rows; ++i) {
1142 int cell_id = cell_ids[i * columns + column]; 1142 int cell_id = cell_ids[i * columns + column];
1143 BrowserAccessibilityWin* cell = static_cast<BrowserAccessibilityWin*>( 1143 BrowserAccessibilityWin* cell = static_cast<BrowserAccessibilityWin*>(
1144 manager()->GetFromRendererID(cell_id)); 1144 manager()->GetFromRendererID(cell_id));
1145 if (cell && cell->blink_role() == ui::AX_ROLE_COLUMN_HEADER) { 1145 if (cell && cell->GetRole() == ui::AX_ROLE_COLUMN_HEADER) {
1146 base::string16 cell_name = cell->GetString16Attribute( 1146 base::string16 cell_name = cell->GetString16Attribute(
1147 ui::AX_ATTR_NAME); 1147 ui::AX_ATTR_NAME);
1148 if (cell_name.size() > 0) { 1148 if (cell_name.size() > 0) {
1149 *description = SysAllocString(cell_name.c_str()); 1149 *description = SysAllocString(cell_name.c_str());
1150 return S_OK; 1150 return S_OK;
1151 } 1151 }
1152 1152
1153 return cell->GetStringAttributeAsBstr( 1153 return cell->GetStringAttributeAsBstr(
1154 ui::AX_ATTR_DESCRIPTION, description); 1154 ui::AX_ATTR_DESCRIPTION, description);
1155 } 1155 }
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
1322 1322
1323 if (row < 0 || row >= rows) 1323 if (row < 0 || row >= rows)
1324 return E_INVALIDARG; 1324 return E_INVALIDARG;
1325 1325
1326 const std::vector<int32>& cell_ids = GetIntListAttribute( 1326 const std::vector<int32>& cell_ids = GetIntListAttribute(
1327 ui::AX_ATTR_CELL_IDS); 1327 ui::AX_ATTR_CELL_IDS);
1328 for (int i = 0; i < columns; ++i) { 1328 for (int i = 0; i < columns; ++i) {
1329 int cell_id = cell_ids[row * columns + i]; 1329 int cell_id = cell_ids[row * columns + i];
1330 BrowserAccessibilityWin* cell = 1330 BrowserAccessibilityWin* cell =
1331 manager()->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin(); 1331 manager()->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin();
1332 if (cell && cell->blink_role() == ui::AX_ROLE_ROW_HEADER) { 1332 if (cell && cell->GetRole() == ui::AX_ROLE_ROW_HEADER) {
1333 base::string16 cell_name = cell->GetString16Attribute( 1333 base::string16 cell_name = cell->GetString16Attribute(
1334 ui::AX_ATTR_NAME); 1334 ui::AX_ATTR_NAME);
1335 if (cell_name.size() > 0) { 1335 if (cell_name.size() > 0) {
1336 *description = SysAllocString(cell_name.c_str()); 1336 *description = SysAllocString(cell_name.c_str());
1337 return S_OK; 1337 return S_OK;
1338 } 1338 }
1339 1339
1340 return cell->GetStringAttributeAsBstr( 1340 return cell->GetStringAttributeAsBstr(
1341 ui::AX_ATTR_DESCRIPTION, description); 1341 ui::AX_ATTR_DESCRIPTION, description);
1342 } 1342 }
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
1644 return E_INVALIDARG; 1644 return E_INVALIDARG;
1645 1645
1646 *n_column_header_cells = 0; 1646 *n_column_header_cells = 0;
1647 1647
1648 int column; 1648 int column;
1649 if (!GetIntAttribute( 1649 if (!GetIntAttribute(
1650 ui::AX_ATTR_TABLE_CELL_COLUMN_INDEX, &column)) { 1650 ui::AX_ATTR_TABLE_CELL_COLUMN_INDEX, &column)) {
1651 return S_FALSE; 1651 return S_FALSE;
1652 } 1652 }
1653 1653
1654 BrowserAccessibility* table = parent(); 1654 BrowserAccessibility* table = GetParent();
1655 while (table && table->role() != ui::AX_ROLE_TABLE) 1655 while (table && table->GetRole() != ui::AX_ROLE_TABLE)
1656 table = table->parent(); 1656 table = table->GetParent();
1657 if (!table) { 1657 if (!table) {
1658 NOTREACHED(); 1658 NOTREACHED();
1659 return S_FALSE; 1659 return S_FALSE;
1660 } 1660 }
1661 1661
1662 int columns; 1662 int columns;
1663 int rows; 1663 int rows;
1664 if (!table->GetIntAttribute( 1664 if (!table->GetIntAttribute(
1665 ui::AX_ATTR_TABLE_COLUMN_COUNT, &columns) || 1665 ui::AX_ATTR_TABLE_COLUMN_COUNT, &columns) ||
1666 !table->GetIntAttribute( 1666 !table->GetIntAttribute(
1667 ui::AX_ATTR_TABLE_ROW_COUNT, &rows)) { 1667 ui::AX_ATTR_TABLE_ROW_COUNT, &rows)) {
1668 return S_FALSE; 1668 return S_FALSE;
1669 } 1669 }
1670 if (columns <= 0 || rows <= 0 || column < 0 || column >= columns) 1670 if (columns <= 0 || rows <= 0 || column < 0 || column >= columns)
1671 return S_FALSE; 1671 return S_FALSE;
1672 1672
1673 const std::vector<int32>& cell_ids = table->GetIntListAttribute( 1673 const std::vector<int32>& cell_ids = table->GetIntListAttribute(
1674 ui::AX_ATTR_CELL_IDS); 1674 ui::AX_ATTR_CELL_IDS);
1675 1675
1676 for (int i = 0; i < rows; ++i) { 1676 for (int i = 0; i < rows; ++i) {
1677 int cell_id = cell_ids[i * columns + column]; 1677 int cell_id = cell_ids[i * columns + column];
1678 BrowserAccessibilityWin* cell = 1678 BrowserAccessibilityWin* cell =
1679 manager()->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin(); 1679 manager()->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin();
1680 if (cell && cell->blink_role() == ui::AX_ROLE_COLUMN_HEADER) 1680 if (cell && cell->GetRole() == ui::AX_ROLE_COLUMN_HEADER)
1681 (*n_column_header_cells)++; 1681 (*n_column_header_cells)++;
1682 } 1682 }
1683 1683
1684 *cell_accessibles = static_cast<IUnknown**>(CoTaskMemAlloc( 1684 *cell_accessibles = static_cast<IUnknown**>(CoTaskMemAlloc(
1685 (*n_column_header_cells) * sizeof(cell_accessibles[0]))); 1685 (*n_column_header_cells) * sizeof(cell_accessibles[0])));
1686 int index = 0; 1686 int index = 0;
1687 for (int i = 0; i < rows; ++i) { 1687 for (int i = 0; i < rows; ++i) {
1688 int cell_id = cell_ids[i * columns + column]; 1688 int cell_id = cell_ids[i * columns + column];
1689 BrowserAccessibility* cell = manager()->GetFromRendererID(cell_id); 1689 BrowserAccessibility* cell = manager()->GetFromRendererID(cell_id);
1690 if (cell && cell->role() == ui::AX_ROLE_COLUMN_HEADER) { 1690 if (cell && cell->GetRole() == ui::AX_ROLE_COLUMN_HEADER) {
1691 (*cell_accessibles)[index] = static_cast<IAccessible*>( 1691 (*cell_accessibles)[index] = static_cast<IAccessible*>(
1692 cell->ToBrowserAccessibilityWin()->NewReference()); 1692 cell->ToBrowserAccessibilityWin()->NewReference());
1693 ++index; 1693 ++index;
1694 } 1694 }
1695 } 1695 }
1696 1696
1697 return S_OK; 1697 return S_OK;
1698 } 1698 }
1699 1699
1700 STDMETHODIMP BrowserAccessibilityWin::get_columnIndex(long* column_index) { 1700 STDMETHODIMP BrowserAccessibilityWin::get_columnIndex(long* column_index) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1742 return E_INVALIDARG; 1742 return E_INVALIDARG;
1743 1743
1744 *n_row_header_cells = 0; 1744 *n_row_header_cells = 0;
1745 1745
1746 int row; 1746 int row;
1747 if (!GetIntAttribute( 1747 if (!GetIntAttribute(
1748 ui::AX_ATTR_TABLE_CELL_ROW_INDEX, &row)) { 1748 ui::AX_ATTR_TABLE_CELL_ROW_INDEX, &row)) {
1749 return S_FALSE; 1749 return S_FALSE;
1750 } 1750 }
1751 1751
1752 BrowserAccessibility* table = parent(); 1752 BrowserAccessibility* table = GetParent();
1753 while (table && table->role() != ui::AX_ROLE_TABLE) 1753 while (table && table->GetRole() != ui::AX_ROLE_TABLE)
1754 table = table->parent(); 1754 table = table->GetParent();
1755 if (!table) { 1755 if (!table) {
1756 NOTREACHED(); 1756 NOTREACHED();
1757 return S_FALSE; 1757 return S_FALSE;
1758 } 1758 }
1759 1759
1760 int columns; 1760 int columns;
1761 int rows; 1761 int rows;
1762 if (!table->GetIntAttribute( 1762 if (!table->GetIntAttribute(
1763 ui::AX_ATTR_TABLE_COLUMN_COUNT, &columns) || 1763 ui::AX_ATTR_TABLE_COLUMN_COUNT, &columns) ||
1764 !table->GetIntAttribute( 1764 !table->GetIntAttribute(
1765 ui::AX_ATTR_TABLE_ROW_COUNT, &rows)) { 1765 ui::AX_ATTR_TABLE_ROW_COUNT, &rows)) {
1766 return S_FALSE; 1766 return S_FALSE;
1767 } 1767 }
1768 if (columns <= 0 || rows <= 0 || row < 0 || row >= rows) 1768 if (columns <= 0 || rows <= 0 || row < 0 || row >= rows)
1769 return S_FALSE; 1769 return S_FALSE;
1770 1770
1771 const std::vector<int32>& cell_ids = table->GetIntListAttribute( 1771 const std::vector<int32>& cell_ids = table->GetIntListAttribute(
1772 ui::AX_ATTR_CELL_IDS); 1772 ui::AX_ATTR_CELL_IDS);
1773 1773
1774 for (int i = 0; i < columns; ++i) { 1774 for (int i = 0; i < columns; ++i) {
1775 int cell_id = cell_ids[row * columns + i]; 1775 int cell_id = cell_ids[row * columns + i];
1776 BrowserAccessibility* cell = manager()->GetFromRendererID(cell_id); 1776 BrowserAccessibility* cell = manager()->GetFromRendererID(cell_id);
1777 if (cell && cell->role() == ui::AX_ROLE_ROW_HEADER) 1777 if (cell && cell->GetRole() == ui::AX_ROLE_ROW_HEADER)
1778 (*n_row_header_cells)++; 1778 (*n_row_header_cells)++;
1779 } 1779 }
1780 1780
1781 *cell_accessibles = static_cast<IUnknown**>(CoTaskMemAlloc( 1781 *cell_accessibles = static_cast<IUnknown**>(CoTaskMemAlloc(
1782 (*n_row_header_cells) * sizeof(cell_accessibles[0]))); 1782 (*n_row_header_cells) * sizeof(cell_accessibles[0])));
1783 int index = 0; 1783 int index = 0;
1784 for (int i = 0; i < columns; ++i) { 1784 for (int i = 0; i < columns; ++i) {
1785 int cell_id = cell_ids[row * columns + i]; 1785 int cell_id = cell_ids[row * columns + i];
1786 BrowserAccessibility* cell = manager()->GetFromRendererID(cell_id); 1786 BrowserAccessibility* cell = manager()->GetFromRendererID(cell_id);
1787 if (cell && cell->role() == ui::AX_ROLE_ROW_HEADER) { 1787 if (cell && cell->GetRole() == ui::AX_ROLE_ROW_HEADER) {
1788 (*cell_accessibles)[index] = static_cast<IAccessible*>( 1788 (*cell_accessibles)[index] = static_cast<IAccessible*>(
1789 cell->ToBrowserAccessibilityWin()->NewReference()); 1789 cell->ToBrowserAccessibilityWin()->NewReference());
1790 ++index; 1790 ++index;
1791 } 1791 }
1792 } 1792 }
1793 1793
1794 return S_OK; 1794 return S_OK;
1795 } 1795 }
1796 1796
1797 STDMETHODIMP BrowserAccessibilityWin::get_rowIndex(long* row_index) { 1797 STDMETHODIMP BrowserAccessibilityWin::get_rowIndex(long* row_index) {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1865 1865
1866 if (!table) 1866 if (!table)
1867 return E_INVALIDARG; 1867 return E_INVALIDARG;
1868 1868
1869 1869
1870 int row; 1870 int row;
1871 int column; 1871 int column;
1872 GetIntAttribute(ui::AX_ATTR_TABLE_CELL_ROW_INDEX, &row); 1872 GetIntAttribute(ui::AX_ATTR_TABLE_CELL_ROW_INDEX, &row);
1873 GetIntAttribute(ui::AX_ATTR_TABLE_CELL_COLUMN_INDEX, &column); 1873 GetIntAttribute(ui::AX_ATTR_TABLE_CELL_COLUMN_INDEX, &column);
1874 1874
1875 BrowserAccessibility* find_table = parent(); 1875 BrowserAccessibility* find_table = GetParent();
1876 while (find_table && find_table->role() != ui::AX_ROLE_TABLE) 1876 while (find_table && find_table->GetRole() != ui::AX_ROLE_TABLE)
1877 find_table = find_table->parent(); 1877 find_table = find_table->GetParent();
1878 if (!find_table) { 1878 if (!find_table) {
1879 NOTREACHED(); 1879 NOTREACHED();
1880 return S_FALSE; 1880 return S_FALSE;
1881 } 1881 }
1882 1882
1883 *table = static_cast<IAccessibleTable*>( 1883 *table = static_cast<IAccessibleTable*>(
1884 find_table->ToBrowserAccessibilityWin()->NewReference()); 1884 find_table->ToBrowserAccessibilityWin()->NewReference());
1885 1885
1886 return S_OK; 1886 return S_OK;
1887 } 1887 }
(...skipping 14 matching lines...) Expand all
1902 } 1902 }
1903 1903
1904 STDMETHODIMP BrowserAccessibilityWin::get_caretOffset(LONG* offset) { 1904 STDMETHODIMP BrowserAccessibilityWin::get_caretOffset(LONG* offset) {
1905 if (!instance_active()) 1905 if (!instance_active())
1906 return E_FAIL; 1906 return E_FAIL;
1907 1907
1908 if (!offset) 1908 if (!offset)
1909 return E_INVALIDARG; 1909 return E_INVALIDARG;
1910 1910
1911 *offset = 0; 1911 *offset = 0;
1912 if (blink_role() == ui::AX_ROLE_TEXT_FIELD || 1912 if (GetRole() == ui::AX_ROLE_TEXT_FIELD ||
1913 blink_role() == ui::AX_ROLE_TEXT_AREA) { 1913 GetRole() == ui::AX_ROLE_TEXT_AREA) {
1914 int sel_start = 0; 1914 int sel_start = 0;
1915 if (GetIntAttribute(ui::AX_ATTR_TEXT_SEL_START, 1915 if (GetIntAttribute(ui::AX_ATTR_TEXT_SEL_START,
1916 &sel_start)) 1916 &sel_start))
1917 *offset = sel_start; 1917 *offset = sel_start;
1918 } 1918 }
1919 1919
1920 return S_OK; 1920 return S_OK;
1921 } 1921 }
1922 1922
1923 STDMETHODIMP BrowserAccessibilityWin::get_characterExtents( 1923 STDMETHODIMP BrowserAccessibilityWin::get_characterExtents(
(...skipping 13 matching lines...) Expand all
1937 HandleSpecialTextOffset(text_str, &offset); 1937 HandleSpecialTextOffset(text_str, &offset);
1938 1938
1939 if (offset < 0 || offset > static_cast<LONG>(text_str.size())) 1939 if (offset < 0 || offset > static_cast<LONG>(text_str.size()))
1940 return E_INVALIDARG; 1940 return E_INVALIDARG;
1941 1941
1942 gfx::Rect character_bounds; 1942 gfx::Rect character_bounds;
1943 if (coordinate_type == IA2_COORDTYPE_SCREEN_RELATIVE) { 1943 if (coordinate_type == IA2_COORDTYPE_SCREEN_RELATIVE) {
1944 character_bounds = GetGlobalBoundsForRange(offset, 1); 1944 character_bounds = GetGlobalBoundsForRange(offset, 1);
1945 } else if (coordinate_type == IA2_COORDTYPE_PARENT_RELATIVE) { 1945 } else if (coordinate_type == IA2_COORDTYPE_PARENT_RELATIVE) {
1946 character_bounds = GetLocalBoundsForRange(offset, 1); 1946 character_bounds = GetLocalBoundsForRange(offset, 1);
1947 character_bounds -= location().OffsetFromOrigin(); 1947 character_bounds -= GetLocation().OffsetFromOrigin();
1948 } else { 1948 } else {
1949 return E_INVALIDARG; 1949 return E_INVALIDARG;
1950 } 1950 }
1951 1951
1952 *out_x = character_bounds.x(); 1952 *out_x = character_bounds.x();
1953 *out_y = character_bounds.y(); 1953 *out_y = character_bounds.y();
1954 *out_width = character_bounds.width(); 1954 *out_width = character_bounds.width();
1955 *out_height = character_bounds.height(); 1955 *out_height = character_bounds.height();
1956 1956
1957 return S_OK; 1957 return S_OK;
1958 } 1958 }
1959 1959
1960 STDMETHODIMP BrowserAccessibilityWin::get_nSelections(LONG* n_selections) { 1960 STDMETHODIMP BrowserAccessibilityWin::get_nSelections(LONG* n_selections) {
1961 if (!instance_active()) 1961 if (!instance_active())
1962 return E_FAIL; 1962 return E_FAIL;
1963 1963
1964 if (!n_selections) 1964 if (!n_selections)
1965 return E_INVALIDARG; 1965 return E_INVALIDARG;
1966 1966
1967 *n_selections = 0; 1967 *n_selections = 0;
1968 if (blink_role() == ui::AX_ROLE_TEXT_FIELD || 1968 if (GetRole() == ui::AX_ROLE_TEXT_FIELD ||
1969 blink_role() == ui::AX_ROLE_TEXT_AREA) { 1969 GetRole() == ui::AX_ROLE_TEXT_AREA) {
1970 int sel_start = 0; 1970 int sel_start = 0;
1971 int sel_end = 0; 1971 int sel_end = 0;
1972 if (GetIntAttribute(ui::AX_ATTR_TEXT_SEL_START, 1972 if (GetIntAttribute(ui::AX_ATTR_TEXT_SEL_START,
1973 &sel_start) && 1973 &sel_start) &&
1974 GetIntAttribute(ui::AX_ATTR_TEXT_SEL_END, &sel_end) && 1974 GetIntAttribute(ui::AX_ATTR_TEXT_SEL_END, &sel_end) &&
1975 sel_start != sel_end) 1975 sel_start != sel_end)
1976 *n_selections = 1; 1976 *n_selections = 1;
1977 } 1977 }
1978 1978
1979 return S_OK; 1979 return S_OK;
1980 } 1980 }
1981 1981
1982 STDMETHODIMP BrowserAccessibilityWin::get_selection(LONG selection_index, 1982 STDMETHODIMP BrowserAccessibilityWin::get_selection(LONG selection_index,
1983 LONG* start_offset, 1983 LONG* start_offset,
1984 LONG* end_offset) { 1984 LONG* end_offset) {
1985 if (!instance_active()) 1985 if (!instance_active())
1986 return E_FAIL; 1986 return E_FAIL;
1987 1987
1988 if (!start_offset || !end_offset || selection_index != 0) 1988 if (!start_offset || !end_offset || selection_index != 0)
1989 return E_INVALIDARG; 1989 return E_INVALIDARG;
1990 1990
1991 *start_offset = 0; 1991 *start_offset = 0;
1992 *end_offset = 0; 1992 *end_offset = 0;
1993 if (blink_role() == ui::AX_ROLE_TEXT_FIELD || 1993 if (GetRole() == ui::AX_ROLE_TEXT_FIELD ||
1994 blink_role() == ui::AX_ROLE_TEXT_AREA) { 1994 GetRole() == ui::AX_ROLE_TEXT_AREA) {
1995 int sel_start = 0; 1995 int sel_start = 0;
1996 int sel_end = 0; 1996 int sel_end = 0;
1997 if (GetIntAttribute( 1997 if (GetIntAttribute(
1998 ui::AX_ATTR_TEXT_SEL_START, &sel_start) && 1998 ui::AX_ATTR_TEXT_SEL_START, &sel_start) &&
1999 GetIntAttribute(ui::AX_ATTR_TEXT_SEL_END, &sel_end)) { 1999 GetIntAttribute(ui::AX_ATTR_TEXT_SEL_END, &sel_end)) {
2000 *start_offset = sel_start; 2000 *start_offset = sel_start;
2001 *end_offset = sel_end; 2001 *end_offset = sel_end;
2002 } 2002 }
2003 } 2003 }
2004 2004
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
2268 if (!instance_active()) 2268 if (!instance_active())
2269 return E_FAIL; 2269 return E_FAIL;
2270 2270
2271 if (!hyperlink || 2271 if (!hyperlink ||
2272 index < 0 || 2272 index < 0 ||
2273 index >= static_cast<long>(hyperlinks_.size())) { 2273 index >= static_cast<long>(hyperlinks_.size())) {
2274 return E_INVALIDARG; 2274 return E_INVALIDARG;
2275 } 2275 }
2276 2276
2277 BrowserAccessibilityWin* child = 2277 BrowserAccessibilityWin* child =
2278 children()[hyperlinks_[index]]->ToBrowserAccessibilityWin(); 2278 InternalGetChild(hyperlinks_[index])->ToBrowserAccessibilityWin();
2279 *hyperlink = static_cast<IAccessibleHyperlink*>(child->NewReference()); 2279 *hyperlink = static_cast<IAccessibleHyperlink*>(child->NewReference());
2280 return S_OK; 2280 return S_OK;
2281 } 2281 }
2282 2282
2283 STDMETHODIMP BrowserAccessibilityWin::get_hyperlinkIndex( 2283 STDMETHODIMP BrowserAccessibilityWin::get_hyperlinkIndex(
2284 long char_index, 2284 long char_index,
2285 long* hyperlink_index) { 2285 long* hyperlink_index) {
2286 if (!instance_active()) 2286 if (!instance_active())
2287 return E_FAIL; 2287 return E_FAIL;
2288 2288
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
2463 short* name_space_id, 2463 short* name_space_id,
2464 BSTR* attrib_values, 2464 BSTR* attrib_values,
2465 unsigned short* num_attribs) { 2465 unsigned short* num_attribs) {
2466 if (!instance_active()) 2466 if (!instance_active())
2467 return E_FAIL; 2467 return E_FAIL;
2468 2468
2469 if (!attrib_names || !name_space_id || !attrib_values || !num_attribs) 2469 if (!attrib_names || !name_space_id || !attrib_values || !num_attribs)
2470 return E_INVALIDARG; 2470 return E_INVALIDARG;
2471 2471
2472 *num_attribs = max_attribs; 2472 *num_attribs = max_attribs;
2473 if (*num_attribs > html_attributes().size()) 2473 if (*num_attribs > GetHtmlAttributes().size())
2474 *num_attribs = html_attributes().size(); 2474 *num_attribs = GetHtmlAttributes().size();
2475 2475
2476 for (unsigned short i = 0; i < *num_attribs; ++i) { 2476 for (unsigned short i = 0; i < *num_attribs; ++i) {
2477 attrib_names[i] = SysAllocString( 2477 attrib_names[i] = SysAllocString(
2478 base::UTF8ToUTF16(html_attributes()[i].first).c_str()); 2478 base::UTF8ToUTF16(GetHtmlAttributes()[i].first).c_str());
2479 name_space_id[i] = 0; 2479 name_space_id[i] = 0;
2480 attrib_values[i] = SysAllocString( 2480 attrib_values[i] = SysAllocString(
2481 base::UTF8ToUTF16(html_attributes()[i].second).c_str()); 2481 base::UTF8ToUTF16(GetHtmlAttributes()[i].second).c_str());
2482 } 2482 }
2483 return S_OK; 2483 return S_OK;
2484 } 2484 }
2485 2485
2486 STDMETHODIMP BrowserAccessibilityWin::get_attributesForNames( 2486 STDMETHODIMP BrowserAccessibilityWin::get_attributesForNames(
2487 unsigned short num_attribs, 2487 unsigned short num_attribs,
2488 BSTR* attrib_names, 2488 BSTR* attrib_names,
2489 short* name_space_id, 2489 short* name_space_id,
2490 BSTR* attrib_values) { 2490 BSTR* attrib_values) {
2491 if (!instance_active()) 2491 if (!instance_active())
2492 return E_FAIL; 2492 return E_FAIL;
2493 2493
2494 if (!attrib_names || !name_space_id || !attrib_values) 2494 if (!attrib_names || !name_space_id || !attrib_values)
2495 return E_INVALIDARG; 2495 return E_INVALIDARG;
2496 2496
2497 for (unsigned short i = 0; i < num_attribs; ++i) { 2497 for (unsigned short i = 0; i < num_attribs; ++i) {
2498 name_space_id[i] = 0; 2498 name_space_id[i] = 0;
2499 bool found = false; 2499 bool found = false;
2500 std::string name = base::UTF16ToUTF8((LPCWSTR)attrib_names[i]); 2500 std::string name = base::UTF16ToUTF8((LPCWSTR)attrib_names[i]);
2501 for (unsigned int j = 0; j < html_attributes().size(); ++j) { 2501 for (unsigned int j = 0; j < GetHtmlAttributes().size(); ++j) {
2502 if (html_attributes()[j].first == name) { 2502 if (GetHtmlAttributes()[j].first == name) {
2503 attrib_values[i] = SysAllocString( 2503 attrib_values[i] = SysAllocString(
2504 base::UTF8ToUTF16(html_attributes()[j].second).c_str()); 2504 base::UTF8ToUTF16(GetHtmlAttributes()[j].second).c_str());
2505 found = true; 2505 found = true;
2506 break; 2506 break;
2507 } 2507 }
2508 } 2508 }
2509 if (!found) { 2509 if (!found) {
2510 attrib_values[i] = NULL; 2510 attrib_values[i] = NULL;
2511 } 2511 }
2512 } 2512 }
2513 return S_OK; 2513 return S_OK;
2514 } 2514 }
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
2574 IA2_SCROLL_TYPE_TOP_LEFT : IA2_SCROLL_TYPE_ANYWHERE); 2574 IA2_SCROLL_TYPE_TOP_LEFT : IA2_SCROLL_TYPE_ANYWHERE);
2575 } 2575 }
2576 2576
2577 STDMETHODIMP BrowserAccessibilityWin::get_parentNode(ISimpleDOMNode** node) { 2577 STDMETHODIMP BrowserAccessibilityWin::get_parentNode(ISimpleDOMNode** node) {
2578 if (!instance_active()) 2578 if (!instance_active())
2579 return E_FAIL; 2579 return E_FAIL;
2580 2580
2581 if (!node) 2581 if (!node)
2582 return E_INVALIDARG; 2582 return E_INVALIDARG;
2583 2583
2584 *node = parent()->ToBrowserAccessibilityWin()->NewReference(); 2584 *node = GetParent()->ToBrowserAccessibilityWin()->NewReference();
2585 return S_OK; 2585 return S_OK;
2586 } 2586 }
2587 2587
2588 STDMETHODIMP BrowserAccessibilityWin::get_firstChild(ISimpleDOMNode** node) { 2588 STDMETHODIMP BrowserAccessibilityWin::get_firstChild(ISimpleDOMNode** node) {
2589 if (!instance_active()) 2589 if (!instance_active())
2590 return E_FAIL; 2590 return E_FAIL;
2591 2591
2592 if (!node) 2592 if (!node)
2593 return E_INVALIDARG; 2593 return E_INVALIDARG;
2594 2594
(...skipping 24 matching lines...) Expand all
2619 } 2619 }
2620 2620
2621 STDMETHODIMP BrowserAccessibilityWin::get_previousSibling( 2621 STDMETHODIMP BrowserAccessibilityWin::get_previousSibling(
2622 ISimpleDOMNode** node) { 2622 ISimpleDOMNode** node) {
2623 if (!instance_active()) 2623 if (!instance_active())
2624 return E_FAIL; 2624 return E_FAIL;
2625 2625
2626 if (!node) 2626 if (!node)
2627 return E_INVALIDARG; 2627 return E_INVALIDARG;
2628 2628
2629 if (!parent() || index_in_parent() <= 0) { 2629 if (!GetParent() || GetIndexInParent() <= 0) {
2630 *node = NULL; 2630 *node = NULL;
2631 return S_FALSE; 2631 return S_FALSE;
2632 } 2632 }
2633 2633
2634 *node = parent()->children()[index_in_parent() - 1]-> 2634 *node = GetParent()->InternalGetChild(GetIndexInParent() - 1)->
2635 ToBrowserAccessibilityWin()->NewReference(); 2635 ToBrowserAccessibilityWin()->NewReference();
2636 return S_OK; 2636 return S_OK;
2637 } 2637 }
2638 2638
2639 STDMETHODIMP BrowserAccessibilityWin::get_nextSibling(ISimpleDOMNode** node) { 2639 STDMETHODIMP BrowserAccessibilityWin::get_nextSibling(ISimpleDOMNode** node) {
2640 if (!instance_active()) 2640 if (!instance_active())
2641 return E_FAIL; 2641 return E_FAIL;
2642 2642
2643 if (!node) 2643 if (!node)
2644 return E_INVALIDARG; 2644 return E_INVALIDARG;
2645 2645
2646 if (!parent() || 2646 if (!GetParent() ||
2647 index_in_parent() < 0 || 2647 GetIndexInParent() < 0 ||
2648 index_in_parent() >= static_cast<int>(parent()->children().size()) - 1) { 2648 GetIndexInParent() >= static_cast<int>(
2649 GetParent()->InternalChildCount()) - 1) {
2649 *node = NULL; 2650 *node = NULL;
2650 return S_FALSE; 2651 return S_FALSE;
2651 } 2652 }
2652 2653
2653 *node = parent()->children()[index_in_parent() + 1]-> 2654 *node = GetParent()->InternalGetChild(GetIndexInParent() + 1)->
2654 ToBrowserAccessibilityWin()->NewReference(); 2655 ToBrowserAccessibilityWin()->NewReference();
2655 return S_OK; 2656 return S_OK;
2656 } 2657 }
2657 2658
2658 STDMETHODIMP BrowserAccessibilityWin::get_childAt( 2659 STDMETHODIMP BrowserAccessibilityWin::get_childAt(
2659 unsigned int child_index, 2660 unsigned int child_index,
2660 ISimpleDOMNode** node) { 2661 ISimpleDOMNode** node) {
2661 if (!instance_active()) 2662 if (!instance_active())
2662 return E_FAIL; 2663 return E_FAIL;
2663 2664
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
2904 2905
2905 // Expose the "display" and "tag" attributes. 2906 // Expose the "display" and "tag" attributes.
2906 StringAttributeToIA2(ui::AX_ATTR_DISPLAY, "display"); 2907 StringAttributeToIA2(ui::AX_ATTR_DISPLAY, "display");
2907 StringAttributeToIA2(ui::AX_ATTR_HTML_TAG, "tag"); 2908 StringAttributeToIA2(ui::AX_ATTR_HTML_TAG, "tag");
2908 StringAttributeToIA2(ui::AX_ATTR_ROLE, "xml-roles"); 2909 StringAttributeToIA2(ui::AX_ATTR_ROLE, "xml-roles");
2909 2910
2910 // Expose "level" attribute for headings, trees, etc. 2911 // Expose "level" attribute for headings, trees, etc.
2911 IntAttributeToIA2(ui::AX_ATTR_HIERARCHICAL_LEVEL, "level"); 2912 IntAttributeToIA2(ui::AX_ATTR_HIERARCHICAL_LEVEL, "level");
2912 2913
2913 // Expose the set size and position in set for listbox options. 2914 // Expose the set size and position in set for listbox options.
2914 if (blink_role() == ui::AX_ROLE_LIST_BOX_OPTION && 2915 if (GetRole() == ui::AX_ROLE_LIST_BOX_OPTION &&
2915 parent() && 2916 GetParent() &&
2916 parent()->role() == ui::AX_ROLE_LIST_BOX) { 2917 GetParent()->GetRole() == ui::AX_ROLE_LIST_BOX) {
2917 ia2_attributes_.push_back( 2918 ia2_attributes_.push_back(
2918 L"setsize:" + base::IntToString16(parent()->PlatformChildCount())); 2919 L"setsize:" + base::IntToString16(GetParent()->PlatformChildCount()));
2919 ia2_attributes_.push_back( 2920 ia2_attributes_.push_back(
2920 L"setsize:" + base::IntToString16(index_in_parent() + 1)); 2921 L"setsize:" + base::IntToString16(GetIndexInParent() + 1));
2921 } 2922 }
2922 2923
2923 if (ia_role_ == ROLE_SYSTEM_CHECKBUTTON || 2924 if (ia_role_ == ROLE_SYSTEM_CHECKBUTTON ||
2924 ia_role_ == ROLE_SYSTEM_RADIOBUTTON || 2925 ia_role_ == ROLE_SYSTEM_RADIOBUTTON ||
2925 ia2_role_ == IA2_ROLE_TOGGLE_BUTTON) { 2926 ia2_role_ == IA2_ROLE_TOGGLE_BUTTON) {
2926 ia2_attributes_.push_back(L"checkable:true"); 2927 ia2_attributes_.push_back(L"checkable:true");
2927 } 2928 }
2928 2929
2929 // Expose live region attributes. 2930 // Expose live region attributes.
2930 StringAttributeToIA2(ui::AX_ATTR_LIVE_STATUS, "live"); 2931 StringAttributeToIA2(ui::AX_ATTR_LIVE_STATUS, "live");
(...skipping 13 matching lines...) Expand all
2944 2945
2945 // Expose slider value. 2946 // Expose slider value.
2946 if (ia_role_ == ROLE_SYSTEM_PROGRESSBAR || 2947 if (ia_role_ == ROLE_SYSTEM_PROGRESSBAR ||
2947 ia_role_ == ROLE_SYSTEM_SCROLLBAR || 2948 ia_role_ == ROLE_SYSTEM_SCROLLBAR ||
2948 ia_role_ == ROLE_SYSTEM_SLIDER) { 2949 ia_role_ == ROLE_SYSTEM_SLIDER) {
2949 ia2_attributes_.push_back(L"valuetext:" + GetValueText()); 2950 ia2_attributes_.push_back(L"valuetext:" + GetValueText());
2950 } 2951 }
2951 2952
2952 // Expose table cell index. 2953 // Expose table cell index.
2953 if (ia_role_ == ROLE_SYSTEM_CELL) { 2954 if (ia_role_ == ROLE_SYSTEM_CELL) {
2954 BrowserAccessibility* table = parent(); 2955 BrowserAccessibility* table = GetParent();
2955 while (table && table->role() != ui::AX_ROLE_TABLE) 2956 while (table && table->GetRole() != ui::AX_ROLE_TABLE)
2956 table = table->parent(); 2957 table = table->GetParent();
2957 if (table) { 2958 if (table) {
2958 const std::vector<int32>& unique_cell_ids = table->GetIntListAttribute( 2959 const std::vector<int32>& unique_cell_ids = table->GetIntListAttribute(
2959 ui::AX_ATTR_UNIQUE_CELL_IDS); 2960 ui::AX_ATTR_UNIQUE_CELL_IDS);
2960 for (size_t i = 0; i < unique_cell_ids.size(); ++i) { 2961 for (size_t i = 0; i < unique_cell_ids.size(); ++i) {
2961 if (unique_cell_ids[i] == renderer_id()) { 2962 if (unique_cell_ids[i] == GetId()) {
2962 ia2_attributes_.push_back( 2963 ia2_attributes_.push_back(
2963 base::string16(L"table-cell-index:") + base::IntToString16(i)); 2964 base::string16(L"table-cell-index:") + base::IntToString16(i));
2964 } 2965 }
2965 } 2966 }
2966 } 2967 }
2967 } 2968 }
2968 2969
2969 // The calculation of the accessible name of an element has been 2970 // The calculation of the accessible name of an element has been
2970 // standardized in the HTML to Platform Accessibility APIs Implementation 2971 // standardized in the HTML to Platform Accessibility APIs Implementation
2971 // Guide (http://www.w3.org/TR/html-aapi/). In order to return the 2972 // Guide (http://www.w3.org/TR/html-aapi/). In order to return the
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
3015 description = help; 3016 description = help;
3016 help.clear(); 3017 help.clear();
3017 } 3018 }
3018 if (!description.empty() && name().empty() && !title_elem_id) { 3019 if (!description.empty() && name().empty() && !title_elem_id) {
3019 set_name(description); 3020 set_name(description);
3020 description.clear(); 3021 description.clear();
3021 } 3022 }
3022 3023
3023 // If it's a text field, also consider the placeholder. 3024 // If it's a text field, also consider the placeholder.
3024 std::string placeholder; 3025 std::string placeholder;
3025 if (blink_role() == ui::AX_ROLE_TEXT_FIELD && 3026 if (GetRole() == ui::AX_ROLE_TEXT_FIELD &&
3026 HasState(ui::AX_STATE_FOCUSABLE) && 3027 HasState(ui::AX_STATE_FOCUSABLE) &&
3027 GetHtmlAttribute("placeholder", &placeholder)) { 3028 GetHtmlAttribute("placeholder", &placeholder)) {
3028 if (name().empty() && !title_elem_id) { 3029 if (name().empty() && !title_elem_id) {
3029 set_name(placeholder); 3030 set_name(placeholder);
3030 } else if (description.empty()) { 3031 } else if (description.empty()) {
3031 description = placeholder; 3032 description = placeholder;
3032 } 3033 }
3033 } 3034 }
3034 3035
3035 SetStringAttribute(ui::AX_ATTR_DESCRIPTION, description); 3036 SetStringAttribute(ui::AX_ATTR_DESCRIPTION, description);
3036 SetStringAttribute(ui::AX_ATTR_HELP, help); 3037 SetStringAttribute(ui::AX_ATTR_HELP, help);
3037 3038
3038 // On Windows, the value of a document should be its url. 3039 // On Windows, the value of a document should be its url.
3039 if (blink_role() == ui::AX_ROLE_ROOT_WEB_AREA || 3040 if (GetRole() == ui::AX_ROLE_ROOT_WEB_AREA ||
3040 blink_role() == ui::AX_ROLE_WEB_AREA) { 3041 GetRole() == ui::AX_ROLE_WEB_AREA) {
3041 set_value(GetStringAttribute(ui::AX_ATTR_DOC_URL)); 3042 set_value(GetStringAttribute(ui::AX_ATTR_DOC_URL));
3042 } 3043 }
3043 3044
3044 // For certain roles (listbox option, static text, and list marker) 3045 // For certain roles (listbox option, static text, and list marker)
3045 // WebKit stores the main accessible text in the "value" - swap it so 3046 // WebKit stores the main accessible text in the "value" - swap it so
3046 // that it's the "name". 3047 // that it's the "name".
3047 if (name().empty() && 3048 if (name().empty() &&
3048 (blink_role() == ui::AX_ROLE_LIST_BOX_OPTION || 3049 (GetRole() == ui::AX_ROLE_LIST_BOX_OPTION ||
3049 blink_role() == ui::AX_ROLE_STATIC_TEXT || 3050 GetRole() == ui::AX_ROLE_STATIC_TEXT ||
3050 blink_role() == ui::AX_ROLE_LIST_MARKER)) { 3051 GetRole() == ui::AX_ROLE_LIST_MARKER)) {
3051 std::string tmp = value(); 3052 std::string tmp = value();
3052 set_value(name()); 3053 set_value(name());
3053 set_name(tmp); 3054 set_name(tmp);
3054 } 3055 }
3055 3056
3056 // If this doesn't have a value and is linked then set its value to the url 3057 // If this doesn't have a value and is linked then set its value to the url
3057 // attribute. This allows screen readers to read an empty link's destination. 3058 // attribute. This allows screen readers to read an empty link's destination.
3058 if (value().empty() && (ia_state_ & STATE_SYSTEM_LINKED)) 3059 if (value().empty() && (ia_state_ & STATE_SYSTEM_LINKED))
3059 set_value(GetStringAttribute(ui::AX_ATTR_URL)); 3060 set_value(GetStringAttribute(ui::AX_ATTR_URL));
3060 3061
(...skipping 18 matching lines...) Expand all
3079 3080
3080 void BrowserAccessibilityWin::PostInitialize() { 3081 void BrowserAccessibilityWin::PostInitialize() {
3081 BrowserAccessibility::PostInitialize(); 3082 BrowserAccessibility::PostInitialize();
3082 3083
3083 // Construct the hypertext for this node. 3084 // Construct the hypertext for this node.
3084 hyperlink_offset_to_index_.clear(); 3085 hyperlink_offset_to_index_.clear();
3085 hyperlinks_.clear(); 3086 hyperlinks_.clear();
3086 hypertext_.clear(); 3087 hypertext_.clear();
3087 for (unsigned int i = 0; i < PlatformChildCount(); ++i) { 3088 for (unsigned int i = 0; i < PlatformChildCount(); ++i) {
3088 BrowserAccessibility* child = PlatformGetChild(i); 3089 BrowserAccessibility* child = PlatformGetChild(i);
3089 if (child->role() == ui::AX_ROLE_STATIC_TEXT) { 3090 if (child->GetRole() == ui::AX_ROLE_STATIC_TEXT) {
3090 hypertext_ += base::UTF8ToUTF16(child->name()); 3091 hypertext_ += base::UTF8ToUTF16(child->name());
3091 } else { 3092 } else {
3092 hyperlink_offset_to_index_[hypertext_.size()] = hyperlinks_.size(); 3093 hyperlink_offset_to_index_[hypertext_.size()] = hyperlinks_.size();
3093 hypertext_ += kEmbeddedCharacter; 3094 hypertext_ += kEmbeddedCharacter;
3094 hyperlinks_.push_back(i); 3095 hyperlinks_.push_back(i);
3095 } 3096 }
3096 } 3097 }
3097 DCHECK_EQ(hyperlink_offset_to_index_.size(), hyperlinks_.size()); 3098 DCHECK_EQ(hyperlink_offset_to_index_.size(), hyperlinks_.size());
3098 3099
3099 // Fire an event when an alert first appears. 3100 // Fire an event when an alert first appears.
3100 if (blink_role() == ui::AX_ROLE_ALERT && first_time_) 3101 if (GetRole() == ui::AX_ROLE_ALERT && first_time_)
3101 manager()->NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, this); 3102 manager()->NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, this);
3102 3103
3103 // Fire events if text has changed. 3104 // Fire events if text has changed.
3104 base::string16 text = TextForIAccessibleText(); 3105 base::string16 text = TextForIAccessibleText();
3105 if (previous_text_ != text) { 3106 if (previous_text_ != text) {
3106 if (!previous_text_.empty() && !text.empty()) { 3107 if (!previous_text_.empty() && !text.empty()) {
3107 manager()->NotifyAccessibilityEvent( 3108 manager()->NotifyAccessibilityEvent(
3108 ui::AX_EVENT_SHOW, this); 3109 ui::AX_EVENT_SHOW, this);
3109 } 3110 }
3110 3111
3111 // TODO(dmazzoni): Look into HIDE events, too. 3112 // TODO(dmazzoni): Look into HIDE events, too.
3112 3113
3113 old_text_ = previous_text_; 3114 old_text_ = previous_text_;
3114 previous_text_ = text; 3115 previous_text_ = text;
3115 } 3116 }
3116 3117
3117 BrowserAccessibilityManagerWin* manager = 3118 BrowserAccessibilityManagerWin* manager =
3118 this->manager()->ToBrowserAccessibilityManagerWin(); 3119 this->manager()->ToBrowserAccessibilityManagerWin();
3119 3120
3120 // Fire events if the state has changed. 3121 // Fire events if the state has changed.
3121 if (!first_time_ && ia_state_ != old_ia_state_) { 3122 if (!first_time_ && ia_state_ != old_ia_state_) {
3122 // Normally focus events are handled elsewhere, however 3123 // Normally focus events are handled elsewhere, however
3123 // focus for managed descendants is platform-specific. 3124 // focus for managed descendants is platform-specific.
3124 // Fire a focus event if the focused descendant in a multi-select 3125 // Fire a focus event if the focused descendant in a multi-select
3125 // list box changes. 3126 // list box changes.
3126 if (blink_role() == ui::AX_ROLE_LIST_BOX_OPTION && 3127 if (GetRole() == ui::AX_ROLE_LIST_BOX_OPTION &&
3127 (ia_state_ & STATE_SYSTEM_FOCUSABLE) && 3128 (ia_state_ & STATE_SYSTEM_FOCUSABLE) &&
3128 (ia_state_ & STATE_SYSTEM_SELECTABLE) && 3129 (ia_state_ & STATE_SYSTEM_SELECTABLE) &&
3129 (ia_state_ & STATE_SYSTEM_FOCUSED) && 3130 (ia_state_ & STATE_SYSTEM_FOCUSED) &&
3130 !(old_ia_state_ & STATE_SYSTEM_FOCUSED)) { 3131 !(old_ia_state_ & STATE_SYSTEM_FOCUSED)) {
3131 manager->MaybeCallNotifyWinEvent(EVENT_OBJECT_FOCUS, unique_id_win()); 3132 manager->MaybeCallNotifyWinEvent(EVENT_OBJECT_FOCUS, unique_id_win());
3132 } 3133 }
3133 3134
3134 if ((ia_state_ & STATE_SYSTEM_SELECTED) && 3135 if ((ia_state_ & STATE_SYSTEM_SELECTED) &&
3135 !(old_ia_state_ & STATE_SYSTEM_SELECTED)) { 3136 !(old_ia_state_ & STATE_SYSTEM_SELECTED)) {
3136 manager->MaybeCallNotifyWinEvent(EVENT_OBJECT_SELECTIONADD, 3137 manager->MaybeCallNotifyWinEvent(EVENT_OBJECT_SELECTIONADD,
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
3252 if (value.empty() && 3253 if (value.empty() &&
3253 GetFloatAttribute(ui::AX_ATTR_VALUE_FOR_RANGE, &fval)) { 3254 GetFloatAttribute(ui::AX_ATTR_VALUE_FOR_RANGE, &fval)) {
3254 value = base::UTF8ToUTF16(base::DoubleToString(fval)); 3255 value = base::UTF8ToUTF16(base::DoubleToString(fval));
3255 } 3256 }
3256 return value; 3257 return value;
3257 } 3258 }
3258 3259
3259 base::string16 BrowserAccessibilityWin::TextForIAccessibleText() { 3260 base::string16 BrowserAccessibilityWin::TextForIAccessibleText() {
3260 if (IsEditableText()) 3261 if (IsEditableText())
3261 return base::UTF8ToUTF16(value()); 3262 return base::UTF8ToUTF16(value());
3262 return (blink_role() == ui::AX_ROLE_STATIC_TEXT) ? 3263 return (GetRole() == ui::AX_ROLE_STATIC_TEXT) ?
3263 base::UTF8ToUTF16(name()) : hypertext_; 3264 base::UTF8ToUTF16(name()) : hypertext_;
3264 } 3265 }
3265 3266
3266 void BrowserAccessibilityWin::HandleSpecialTextOffset( 3267 void BrowserAccessibilityWin::HandleSpecialTextOffset(
3267 const base::string16& text, 3268 const base::string16& text,
3268 LONG* offset) { 3269 LONG* offset) {
3269 if (*offset == IA2_TEXT_OFFSET_LENGTH) 3270 if (*offset == IA2_TEXT_OFFSET_LENGTH)
3270 *offset = static_cast<LONG>(text.size()); 3271 *offset = static_cast<LONG>(text.size());
3271 else if (*offset == IA2_TEXT_OFFSET_CARET) 3272 else if (*offset == IA2_TEXT_OFFSET_CARET)
3272 get_caretOffset(offset); 3273 get_caretOffset(offset);
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
3372 if (GetBoolAttribute(ui::AX_ATTR_BUTTON_MIXED)) 3373 if (GetBoolAttribute(ui::AX_ATTR_BUTTON_MIXED))
3373 ia_state_ |= STATE_SYSTEM_MIXED; 3374 ia_state_ |= STATE_SYSTEM_MIXED;
3374 3375
3375 if (GetBoolAttribute(ui::AX_ATTR_CAN_SET_VALUE)) 3376 if (GetBoolAttribute(ui::AX_ATTR_CAN_SET_VALUE))
3376 ia2_state_ |= IA2_STATE_EDITABLE; 3377 ia2_state_ |= IA2_STATE_EDITABLE;
3377 3378
3378 base::string16 html_tag = GetString16Attribute( 3379 base::string16 html_tag = GetString16Attribute(
3379 ui::AX_ATTR_HTML_TAG); 3380 ui::AX_ATTR_HTML_TAG);
3380 ia_role_ = 0; 3381 ia_role_ = 0;
3381 ia2_role_ = 0; 3382 ia2_role_ = 0;
3382 switch (blink_role()) { 3383 switch (GetRole()) {
3383 case ui::AX_ROLE_ALERT: 3384 case ui::AX_ROLE_ALERT:
3384 ia_role_ = ROLE_SYSTEM_ALERT; 3385 ia_role_ = ROLE_SYSTEM_ALERT;
3385 break; 3386 break;
3386 case ui::AX_ROLE_ALERT_DIALOG: 3387 case ui::AX_ROLE_ALERT_DIALOG:
3387 ia_role_ = ROLE_SYSTEM_DIALOG; 3388 ia_role_ = ROLE_SYSTEM_DIALOG;
3388 break; 3389 break;
3389 case ui::AX_ROLE_APPLICATION: 3390 case ui::AX_ROLE_APPLICATION:
3390 ia_role_ = ROLE_SYSTEM_APPLICATION; 3391 ia_role_ = ROLE_SYSTEM_APPLICATION;
3391 break; 3392 break;
3392 case ui::AX_ROLE_ARTICLE: 3393 case ui::AX_ROLE_ARTICLE:
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
3791 // The role should always be set. 3792 // The role should always be set.
3792 DCHECK(!role_name_.empty() || ia_role_); 3793 DCHECK(!role_name_.empty() || ia_role_);
3793 3794
3794 // If we didn't explicitly set the IAccessible2 role, make it the same 3795 // If we didn't explicitly set the IAccessible2 role, make it the same
3795 // as the MSAA role. 3796 // as the MSAA role.
3796 if (!ia2_role_) 3797 if (!ia2_role_)
3797 ia2_role_ = ia_role_; 3798 ia2_role_ = ia_role_;
3798 } 3799 }
3799 3800
3800 } // namespace content 3801 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698