| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3869 ui::AX_ATTR_DESCRIBEDBY_IDS); | 3882 ui::AX_ATTR_DESCRIBEDBY_IDS); |
| 3870 AddBidirectionalRelations(IA2_RELATION_FLOWS_TO, IA2_RELATION_FLOWS_FROM, | 3883 AddBidirectionalRelations(IA2_RELATION_FLOWS_TO, IA2_RELATION_FLOWS_FROM, |
| 3871 ui::AX_ATTR_FLOWTO_IDS); | 3884 ui::AX_ATTR_FLOWTO_IDS); |
| 3872 AddBidirectionalRelations(IA2_RELATION_LABELLED_BY, IA2_RELATION_LABEL_FOR, | 3885 AddBidirectionalRelations(IA2_RELATION_LABELLED_BY, IA2_RELATION_LABEL_FOR, |
| 3873 ui::AX_ATTR_LABELLEDBY_IDS); | 3886 ui::AX_ATTR_LABELLEDBY_IDS); |
| 3874 | 3887 |
| 3875 int member_of_id; | 3888 int member_of_id; |
| 3876 if (GetIntAttribute(ui::AX_ATTR_MEMBER_OF_ID, &member_of_id)) | 3889 if (GetIntAttribute(ui::AX_ATTR_MEMBER_OF_ID, &member_of_id)) |
| 3877 AddRelation(IA2_RELATION_MEMBER_OF, member_of_id); | 3890 AddRelation(IA2_RELATION_MEMBER_OF, member_of_id); |
| 3878 | 3891 |
| 3892 // Expose slider value. |
| 3893 if (ia_role() == ROLE_SYSTEM_PROGRESSBAR || |
| 3894 ia_role() == ROLE_SYSTEM_SCROLLBAR || |
| 3895 ia_role() == ROLE_SYSTEM_SLIDER) { |
| 3896 base::string16 value_text = GetValueText(); |
| 3897 SanitizeStringAttributeForIA2(value_text, &value_text); |
| 3898 win_attributes_->ia2_attributes.push_back(L"valuetext:" + value_text); |
| 3899 } |
| 3900 |
| 3879 UpdateRequiredAttributes(); | 3901 UpdateRequiredAttributes(); |
| 3880 // If this is a web area for a presentational iframe, give it a role of | 3902 // If this is a web area for a presentational iframe, give it a role of |
| 3881 // something other than DOCUMENT so that the fact that it's a separate doc | 3903 // something other than DOCUMENT so that the fact that it's a separate doc |
| 3882 // is not exposed to AT. | 3904 // is not exposed to AT. |
| 3883 if (IsWebAreaForPresentationalIframe()) { | 3905 if (IsWebAreaForPresentationalIframe()) { |
| 3884 win_attributes_->ia_role = ROLE_SYSTEM_GROUPING; | 3906 win_attributes_->ia_role = ROLE_SYSTEM_GROUPING; |
| 3885 win_attributes_->ia2_role = ROLE_SYSTEM_GROUPING; | 3907 win_attributes_->ia2_role = ROLE_SYSTEM_GROUPING; |
| 3886 } | 3908 } |
| 3887 } | 3909 } |
| 3888 | 3910 |
| (...skipping 994 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4883 if (relation->get_target_ids().empty()) { | 4905 if (relation->get_target_ids().empty()) { |
| 4884 iter = relations_.erase(iter); | 4906 iter = relations_.erase(iter); |
| 4885 relation->Release(); | 4907 relation->Release(); |
| 4886 } else { | 4908 } else { |
| 4887 ++iter; | 4909 ++iter; |
| 4888 } | 4910 } |
| 4889 } | 4911 } |
| 4890 } | 4912 } |
| 4891 | 4913 |
| 4892 void BrowserAccessibilityWin::UpdateRequiredAttributes() { | 4914 void BrowserAccessibilityWin::UpdateRequiredAttributes() { |
| 4893 // Expose slider value. | 4915 if (IsCellOrTableHeaderRole()) { |
| 4894 if (ia_role() == ROLE_SYSTEM_PROGRESSBAR || | 4916 // Expose colspan attribute. |
| 4895 ia_role() == ROLE_SYSTEM_SCROLLBAR || | 4917 base::string16 colspan; |
| 4896 ia_role() == ROLE_SYSTEM_SLIDER) { | 4918 if (GetHtmlAttribute("aria-colspan", &colspan)) { |
| 4897 base::string16 value_text = GetValueText(); | 4919 SanitizeStringAttributeForIA2(colspan, &colspan); |
| 4898 SanitizeStringAttributeForIA2(value_text, &value_text); | 4920 win_attributes_->ia2_attributes.push_back(L"colspan:" + colspan); |
| 4899 win_attributes_->ia2_attributes.push_back(L"valuetext:" + value_text); | 4921 } |
| 4922 // Expose rowspan attribute. |
| 4923 base::string16 rowspan; |
| 4924 if (GetHtmlAttribute("aria-rowspan", &rowspan)) { |
| 4925 SanitizeStringAttributeForIA2(rowspan, &rowspan); |
| 4926 win_attributes_->ia2_attributes.push_back(L"rowspan:" + rowspan); |
| 4927 } |
| 4900 } | 4928 } |
| 4901 | 4929 |
| 4902 // Expose dropeffect attribute. | 4930 // Expose dropeffect attribute. |
| 4903 base::string16 drop_effect; | 4931 base::string16 drop_effect; |
| 4904 if (GetHtmlAttribute("aria-dropeffect", &drop_effect)) { | 4932 if (GetHtmlAttribute("aria-dropeffect", &drop_effect)) { |
| 4905 SanitizeStringAttributeForIA2(drop_effect, &drop_effect); | 4933 SanitizeStringAttributeForIA2(drop_effect, &drop_effect); |
| 4906 win_attributes_->ia2_attributes.push_back(L"dropeffect:" + drop_effect); | 4934 win_attributes_->ia2_attributes.push_back(L"dropeffect:" + drop_effect); |
| 4907 } | 4935 } |
| 4908 | 4936 |
| 4909 // Expose grabbed attribute. | 4937 // Expose grabbed attribute. |
| (...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5531 return static_cast<BrowserAccessibilityWin*>(obj); | 5559 return static_cast<BrowserAccessibilityWin*>(obj); |
| 5532 } | 5560 } |
| 5533 | 5561 |
| 5534 const BrowserAccessibilityWin* | 5562 const BrowserAccessibilityWin* |
| 5535 ToBrowserAccessibilityWin(const BrowserAccessibility* obj) { | 5563 ToBrowserAccessibilityWin(const BrowserAccessibility* obj) { |
| 5536 DCHECK(!obj || obj->IsNative()); | 5564 DCHECK(!obj || obj->IsNative()); |
| 5537 return static_cast<const BrowserAccessibilityWin*>(obj); | 5565 return static_cast<const BrowserAccessibilityWin*>(obj); |
| 5538 } | 5566 } |
| 5539 | 5567 |
| 5540 } // namespace content | 5568 } // namespace content |
| OLD | NEW |