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 <algorithm> | 10 #include <algorithm> |
(...skipping 3804 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3815 table->GetIntListAttribute(ui::AX_ATTR_UNIQUE_CELL_IDS); | 3815 table->GetIntListAttribute(ui::AX_ATTR_UNIQUE_CELL_IDS); |
3816 for (size_t i = 0; i < unique_cell_ids.size(); ++i) { | 3816 for (size_t i = 0; i < unique_cell_ids.size(); ++i) { |
3817 if (unique_cell_ids[i] == GetId()) { | 3817 if (unique_cell_ids[i] == GetId()) { |
3818 win_attributes_->ia2_attributes.push_back( | 3818 win_attributes_->ia2_attributes.push_back( |
3819 base::string16(L"table-cell-index:") + base::IntToString16(i)); | 3819 base::string16(L"table-cell-index:") + base::IntToString16(i)); |
3820 } | 3820 } |
3821 } | 3821 } |
3822 } | 3822 } |
3823 } | 3823 } |
3824 | 3824 |
| 3825 // Expose aria-colcount and aria-rowcount in a table, grid or treegrid. |
| 3826 if (IsTableOrGridOrTreeGridRole()) { |
| 3827 IntAttributeToIA2(ui::AX_ATTR_ARIA_COL_COUNT, "colcount"); |
| 3828 IntAttributeToIA2(ui::AX_ATTR_ARIA_ROW_COUNT, "rowcount"); |
| 3829 } |
| 3830 |
| 3831 // Expose aria-colindex and aria-rowindex in a cell or row. |
| 3832 if (IsCellOrTableHeaderRole() || GetRole() == ui::AX_ROLE_ROW) { |
| 3833 if (GetRole() != ui::AX_ROLE_ROW) |
| 3834 IntAttributeToIA2(ui::AX_ATTR_ARIA_COL_INDEX, "colindex"); |
| 3835 IntAttributeToIA2(ui::AX_ATTR_ARIA_ROW_INDEX, "rowindex"); |
| 3836 } |
| 3837 |
3825 // Expose row or column header sort direction. | 3838 // Expose row or column header sort direction. |
3826 int32_t sort_direction; | 3839 int32_t sort_direction; |
3827 if ((ia_role() == ROLE_SYSTEM_COLUMNHEADER || | 3840 if ((ia_role() == ROLE_SYSTEM_COLUMNHEADER || |
3828 ia_role() == ROLE_SYSTEM_ROWHEADER) && | 3841 ia_role() == ROLE_SYSTEM_ROWHEADER) && |
3829 GetIntAttribute(ui::AX_ATTR_SORT_DIRECTION, &sort_direction)) { | 3842 GetIntAttribute(ui::AX_ATTR_SORT_DIRECTION, &sort_direction)) { |
3830 switch (static_cast<ui::AXSortDirection>(sort_direction)) { | 3843 switch (static_cast<ui::AXSortDirection>(sort_direction)) { |
3831 case ui::AX_SORT_DIRECTION_NONE: | 3844 case ui::AX_SORT_DIRECTION_NONE: |
3832 break; | 3845 break; |
3833 case ui::AX_SORT_DIRECTION_UNSORTED: | 3846 case ui::AX_SORT_DIRECTION_UNSORTED: |
3834 win_attributes_->ia2_attributes.push_back(L"sort:none"); | 3847 win_attributes_->ia2_attributes.push_back(L"sort:none"); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3870 ui::AX_ATTR_DESCRIBEDBY_IDS); | 3883 ui::AX_ATTR_DESCRIBEDBY_IDS); |
3871 AddBidirectionalRelations(IA2_RELATION_FLOWS_TO, IA2_RELATION_FLOWS_FROM, | 3884 AddBidirectionalRelations(IA2_RELATION_FLOWS_TO, IA2_RELATION_FLOWS_FROM, |
3872 ui::AX_ATTR_FLOWTO_IDS); | 3885 ui::AX_ATTR_FLOWTO_IDS); |
3873 AddBidirectionalRelations(IA2_RELATION_LABELLED_BY, IA2_RELATION_LABEL_FOR, | 3886 AddBidirectionalRelations(IA2_RELATION_LABELLED_BY, IA2_RELATION_LABEL_FOR, |
3874 ui::AX_ATTR_LABELLEDBY_IDS); | 3887 ui::AX_ATTR_LABELLEDBY_IDS); |
3875 | 3888 |
3876 int member_of_id; | 3889 int member_of_id; |
3877 if (GetIntAttribute(ui::AX_ATTR_MEMBER_OF_ID, &member_of_id)) | 3890 if (GetIntAttribute(ui::AX_ATTR_MEMBER_OF_ID, &member_of_id)) |
3878 AddRelation(IA2_RELATION_MEMBER_OF, member_of_id); | 3891 AddRelation(IA2_RELATION_MEMBER_OF, member_of_id); |
3879 | 3892 |
| 3893 // Expose slider value. |
| 3894 if (ia_role() == ROLE_SYSTEM_PROGRESSBAR || |
| 3895 ia_role() == ROLE_SYSTEM_SCROLLBAR || |
| 3896 ia_role() == ROLE_SYSTEM_SLIDER) { |
| 3897 base::string16 value_text = GetValueText(); |
| 3898 SanitizeStringAttributeForIA2(value_text, &value_text); |
| 3899 win_attributes_->ia2_attributes.push_back(L"valuetext:" + value_text); |
| 3900 } |
| 3901 |
3880 UpdateRequiredAttributes(); | 3902 UpdateRequiredAttributes(); |
3881 // If this is a web area for a presentational iframe, give it a role of | 3903 // If this is a web area for a presentational iframe, give it a role of |
3882 // something other than DOCUMENT so that the fact that it's a separate doc | 3904 // something other than DOCUMENT so that the fact that it's a separate doc |
3883 // is not exposed to AT. | 3905 // is not exposed to AT. |
3884 if (IsWebAreaForPresentationalIframe()) { | 3906 if (IsWebAreaForPresentationalIframe()) { |
3885 win_attributes_->ia_role = ROLE_SYSTEM_GROUPING; | 3907 win_attributes_->ia_role = ROLE_SYSTEM_GROUPING; |
3886 win_attributes_->ia2_role = ROLE_SYSTEM_GROUPING; | 3908 win_attributes_->ia2_role = ROLE_SYSTEM_GROUPING; |
3887 } | 3909 } |
3888 } | 3910 } |
3889 | 3911 |
(...skipping 994 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4884 if (relation->get_target_ids().empty()) { | 4906 if (relation->get_target_ids().empty()) { |
4885 iter = relations_.erase(iter); | 4907 iter = relations_.erase(iter); |
4886 relation->Release(); | 4908 relation->Release(); |
4887 } else { | 4909 } else { |
4888 ++iter; | 4910 ++iter; |
4889 } | 4911 } |
4890 } | 4912 } |
4891 } | 4913 } |
4892 | 4914 |
4893 void BrowserAccessibilityWin::UpdateRequiredAttributes() { | 4915 void BrowserAccessibilityWin::UpdateRequiredAttributes() { |
4894 // Expose slider value. | 4916 if (IsCellOrTableHeaderRole()) { |
4895 if (ia_role() == ROLE_SYSTEM_PROGRESSBAR || | 4917 // Expose colspan attribute. |
4896 ia_role() == ROLE_SYSTEM_SCROLLBAR || | 4918 base::string16 colspan; |
4897 ia_role() == ROLE_SYSTEM_SLIDER) { | 4919 if (GetHtmlAttribute("aria-colspan", &colspan)) { |
4898 base::string16 value_text = GetValueText(); | 4920 SanitizeStringAttributeForIA2(colspan, &colspan); |
4899 SanitizeStringAttributeForIA2(value_text, &value_text); | 4921 win_attributes_->ia2_attributes.push_back(L"colspan:" + colspan); |
4900 win_attributes_->ia2_attributes.push_back(L"valuetext:" + value_text); | 4922 } |
| 4923 // Expose rowspan attribute. |
| 4924 base::string16 rowspan; |
| 4925 if (GetHtmlAttribute("aria-rowspan", &rowspan)) { |
| 4926 SanitizeStringAttributeForIA2(rowspan, &rowspan); |
| 4927 win_attributes_->ia2_attributes.push_back(L"rowspan:" + rowspan); |
| 4928 } |
4901 } | 4929 } |
4902 | 4930 |
4903 // Expose dropeffect attribute. | 4931 // Expose dropeffect attribute. |
4904 base::string16 drop_effect; | 4932 base::string16 drop_effect; |
4905 if (GetHtmlAttribute("aria-dropeffect", &drop_effect)) { | 4933 if (GetHtmlAttribute("aria-dropeffect", &drop_effect)) { |
4906 SanitizeStringAttributeForIA2(drop_effect, &drop_effect); | 4934 SanitizeStringAttributeForIA2(drop_effect, &drop_effect); |
4907 win_attributes_->ia2_attributes.push_back(L"dropeffect:" + drop_effect); | 4935 win_attributes_->ia2_attributes.push_back(L"dropeffect:" + drop_effect); |
4908 } | 4936 } |
4909 | 4937 |
4910 // Expose grabbed attribute. | 4938 // Expose grabbed attribute. |
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5532 return static_cast<BrowserAccessibilityWin*>(obj); | 5560 return static_cast<BrowserAccessibilityWin*>(obj); |
5533 } | 5561 } |
5534 | 5562 |
5535 const BrowserAccessibilityWin* | 5563 const BrowserAccessibilityWin* |
5536 ToBrowserAccessibilityWin(const BrowserAccessibility* obj) { | 5564 ToBrowserAccessibilityWin(const BrowserAccessibility* obj) { |
5537 DCHECK(!obj || obj->IsNative()); | 5565 DCHECK(!obj || obj->IsNative()); |
5538 return static_cast<const BrowserAccessibilityWin*>(obj); | 5566 return static_cast<const BrowserAccessibilityWin*>(obj); |
5539 } | 5567 } |
5540 | 5568 |
5541 } // namespace content | 5569 } // namespace content |
OLD | NEW |