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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 : public CComObjectRootEx<CComMultiThreadModel>, | 51 : public CComObjectRootEx<CComMultiThreadModel>, |
52 public IAccessibleRelation { | 52 public IAccessibleRelation { |
53 BEGIN_COM_MAP(BrowserAccessibilityRelation) | 53 BEGIN_COM_MAP(BrowserAccessibilityRelation) |
54 COM_INTERFACE_ENTRY(IAccessibleRelation) | 54 COM_INTERFACE_ENTRY(IAccessibleRelation) |
55 END_COM_MAP() | 55 END_COM_MAP() |
56 | 56 |
57 CONTENT_EXPORT BrowserAccessibilityRelation() {} | 57 CONTENT_EXPORT BrowserAccessibilityRelation() {} |
58 CONTENT_EXPORT virtual ~BrowserAccessibilityRelation() {} | 58 CONTENT_EXPORT virtual ~BrowserAccessibilityRelation() {} |
59 | 59 |
60 CONTENT_EXPORT void Initialize(BrowserAccessibilityWin* owner, | 60 CONTENT_EXPORT void Initialize(BrowserAccessibilityWin* owner, |
61 const string16& type); | 61 const base::string16& type); |
62 CONTENT_EXPORT void AddTarget(int target_id); | 62 CONTENT_EXPORT void AddTarget(int target_id); |
63 | 63 |
64 // IAccessibleRelation methods. | 64 // IAccessibleRelation methods. |
65 CONTENT_EXPORT STDMETHODIMP get_relationType(BSTR* relation_type); | 65 CONTENT_EXPORT STDMETHODIMP get_relationType(BSTR* relation_type); |
66 CONTENT_EXPORT STDMETHODIMP get_nTargets(long* n_targets); | 66 CONTENT_EXPORT STDMETHODIMP get_nTargets(long* n_targets); |
67 CONTENT_EXPORT STDMETHODIMP get_target(long target_index, IUnknown** target); | 67 CONTENT_EXPORT STDMETHODIMP get_target(long target_index, IUnknown** target); |
68 CONTENT_EXPORT STDMETHODIMP get_targets(long max_targets, | 68 CONTENT_EXPORT STDMETHODIMP get_targets(long max_targets, |
69 IUnknown** targets, | 69 IUnknown** targets, |
70 long* n_targets); | 70 long* n_targets); |
71 | 71 |
72 // IAccessibleRelation methods not implemented. | 72 // IAccessibleRelation methods not implemented. |
73 CONTENT_EXPORT STDMETHODIMP get_localizedRelationType(BSTR* relation_type) { | 73 CONTENT_EXPORT STDMETHODIMP get_localizedRelationType(BSTR* relation_type) { |
74 return E_NOTIMPL; | 74 return E_NOTIMPL; |
75 } | 75 } |
76 | 76 |
77 private: | 77 private: |
78 string16 type_; | 78 base::string16 type_; |
79 base::win::ScopedComPtr<BrowserAccessibilityWin> owner_; | 79 base::win::ScopedComPtr<BrowserAccessibilityWin> owner_; |
80 std::vector<int> target_ids_; | 80 std::vector<int> target_ids_; |
81 }; | 81 }; |
82 | 82 |
83 void BrowserAccessibilityRelation::Initialize(BrowserAccessibilityWin* owner, | 83 void BrowserAccessibilityRelation::Initialize(BrowserAccessibilityWin* owner, |
84 const string16& type) { | 84 const base::string16& type) { |
85 owner_ = owner; | 85 owner_ = owner; |
86 type_ = type; | 86 type_ = type; |
87 } | 87 } |
88 | 88 |
89 void BrowserAccessibilityRelation::AddTarget(int target_id) { | 89 void BrowserAccessibilityRelation::AddTarget(int target_id) { |
90 target_ids_.push_back(target_id); | 90 target_ids_.push_back(target_id); |
91 } | 91 } |
92 | 92 |
93 STDMETHODIMP BrowserAccessibilityRelation::get_relationType( | 93 STDMETHODIMP BrowserAccessibilityRelation::get_relationType( |
94 BSTR* relation_type) { | 94 BSTR* relation_type) { |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
557 if (!value) | 557 if (!value) |
558 return E_INVALIDARG; | 558 return E_INVALIDARG; |
559 | 559 |
560 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); | 560 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); |
561 if (!target) | 561 if (!target) |
562 return E_INVALIDARG; | 562 return E_INVALIDARG; |
563 | 563 |
564 if (target->ia_role() == ROLE_SYSTEM_PROGRESSBAR || | 564 if (target->ia_role() == ROLE_SYSTEM_PROGRESSBAR || |
565 target->ia_role() == ROLE_SYSTEM_SCROLLBAR || | 565 target->ia_role() == ROLE_SYSTEM_SCROLLBAR || |
566 target->ia_role() == ROLE_SYSTEM_SLIDER) { | 566 target->ia_role() == ROLE_SYSTEM_SLIDER) { |
567 string16 value_text = target->GetValueText(); | 567 base::string16 value_text = target->GetValueText(); |
568 *value = SysAllocString(value_text.c_str()); | 568 *value = SysAllocString(value_text.c_str()); |
569 DCHECK(*value); | 569 DCHECK(*value); |
570 return S_OK; | 570 return S_OK; |
571 } | 571 } |
572 | 572 |
573 // Expose color well value. | 573 // Expose color well value. |
574 if (target->ia2_role() == IA2_ROLE_COLOR_CHOOSER) { | 574 if (target->ia2_role() == IA2_ROLE_COLOR_CHOOSER) { |
575 int r = target->GetIntAttribute( | 575 int r = target->GetIntAttribute( |
576 AccessibilityNodeData::ATTR_COLOR_VALUE_RED); | 576 AccessibilityNodeData::ATTR_COLOR_VALUE_RED); |
577 int g = target->GetIntAttribute( | 577 int g = target->GetIntAttribute( |
578 AccessibilityNodeData::ATTR_COLOR_VALUE_GREEN); | 578 AccessibilityNodeData::ATTR_COLOR_VALUE_GREEN); |
579 int b = target->GetIntAttribute( | 579 int b = target->GetIntAttribute( |
580 AccessibilityNodeData::ATTR_COLOR_VALUE_BLUE); | 580 AccessibilityNodeData::ATTR_COLOR_VALUE_BLUE); |
581 string16 value_text; | 581 base::string16 value_text; |
582 value_text = base::IntToString16((r * 100) / 255) + L"% red " + | 582 value_text = base::IntToString16((r * 100) / 255) + L"% red " + |
583 base::IntToString16((g * 100) / 255) + L"% green " + | 583 base::IntToString16((g * 100) / 255) + L"% green " + |
584 base::IntToString16((b * 100) / 255) + L"% blue"; | 584 base::IntToString16((b * 100) / 255) + L"% blue"; |
585 *value = SysAllocString(value_text.c_str()); | 585 *value = SysAllocString(value_text.c_str()); |
586 DCHECK(*value); | 586 DCHECK(*value); |
587 return S_OK; | 587 return S_OK; |
588 } | 588 } |
589 | 589 |
590 *value = SysAllocString(UTF8ToUTF16(target->value()).c_str()); | 590 *value = SysAllocString(UTF8ToUTF16(target->value()).c_str()); |
591 DCHECK(*value); | 591 DCHECK(*value); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
677 | 677 |
678 STDMETHODIMP BrowserAccessibilityWin::get_attributes(BSTR* attributes) { | 678 STDMETHODIMP BrowserAccessibilityWin::get_attributes(BSTR* attributes) { |
679 if (!instance_active_) | 679 if (!instance_active_) |
680 return E_FAIL; | 680 return E_FAIL; |
681 | 681 |
682 if (!attributes) | 682 if (!attributes) |
683 return E_INVALIDARG; | 683 return E_INVALIDARG; |
684 | 684 |
685 // The iaccessible2 attributes are a set of key-value pairs | 685 // The iaccessible2 attributes are a set of key-value pairs |
686 // separated by semicolons, with a colon between the key and the value. | 686 // separated by semicolons, with a colon between the key and the value. |
687 string16 str; | 687 base::string16 str; |
688 for (unsigned int i = 0; i < ia2_attributes_.size(); ++i) { | 688 for (unsigned int i = 0; i < ia2_attributes_.size(); ++i) { |
689 if (i != 0) | 689 if (i != 0) |
690 str += L';'; | 690 str += L';'; |
691 str += ia2_attributes_[i]; | 691 str += ia2_attributes_[i]; |
692 } | 692 } |
693 | 693 |
694 if (str.empty()) | 694 if (str.empty()) |
695 return S_FALSE; | 695 return S_FALSE; |
696 | 696 |
697 *attributes = SysAllocString(str.c_str()); | 697 *attributes = SysAllocString(str.c_str()); |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1126 if (column < 0 || column >= columns) | 1126 if (column < 0 || column >= columns) |
1127 return E_INVALIDARG; | 1127 return E_INVALIDARG; |
1128 | 1128 |
1129 const std::vector<int32>& cell_ids = GetIntListAttribute( | 1129 const std::vector<int32>& cell_ids = GetIntListAttribute( |
1130 AccessibilityNodeData::ATTR_CELL_IDS); | 1130 AccessibilityNodeData::ATTR_CELL_IDS); |
1131 for (int i = 0; i < rows; ++i) { | 1131 for (int i = 0; i < rows; ++i) { |
1132 int cell_id = cell_ids[i * columns + column]; | 1132 int cell_id = cell_ids[i * columns + column]; |
1133 BrowserAccessibilityWin* cell = static_cast<BrowserAccessibilityWin*>( | 1133 BrowserAccessibilityWin* cell = static_cast<BrowserAccessibilityWin*>( |
1134 manager_->GetFromRendererID(cell_id)); | 1134 manager_->GetFromRendererID(cell_id)); |
1135 if (cell && cell->role_ == blink::WebAXRoleColumnHeader) { | 1135 if (cell && cell->role_ == blink::WebAXRoleColumnHeader) { |
1136 string16 cell_name = cell->GetString16Attribute( | 1136 base::string16 cell_name = cell->GetString16Attribute( |
1137 AccessibilityNodeData::ATTR_NAME); | 1137 AccessibilityNodeData::ATTR_NAME); |
1138 if (cell_name.size() > 0) { | 1138 if (cell_name.size() > 0) { |
1139 *description = SysAllocString(cell_name.c_str()); | 1139 *description = SysAllocString(cell_name.c_str()); |
1140 return S_OK; | 1140 return S_OK; |
1141 } | 1141 } |
1142 | 1142 |
1143 return cell->GetStringAttributeAsBstr( | 1143 return cell->GetStringAttributeAsBstr( |
1144 AccessibilityNodeData::ATTR_DESCRIPTION, description); | 1144 AccessibilityNodeData::ATTR_DESCRIPTION, description); |
1145 } | 1145 } |
1146 } | 1146 } |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1313 if (row < 0 || row >= rows) | 1313 if (row < 0 || row >= rows) |
1314 return E_INVALIDARG; | 1314 return E_INVALIDARG; |
1315 | 1315 |
1316 const std::vector<int32>& cell_ids = GetIntListAttribute( | 1316 const std::vector<int32>& cell_ids = GetIntListAttribute( |
1317 AccessibilityNodeData::ATTR_CELL_IDS); | 1317 AccessibilityNodeData::ATTR_CELL_IDS); |
1318 for (int i = 0; i < columns; ++i) { | 1318 for (int i = 0; i < columns; ++i) { |
1319 int cell_id = cell_ids[row * columns + i]; | 1319 int cell_id = cell_ids[row * columns + i]; |
1320 BrowserAccessibilityWin* cell = | 1320 BrowserAccessibilityWin* cell = |
1321 manager_->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin(); | 1321 manager_->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin(); |
1322 if (cell && cell->role_ == blink::WebAXRoleRowHeader) { | 1322 if (cell && cell->role_ == blink::WebAXRoleRowHeader) { |
1323 string16 cell_name = cell->GetString16Attribute( | 1323 base::string16 cell_name = cell->GetString16Attribute( |
1324 AccessibilityNodeData::ATTR_NAME); | 1324 AccessibilityNodeData::ATTR_NAME); |
1325 if (cell_name.size() > 0) { | 1325 if (cell_name.size() > 0) { |
1326 *description = SysAllocString(cell_name.c_str()); | 1326 *description = SysAllocString(cell_name.c_str()); |
1327 return S_OK; | 1327 return S_OK; |
1328 } | 1328 } |
1329 | 1329 |
1330 return cell->GetStringAttributeAsBstr( | 1330 return cell->GetStringAttributeAsBstr( |
1331 AccessibilityNodeData::ATTR_DESCRIPTION, description); | 1331 AccessibilityNodeData::ATTR_DESCRIPTION, description); |
1332 } | 1332 } |
1333 } | 1333 } |
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1919 LONG* out_x, | 1919 LONG* out_x, |
1920 LONG* out_y, | 1920 LONG* out_y, |
1921 LONG* out_width, | 1921 LONG* out_width, |
1922 LONG* out_height) { | 1922 LONG* out_height) { |
1923 if (!instance_active_) | 1923 if (!instance_active_) |
1924 return E_FAIL; | 1924 return E_FAIL; |
1925 | 1925 |
1926 if (!out_x || !out_y || !out_width || !out_height) | 1926 if (!out_x || !out_y || !out_width || !out_height) |
1927 return E_INVALIDARG; | 1927 return E_INVALIDARG; |
1928 | 1928 |
1929 const string16& text_str = TextForIAccessibleText(); | 1929 const base::string16& text_str = TextForIAccessibleText(); |
1930 HandleSpecialTextOffset(text_str, &offset); | 1930 HandleSpecialTextOffset(text_str, &offset); |
1931 | 1931 |
1932 if (offset < 0 || offset > static_cast<LONG>(text_str.size())) | 1932 if (offset < 0 || offset > static_cast<LONG>(text_str.size())) |
1933 return E_INVALIDARG; | 1933 return E_INVALIDARG; |
1934 | 1934 |
1935 if (role_ != blink::WebAXRoleStaticText) | 1935 if (role_ != blink::WebAXRoleStaticText) |
1936 return E_FAIL; | 1936 return E_FAIL; |
1937 | 1937 |
1938 gfx::Rect character_bounds; | 1938 gfx::Rect character_bounds; |
1939 if (coordinate_type == IA2_COORDTYPE_SCREEN_RELATIVE) { | 1939 if (coordinate_type == IA2_COORDTYPE_SCREEN_RELATIVE) { |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2003 | 2003 |
2004 STDMETHODIMP BrowserAccessibilityWin::get_text(LONG start_offset, | 2004 STDMETHODIMP BrowserAccessibilityWin::get_text(LONG start_offset, |
2005 LONG end_offset, | 2005 LONG end_offset, |
2006 BSTR* text) { | 2006 BSTR* text) { |
2007 if (!instance_active_) | 2007 if (!instance_active_) |
2008 return E_FAIL; | 2008 return E_FAIL; |
2009 | 2009 |
2010 if (!text) | 2010 if (!text) |
2011 return E_INVALIDARG; | 2011 return E_INVALIDARG; |
2012 | 2012 |
2013 const string16& text_str = TextForIAccessibleText(); | 2013 const base::string16& text_str = TextForIAccessibleText(); |
2014 | 2014 |
2015 // Handle special text offsets. | 2015 // Handle special text offsets. |
2016 HandleSpecialTextOffset(text_str, &start_offset); | 2016 HandleSpecialTextOffset(text_str, &start_offset); |
2017 HandleSpecialTextOffset(text_str, &end_offset); | 2017 HandleSpecialTextOffset(text_str, &end_offset); |
2018 | 2018 |
2019 // The spec allows the arguments to be reversed. | 2019 // The spec allows the arguments to be reversed. |
2020 if (start_offset > end_offset) { | 2020 if (start_offset > end_offset) { |
2021 LONG tmp = start_offset; | 2021 LONG tmp = start_offset; |
2022 start_offset = end_offset; | 2022 start_offset = end_offset; |
2023 end_offset = tmp; | 2023 end_offset = tmp; |
2024 } | 2024 } |
2025 | 2025 |
2026 // The spec does not allow the start or end offsets to be out or range; | 2026 // The spec does not allow the start or end offsets to be out or range; |
2027 // we must return an error if so. | 2027 // we must return an error if so. |
2028 LONG len = text_str.length(); | 2028 LONG len = text_str.length(); |
2029 if (start_offset < 0) | 2029 if (start_offset < 0) |
2030 return E_INVALIDARG; | 2030 return E_INVALIDARG; |
2031 if (end_offset > len) | 2031 if (end_offset > len) |
2032 return E_INVALIDARG; | 2032 return E_INVALIDARG; |
2033 | 2033 |
2034 string16 substr = text_str.substr(start_offset, end_offset - start_offset); | 2034 base::string16 substr = text_str.substr(start_offset, |
| 2035 end_offset - start_offset); |
2035 if (substr.empty()) | 2036 if (substr.empty()) |
2036 return S_FALSE; | 2037 return S_FALSE; |
2037 | 2038 |
2038 *text = SysAllocString(substr.c_str()); | 2039 *text = SysAllocString(substr.c_str()); |
2039 DCHECK(*text); | 2040 DCHECK(*text); |
2040 return S_OK; | 2041 return S_OK; |
2041 } | 2042 } |
2042 | 2043 |
2043 STDMETHODIMP BrowserAccessibilityWin::get_textAtOffset( | 2044 STDMETHODIMP BrowserAccessibilityWin::get_textAtOffset( |
2044 LONG offset, | 2045 LONG offset, |
2045 enum IA2TextBoundaryType boundary_type, | 2046 enum IA2TextBoundaryType boundary_type, |
2046 LONG* start_offset, | 2047 LONG* start_offset, |
2047 LONG* end_offset, | 2048 LONG* end_offset, |
2048 BSTR* text) { | 2049 BSTR* text) { |
2049 if (!instance_active_) | 2050 if (!instance_active_) |
2050 return E_FAIL; | 2051 return E_FAIL; |
2051 | 2052 |
2052 if (!start_offset || !end_offset || !text) | 2053 if (!start_offset || !end_offset || !text) |
2053 return E_INVALIDARG; | 2054 return E_INVALIDARG; |
2054 | 2055 |
2055 // The IAccessible2 spec says we don't have to implement the "sentence" | 2056 // The IAccessible2 spec says we don't have to implement the "sentence" |
2056 // boundary type, we can just let the screenreader handle it. | 2057 // boundary type, we can just let the screenreader handle it. |
2057 if (boundary_type == IA2_TEXT_BOUNDARY_SENTENCE) { | 2058 if (boundary_type == IA2_TEXT_BOUNDARY_SENTENCE) { |
2058 *start_offset = 0; | 2059 *start_offset = 0; |
2059 *end_offset = 0; | 2060 *end_offset = 0; |
2060 *text = NULL; | 2061 *text = NULL; |
2061 return S_FALSE; | 2062 return S_FALSE; |
2062 } | 2063 } |
2063 | 2064 |
2064 const string16& text_str = TextForIAccessibleText(); | 2065 const base::string16& text_str = TextForIAccessibleText(); |
2065 | 2066 |
2066 *start_offset = FindBoundary( | 2067 *start_offset = FindBoundary( |
2067 text_str, boundary_type, offset, ui::BACKWARDS_DIRECTION); | 2068 text_str, boundary_type, offset, ui::BACKWARDS_DIRECTION); |
2068 *end_offset = FindBoundary( | 2069 *end_offset = FindBoundary( |
2069 text_str, boundary_type, offset, ui::FORWARDS_DIRECTION); | 2070 text_str, boundary_type, offset, ui::FORWARDS_DIRECTION); |
2070 return get_text(*start_offset, *end_offset, text); | 2071 return get_text(*start_offset, *end_offset, text); |
2071 } | 2072 } |
2072 | 2073 |
2073 STDMETHODIMP BrowserAccessibilityWin::get_textBeforeOffset( | 2074 STDMETHODIMP BrowserAccessibilityWin::get_textBeforeOffset( |
2074 LONG offset, | 2075 LONG offset, |
2075 enum IA2TextBoundaryType boundary_type, | 2076 enum IA2TextBoundaryType boundary_type, |
2076 LONG* start_offset, | 2077 LONG* start_offset, |
2077 LONG* end_offset, | 2078 LONG* end_offset, |
2078 BSTR* text) { | 2079 BSTR* text) { |
2079 if (!instance_active_) | 2080 if (!instance_active_) |
2080 return E_FAIL; | 2081 return E_FAIL; |
2081 | 2082 |
2082 if (!start_offset || !end_offset || !text) | 2083 if (!start_offset || !end_offset || !text) |
2083 return E_INVALIDARG; | 2084 return E_INVALIDARG; |
2084 | 2085 |
2085 // The IAccessible2 spec says we don't have to implement the "sentence" | 2086 // The IAccessible2 spec says we don't have to implement the "sentence" |
2086 // boundary type, we can just let the screenreader handle it. | 2087 // boundary type, we can just let the screenreader handle it. |
2087 if (boundary_type == IA2_TEXT_BOUNDARY_SENTENCE) { | 2088 if (boundary_type == IA2_TEXT_BOUNDARY_SENTENCE) { |
2088 *start_offset = 0; | 2089 *start_offset = 0; |
2089 *end_offset = 0; | 2090 *end_offset = 0; |
2090 *text = NULL; | 2091 *text = NULL; |
2091 return S_FALSE; | 2092 return S_FALSE; |
2092 } | 2093 } |
2093 | 2094 |
2094 const string16& text_str = TextForIAccessibleText(); | 2095 const base::string16& text_str = TextForIAccessibleText(); |
2095 | 2096 |
2096 *start_offset = FindBoundary( | 2097 *start_offset = FindBoundary( |
2097 text_str, boundary_type, offset, ui::BACKWARDS_DIRECTION); | 2098 text_str, boundary_type, offset, ui::BACKWARDS_DIRECTION); |
2098 *end_offset = offset; | 2099 *end_offset = offset; |
2099 return get_text(*start_offset, *end_offset, text); | 2100 return get_text(*start_offset, *end_offset, text); |
2100 } | 2101 } |
2101 | 2102 |
2102 STDMETHODIMP BrowserAccessibilityWin::get_textAfterOffset( | 2103 STDMETHODIMP BrowserAccessibilityWin::get_textAfterOffset( |
2103 LONG offset, | 2104 LONG offset, |
2104 enum IA2TextBoundaryType boundary_type, | 2105 enum IA2TextBoundaryType boundary_type, |
2105 LONG* start_offset, | 2106 LONG* start_offset, |
2106 LONG* end_offset, | 2107 LONG* end_offset, |
2107 BSTR* text) { | 2108 BSTR* text) { |
2108 if (!instance_active_) | 2109 if (!instance_active_) |
2109 return E_FAIL; | 2110 return E_FAIL; |
2110 | 2111 |
2111 if (!start_offset || !end_offset || !text) | 2112 if (!start_offset || !end_offset || !text) |
2112 return E_INVALIDARG; | 2113 return E_INVALIDARG; |
2113 | 2114 |
2114 // The IAccessible2 spec says we don't have to implement the "sentence" | 2115 // The IAccessible2 spec says we don't have to implement the "sentence" |
2115 // boundary type, we can just let the screenreader handle it. | 2116 // boundary type, we can just let the screenreader handle it. |
2116 if (boundary_type == IA2_TEXT_BOUNDARY_SENTENCE) { | 2117 if (boundary_type == IA2_TEXT_BOUNDARY_SENTENCE) { |
2117 *start_offset = 0; | 2118 *start_offset = 0; |
2118 *end_offset = 0; | 2119 *end_offset = 0; |
2119 *text = NULL; | 2120 *text = NULL; |
2120 return S_FALSE; | 2121 return S_FALSE; |
2121 } | 2122 } |
2122 | 2123 |
2123 const string16& text_str = TextForIAccessibleText(); | 2124 const base::string16& text_str = TextForIAccessibleText(); |
2124 | 2125 |
2125 *start_offset = offset; | 2126 *start_offset = offset; |
2126 *end_offset = FindBoundary( | 2127 *end_offset = FindBoundary( |
2127 text_str, boundary_type, offset, ui::FORWARDS_DIRECTION); | 2128 text_str, boundary_type, offset, ui::FORWARDS_DIRECTION); |
2128 return get_text(*start_offset, *end_offset, text); | 2129 return get_text(*start_offset, *end_offset, text); |
2129 } | 2130 } |
2130 | 2131 |
2131 STDMETHODIMP BrowserAccessibilityWin::get_newText(IA2TextSegment* new_text) { | 2132 STDMETHODIMP BrowserAccessibilityWin::get_newText(IA2TextSegment* new_text) { |
2132 if (!instance_active_) | 2133 if (!instance_active_) |
2133 return E_FAIL; | 2134 return E_FAIL; |
2134 | 2135 |
2135 if (!new_text) | 2136 if (!new_text) |
2136 return E_INVALIDARG; | 2137 return E_INVALIDARG; |
2137 | 2138 |
2138 string16 text = TextForIAccessibleText(); | 2139 base::string16 text = TextForIAccessibleText(); |
2139 | 2140 |
2140 new_text->text = SysAllocString(text.c_str()); | 2141 new_text->text = SysAllocString(text.c_str()); |
2141 new_text->start = 0; | 2142 new_text->start = 0; |
2142 new_text->end = static_cast<long>(text.size()); | 2143 new_text->end = static_cast<long>(text.size()); |
2143 return S_OK; | 2144 return S_OK; |
2144 } | 2145 } |
2145 | 2146 |
2146 STDMETHODIMP BrowserAccessibilityWin::get_oldText(IA2TextSegment* old_text) { | 2147 STDMETHODIMP BrowserAccessibilityWin::get_oldText(IA2TextSegment* old_text) { |
2147 if (!instance_active_) | 2148 if (!instance_active_) |
2148 return E_FAIL; | 2149 return E_FAIL; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2189 LONG x, LONG y) { | 2190 LONG x, LONG y) { |
2190 // TODO(dmazzoni): adjust this for the start and end index, too. | 2191 // TODO(dmazzoni): adjust this for the start and end index, too. |
2191 return scrollToPoint(coordinate_type, x, y); | 2192 return scrollToPoint(coordinate_type, x, y); |
2192 } | 2193 } |
2193 | 2194 |
2194 STDMETHODIMP BrowserAccessibilityWin::addSelection(LONG start_offset, | 2195 STDMETHODIMP BrowserAccessibilityWin::addSelection(LONG start_offset, |
2195 LONG end_offset) { | 2196 LONG end_offset) { |
2196 if (!instance_active_) | 2197 if (!instance_active_) |
2197 return E_FAIL; | 2198 return E_FAIL; |
2198 | 2199 |
2199 const string16& text_str = TextForIAccessibleText(); | 2200 const base::string16& text_str = TextForIAccessibleText(); |
2200 HandleSpecialTextOffset(text_str, &start_offset); | 2201 HandleSpecialTextOffset(text_str, &start_offset); |
2201 HandleSpecialTextOffset(text_str, &end_offset); | 2202 HandleSpecialTextOffset(text_str, &end_offset); |
2202 | 2203 |
2203 manager_->SetTextSelection(*this, start_offset, end_offset); | 2204 manager_->SetTextSelection(*this, start_offset, end_offset); |
2204 return S_OK; | 2205 return S_OK; |
2205 } | 2206 } |
2206 | 2207 |
2207 STDMETHODIMP BrowserAccessibilityWin::removeSelection(LONG selection_index) { | 2208 STDMETHODIMP BrowserAccessibilityWin::removeSelection(LONG selection_index) { |
2208 if (!instance_active_) | 2209 if (!instance_active_) |
2209 return E_FAIL; | 2210 return E_FAIL; |
2210 | 2211 |
2211 if (selection_index != 0) | 2212 if (selection_index != 0) |
2212 return E_INVALIDARG; | 2213 return E_INVALIDARG; |
2213 | 2214 |
2214 manager_->SetTextSelection(*this, 0, 0); | 2215 manager_->SetTextSelection(*this, 0, 0); |
2215 return S_OK; | 2216 return S_OK; |
2216 } | 2217 } |
2217 | 2218 |
2218 STDMETHODIMP BrowserAccessibilityWin::setCaretOffset(LONG offset) { | 2219 STDMETHODIMP BrowserAccessibilityWin::setCaretOffset(LONG offset) { |
2219 if (!instance_active_) | 2220 if (!instance_active_) |
2220 return E_FAIL; | 2221 return E_FAIL; |
2221 | 2222 |
2222 const string16& text_str = TextForIAccessibleText(); | 2223 const base::string16& text_str = TextForIAccessibleText(); |
2223 HandleSpecialTextOffset(text_str, &offset); | 2224 HandleSpecialTextOffset(text_str, &offset); |
2224 manager_->SetTextSelection(*this, offset, offset); | 2225 manager_->SetTextSelection(*this, offset, offset); |
2225 return S_OK; | 2226 return S_OK; |
2226 } | 2227 } |
2227 | 2228 |
2228 STDMETHODIMP BrowserAccessibilityWin::setSelection(LONG selection_index, | 2229 STDMETHODIMP BrowserAccessibilityWin::setSelection(LONG selection_index, |
2229 LONG start_offset, | 2230 LONG start_offset, |
2230 LONG end_offset) { | 2231 LONG end_offset) { |
2231 if (!instance_active_) | 2232 if (!instance_active_) |
2232 return E_FAIL; | 2233 return E_FAIL; |
2233 | 2234 |
2234 if (selection_index != 0) | 2235 if (selection_index != 0) |
2235 return E_INVALIDARG; | 2236 return E_INVALIDARG; |
2236 | 2237 |
2237 const string16& text_str = TextForIAccessibleText(); | 2238 const base::string16& text_str = TextForIAccessibleText(); |
2238 HandleSpecialTextOffset(text_str, &start_offset); | 2239 HandleSpecialTextOffset(text_str, &start_offset); |
2239 HandleSpecialTextOffset(text_str, &end_offset); | 2240 HandleSpecialTextOffset(text_str, &end_offset); |
2240 | 2241 |
2241 manager_->SetTextSelection(*this, start_offset, end_offset); | 2242 manager_->SetTextSelection(*this, start_offset, end_offset); |
2242 return S_OK; | 2243 return S_OK; |
2243 } | 2244 } |
2244 | 2245 |
2245 // | 2246 // |
2246 // IAccessibleHypertext methods. | 2247 // IAccessibleHypertext methods. |
2247 // | 2248 // |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2422 unsigned int* unique_id, | 2423 unsigned int* unique_id, |
2423 unsigned short* node_type) { | 2424 unsigned short* node_type) { |
2424 if (!instance_active_) | 2425 if (!instance_active_) |
2425 return E_FAIL; | 2426 return E_FAIL; |
2426 | 2427 |
2427 if (!node_name || !name_space_id || !node_value || !num_children || | 2428 if (!node_name || !name_space_id || !node_value || !num_children || |
2428 !unique_id || !node_type) { | 2429 !unique_id || !node_type) { |
2429 return E_INVALIDARG; | 2430 return E_INVALIDARG; |
2430 } | 2431 } |
2431 | 2432 |
2432 string16 tag; | 2433 base::string16 tag; |
2433 if (GetString16Attribute(AccessibilityNodeData::ATTR_HTML_TAG, &tag)) | 2434 if (GetString16Attribute(AccessibilityNodeData::ATTR_HTML_TAG, &tag)) |
2434 *node_name = SysAllocString(tag.c_str()); | 2435 *node_name = SysAllocString(tag.c_str()); |
2435 else | 2436 else |
2436 *node_name = NULL; | 2437 *node_name = NULL; |
2437 | 2438 |
2438 *name_space_id = 0; | 2439 *name_space_id = 0; |
2439 *node_value = SysAllocString(UTF8ToUTF16(value_).c_str()); | 2440 *node_value = SysAllocString(UTF8ToUTF16(value_).c_str()); |
2440 *num_children = PlatformChildCount(); | 2441 *num_children = PlatformChildCount(); |
2441 *unique_id = unique_id_win_; | 2442 *unique_id = unique_id_win_; |
2442 | 2443 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2515 BSTR* style_values, | 2516 BSTR* style_values, |
2516 unsigned short *num_style_properties) { | 2517 unsigned short *num_style_properties) { |
2517 if (!instance_active_) | 2518 if (!instance_active_) |
2518 return E_FAIL; | 2519 return E_FAIL; |
2519 | 2520 |
2520 if (!style_properties || !style_values) | 2521 if (!style_properties || !style_values) |
2521 return E_INVALIDARG; | 2522 return E_INVALIDARG; |
2522 | 2523 |
2523 // We only cache a single style property for now: DISPLAY | 2524 // We only cache a single style property for now: DISPLAY |
2524 | 2525 |
2525 string16 display; | 2526 base::string16 display; |
2526 if (max_style_properties == 0 || | 2527 if (max_style_properties == 0 || |
2527 !GetString16Attribute(AccessibilityNodeData::ATTR_DISPLAY, &display)) { | 2528 !GetString16Attribute(AccessibilityNodeData::ATTR_DISPLAY, &display)) { |
2528 *num_style_properties = 0; | 2529 *num_style_properties = 0; |
2529 return S_OK; | 2530 return S_OK; |
2530 } | 2531 } |
2531 | 2532 |
2532 *num_style_properties = 1; | 2533 *num_style_properties = 1; |
2533 style_properties[0] = SysAllocString(L"display"); | 2534 style_properties[0] = SysAllocString(L"display"); |
2534 style_values[0] = SysAllocString(display.c_str()); | 2535 style_values[0] = SysAllocString(display.c_str()); |
2535 | 2536 |
2536 return S_OK; | 2537 return S_OK; |
2537 } | 2538 } |
2538 | 2539 |
2539 STDMETHODIMP BrowserAccessibilityWin::get_computedStyleForProperties( | 2540 STDMETHODIMP BrowserAccessibilityWin::get_computedStyleForProperties( |
2540 unsigned short num_style_properties, | 2541 unsigned short num_style_properties, |
2541 boolean use_alternate_view, | 2542 boolean use_alternate_view, |
2542 BSTR* style_properties, | 2543 BSTR* style_properties, |
2543 BSTR* style_values) { | 2544 BSTR* style_values) { |
2544 if (!instance_active_) | 2545 if (!instance_active_) |
2545 return E_FAIL; | 2546 return E_FAIL; |
2546 | 2547 |
2547 if (!style_properties || !style_values) | 2548 if (!style_properties || !style_values) |
2548 return E_INVALIDARG; | 2549 return E_INVALIDARG; |
2549 | 2550 |
2550 // We only cache a single style property for now: DISPLAY | 2551 // We only cache a single style property for now: DISPLAY |
2551 | 2552 |
2552 for (unsigned short i = 0; i < num_style_properties; ++i) { | 2553 for (unsigned short i = 0; i < num_style_properties; ++i) { |
2553 string16 name = (LPCWSTR)style_properties[i]; | 2554 base::string16 name = (LPCWSTR)style_properties[i]; |
2554 StringToLowerASCII(&name); | 2555 StringToLowerASCII(&name); |
2555 if (name == L"display") { | 2556 if (name == L"display") { |
2556 string16 display = GetString16Attribute( | 2557 base::string16 display = GetString16Attribute( |
2557 AccessibilityNodeData::ATTR_DISPLAY); | 2558 AccessibilityNodeData::ATTR_DISPLAY); |
2558 style_values[i] = SysAllocString(display.c_str()); | 2559 style_values[i] = SysAllocString(display.c_str()); |
2559 } else { | 2560 } else { |
2560 style_values[i] = NULL; | 2561 style_values[i] = NULL; |
2561 } | 2562 } |
2562 } | 2563 } |
2563 | 2564 |
2564 return S_OK; | 2565 return S_OK; |
2565 } | 2566 } |
2566 | 2567 |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2706 int* out_x, | 2707 int* out_x, |
2707 int* out_y, | 2708 int* out_y, |
2708 int* out_width, | 2709 int* out_width, |
2709 int* out_height) { | 2710 int* out_height) { |
2710 if (!instance_active_) | 2711 if (!instance_active_) |
2711 return E_FAIL; | 2712 return E_FAIL; |
2712 | 2713 |
2713 if (!out_x || !out_y || !out_width || !out_height) | 2714 if (!out_x || !out_y || !out_width || !out_height) |
2714 return E_INVALIDARG; | 2715 return E_INVALIDARG; |
2715 | 2716 |
2716 const string16& text_str = TextForIAccessibleText(); | 2717 const base::string16& text_str = TextForIAccessibleText(); |
2717 if (start_index > text_str.size() || | 2718 if (start_index > text_str.size() || |
2718 end_index > text_str.size() || | 2719 end_index > text_str.size() || |
2719 start_index > end_index) { | 2720 start_index > end_index) { |
2720 return E_INVALIDARG; | 2721 return E_INVALIDARG; |
2721 } | 2722 } |
2722 | 2723 |
2723 if (role_ != blink::WebAXRoleStaticText) | 2724 if (role_ != blink::WebAXRoleStaticText) |
2724 return E_FAIL; | 2725 return E_FAIL; |
2725 | 2726 |
2726 gfx::Rect bounds = GetGlobalBoundsForRange( | 2727 gfx::Rect bounds = GetGlobalBoundsForRange( |
2727 start_index, end_index - start_index); | 2728 start_index, end_index - start_index); |
2728 *out_x = bounds.x(); | 2729 *out_x = bounds.x(); |
2729 *out_y = bounds.y(); | 2730 *out_y = bounds.y(); |
2730 *out_width = bounds.width(); | 2731 *out_width = bounds.width(); |
2731 *out_height = bounds.height(); | 2732 *out_height = bounds.height(); |
2732 return S_OK; | 2733 return S_OK; |
2733 } | 2734 } |
2734 | 2735 |
2735 STDMETHODIMP BrowserAccessibilityWin::scrollToSubstring( | 2736 STDMETHODIMP BrowserAccessibilityWin::scrollToSubstring( |
2736 unsigned int start_index, | 2737 unsigned int start_index, |
2737 unsigned int end_index) { | 2738 unsigned int end_index) { |
2738 if (!instance_active_) | 2739 if (!instance_active_) |
2739 return E_FAIL; | 2740 return E_FAIL; |
2740 | 2741 |
2741 const string16& text_str = TextForIAccessibleText(); | 2742 const base::string16& text_str = TextForIAccessibleText(); |
2742 if (start_index > text_str.size() || | 2743 if (start_index > text_str.size() || |
2743 end_index > text_str.size() || | 2744 end_index > text_str.size() || |
2744 start_index > end_index) { | 2745 start_index > end_index) { |
2745 return E_INVALIDARG; | 2746 return E_INVALIDARG; |
2746 } | 2747 } |
2747 | 2748 |
2748 manager_->ScrollToMakeVisible(*this, GetLocalBoundsForRange( | 2749 manager_->ScrollToMakeVisible(*this, GetLocalBoundsForRange( |
2749 start_index, end_index - start_index)); | 2750 start_index, end_index - start_index)); |
2750 manager_->ToBrowserAccessibilityManagerWin()->TrackScrollingObject(this); | 2751 manager_->ToBrowserAccessibilityManagerWin()->TrackScrollingObject(this); |
2751 | 2752 |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2951 if (ia_role_ == ROLE_SYSTEM_CELL) { | 2952 if (ia_role_ == ROLE_SYSTEM_CELL) { |
2952 BrowserAccessibility* table = parent(); | 2953 BrowserAccessibility* table = parent(); |
2953 while (table && table->role() != blink::WebAXRoleTable) | 2954 while (table && table->role() != blink::WebAXRoleTable) |
2954 table = table->parent(); | 2955 table = table->parent(); |
2955 if (table) { | 2956 if (table) { |
2956 const std::vector<int32>& unique_cell_ids = table->GetIntListAttribute( | 2957 const std::vector<int32>& unique_cell_ids = table->GetIntListAttribute( |
2957 AccessibilityNodeData::ATTR_UNIQUE_CELL_IDS); | 2958 AccessibilityNodeData::ATTR_UNIQUE_CELL_IDS); |
2958 for (size_t i = 0; i < unique_cell_ids.size(); ++i) { | 2959 for (size_t i = 0; i < unique_cell_ids.size(); ++i) { |
2959 if (unique_cell_ids[i] == renderer_id_) { | 2960 if (unique_cell_ids[i] == renderer_id_) { |
2960 ia2_attributes_.push_back( | 2961 ia2_attributes_.push_back( |
2961 string16(L"table-cell-index:") + base::IntToString16(i)); | 2962 base::string16(L"table-cell-index:") + base::IntToString16(i)); |
2962 } | 2963 } |
2963 } | 2964 } |
2964 } | 2965 } |
2965 } | 2966 } |
2966 | 2967 |
2967 // The calculation of the accessible name of an element has been | 2968 // The calculation of the accessible name of an element has been |
2968 // standardized in the HTML to Platform Accessibility APIs Implementation | 2969 // standardized in the HTML to Platform Accessibility APIs Implementation |
2969 // Guide (http://www.w3.org/TR/html-aapi/). In order to return the | 2970 // Guide (http://www.w3.org/TR/html-aapi/). In order to return the |
2970 // appropriate accessible name on Windows, we need to apply some logic | 2971 // appropriate accessible name on Windows, we need to apply some logic |
2971 // to the fields we get from WebKit. | 2972 // to the fields we get from WebKit. |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3090 hyperlinks_.push_back(i); | 3091 hyperlinks_.push_back(i); |
3091 } | 3092 } |
3092 } | 3093 } |
3093 DCHECK_EQ(hyperlink_offset_to_index_.size(), hyperlinks_.size()); | 3094 DCHECK_EQ(hyperlink_offset_to_index_.size(), hyperlinks_.size()); |
3094 | 3095 |
3095 // Fire an event when an alert first appears. | 3096 // Fire an event when an alert first appears. |
3096 if (role_ == blink::WebAXRoleAlert && first_time_) | 3097 if (role_ == blink::WebAXRoleAlert && first_time_) |
3097 manager_->NotifyAccessibilityEvent(blink::WebAXEventAlert, this); | 3098 manager_->NotifyAccessibilityEvent(blink::WebAXEventAlert, this); |
3098 | 3099 |
3099 // Fire events if text has changed. | 3100 // Fire events if text has changed. |
3100 string16 text = TextForIAccessibleText(); | 3101 base::string16 text = TextForIAccessibleText(); |
3101 if (previous_text_ != text) { | 3102 if (previous_text_ != text) { |
3102 if (!previous_text_.empty() && !text.empty()) { | 3103 if (!previous_text_.empty() && !text.empty()) { |
3103 manager_->NotifyAccessibilityEvent( | 3104 manager_->NotifyAccessibilityEvent( |
3104 blink::WebAXEventShow, this); | 3105 blink::WebAXEventShow, this); |
3105 } | 3106 } |
3106 | 3107 |
3107 // TODO(dmazzoni): Look into HIDE events, too. | 3108 // TODO(dmazzoni): Look into HIDE events, too. |
3108 | 3109 |
3109 old_text_ = previous_text_; | 3110 old_text_ = previous_text_; |
3110 previous_text_ = text; | 3111 previous_text_ = text; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3178 if (child_id >= 1 && child_id <= static_cast<LONG>(PlatformChildCount())) | 3179 if (child_id >= 1 && child_id <= static_cast<LONG>(PlatformChildCount())) |
3179 return PlatformGetChild(child_id - 1)->ToBrowserAccessibilityWin(); | 3180 return PlatformGetChild(child_id - 1)->ToBrowserAccessibilityWin(); |
3180 | 3181 |
3181 return manager_->ToBrowserAccessibilityManagerWin()-> | 3182 return manager_->ToBrowserAccessibilityManagerWin()-> |
3182 GetFromUniqueIdWin(child_id); | 3183 GetFromUniqueIdWin(child_id); |
3183 } | 3184 } |
3184 | 3185 |
3185 HRESULT BrowserAccessibilityWin::GetStringAttributeAsBstr( | 3186 HRESULT BrowserAccessibilityWin::GetStringAttributeAsBstr( |
3186 AccessibilityNodeData::StringAttribute attribute, | 3187 AccessibilityNodeData::StringAttribute attribute, |
3187 BSTR* value_bstr) { | 3188 BSTR* value_bstr) { |
3188 string16 str; | 3189 base::string16 str; |
3189 | 3190 |
3190 if (!GetString16Attribute(attribute, &str)) | 3191 if (!GetString16Attribute(attribute, &str)) |
3191 return S_FALSE; | 3192 return S_FALSE; |
3192 | 3193 |
3193 if (str.empty()) | 3194 if (str.empty()) |
3194 return S_FALSE; | 3195 return S_FALSE; |
3195 | 3196 |
3196 *value_bstr = SysAllocString(str.c_str()); | 3197 *value_bstr = SysAllocString(str.c_str()); |
3197 DCHECK(*value_bstr); | 3198 DCHECK(*value_bstr); |
3198 | 3199 |
3199 return S_OK; | 3200 return S_OK; |
3200 } | 3201 } |
3201 | 3202 |
3202 void BrowserAccessibilityWin::StringAttributeToIA2( | 3203 void BrowserAccessibilityWin::StringAttributeToIA2( |
3203 AccessibilityNodeData::StringAttribute attribute, | 3204 AccessibilityNodeData::StringAttribute attribute, |
3204 const char* ia2_attr) { | 3205 const char* ia2_attr) { |
3205 string16 value; | 3206 base::string16 value; |
3206 if (GetString16Attribute(attribute, &value)) | 3207 if (GetString16Attribute(attribute, &value)) |
3207 ia2_attributes_.push_back(ASCIIToUTF16(ia2_attr) + L":" + value); | 3208 ia2_attributes_.push_back(ASCIIToUTF16(ia2_attr) + L":" + value); |
3208 } | 3209 } |
3209 | 3210 |
3210 void BrowserAccessibilityWin::BoolAttributeToIA2( | 3211 void BrowserAccessibilityWin::BoolAttributeToIA2( |
3211 AccessibilityNodeData::BoolAttribute attribute, | 3212 AccessibilityNodeData::BoolAttribute attribute, |
3212 const char* ia2_attr) { | 3213 const char* ia2_attr) { |
3213 bool value; | 3214 bool value; |
3214 if (GetBoolAttribute(attribute, &value)) { | 3215 if (GetBoolAttribute(attribute, &value)) { |
3215 ia2_attributes_.push_back((ASCIIToUTF16(ia2_attr) + L":") + | 3216 ia2_attributes_.push_back((ASCIIToUTF16(ia2_attr) + L":") + |
3216 (value ? L"true" : L"false")); | 3217 (value ? L"true" : L"false")); |
3217 } | 3218 } |
3218 } | 3219 } |
3219 | 3220 |
3220 void BrowserAccessibilityWin::IntAttributeToIA2( | 3221 void BrowserAccessibilityWin::IntAttributeToIA2( |
3221 AccessibilityNodeData::IntAttribute attribute, | 3222 AccessibilityNodeData::IntAttribute attribute, |
3222 const char* ia2_attr) { | 3223 const char* ia2_attr) { |
3223 int value; | 3224 int value; |
3224 if (GetIntAttribute(attribute, &value)) { | 3225 if (GetIntAttribute(attribute, &value)) { |
3225 ia2_attributes_.push_back(ASCIIToUTF16(ia2_attr) + L":" + | 3226 ia2_attributes_.push_back(ASCIIToUTF16(ia2_attr) + L":" + |
3226 base::IntToString16(value)); | 3227 base::IntToString16(value)); |
3227 } | 3228 } |
3228 } | 3229 } |
3229 | 3230 |
3230 string16 BrowserAccessibilityWin::GetValueText() { | 3231 base::string16 BrowserAccessibilityWin::GetValueText() { |
3231 float fval; | 3232 float fval; |
3232 string16 value = UTF8ToUTF16(value_); | 3233 base::string16 value = UTF8ToUTF16(value_); |
3233 if (value.empty() && | 3234 if (value.empty() && |
3234 GetFloatAttribute(AccessibilityNodeData::ATTR_VALUE_FOR_RANGE, &fval)) { | 3235 GetFloatAttribute(AccessibilityNodeData::ATTR_VALUE_FOR_RANGE, &fval)) { |
3235 value = UTF8ToUTF16(base::DoubleToString(fval)); | 3236 value = UTF8ToUTF16(base::DoubleToString(fval)); |
3236 } | 3237 } |
3237 return value; | 3238 return value; |
3238 } | 3239 } |
3239 | 3240 |
3240 string16 BrowserAccessibilityWin::TextForIAccessibleText() { | 3241 base::string16 BrowserAccessibilityWin::TextForIAccessibleText() { |
3241 if (IsEditableText()) | 3242 if (IsEditableText()) |
3242 return UTF8ToUTF16(value_); | 3243 return UTF8ToUTF16(value_); |
3243 return (role_ == blink::WebAXRoleStaticText) ? | 3244 return (role_ == blink::WebAXRoleStaticText) ? |
3244 UTF8ToUTF16(name_) : hypertext_; | 3245 UTF8ToUTF16(name_) : hypertext_; |
3245 } | 3246 } |
3246 | 3247 |
3247 void BrowserAccessibilityWin::HandleSpecialTextOffset(const string16& text, | 3248 void BrowserAccessibilityWin::HandleSpecialTextOffset( |
3248 LONG* offset) { | 3249 const base::string16& text, |
| 3250 LONG* offset) { |
3249 if (*offset == IA2_TEXT_OFFSET_LENGTH) | 3251 if (*offset == IA2_TEXT_OFFSET_LENGTH) |
3250 *offset = static_cast<LONG>(text.size()); | 3252 *offset = static_cast<LONG>(text.size()); |
3251 else if (*offset == IA2_TEXT_OFFSET_CARET) | 3253 else if (*offset == IA2_TEXT_OFFSET_CARET) |
3252 get_caretOffset(offset); | 3254 get_caretOffset(offset); |
3253 } | 3255 } |
3254 | 3256 |
3255 ui::TextBoundaryType BrowserAccessibilityWin::IA2TextBoundaryToTextBoundary( | 3257 ui::TextBoundaryType BrowserAccessibilityWin::IA2TextBoundaryToTextBoundary( |
3256 IA2TextBoundaryType ia2_boundary) { | 3258 IA2TextBoundaryType ia2_boundary) { |
3257 switch(ia2_boundary) { | 3259 switch(ia2_boundary) { |
3258 case IA2_TEXT_BOUNDARY_CHAR: return ui::CHAR_BOUNDARY; | 3260 case IA2_TEXT_BOUNDARY_CHAR: return ui::CHAR_BOUNDARY; |
3259 case IA2_TEXT_BOUNDARY_WORD: return ui::WORD_BOUNDARY; | 3261 case IA2_TEXT_BOUNDARY_WORD: return ui::WORD_BOUNDARY; |
3260 case IA2_TEXT_BOUNDARY_LINE: return ui::LINE_BOUNDARY; | 3262 case IA2_TEXT_BOUNDARY_LINE: return ui::LINE_BOUNDARY; |
3261 case IA2_TEXT_BOUNDARY_SENTENCE: return ui::SENTENCE_BOUNDARY; | 3263 case IA2_TEXT_BOUNDARY_SENTENCE: return ui::SENTENCE_BOUNDARY; |
3262 case IA2_TEXT_BOUNDARY_PARAGRAPH: return ui::PARAGRAPH_BOUNDARY; | 3264 case IA2_TEXT_BOUNDARY_PARAGRAPH: return ui::PARAGRAPH_BOUNDARY; |
3263 case IA2_TEXT_BOUNDARY_ALL: return ui::ALL_BOUNDARY; | 3265 case IA2_TEXT_BOUNDARY_ALL: return ui::ALL_BOUNDARY; |
3264 default: | 3266 default: |
3265 NOTREACHED(); | 3267 NOTREACHED(); |
3266 return ui::CHAR_BOUNDARY; | 3268 return ui::CHAR_BOUNDARY; |
3267 } | 3269 } |
3268 } | 3270 } |
3269 | 3271 |
3270 LONG BrowserAccessibilityWin::FindBoundary( | 3272 LONG BrowserAccessibilityWin::FindBoundary( |
3271 const string16& text, | 3273 const base::string16& text, |
3272 IA2TextBoundaryType ia2_boundary, | 3274 IA2TextBoundaryType ia2_boundary, |
3273 LONG start_offset, | 3275 LONG start_offset, |
3274 ui::TextBoundaryDirection direction) { | 3276 ui::TextBoundaryDirection direction) { |
3275 HandleSpecialTextOffset(text, &start_offset); | 3277 HandleSpecialTextOffset(text, &start_offset); |
3276 ui::TextBoundaryType boundary = IA2TextBoundaryToTextBoundary(ia2_boundary); | 3278 ui::TextBoundaryType boundary = IA2TextBoundaryToTextBoundary(ia2_boundary); |
3277 const std::vector<int32>& line_breaks = GetIntListAttribute( | 3279 const std::vector<int32>& line_breaks = GetIntListAttribute( |
3278 AccessibilityNodeData::ATTR_LINE_BREAKS); | 3280 AccessibilityNodeData::ATTR_LINE_BREAKS); |
3279 return ui::FindAccessibleTextBoundary( | 3281 return ui::FindAccessibleTextBoundary( |
3280 text, line_breaks, boundary, start_offset, direction); | 3282 text, line_breaks, boundary, start_offset, direction); |
3281 } | 3283 } |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3338 } | 3340 } |
3339 if (HasState(blink::WebAXStateVisited)) | 3341 if (HasState(blink::WebAXStateVisited)) |
3340 ia_state_ |= STATE_SYSTEM_TRAVERSED; | 3342 ia_state_ |= STATE_SYSTEM_TRAVERSED; |
3341 | 3343 |
3342 // WebKit marks everything as readonly unless it's editable text, so if it's | 3344 // WebKit marks everything as readonly unless it's editable text, so if it's |
3343 // not readonly, mark it as editable now. The final computation of the | 3345 // not readonly, mark it as editable now. The final computation of the |
3344 // READONLY state for MSAA is below, after the switch. | 3346 // READONLY state for MSAA is below, after the switch. |
3345 if (!HasState(blink::WebAXStateReadonly)) | 3347 if (!HasState(blink::WebAXStateReadonly)) |
3346 ia2_state_ |= IA2_STATE_EDITABLE; | 3348 ia2_state_ |= IA2_STATE_EDITABLE; |
3347 | 3349 |
3348 string16 invalid; | 3350 base::string16 invalid; |
3349 if (GetHtmlAttribute("aria-invalid", &invalid)) | 3351 if (GetHtmlAttribute("aria-invalid", &invalid)) |
3350 ia2_state_ |= IA2_STATE_INVALID_ENTRY; | 3352 ia2_state_ |= IA2_STATE_INVALID_ENTRY; |
3351 | 3353 |
3352 if (GetBoolAttribute(AccessibilityNodeData::ATTR_BUTTON_MIXED)) | 3354 if (GetBoolAttribute(AccessibilityNodeData::ATTR_BUTTON_MIXED)) |
3353 ia_state_ |= STATE_SYSTEM_MIXED; | 3355 ia_state_ |= STATE_SYSTEM_MIXED; |
3354 | 3356 |
3355 if (GetBoolAttribute(AccessibilityNodeData::ATTR_CAN_SET_VALUE)) | 3357 if (GetBoolAttribute(AccessibilityNodeData::ATTR_CAN_SET_VALUE)) |
3356 ia2_state_ |= IA2_STATE_EDITABLE; | 3358 ia2_state_ |= IA2_STATE_EDITABLE; |
3357 | 3359 |
3358 string16 html_tag = GetString16Attribute( | 3360 base::string16 html_tag = GetString16Attribute( |
3359 AccessibilityNodeData::ATTR_HTML_TAG); | 3361 AccessibilityNodeData::ATTR_HTML_TAG); |
3360 ia_role_ = 0; | 3362 ia_role_ = 0; |
3361 ia2_role_ = 0; | 3363 ia2_role_ = 0; |
3362 switch (role_) { | 3364 switch (role_) { |
3363 case blink::WebAXRoleAlert: | 3365 case blink::WebAXRoleAlert: |
3364 ia_role_ = ROLE_SYSTEM_ALERT; | 3366 ia_role_ = ROLE_SYSTEM_ALERT; |
3365 break; | 3367 break; |
3366 case blink::WebAXRoleAlertDialog: | 3368 case blink::WebAXRoleAlertDialog: |
3367 ia_role_ = ROLE_SYSTEM_DIALOG; | 3369 ia_role_ = ROLE_SYSTEM_DIALOG; |
3368 break; | 3370 break; |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3462 break; | 3464 break; |
3463 case blink::WebAXRoleFooter: | 3465 case blink::WebAXRoleFooter: |
3464 ia_role_ = IA2_ROLE_FOOTER; | 3466 ia_role_ = IA2_ROLE_FOOTER; |
3465 ia_state_ |= STATE_SYSTEM_READONLY; | 3467 ia_state_ |= STATE_SYSTEM_READONLY; |
3466 break; | 3468 break; |
3467 case blink::WebAXRoleGrid: | 3469 case blink::WebAXRoleGrid: |
3468 ia_role_ = ROLE_SYSTEM_TABLE; | 3470 ia_role_ = ROLE_SYSTEM_TABLE; |
3469 ia_state_ |= STATE_SYSTEM_READONLY; | 3471 ia_state_ |= STATE_SYSTEM_READONLY; |
3470 break; | 3472 break; |
3471 case blink::WebAXRoleGroup: { | 3473 case blink::WebAXRoleGroup: { |
3472 string16 aria_role = GetString16Attribute( | 3474 base::string16 aria_role = GetString16Attribute( |
3473 AccessibilityNodeData::ATTR_ROLE); | 3475 AccessibilityNodeData::ATTR_ROLE); |
3474 if (aria_role == L"group" || html_tag == L"fieldset") { | 3476 if (aria_role == L"group" || html_tag == L"fieldset") { |
3475 ia_role_ = ROLE_SYSTEM_GROUPING; | 3477 ia_role_ = ROLE_SYSTEM_GROUPING; |
3476 } else if (html_tag == L"li") { | 3478 } else if (html_tag == L"li") { |
3477 ia_role_ = ROLE_SYSTEM_LISTITEM; | 3479 ia_role_ = ROLE_SYSTEM_LISTITEM; |
3478 } else { | 3480 } else { |
3479 if (html_tag.empty()) | 3481 if (html_tag.empty()) |
3480 role_name_ = L"div"; | 3482 role_name_ = L"div"; |
3481 else | 3483 else |
3482 role_name_ = html_tag; | 3484 role_name_ = html_tag; |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3660 case blink::WebAXRoleSplitter: | 3662 case blink::WebAXRoleSplitter: |
3661 ia_role_ = ROLE_SYSTEM_SEPARATOR; | 3663 ia_role_ = ROLE_SYSTEM_SEPARATOR; |
3662 break; | 3664 break; |
3663 case blink::WebAXRoleSVGRoot: | 3665 case blink::WebAXRoleSVGRoot: |
3664 ia_role_ = ROLE_SYSTEM_GRAPHIC; | 3666 ia_role_ = ROLE_SYSTEM_GRAPHIC; |
3665 break; | 3667 break; |
3666 case blink::WebAXRoleTab: | 3668 case blink::WebAXRoleTab: |
3667 ia_role_ = ROLE_SYSTEM_PAGETAB; | 3669 ia_role_ = ROLE_SYSTEM_PAGETAB; |
3668 break; | 3670 break; |
3669 case blink::WebAXRoleTable: { | 3671 case blink::WebAXRoleTable: { |
3670 string16 aria_role = GetString16Attribute( | 3672 base::string16 aria_role = GetString16Attribute( |
3671 AccessibilityNodeData::ATTR_ROLE); | 3673 AccessibilityNodeData::ATTR_ROLE); |
3672 if (aria_role == L"treegrid") { | 3674 if (aria_role == L"treegrid") { |
3673 ia_role_ = ROLE_SYSTEM_OUTLINE; | 3675 ia_role_ = ROLE_SYSTEM_OUTLINE; |
3674 } else { | 3676 } else { |
3675 ia_role_ = ROLE_SYSTEM_TABLE; | 3677 ia_role_ = ROLE_SYSTEM_TABLE; |
3676 ia_state_ |= STATE_SYSTEM_READONLY; | 3678 ia_state_ |= STATE_SYSTEM_READONLY; |
3677 } | 3679 } |
3678 break; | 3680 break; |
3679 } | 3681 } |
3680 case blink::WebAXRoleTableHeaderContainer: | 3682 case blink::WebAXRoleTableHeaderContainer: |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3771 // The role should always be set. | 3773 // The role should always be set. |
3772 DCHECK(!role_name_.empty() || ia_role_); | 3774 DCHECK(!role_name_.empty() || ia_role_); |
3773 | 3775 |
3774 // If we didn't explicitly set the IAccessible2 role, make it the same | 3776 // If we didn't explicitly set the IAccessible2 role, make it the same |
3775 // as the MSAA role. | 3777 // as the MSAA role. |
3776 if (!ia2_role_) | 3778 if (!ia2_role_) |
3777 ia2_role_ = ia_role_; | 3779 ia2_role_ = ia_role_; |
3778 } | 3780 } |
3779 | 3781 |
3780 } // namespace content | 3782 } // namespace content |
OLD | NEW |