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/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
107 for (long i = *n_targets - 1; i >= 0; --i) { | 107 for (long i = *n_targets - 1; i >= 0; --i) { |
108 BrowserAccessibility* result = manager->GetFromRendererID(target_ids_[i]); | 108 BrowserAccessibility* result = manager->GetFromRendererID(target_ids_[i]); |
109 if (!result || !result->instance_active()) { | 109 if (!result || !result->instance_active()) { |
110 *n_targets = 0; | 110 *n_targets = 0; |
111 break; | 111 break; |
112 } | 112 } |
113 } | 113 } |
114 return S_OK; | 114 return S_OK; |
115 } | 115 } |
116 | 116 |
117 STDMETHODIMP BrowserAccessibilityRelation::get_target( | 117 STDMETHODIMP BrowserAccessibilityRelation::get_target(long target_index, |
118 long target_index, IUnknown** target) { | 118 IUnknown** target) { |
119 if (!target) | 119 if (!target) |
120 return E_INVALIDARG; | 120 return E_INVALIDARG; |
121 | 121 |
122 if (!owner_->instance_active()) | 122 if (!owner_->instance_active()) |
123 return E_FAIL; | 123 return E_FAIL; |
124 | 124 |
125 if (target_index < 0 || | 125 if (target_index < 0 || |
126 target_index >= static_cast<long>(target_ids_.size())) { | 126 target_index >= static_cast<long>(target_ids_.size())) { |
127 return E_INVALIDARG; | 127 return E_INVALIDARG; |
128 } | 128 } |
129 | 129 |
130 BrowserAccessibilityManager* manager = owner_->manager(); | 130 BrowserAccessibilityManager* manager = owner_->manager(); |
131 BrowserAccessibility* result = | 131 BrowserAccessibility* result = |
132 manager->GetFromRendererID(target_ids_[target_index]); | 132 manager->GetFromRendererID(target_ids_[target_index]); |
133 if (!result || !result->instance_active()) | 133 if (!result || !result->instance_active()) |
134 return E_FAIL; | 134 return E_FAIL; |
135 | 135 |
136 *target = static_cast<IAccessible*>( | 136 *target = static_cast<IAccessible*>( |
137 result->ToBrowserAccessibilityWin()->NewReference()); | 137 result->ToBrowserAccessibilityWin()->NewReference()); |
138 return S_OK; | 138 return S_OK; |
139 } | 139 } |
140 | 140 |
141 STDMETHODIMP BrowserAccessibilityRelation::get_targets( | 141 STDMETHODIMP BrowserAccessibilityRelation::get_targets(long max_targets, |
142 long max_targets, IUnknown** targets, long* n_targets) { | 142 IUnknown** targets, |
143 long* n_targets) { | |
143 if (!targets || !n_targets) | 144 if (!targets || !n_targets) |
144 return E_INVALIDARG; | 145 return E_INVALIDARG; |
145 | 146 |
146 if (!owner_->instance_active()) | 147 if (!owner_->instance_active()) |
147 return E_FAIL; | 148 return E_FAIL; |
148 | 149 |
149 long count = static_cast<long>(target_ids_.size()); | 150 long count = static_cast<long>(target_ids_.size()); |
150 if (count > max_targets) | 151 if (count > max_targets) |
151 count = max_targets; | 152 count = max_targets; |
152 | 153 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
235 // Point is within this object. | 236 // Point is within this object. |
236 child->vt = VT_I4; | 237 child->vt = VT_I4; |
237 child->lVal = CHILDID_SELF; | 238 child->lVal = CHILDID_SELF; |
238 } else { | 239 } else { |
239 child->vt = VT_DISPATCH; | 240 child->vt = VT_DISPATCH; |
240 child->pdispVal = result->ToBrowserAccessibilityWin()->NewReference(); | 241 child->pdispVal = result->ToBrowserAccessibilityWin()->NewReference(); |
241 } | 242 } |
242 return S_OK; | 243 return S_OK; |
243 } | 244 } |
244 | 245 |
245 STDMETHODIMP BrowserAccessibilityWin::accLocation(LONG* x_left, LONG* y_top, | 246 STDMETHODIMP BrowserAccessibilityWin::accLocation(LONG* x_left, |
dmazzoni
2012/11/13 03:54:02
The style guide used to allow this, oh well.
| |
246 LONG* width, LONG* height, | 247 LONG* y_top, |
248 LONG* width, | |
249 LONG* height, | |
247 VARIANT var_id) { | 250 VARIANT var_id) { |
248 if (!instance_active_) | 251 if (!instance_active_) |
249 return E_FAIL; | 252 return E_FAIL; |
250 | 253 |
251 if (!x_left || !y_top || !width || !height) | 254 if (!x_left || !y_top || !width || !height) |
252 return E_INVALIDARG; | 255 return E_INVALIDARG; |
253 | 256 |
254 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); | 257 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); |
255 if (!target) | 258 if (!target) |
256 return E_INVALIDARG; | 259 return E_INVALIDARG; |
257 | 260 |
258 gfx::Rect bounds = target->GetGlobalBoundsRect(); | 261 gfx::Rect bounds = target->GetGlobalBoundsRect(); |
259 *x_left = bounds.x(); | 262 *x_left = bounds.x(); |
260 *y_top = bounds.y(); | 263 *y_top = bounds.y(); |
261 *width = bounds.width(); | 264 *width = bounds.width(); |
262 *height = bounds.height(); | 265 *height = bounds.height(); |
263 | 266 |
264 return S_OK; | 267 return S_OK; |
265 } | 268 } |
266 | 269 |
267 STDMETHODIMP BrowserAccessibilityWin::accNavigate( | 270 STDMETHODIMP BrowserAccessibilityWin::accNavigate(LONG nav_dir, |
268 LONG nav_dir, VARIANT start, VARIANT* end) { | 271 VARIANT start, |
272 VARIANT* end) { | |
269 BrowserAccessibilityWin* target = GetTargetFromChildID(start); | 273 BrowserAccessibilityWin* target = GetTargetFromChildID(start); |
270 if (!target) | 274 if (!target) |
271 return E_INVALIDARG; | 275 return E_INVALIDARG; |
272 | 276 |
273 if ((nav_dir == NAVDIR_LASTCHILD || nav_dir == NAVDIR_FIRSTCHILD) && | 277 if ((nav_dir == NAVDIR_LASTCHILD || nav_dir == NAVDIR_FIRSTCHILD) && |
274 start.lVal != CHILDID_SELF) { | 278 start.lVal != CHILDID_SELF) { |
275 // MSAA states that navigating to first/last child can only be from self. | 279 // MSAA states that navigating to first/last child can only be from self. |
276 return E_INVALIDARG; | 280 return E_INVALIDARG; |
277 } | 281 } |
278 | 282 |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
471 // return the IAccessible for the window. | 475 // return the IAccessible for the window. |
472 parent = manager_->ToBrowserAccessibilityManagerWin()-> | 476 parent = manager_->ToBrowserAccessibilityManagerWin()-> |
473 GetParentWindowIAccessible(); | 477 GetParentWindowIAccessible(); |
474 } | 478 } |
475 | 479 |
476 parent->AddRef(); | 480 parent->AddRef(); |
477 *disp_parent = parent; | 481 *disp_parent = parent; |
478 return S_OK; | 482 return S_OK; |
479 } | 483 } |
480 | 484 |
481 STDMETHODIMP BrowserAccessibilityWin::get_accRole( | 485 STDMETHODIMP BrowserAccessibilityWin::get_accRole(VARIANT var_id, |
482 VARIANT var_id, VARIANT* role) { | 486 VARIANT* role) { |
483 if (!instance_active_) | 487 if (!instance_active_) |
484 return E_FAIL; | 488 return E_FAIL; |
485 | 489 |
486 if (!role) | 490 if (!role) |
487 return E_INVALIDARG; | 491 return E_INVALIDARG; |
488 | 492 |
489 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); | 493 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); |
490 if (!target) | 494 if (!target) |
491 return E_INVALIDARG; | 495 return E_INVALIDARG; |
492 | 496 |
(...skipping 20 matching lines...) Expand all Loading... | |
513 return E_INVALIDARG; | 517 return E_INVALIDARG; |
514 | 518 |
515 state->vt = VT_I4; | 519 state->vt = VT_I4; |
516 state->lVal = target->ia_state_; | 520 state->lVal = target->ia_state_; |
517 if (manager_->GetFocus(NULL) == this) | 521 if (manager_->GetFocus(NULL) == this) |
518 state->lVal |= STATE_SYSTEM_FOCUSED; | 522 state->lVal |= STATE_SYSTEM_FOCUSED; |
519 | 523 |
520 return S_OK; | 524 return S_OK; |
521 } | 525 } |
522 | 526 |
523 STDMETHODIMP BrowserAccessibilityWin::get_accValue( | 527 STDMETHODIMP BrowserAccessibilityWin::get_accValue(VARIANT var_id, |
524 VARIANT var_id, BSTR* value) { | 528 BSTR* value) { |
525 if (!instance_active_) | 529 if (!instance_active_) |
526 return E_FAIL; | 530 return E_FAIL; |
527 | 531 |
528 if (!value) | 532 if (!value) |
529 return E_INVALIDARG; | 533 return E_INVALIDARG; |
530 | 534 |
531 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); | 535 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); |
532 if (!target) | 536 if (!target) |
533 return E_INVALIDARG; | 537 return E_INVALIDARG; |
534 | 538 |
535 *value = SysAllocString(target->value_.c_str()); | 539 *value = SysAllocString(target->value_.c_str()); |
536 | 540 |
537 DCHECK(*value); | 541 DCHECK(*value); |
538 return S_OK; | 542 return S_OK; |
539 } | 543 } |
540 | 544 |
541 STDMETHODIMP BrowserAccessibilityWin::get_accHelpTopic( | 545 STDMETHODIMP BrowserAccessibilityWin::get_accHelpTopic(BSTR* help_file, |
542 BSTR* help_file, VARIANT var_id, LONG* topic_id) { | 546 VARIANT var_id, |
547 LONG* topic_id) { | |
543 return E_NOTIMPL; | 548 return E_NOTIMPL; |
544 } | 549 } |
545 | 550 |
546 STDMETHODIMP BrowserAccessibilityWin::get_accSelection(VARIANT* selected) { | 551 STDMETHODIMP BrowserAccessibilityWin::get_accSelection(VARIANT* selected) { |
547 if (!instance_active_) | 552 if (!instance_active_) |
548 return E_FAIL; | 553 return E_FAIL; |
549 | 554 |
550 if (role_ != AccessibilityNodeData::ROLE_LISTBOX) | 555 if (role_ != AccessibilityNodeData::ROLE_LISTBOX) |
551 return E_NOTIMPL; | 556 return E_NOTIMPL; |
552 | 557 |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
840 return E_FAIL; | 845 return E_FAIL; |
841 | 846 |
842 if (!desc) | 847 if (!desc) |
843 return E_INVALIDARG; | 848 return E_INVALIDARG; |
844 | 849 |
845 return GetStringAttributeAsBstr( | 850 return GetStringAttributeAsBstr( |
846 AccessibilityNodeData::ATTR_DESCRIPTION, desc); | 851 AccessibilityNodeData::ATTR_DESCRIPTION, desc); |
847 } | 852 } |
848 | 853 |
849 STDMETHODIMP BrowserAccessibilityWin::get_imagePosition( | 854 STDMETHODIMP BrowserAccessibilityWin::get_imagePosition( |
850 enum IA2CoordinateType coordinate_type, LONG* x, LONG* y) { | 855 enum IA2CoordinateType coordinate_type, |
856 LONG* x, | |
857 LONG* y) { | |
851 if (!instance_active_) | 858 if (!instance_active_) |
852 return E_FAIL; | 859 return E_FAIL; |
853 | 860 |
854 if (!x || !y) | 861 if (!x || !y) |
855 return E_INVALIDARG; | 862 return E_INVALIDARG; |
856 | 863 |
857 if (coordinate_type == IA2_COORDTYPE_SCREEN_RELATIVE) { | 864 if (coordinate_type == IA2_COORDTYPE_SCREEN_RELATIVE) { |
858 HWND parent_hwnd = manager_->GetParentView(); | 865 HWND parent_hwnd = manager_->GetParentView(); |
859 POINT top_left = {0, 0}; | 866 POINT top_left = {0, 0}; |
860 ::ClientToScreen(parent_hwnd, &top_left); | 867 ::ClientToScreen(parent_hwnd, &top_left); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
931 if (!instance_active_) | 938 if (!instance_active_) |
932 return E_FAIL; | 939 return E_FAIL; |
933 | 940 |
934 if (!accessible) | 941 if (!accessible) |
935 return E_INVALIDARG; | 942 return E_INVALIDARG; |
936 | 943 |
937 // TODO(dmazzoni): implement | 944 // TODO(dmazzoni): implement |
938 return S_FALSE; | 945 return S_FALSE; |
939 } | 946 } |
940 | 947 |
941 STDMETHODIMP BrowserAccessibilityWin::get_childIndex( | 948 STDMETHODIMP BrowserAccessibilityWin::get_childIndex(long row, |
942 long row, | 949 long column, |
943 long column, | 950 long* cell_index) { |
944 long* cell_index) { | |
945 if (!instance_active_) | 951 if (!instance_active_) |
946 return E_FAIL; | 952 return E_FAIL; |
947 | 953 |
948 if (!cell_index) | 954 if (!cell_index) |
949 return E_INVALIDARG; | 955 return E_INVALIDARG; |
950 | 956 |
951 int columns; | 957 int columns; |
952 int rows; | 958 int rows; |
953 if (!GetIntAttribute( | 959 if (!GetIntAttribute( |
954 AccessibilityNodeData::ATTR_TABLE_COLUMN_COUNT, &columns) || | 960 AccessibilityNodeData::ATTR_TABLE_COLUMN_COUNT, &columns) || |
(...skipping 12 matching lines...) Expand all Loading... | |
967 for (size_t i = 0; i < unique_cell_ids_.size(); ++i) { | 973 for (size_t i = 0; i < unique_cell_ids_.size(); ++i) { |
968 if (unique_cell_ids_[i] == cell_id) { | 974 if (unique_cell_ids_[i] == cell_id) { |
969 *cell_index = (long)i; | 975 *cell_index = (long)i; |
970 return S_OK; | 976 return S_OK; |
971 } | 977 } |
972 } | 978 } |
973 | 979 |
974 return S_FALSE; | 980 return S_FALSE; |
975 } | 981 } |
976 | 982 |
977 STDMETHODIMP BrowserAccessibilityWin::get_columnDescription( | 983 STDMETHODIMP BrowserAccessibilityWin::get_columnDescription(long column, |
978 long column, | 984 BSTR* description) { |
979 BSTR* description) { | |
980 if (!instance_active_) | 985 if (!instance_active_) |
981 return E_FAIL; | 986 return E_FAIL; |
982 | 987 |
983 if (!description) | 988 if (!description) |
984 return E_INVALIDARG; | 989 return E_INVALIDARG; |
985 | 990 |
986 int columns; | 991 int columns; |
987 int rows; | 992 int rows; |
988 if (!GetIntAttribute( | 993 if (!GetIntAttribute( |
989 AccessibilityNodeData::ATTR_TABLE_COLUMN_COUNT, &columns) || | 994 AccessibilityNodeData::ATTR_TABLE_COLUMN_COUNT, &columns) || |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1052 return S_FALSE; | 1057 return S_FALSE; |
1053 } | 1058 } |
1054 | 1059 |
1055 STDMETHODIMP BrowserAccessibilityWin::get_columnHeader( | 1060 STDMETHODIMP BrowserAccessibilityWin::get_columnHeader( |
1056 IAccessibleTable** accessible_table, | 1061 IAccessibleTable** accessible_table, |
1057 long* starting_row_index) { | 1062 long* starting_row_index) { |
1058 // TODO(dmazzoni): implement | 1063 // TODO(dmazzoni): implement |
1059 return E_NOTIMPL; | 1064 return E_NOTIMPL; |
1060 } | 1065 } |
1061 | 1066 |
1062 STDMETHODIMP BrowserAccessibilityWin::get_columnIndex( | 1067 STDMETHODIMP BrowserAccessibilityWin::get_columnIndex(long cell_index, |
1063 long cell_index, | 1068 long* column_index) { |
1064 long* column_index) { | |
1065 if (!instance_active_) | 1069 if (!instance_active_) |
1066 return E_FAIL; | 1070 return E_FAIL; |
1067 | 1071 |
1068 if (!column_index) | 1072 if (!column_index) |
1069 return E_INVALIDARG; | 1073 return E_INVALIDARG; |
1070 | 1074 |
1071 int cell_id_count = static_cast<int>(unique_cell_ids_.size()); | 1075 int cell_id_count = static_cast<int>(unique_cell_ids_.size()); |
1072 if (cell_index < 0) | 1076 if (cell_index < 0) |
1073 return E_INVALIDARG; | 1077 return E_INVALIDARG; |
1074 if (cell_index >= cell_id_count) | 1078 if (cell_index >= cell_id_count) |
1075 return S_FALSE; | 1079 return S_FALSE; |
1076 | 1080 |
1077 int cell_id = unique_cell_ids_[cell_index]; | 1081 int cell_id = unique_cell_ids_[cell_index]; |
1078 BrowserAccessibilityWin* cell = | 1082 BrowserAccessibilityWin* cell = |
1079 manager_->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin(); | 1083 manager_->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin(); |
1080 int col_index; | 1084 int col_index; |
1081 if (cell && | 1085 if (cell && |
1082 cell->GetIntAttribute( | 1086 cell->GetIntAttribute( |
1083 AccessibilityNodeData::ATTR_TABLE_CELL_COLUMN_INDEX, &col_index)) { | 1087 AccessibilityNodeData::ATTR_TABLE_CELL_COLUMN_INDEX, &col_index)) { |
1084 *column_index = col_index; | 1088 *column_index = col_index; |
1085 return S_OK; | 1089 return S_OK; |
1086 } | 1090 } |
1087 | 1091 |
1088 return S_FALSE; | 1092 return S_FALSE; |
1089 } | 1093 } |
1090 | 1094 |
1091 STDMETHODIMP BrowserAccessibilityWin::get_nColumns( | 1095 STDMETHODIMP BrowserAccessibilityWin::get_nColumns(long* column_count) { |
1092 long* column_count) { | |
1093 if (!instance_active_) | 1096 if (!instance_active_) |
1094 return E_FAIL; | 1097 return E_FAIL; |
1095 | 1098 |
1096 if (!column_count) | 1099 if (!column_count) |
1097 return E_INVALIDARG; | 1100 return E_INVALIDARG; |
1098 | 1101 |
1099 int columns; | 1102 int columns; |
1100 if (GetIntAttribute( | 1103 if (GetIntAttribute( |
1101 AccessibilityNodeData::ATTR_TABLE_COLUMN_COUNT, &columns)) { | 1104 AccessibilityNodeData::ATTR_TABLE_COLUMN_COUNT, &columns)) { |
1102 *column_count = columns; | 1105 *column_count = columns; |
1103 return S_OK; | 1106 return S_OK; |
1104 } | 1107 } |
1105 | 1108 |
1106 return S_FALSE; | 1109 return S_FALSE; |
1107 } | 1110 } |
1108 | 1111 |
1109 STDMETHODIMP BrowserAccessibilityWin::get_nRows( | 1112 STDMETHODIMP BrowserAccessibilityWin::get_nRows(long* row_count) { |
1110 long* row_count) { | |
1111 if (!instance_active_) | 1113 if (!instance_active_) |
1112 return E_FAIL; | 1114 return E_FAIL; |
1113 | 1115 |
1114 if (!row_count) | 1116 if (!row_count) |
1115 return E_INVALIDARG; | 1117 return E_INVALIDARG; |
1116 | 1118 |
1117 int rows; | 1119 int rows; |
1118 if (GetIntAttribute(AccessibilityNodeData::ATTR_TABLE_ROW_COUNT, &rows)) { | 1120 if (GetIntAttribute(AccessibilityNodeData::ATTR_TABLE_ROW_COUNT, &rows)) { |
1119 *row_count = rows; | 1121 *row_count = rows; |
1120 return S_OK; | 1122 return S_OK; |
1121 } | 1123 } |
1122 | 1124 |
1123 return S_FALSE; | 1125 return S_FALSE; |
1124 } | 1126 } |
1125 | 1127 |
1126 STDMETHODIMP BrowserAccessibilityWin::get_nSelectedChildren( | 1128 STDMETHODIMP BrowserAccessibilityWin::get_nSelectedChildren(long* cell_count) { |
1127 long* cell_count) { | |
1128 if (!instance_active_) | 1129 if (!instance_active_) |
1129 return E_FAIL; | 1130 return E_FAIL; |
1130 | 1131 |
1131 if (!cell_count) | 1132 if (!cell_count) |
1132 return E_INVALIDARG; | 1133 return E_INVALIDARG; |
1133 | 1134 |
1134 // TODO(dmazzoni): add support for selected cells/rows/columns in tables. | 1135 // TODO(dmazzoni): add support for selected cells/rows/columns in tables. |
1135 *cell_count = 0; | 1136 *cell_count = 0; |
1136 return S_OK; | 1137 return S_OK; |
1137 } | 1138 } |
1138 | 1139 |
1139 STDMETHODIMP BrowserAccessibilityWin::get_nSelectedColumns( | 1140 STDMETHODIMP BrowserAccessibilityWin::get_nSelectedColumns(long* column_count) { |
1140 long* column_count) { | |
1141 if (!instance_active_) | 1141 if (!instance_active_) |
1142 return E_FAIL; | 1142 return E_FAIL; |
1143 | 1143 |
1144 if (!column_count) | 1144 if (!column_count) |
1145 return E_INVALIDARG; | 1145 return E_INVALIDARG; |
1146 | 1146 |
1147 *column_count = 0; | 1147 *column_count = 0; |
1148 return S_OK; | 1148 return S_OK; |
1149 } | 1149 } |
1150 | 1150 |
1151 STDMETHODIMP BrowserAccessibilityWin::get_nSelectedRows( | 1151 STDMETHODIMP BrowserAccessibilityWin::get_nSelectedRows(long* row_count) { |
1152 long* row_count) { | |
1153 if (!instance_active_) | 1152 if (!instance_active_) |
1154 return E_FAIL; | 1153 return E_FAIL; |
1155 | 1154 |
1156 if (!row_count) | 1155 if (!row_count) |
1157 return E_INVALIDARG; | 1156 return E_INVALIDARG; |
1158 | 1157 |
1159 *row_count = 0; | 1158 *row_count = 0; |
1160 return S_OK; | 1159 return S_OK; |
1161 } | 1160 } |
1162 | 1161 |
1163 STDMETHODIMP BrowserAccessibilityWin::get_rowDescription( | 1162 STDMETHODIMP BrowserAccessibilityWin::get_rowDescription(long row, |
1164 long row, | 1163 BSTR* description) { |
1165 BSTR* description) { | |
1166 if (!instance_active_) | 1164 if (!instance_active_) |
1167 return E_FAIL; | 1165 return E_FAIL; |
1168 | 1166 |
1169 if (!description) | 1167 if (!description) |
1170 return E_INVALIDARG; | 1168 return E_INVALIDARG; |
1171 | 1169 |
1172 int columns; | 1170 int columns; |
1173 int rows; | 1171 int rows; |
1174 if (!GetIntAttribute( | 1172 if (!GetIntAttribute( |
1175 AccessibilityNodeData::ATTR_TABLE_COLUMN_COUNT, &columns) || | 1173 AccessibilityNodeData::ATTR_TABLE_COLUMN_COUNT, &columns) || |
(...skipping 17 matching lines...) Expand all Loading... | |
1193 } | 1191 } |
1194 | 1192 |
1195 return cell->GetStringAttributeAsBstr( | 1193 return cell->GetStringAttributeAsBstr( |
1196 AccessibilityNodeData::ATTR_DESCRIPTION, description); | 1194 AccessibilityNodeData::ATTR_DESCRIPTION, description); |
1197 } | 1195 } |
1198 } | 1196 } |
1199 | 1197 |
1200 return S_FALSE; | 1198 return S_FALSE; |
1201 } | 1199 } |
1202 | 1200 |
1203 STDMETHODIMP BrowserAccessibilityWin::get_rowExtentAt( | 1201 STDMETHODIMP BrowserAccessibilityWin::get_rowExtentAt(long row, |
1204 long row, | 1202 long column, |
1205 long column, | 1203 long* n_rows_spanned) { |
1206 long* n_rows_spanned) { | |
1207 if (!instance_active_) | 1204 if (!instance_active_) |
1208 return E_FAIL; | 1205 return E_FAIL; |
1209 | 1206 |
1210 if (!n_rows_spanned) | 1207 if (!n_rows_spanned) |
1211 return E_INVALIDARG; | 1208 return E_INVALIDARG; |
1212 | 1209 |
1213 int columns; | 1210 int columns; |
1214 int rows; | 1211 int rows; |
1215 if (!GetIntAttribute( | 1212 if (!GetIntAttribute( |
1216 AccessibilityNodeData::ATTR_TABLE_COLUMN_COUNT, &columns) || | 1213 AccessibilityNodeData::ATTR_TABLE_COLUMN_COUNT, &columns) || |
(...skipping 15 matching lines...) Expand all Loading... | |
1232 AccessibilityNodeData::ATTR_TABLE_CELL_ROW_SPAN, &rowspan) && | 1229 AccessibilityNodeData::ATTR_TABLE_CELL_ROW_SPAN, &rowspan) && |
1233 rowspan >= 1) { | 1230 rowspan >= 1) { |
1234 *n_rows_spanned = rowspan; | 1231 *n_rows_spanned = rowspan; |
1235 return S_OK; | 1232 return S_OK; |
1236 } | 1233 } |
1237 | 1234 |
1238 return S_FALSE; | 1235 return S_FALSE; |
1239 } | 1236 } |
1240 | 1237 |
1241 STDMETHODIMP BrowserAccessibilityWin::get_rowHeader( | 1238 STDMETHODIMP BrowserAccessibilityWin::get_rowHeader( |
1242 IAccessibleTable **accessible_table, | 1239 IAccessibleTable** accessible_table, |
1243 long* starting_column_index) { | 1240 long* starting_column_index) { |
1244 // TODO(dmazzoni): implement | 1241 // TODO(dmazzoni): implement |
1245 return E_NOTIMPL; | 1242 return E_NOTIMPL; |
1246 } | 1243 } |
1247 | 1244 |
1248 STDMETHODIMP BrowserAccessibilityWin::get_rowIndex( | 1245 STDMETHODIMP BrowserAccessibilityWin::get_rowIndex(long cell_index, |
1249 long cell_index, | 1246 long* row_index) { |
1250 long* row_index) { | |
1251 if (!instance_active_) | 1247 if (!instance_active_) |
1252 return E_FAIL; | 1248 return E_FAIL; |
1253 | 1249 |
1254 if (!row_index) | 1250 if (!row_index) |
1255 return E_INVALIDARG; | 1251 return E_INVALIDARG; |
1256 | 1252 |
1257 int cell_id_count = static_cast<int>(unique_cell_ids_.size()); | 1253 int cell_id_count = static_cast<int>(unique_cell_ids_.size()); |
1258 if (cell_index < 0) | 1254 if (cell_index < 0) |
1259 return E_INVALIDARG; | 1255 return E_INVALIDARG; |
1260 if (cell_index >= cell_id_count) | 1256 if (cell_index >= cell_id_count) |
1261 return S_FALSE; | 1257 return S_FALSE; |
1262 | 1258 |
1263 int cell_id = unique_cell_ids_[cell_index]; | 1259 int cell_id = unique_cell_ids_[cell_index]; |
1264 BrowserAccessibilityWin* cell = | 1260 BrowserAccessibilityWin* cell = |
1265 manager_->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin(); | 1261 manager_->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin(); |
1266 int cell_row_index; | 1262 int cell_row_index; |
1267 if (cell && | 1263 if (cell && |
1268 cell->GetIntAttribute( | 1264 cell->GetIntAttribute( |
1269 AccessibilityNodeData::ATTR_TABLE_CELL_ROW_INDEX, &cell_row_index)) { | 1265 AccessibilityNodeData::ATTR_TABLE_CELL_ROW_INDEX, &cell_row_index)) { |
1270 *row_index = cell_row_index; | 1266 *row_index = cell_row_index; |
1271 return S_OK; | 1267 return S_OK; |
1272 } | 1268 } |
1273 | 1269 |
1274 return S_FALSE; | 1270 return S_FALSE; |
1275 } | 1271 } |
1276 | 1272 |
1277 STDMETHODIMP BrowserAccessibilityWin::get_selectedChildren( | 1273 STDMETHODIMP BrowserAccessibilityWin::get_selectedChildren(long max_children, |
1278 long max_children, | 1274 long** children, |
1279 long** children, | 1275 long* n_children) { |
1280 long* n_children) { | |
1281 if (!instance_active_) | 1276 if (!instance_active_) |
1282 return E_FAIL; | 1277 return E_FAIL; |
1283 | 1278 |
1284 if (!children || !n_children) | 1279 if (!children || !n_children) |
1285 return E_INVALIDARG; | 1280 return E_INVALIDARG; |
1286 | 1281 |
1287 // TODO(dmazzoni): Implement this. | 1282 // TODO(dmazzoni): Implement this. |
1288 *n_children = 0; | 1283 *n_children = 0; |
1289 return S_OK; | 1284 return S_OK; |
1290 } | 1285 } |
1291 | 1286 |
1292 STDMETHODIMP BrowserAccessibilityWin::get_selectedColumns( | 1287 STDMETHODIMP BrowserAccessibilityWin::get_selectedColumns(long max_columns, |
1293 long max_columns, | 1288 long** columns, |
1294 long** columns, | 1289 long* n_columns) { |
1295 long* n_columns) { | |
1296 if (!instance_active_) | 1290 if (!instance_active_) |
1297 return E_FAIL; | 1291 return E_FAIL; |
1298 | 1292 |
1299 if (!columns || !n_columns) | 1293 if (!columns || !n_columns) |
1300 return E_INVALIDARG; | 1294 return E_INVALIDARG; |
1301 | 1295 |
1302 // TODO(dmazzoni): Implement this. | 1296 // TODO(dmazzoni): Implement this. |
1303 *n_columns = 0; | 1297 *n_columns = 0; |
1304 return S_OK; | 1298 return S_OK; |
1305 } | 1299 } |
1306 | 1300 |
1307 STDMETHODIMP BrowserAccessibilityWin::get_selectedRows( | 1301 STDMETHODIMP BrowserAccessibilityWin::get_selectedRows(long max_rows, |
1308 long max_rows, | 1302 long** rows, |
1309 long** rows, | 1303 long* n_rows) { |
1310 long* n_rows) { | |
1311 if (!instance_active_) | 1304 if (!instance_active_) |
1312 return E_FAIL; | 1305 return E_FAIL; |
1313 | 1306 |
1314 if (!rows || !n_rows) | 1307 if (!rows || !n_rows) |
1315 return E_INVALIDARG; | 1308 return E_INVALIDARG; |
1316 | 1309 |
1317 // TODO(dmazzoni): Implement this. | 1310 // TODO(dmazzoni): Implement this. |
1318 *n_rows = 0; | 1311 *n_rows = 0; |
1319 return S_OK; | 1312 return S_OK; |
1320 } | 1313 } |
1321 | 1314 |
1322 STDMETHODIMP BrowserAccessibilityWin::get_summary( | 1315 STDMETHODIMP BrowserAccessibilityWin::get_summary(IUnknown** accessible) { |
1323 IUnknown** accessible) { | |
1324 if (!instance_active_) | 1316 if (!instance_active_) |
1325 return E_FAIL; | 1317 return E_FAIL; |
1326 | 1318 |
1327 if (!accessible) | 1319 if (!accessible) |
1328 return E_INVALIDARG; | 1320 return E_INVALIDARG; |
1329 | 1321 |
1330 // TODO(dmazzoni): implement | 1322 // TODO(dmazzoni): implement |
1331 return S_FALSE; | 1323 return S_FALSE; |
1332 } | 1324 } |
1333 | 1325 |
1334 STDMETHODIMP BrowserAccessibilityWin::get_isColumnSelected( | 1326 STDMETHODIMP BrowserAccessibilityWin::get_isColumnSelected( |
1335 long column, | 1327 long column, |
1336 boolean* is_selected) { | 1328 boolean* is_selected) { |
1337 if (!instance_active_) | 1329 if (!instance_active_) |
1338 return E_FAIL; | 1330 return E_FAIL; |
1339 | 1331 |
1340 if (!is_selected) | 1332 if (!is_selected) |
1341 return E_INVALIDARG; | 1333 return E_INVALIDARG; |
1342 | 1334 |
1343 // TODO(dmazzoni): Implement this. | 1335 // TODO(dmazzoni): Implement this. |
1344 *is_selected = false; | 1336 *is_selected = false; |
1345 return S_OK; | 1337 return S_OK; |
1346 } | 1338 } |
1347 | 1339 |
1348 STDMETHODIMP BrowserAccessibilityWin::get_isRowSelected( | 1340 STDMETHODIMP BrowserAccessibilityWin::get_isRowSelected(long row, |
1349 long row, | 1341 boolean* is_selected) { |
1350 boolean* is_selected) { | |
1351 if (!instance_active_) | 1342 if (!instance_active_) |
1352 return E_FAIL; | 1343 return E_FAIL; |
1353 | 1344 |
1354 if (!is_selected) | 1345 if (!is_selected) |
1355 return E_INVALIDARG; | 1346 return E_INVALIDARG; |
1356 | 1347 |
1357 // TODO(dmazzoni): Implement this. | 1348 // TODO(dmazzoni): Implement this. |
1358 *is_selected = false; | 1349 *is_selected = false; |
1359 return S_OK; | 1350 return S_OK; |
1360 } | 1351 } |
1361 | 1352 |
1362 STDMETHODIMP BrowserAccessibilityWin::get_isSelected( | 1353 STDMETHODIMP BrowserAccessibilityWin::get_isSelected(long row, |
1363 long row, | 1354 long column, |
1364 long column, | 1355 boolean* is_selected) { |
1365 boolean* is_selected) { | |
1366 if (!instance_active_) | 1356 if (!instance_active_) |
1367 return E_FAIL; | 1357 return E_FAIL; |
1368 | 1358 |
1369 if (!is_selected) | 1359 if (!is_selected) |
1370 return E_INVALIDARG; | 1360 return E_INVALIDARG; |
1371 | 1361 |
1372 // TODO(dmazzoni): Implement this. | 1362 // TODO(dmazzoni): Implement this. |
1373 *is_selected = false; | 1363 *is_selected = false; |
1374 return S_OK; | 1364 return S_OK; |
1375 } | 1365 } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1410 return S_OK; | 1400 return S_OK; |
1411 } | 1401 } |
1412 | 1402 |
1413 return S_FALSE; | 1403 return S_FALSE; |
1414 } | 1404 } |
1415 | 1405 |
1416 // | 1406 // |
1417 // IAccessibleTable2 methods. | 1407 // IAccessibleTable2 methods. |
1418 // | 1408 // |
1419 | 1409 |
1420 STDMETHODIMP BrowserAccessibilityWin::get_cellAt( | 1410 STDMETHODIMP BrowserAccessibilityWin::get_cellAt(long row, |
1421 long row, | 1411 long column, |
1422 long column, | 1412 IUnknown** cell) { |
1423 IUnknown** cell) { | |
1424 return get_accessibleAt(row, column, cell); | 1413 return get_accessibleAt(row, column, cell); |
1425 } | 1414 } |
1426 | 1415 |
1427 STDMETHODIMP BrowserAccessibilityWin::get_nSelectedCells(long* cell_count) { | 1416 STDMETHODIMP BrowserAccessibilityWin::get_nSelectedCells(long* cell_count) { |
1428 return get_nSelectedChildren(cell_count); | 1417 return get_nSelectedChildren(cell_count); |
1429 } | 1418 } |
1430 | 1419 |
1431 STDMETHODIMP BrowserAccessibilityWin::get_selectedCells( | 1420 STDMETHODIMP BrowserAccessibilityWin::get_selectedCells( |
1432 IUnknown*** cells, | 1421 IUnknown*** cells, |
1433 long* n_selected_cells) { | 1422 long* n_selected_cells) { |
1434 if (!instance_active_) | 1423 if (!instance_active_) |
1435 return E_FAIL; | 1424 return E_FAIL; |
1436 | 1425 |
1437 if (!cells || !n_selected_cells) | 1426 if (!cells || !n_selected_cells) |
1438 return E_INVALIDARG; | 1427 return E_INVALIDARG; |
1439 | 1428 |
1440 // TODO(dmazzoni): Implement this. | 1429 // TODO(dmazzoni): Implement this. |
1441 *n_selected_cells = 0; | 1430 *n_selected_cells = 0; |
1442 return S_OK; | 1431 return S_OK; |
1443 } | 1432 } |
1444 | 1433 |
1445 STDMETHODIMP BrowserAccessibilityWin::get_selectedColumns( | 1434 STDMETHODIMP BrowserAccessibilityWin::get_selectedColumns(long** columns, |
1446 long** columns, | 1435 long* n_columns) { |
1447 long* n_columns) { | |
1448 if (!instance_active_) | 1436 if (!instance_active_) |
1449 return E_FAIL; | 1437 return E_FAIL; |
1450 | 1438 |
1451 if (!columns || !n_columns) | 1439 if (!columns || !n_columns) |
1452 return E_INVALIDARG; | 1440 return E_INVALIDARG; |
1453 | 1441 |
1454 // TODO(dmazzoni): Implement this. | 1442 // TODO(dmazzoni): Implement this. |
1455 *n_columns = 0; | 1443 *n_columns = 0; |
1456 return S_OK; | 1444 return S_OK; |
1457 } | 1445 } |
1458 | 1446 |
1459 STDMETHODIMP BrowserAccessibilityWin::get_selectedRows( | 1447 STDMETHODIMP BrowserAccessibilityWin::get_selectedRows(long** rows, |
1460 long** rows, | 1448 long* n_rows) { |
1461 long* n_rows) { | |
1462 if (!instance_active_) | 1449 if (!instance_active_) |
1463 return E_FAIL; | 1450 return E_FAIL; |
1464 | 1451 |
1465 if (!rows || !n_rows) | 1452 if (!rows || !n_rows) |
1466 return E_INVALIDARG; | 1453 return E_INVALIDARG; |
1467 | 1454 |
1468 // TODO(dmazzoni): Implement this. | 1455 // TODO(dmazzoni): Implement this. |
1469 *n_rows = 0; | 1456 *n_rows = 0; |
1470 return S_OK; | 1457 return S_OK; |
1471 } | 1458 } |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1548 if (cell && cell->role_ == AccessibilityNodeData::ROLE_COLUMN_HEADER) { | 1535 if (cell && cell->role_ == AccessibilityNodeData::ROLE_COLUMN_HEADER) { |
1549 (*cell_accessibles)[index] = | 1536 (*cell_accessibles)[index] = |
1550 static_cast<IAccessible*>(cell->NewReference()); | 1537 static_cast<IAccessible*>(cell->NewReference()); |
1551 ++index; | 1538 ++index; |
1552 } | 1539 } |
1553 } | 1540 } |
1554 | 1541 |
1555 return S_OK; | 1542 return S_OK; |
1556 } | 1543 } |
1557 | 1544 |
1558 STDMETHODIMP BrowserAccessibilityWin::get_columnIndex( | 1545 STDMETHODIMP BrowserAccessibilityWin::get_columnIndex(long* column_index) { |
1559 long* column_index) { | |
1560 if (!instance_active_) | 1546 if (!instance_active_) |
1561 return E_FAIL; | 1547 return E_FAIL; |
1562 | 1548 |
1563 if (!column_index) | 1549 if (!column_index) |
1564 return E_INVALIDARG; | 1550 return E_INVALIDARG; |
1565 | 1551 |
1566 int column; | 1552 int column; |
1567 if (GetIntAttribute( | 1553 if (GetIntAttribute( |
1568 AccessibilityNodeData::ATTR_TABLE_CELL_COLUMN_INDEX, &column)) { | 1554 AccessibilityNodeData::ATTR_TABLE_CELL_COLUMN_INDEX, &column)) { |
1569 *column_index = column; | 1555 *column_index = column; |
1570 return S_OK; | 1556 return S_OK; |
1571 } | 1557 } |
1572 | 1558 |
1573 return S_FALSE; | 1559 return S_FALSE; |
1574 } | 1560 } |
1575 | 1561 |
1576 STDMETHODIMP BrowserAccessibilityWin::get_rowExtent( | 1562 STDMETHODIMP BrowserAccessibilityWin::get_rowExtent(long* n_rows_spanned) { |
1577 long* n_rows_spanned) { | |
1578 if (!instance_active_) | 1563 if (!instance_active_) |
1579 return E_FAIL; | 1564 return E_FAIL; |
1580 | 1565 |
1581 if (!n_rows_spanned) | 1566 if (!n_rows_spanned) |
1582 return E_INVALIDARG; | 1567 return E_INVALIDARG; |
1583 | 1568 |
1584 int rowspan; | 1569 int rowspan; |
1585 if (GetIntAttribute( | 1570 if (GetIntAttribute( |
1586 AccessibilityNodeData::ATTR_TABLE_CELL_ROW_SPAN, &rowspan) && | 1571 AccessibilityNodeData::ATTR_TABLE_CELL_ROW_SPAN, &rowspan) && |
1587 rowspan >= 1) { | 1572 rowspan >= 1) { |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1646 if (cell && cell->role_ == AccessibilityNodeData::ROLE_ROW_HEADER) { | 1631 if (cell && cell->role_ == AccessibilityNodeData::ROLE_ROW_HEADER) { |
1647 (*cell_accessibles)[index] = | 1632 (*cell_accessibles)[index] = |
1648 static_cast<IAccessible*>(cell->NewReference()); | 1633 static_cast<IAccessible*>(cell->NewReference()); |
1649 ++index; | 1634 ++index; |
1650 } | 1635 } |
1651 } | 1636 } |
1652 | 1637 |
1653 return S_OK; | 1638 return S_OK; |
1654 } | 1639 } |
1655 | 1640 |
1656 STDMETHODIMP BrowserAccessibilityWin::get_rowIndex( | 1641 STDMETHODIMP BrowserAccessibilityWin::get_rowIndex(long* row_index) { |
1657 long* row_index) { | |
1658 if (!instance_active_) | 1642 if (!instance_active_) |
1659 return E_FAIL; | 1643 return E_FAIL; |
1660 | 1644 |
1661 if (!row_index) | 1645 if (!row_index) |
1662 return E_INVALIDARG; | 1646 return E_INVALIDARG; |
1663 | 1647 |
1664 int row; | 1648 int row; |
1665 if (GetIntAttribute(AccessibilityNodeData::ATTR_TABLE_CELL_ROW_INDEX, &row)) { | 1649 if (GetIntAttribute(AccessibilityNodeData::ATTR_TABLE_CELL_ROW_INDEX, &row)) { |
1666 *row_index = row; | 1650 *row_index = row; |
1667 return S_OK; | 1651 return S_OK; |
1668 } | 1652 } |
1669 return S_FALSE; | 1653 return S_FALSE; |
1670 } | 1654 } |
1671 | 1655 |
1672 STDMETHODIMP BrowserAccessibilityWin::get_isSelected( | 1656 STDMETHODIMP BrowserAccessibilityWin::get_isSelected(boolean* is_selected) { |
1673 boolean* is_selected) { | |
1674 if (!instance_active_) | 1657 if (!instance_active_) |
1675 return E_FAIL; | 1658 return E_FAIL; |
1676 | 1659 |
1677 if (!is_selected) | 1660 if (!is_selected) |
1678 return E_INVALIDARG; | 1661 return E_INVALIDARG; |
1679 | 1662 |
1680 *is_selected = false; | 1663 *is_selected = false; |
1681 return S_OK; | 1664 return S_OK; |
1682 } | 1665 } |
1683 | 1666 |
(...skipping 29 matching lines...) Expand all Loading... | |
1713 *column_index = column; | 1696 *column_index = column; |
1714 *row_extents = rowspan; | 1697 *row_extents = rowspan; |
1715 *column_extents = colspan; | 1698 *column_extents = colspan; |
1716 *is_selected = false; | 1699 *is_selected = false; |
1717 return S_OK; | 1700 return S_OK; |
1718 } | 1701 } |
1719 | 1702 |
1720 return S_FALSE; | 1703 return S_FALSE; |
1721 } | 1704 } |
1722 | 1705 |
1723 STDMETHODIMP BrowserAccessibilityWin::get_table( | 1706 STDMETHODIMP BrowserAccessibilityWin::get_table(IUnknown** table) { |
1724 IUnknown** table) { | |
1725 if (!instance_active_) | 1707 if (!instance_active_) |
1726 return E_FAIL; | 1708 return E_FAIL; |
1727 | 1709 |
1728 if (!table) | 1710 if (!table) |
1729 return E_INVALIDARG; | 1711 return E_INVALIDARG; |
1730 | 1712 |
1731 | 1713 |
1732 int row; | 1714 int row; |
1733 int column; | 1715 int column; |
1734 GetIntAttribute(AccessibilityNodeData::ATTR_TABLE_CELL_ROW_INDEX, &row); | 1716 GetIntAttribute(AccessibilityNodeData::ATTR_TABLE_CELL_ROW_INDEX, &row); |
(...skipping 28 matching lines...) Expand all Loading... | |
1763 return S_OK; | 1745 return S_OK; |
1764 } | 1746 } |
1765 | 1747 |
1766 STDMETHODIMP BrowserAccessibilityWin::get_caretOffset(LONG* offset) { | 1748 STDMETHODIMP BrowserAccessibilityWin::get_caretOffset(LONG* offset) { |
1767 if (!instance_active_) | 1749 if (!instance_active_) |
1768 return E_FAIL; | 1750 return E_FAIL; |
1769 | 1751 |
1770 if (!offset) | 1752 if (!offset) |
1771 return E_INVALIDARG; | 1753 return E_INVALIDARG; |
1772 | 1754 |
1755 *offset = 0; | |
1773 if (role_ == AccessibilityNodeData::ROLE_TEXT_FIELD || | 1756 if (role_ == AccessibilityNodeData::ROLE_TEXT_FIELD || |
1774 role_ == AccessibilityNodeData::ROLE_TEXTAREA) { | 1757 role_ == AccessibilityNodeData::ROLE_TEXTAREA) { |
1775 int sel_start = 0; | 1758 int sel_start = 0; |
1776 if (GetIntAttribute( | 1759 if (GetIntAttribute(AccessibilityNodeData::ATTR_TEXT_SEL_START, |
1777 AccessibilityNodeData::ATTR_TEXT_SEL_START, &sel_start)) { | 1760 &sel_start)) |
1778 *offset = sel_start; | 1761 *offset = sel_start; |
1779 } else { | |
1780 *offset = 0; | |
1781 } | |
1782 } else { | |
1783 *offset = 0; | |
1784 } | 1762 } |
1785 | 1763 |
1786 return S_OK; | 1764 return S_OK; |
1787 } | 1765 } |
1788 | 1766 |
1789 STDMETHODIMP BrowserAccessibilityWin::get_nSelections(LONG* n_selections) { | 1767 STDMETHODIMP BrowserAccessibilityWin::get_nSelections(LONG* n_selections) { |
1790 if (!instance_active_) | 1768 if (!instance_active_) |
1791 return E_FAIL; | 1769 return E_FAIL; |
1792 | 1770 |
1793 if (!n_selections) | 1771 if (!n_selections) |
1794 return E_INVALIDARG; | 1772 return E_INVALIDARG; |
1795 | 1773 |
1774 *n_selections = 0; | |
1796 if (role_ == AccessibilityNodeData::ROLE_TEXT_FIELD || | 1775 if (role_ == AccessibilityNodeData::ROLE_TEXT_FIELD || |
1797 role_ == AccessibilityNodeData::ROLE_TEXTAREA) { | 1776 role_ == AccessibilityNodeData::ROLE_TEXTAREA) { |
1798 int sel_start = 0; | 1777 int sel_start = 0; |
1799 int sel_end = 0; | 1778 int sel_end = 0; |
1800 if (GetIntAttribute( | 1779 if (GetIntAttribute(AccessibilityNodeData::ATTR_TEXT_SEL_START, |
1801 AccessibilityNodeData::ATTR_TEXT_SEL_START, &sel_start) && | 1780 &sel_start) && |
1802 GetIntAttribute(AccessibilityNodeData::ATTR_TEXT_SEL_END, &sel_end) && | 1781 GetIntAttribute(AccessibilityNodeData::ATTR_TEXT_SEL_END, &sel_end) && |
1803 sel_start != sel_end) { | 1782 sel_start != sel_end) |
1804 *n_selections = 1; | 1783 *n_selections = 1; |
1805 } else { | |
1806 *n_selections = 0; | |
1807 } | |
1808 } else { | |
1809 *n_selections = 0; | |
1810 } | 1784 } |
1811 | 1785 |
1812 return S_OK; | 1786 return S_OK; |
1813 } | 1787 } |
1814 | 1788 |
1815 STDMETHODIMP BrowserAccessibilityWin::get_selection(LONG selection_index, | 1789 STDMETHODIMP BrowserAccessibilityWin::get_selection(LONG selection_index, |
1816 LONG* start_offset, | 1790 LONG* start_offset, |
1817 LONG* end_offset) { | 1791 LONG* end_offset) { |
1818 if (!instance_active_) | 1792 if (!instance_active_) |
1819 return E_FAIL; | 1793 return E_FAIL; |
1820 | 1794 |
1821 if (!start_offset || !end_offset || selection_index != 0) | 1795 if (!start_offset || !end_offset || selection_index != 0) |
1822 return E_INVALIDARG; | 1796 return E_INVALIDARG; |
1823 | 1797 |
1798 *start_offset = 0; | |
1799 *end_offset = 0; | |
1824 if (role_ == AccessibilityNodeData::ROLE_TEXT_FIELD || | 1800 if (role_ == AccessibilityNodeData::ROLE_TEXT_FIELD || |
1825 role_ == AccessibilityNodeData::ROLE_TEXTAREA) { | 1801 role_ == AccessibilityNodeData::ROLE_TEXTAREA) { |
1826 int sel_start = 0; | 1802 int sel_start = 0; |
1827 int sel_end = 0; | 1803 int sel_end = 0; |
1828 if (GetIntAttribute( | 1804 if (GetIntAttribute( |
1829 AccessibilityNodeData::ATTR_TEXT_SEL_START, &sel_start) && | 1805 AccessibilityNodeData::ATTR_TEXT_SEL_START, &sel_start) && |
1830 GetIntAttribute(AccessibilityNodeData::ATTR_TEXT_SEL_END, &sel_end)) { | 1806 GetIntAttribute(AccessibilityNodeData::ATTR_TEXT_SEL_END, &sel_end)) { |
1831 *start_offset = sel_start; | 1807 *start_offset = sel_start; |
1832 *end_offset = sel_end; | 1808 *end_offset = sel_end; |
1833 } else { | |
1834 *start_offset = 0; | |
1835 *end_offset = 0; | |
1836 } | 1809 } |
1837 } else { | |
1838 *start_offset = 0; | |
1839 *end_offset = 0; | |
1840 } | 1810 } |
1841 | 1811 |
1842 return S_OK; | 1812 return S_OK; |
1843 } | 1813 } |
1844 | 1814 |
1845 STDMETHODIMP BrowserAccessibilityWin::get_text( | 1815 STDMETHODIMP BrowserAccessibilityWin::get_text(LONG start_offset, |
1846 LONG start_offset, LONG end_offset, BSTR* text) { | 1816 LONG end_offset, |
1817 BSTR* text) { | |
1847 if (!instance_active_) | 1818 if (!instance_active_) |
1848 return E_FAIL; | 1819 return E_FAIL; |
1849 | 1820 |
1850 if (!text) | 1821 if (!text) |
1851 return E_INVALIDARG; | 1822 return E_INVALIDARG; |
1852 | 1823 |
1853 const string16& text_str = TextForIAccessibleText(); | 1824 const string16& text_str = TextForIAccessibleText(); |
1854 | 1825 |
1855 // Handle special text offsets. | 1826 // Handle special text offsets. |
1856 HandleSpecialTextOffset(text_str, &start_offset); | 1827 HandleSpecialTextOffset(text_str, &start_offset); |
(...skipping 19 matching lines...) Expand all Loading... | |
1876 return S_FALSE; | 1847 return S_FALSE; |
1877 | 1848 |
1878 *text = SysAllocString(substr.c_str()); | 1849 *text = SysAllocString(substr.c_str()); |
1879 DCHECK(*text); | 1850 DCHECK(*text); |
1880 return S_OK; | 1851 return S_OK; |
1881 } | 1852 } |
1882 | 1853 |
1883 STDMETHODIMP BrowserAccessibilityWin::get_textAtOffset( | 1854 STDMETHODIMP BrowserAccessibilityWin::get_textAtOffset( |
1884 LONG offset, | 1855 LONG offset, |
1885 enum IA2TextBoundaryType boundary_type, | 1856 enum IA2TextBoundaryType boundary_type, |
1886 LONG* start_offset, LONG* end_offset, | 1857 LONG* start_offset, |
1858 LONG* end_offset, | |
1887 BSTR* text) { | 1859 BSTR* text) { |
1888 if (!instance_active_) | 1860 if (!instance_active_) |
1889 return E_FAIL; | 1861 return E_FAIL; |
1890 | 1862 |
1891 if (!start_offset || !end_offset || !text) | 1863 if (!start_offset || !end_offset || !text) |
1892 return E_INVALIDARG; | 1864 return E_INVALIDARG; |
1893 | 1865 |
1894 // The IAccessible2 spec says we don't have to implement the "sentence" | 1866 // The IAccessible2 spec says we don't have to implement the "sentence" |
1895 // boundary type, we can just let the screenreader handle it. | 1867 // boundary type, we can just let the screenreader handle it. |
1896 if (boundary_type == IA2_TEXT_BOUNDARY_SENTENCE) { | 1868 if (boundary_type == IA2_TEXT_BOUNDARY_SENTENCE) { |
1897 *start_offset = 0; | 1869 *start_offset = 0; |
1898 *end_offset = 0; | 1870 *end_offset = 0; |
1899 *text = NULL; | 1871 *text = NULL; |
1900 return S_FALSE; | 1872 return S_FALSE; |
1901 } | 1873 } |
1902 | 1874 |
1903 const string16& text_str = TextForIAccessibleText(); | 1875 const string16& text_str = TextForIAccessibleText(); |
1904 | 1876 |
1905 *start_offset = FindBoundary( | 1877 *start_offset = FindBoundary( |
1906 text_str, boundary_type, offset, ui::BACKWARDS_DIRECTION); | 1878 text_str, boundary_type, offset, ui::BACKWARDS_DIRECTION); |
1907 *end_offset = FindBoundary( | 1879 *end_offset = FindBoundary( |
1908 text_str, boundary_type, offset, ui::FORWARDS_DIRECTION); | 1880 text_str, boundary_type, offset, ui::FORWARDS_DIRECTION); |
1909 return get_text(*start_offset, *end_offset, text); | 1881 return get_text(*start_offset, *end_offset, text); |
1910 } | 1882 } |
1911 | 1883 |
1912 STDMETHODIMP BrowserAccessibilityWin::get_textBeforeOffset( | 1884 STDMETHODIMP BrowserAccessibilityWin::get_textBeforeOffset( |
1913 LONG offset, | 1885 LONG offset, |
1914 enum IA2TextBoundaryType boundary_type, | 1886 enum IA2TextBoundaryType boundary_type, |
1915 LONG* start_offset, LONG* end_offset, | 1887 LONG* start_offset, |
1888 LONG* end_offset, | |
1916 BSTR* text) { | 1889 BSTR* text) { |
1917 if (!instance_active_) | 1890 if (!instance_active_) |
1918 return E_FAIL; | 1891 return E_FAIL; |
1919 | 1892 |
1920 if (!start_offset || !end_offset || !text) | 1893 if (!start_offset || !end_offset || !text) |
1921 return E_INVALIDARG; | 1894 return E_INVALIDARG; |
1922 | 1895 |
1923 // The IAccessible2 spec says we don't have to implement the "sentence" | 1896 // The IAccessible2 spec says we don't have to implement the "sentence" |
1924 // boundary type, we can just let the screenreader handle it. | 1897 // boundary type, we can just let the screenreader handle it. |
1925 if (boundary_type == IA2_TEXT_BOUNDARY_SENTENCE) { | 1898 if (boundary_type == IA2_TEXT_BOUNDARY_SENTENCE) { |
1926 *start_offset = 0; | 1899 *start_offset = 0; |
1927 *end_offset = 0; | 1900 *end_offset = 0; |
1928 *text = NULL; | 1901 *text = NULL; |
1929 return S_FALSE; | 1902 return S_FALSE; |
1930 } | 1903 } |
1931 | 1904 |
1932 const string16& text_str = TextForIAccessibleText(); | 1905 const string16& text_str = TextForIAccessibleText(); |
1933 | 1906 |
1934 *start_offset = FindBoundary( | 1907 *start_offset = FindBoundary( |
1935 text_str, boundary_type, offset, ui::BACKWARDS_DIRECTION); | 1908 text_str, boundary_type, offset, ui::BACKWARDS_DIRECTION); |
1936 *end_offset = offset; | 1909 *end_offset = offset; |
1937 return get_text(*start_offset, *end_offset, text); | 1910 return get_text(*start_offset, *end_offset, text); |
1938 } | 1911 } |
1939 | 1912 |
1940 STDMETHODIMP BrowserAccessibilityWin::get_textAfterOffset( | 1913 STDMETHODIMP BrowserAccessibilityWin::get_textAfterOffset( |
1941 LONG offset, | 1914 LONG offset, |
1942 enum IA2TextBoundaryType boundary_type, | 1915 enum IA2TextBoundaryType boundary_type, |
1943 LONG* start_offset, LONG* end_offset, | 1916 LONG* start_offset, |
1917 LONG* end_offset, | |
1944 BSTR* text) { | 1918 BSTR* text) { |
1945 if (!instance_active_) | 1919 if (!instance_active_) |
1946 return E_FAIL; | 1920 return E_FAIL; |
1947 | 1921 |
1948 if (!start_offset || !end_offset || !text) | 1922 if (!start_offset || !end_offset || !text) |
1949 return E_INVALIDARG; | 1923 return E_INVALIDARG; |
1950 | 1924 |
1951 // The IAccessible2 spec says we don't have to implement the "sentence" | 1925 // The IAccessible2 spec says we don't have to implement the "sentence" |
1952 // boundary type, we can just let the screenreader handle it. | 1926 // boundary type, we can just let the screenreader handle it. |
1953 if (boundary_type == IA2_TEXT_BOUNDARY_SENTENCE) { | 1927 if (boundary_type == IA2_TEXT_BOUNDARY_SENTENCE) { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1987 if (!old_text) | 1961 if (!old_text) |
1988 return E_INVALIDARG; | 1962 return E_INVALIDARG; |
1989 | 1963 |
1990 old_text->text = SysAllocString(old_text_.c_str()); | 1964 old_text->text = SysAllocString(old_text_.c_str()); |
1991 old_text->start = 0; | 1965 old_text->start = 0; |
1992 old_text->end = static_cast<long>(old_text_.size()); | 1966 old_text->end = static_cast<long>(old_text_.size()); |
1993 return S_OK; | 1967 return S_OK; |
1994 } | 1968 } |
1995 | 1969 |
1996 STDMETHODIMP BrowserAccessibilityWin::get_offsetAtPoint( | 1970 STDMETHODIMP BrowserAccessibilityWin::get_offsetAtPoint( |
1997 LONG x, LONG y, enum IA2CoordinateType coord_type, LONG* offset) { | 1971 LONG x, |
1972 LONG y, | |
1973 enum IA2CoordinateType coord_type, | |
1974 LONG* offset) { | |
1998 if (!instance_active_) | 1975 if (!instance_active_) |
1999 return E_FAIL; | 1976 return E_FAIL; |
2000 | 1977 |
2001 if (!offset) | 1978 if (!offset) |
2002 return E_INVALIDARG; | 1979 return E_INVALIDARG; |
2003 | 1980 |
2004 // TODO(dmazzoni): implement this. We're returning S_OK for now so that | 1981 // TODO(dmazzoni): implement this. We're returning S_OK for now so that |
2005 // screen readers still return partially accurate results rather than | 1982 // screen readers still return partially accurate results rather than |
2006 // completely failing. | 1983 // completely failing. |
2007 *offset = 0; | 1984 *offset = 0; |
(...skipping 10 matching lines...) Expand all Loading... | |
2018 | 1995 |
2019 STDMETHODIMP BrowserAccessibilityWin::scrollSubstringToPoint( | 1996 STDMETHODIMP BrowserAccessibilityWin::scrollSubstringToPoint( |
2020 LONG start_index, | 1997 LONG start_index, |
2021 LONG end_index, | 1998 LONG end_index, |
2022 enum IA2CoordinateType coordinate_type, | 1999 enum IA2CoordinateType coordinate_type, |
2023 LONG x, LONG y) { | 2000 LONG x, LONG y) { |
2024 // TODO(dmazzoni): adjust this for the start and end index, too. | 2001 // TODO(dmazzoni): adjust this for the start and end index, too. |
2025 return scrollToPoint(coordinate_type, x, y); | 2002 return scrollToPoint(coordinate_type, x, y); |
2026 } | 2003 } |
2027 | 2004 |
2028 STDMETHODIMP BrowserAccessibilityWin::addSelection( | 2005 STDMETHODIMP BrowserAccessibilityWin::addSelection(LONG start_offset, |
2029 LONG start_offset, LONG end_offset) { | 2006 LONG end_offset) { |
2030 if (!instance_active_) | 2007 if (!instance_active_) |
2031 return E_FAIL; | 2008 return E_FAIL; |
2032 | 2009 |
2033 const string16& text_str = TextForIAccessibleText(); | 2010 const string16& text_str = TextForIAccessibleText(); |
2034 HandleSpecialTextOffset(text_str, &start_offset); | 2011 HandleSpecialTextOffset(text_str, &start_offset); |
2035 HandleSpecialTextOffset(text_str, &end_offset); | 2012 HandleSpecialTextOffset(text_str, &end_offset); |
2036 | 2013 |
2037 manager_->SetTextSelection(*this, start_offset, end_offset); | 2014 manager_->SetTextSelection(*this, start_offset, end_offset); |
2038 return S_OK; | 2015 return S_OK; |
2039 } | 2016 } |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2335 if (!found) { | 2312 if (!found) { |
2336 attrib_values[i] = NULL; | 2313 attrib_values[i] = NULL; |
2337 } | 2314 } |
2338 } | 2315 } |
2339 return S_OK; | 2316 return S_OK; |
2340 } | 2317 } |
2341 | 2318 |
2342 STDMETHODIMP BrowserAccessibilityWin::get_computedStyle( | 2319 STDMETHODIMP BrowserAccessibilityWin::get_computedStyle( |
2343 unsigned short max_style_properties, | 2320 unsigned short max_style_properties, |
2344 boolean use_alternate_view, | 2321 boolean use_alternate_view, |
2345 BSTR *style_properties, | 2322 BSTR* style_properties, |
2346 BSTR *style_values, | 2323 BSTR* style_values, |
2347 unsigned short *num_style_properties) { | 2324 unsigned short *num_style_properties) { |
2348 if (!instance_active_) | 2325 if (!instance_active_) |
2349 return E_FAIL; | 2326 return E_FAIL; |
2350 | 2327 |
2351 if (!style_properties || !style_values) | 2328 if (!style_properties || !style_values) |
2352 return E_INVALIDARG; | 2329 return E_INVALIDARG; |
2353 | 2330 |
2354 // We only cache a single style property for now: DISPLAY | 2331 // We only cache a single style property for now: DISPLAY |
2355 | 2332 |
2356 string16 display; | 2333 string16 display; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2390 } else { | 2367 } else { |
2391 style_values[i] = NULL; | 2368 style_values[i] = NULL; |
2392 } | 2369 } |
2393 } | 2370 } |
2394 | 2371 |
2395 return S_OK; | 2372 return S_OK; |
2396 } | 2373 } |
2397 | 2374 |
2398 STDMETHODIMP BrowserAccessibilityWin::scrollTo(boolean placeTopLeft) { | 2375 STDMETHODIMP BrowserAccessibilityWin::scrollTo(boolean placeTopLeft) { |
2399 return scrollTo(placeTopLeft ? | 2376 return scrollTo(placeTopLeft ? |
2400 IA2_SCROLL_TYPE_TOP_LEFT : | 2377 IA2_SCROLL_TYPE_TOP_LEFT : IA2_SCROLL_TYPE_ANYWHERE); |
2401 IA2_SCROLL_TYPE_ANYWHERE); | |
2402 } | 2378 } |
2403 | 2379 |
2404 STDMETHODIMP BrowserAccessibilityWin::get_parentNode(ISimpleDOMNode** node) { | 2380 STDMETHODIMP BrowserAccessibilityWin::get_parentNode(ISimpleDOMNode** node) { |
2405 if (!instance_active_) | 2381 if (!instance_active_) |
2406 return E_FAIL; | 2382 return E_FAIL; |
2407 | 2383 |
2408 if (!node) | 2384 if (!node) |
2409 return E_INVALIDARG; | 2385 return E_INVALIDARG; |
2410 | 2386 |
2411 *node = parent_->ToBrowserAccessibilityWin()->NewReference(); | 2387 *node = parent_->ToBrowserAccessibilityWin()->NewReference(); |
2412 return S_OK; | 2388 return S_OK; |
2413 } | 2389 } |
2414 | 2390 |
2415 STDMETHODIMP BrowserAccessibilityWin::get_firstChild(ISimpleDOMNode** node) { | 2391 STDMETHODIMP BrowserAccessibilityWin::get_firstChild(ISimpleDOMNode** node) { |
2416 if (!instance_active_) | 2392 if (!instance_active_) |
2417 return E_FAIL; | 2393 return E_FAIL; |
2418 | 2394 |
2419 if (!node) | 2395 if (!node) |
2420 return E_INVALIDARG; | 2396 return E_INVALIDARG; |
2421 | 2397 |
2422 if (children_.size()) { | 2398 if (children_.empty()) { |
2423 *node = children_[0]->ToBrowserAccessibilityWin()->NewReference(); | |
2424 return S_OK; | |
2425 } else { | |
2426 *node = NULL; | 2399 *node = NULL; |
2427 return S_FALSE; | 2400 return S_FALSE; |
2428 } | 2401 } |
2402 | |
2403 *node = children_[0]->ToBrowserAccessibilityWin()->NewReference(); | |
2404 return S_OK; | |
2429 } | 2405 } |
2430 | 2406 |
2431 STDMETHODIMP BrowserAccessibilityWin::get_lastChild(ISimpleDOMNode** node) { | 2407 STDMETHODIMP BrowserAccessibilityWin::get_lastChild(ISimpleDOMNode** node) { |
2432 if (!instance_active_) | 2408 if (!instance_active_) |
2433 return E_FAIL; | 2409 return E_FAIL; |
2434 | 2410 |
2435 if (!node) | 2411 if (!node) |
2436 return E_INVALIDARG; | 2412 return E_INVALIDARG; |
2437 | 2413 |
2438 if (children_.size()) { | 2414 if (children_.empty()) { |
2439 *node = children_[children_.size() - 1]->ToBrowserAccessibilityWin()-> | |
2440 NewReference(); | |
2441 return S_OK; | |
2442 } else { | |
2443 *node = NULL; | 2415 *node = NULL; |
2444 return S_FALSE; | 2416 return S_FALSE; |
2445 } | 2417 } |
2418 | |
2419 *node = (*children_.rbegin())->ToBrowserAccessibilityWin()->NewReference(); | |
2420 return S_OK; | |
2446 } | 2421 } |
2447 | 2422 |
2448 STDMETHODIMP BrowserAccessibilityWin::get_previousSibling( | 2423 STDMETHODIMP BrowserAccessibilityWin::get_previousSibling( |
2449 ISimpleDOMNode** node) { | 2424 ISimpleDOMNode** node) { |
2450 if (!instance_active_) | 2425 if (!instance_active_) |
2451 return E_FAIL; | 2426 return E_FAIL; |
2452 | 2427 |
2453 if (!node) | 2428 if (!node) |
2454 return E_INVALIDARG; | 2429 return E_INVALIDARG; |
2455 | 2430 |
2456 if (parent_ && index_in_parent_ > 0) { | 2431 if (!parent_ || index_in_parent_ <= 0) { |
2457 *node = parent_->children()[index_in_parent_ - 1]-> | |
2458 ToBrowserAccessibilityWin()->NewReference(); | |
2459 return S_OK; | |
2460 } else { | |
2461 *node = NULL; | 2432 *node = NULL; |
2462 return S_FALSE; | 2433 return S_FALSE; |
2463 } | 2434 } |
2435 | |
2436 *node = parent_->children()[index_in_parent_ - 1]-> | |
2437 ToBrowserAccessibilityWin()->NewReference(); | |
2438 return S_OK; | |
2464 } | 2439 } |
2465 | 2440 |
2466 STDMETHODIMP BrowserAccessibilityWin::get_nextSibling(ISimpleDOMNode** node) { | 2441 STDMETHODIMP BrowserAccessibilityWin::get_nextSibling(ISimpleDOMNode** node) { |
2467 if (!instance_active_) | 2442 if (!instance_active_) |
2468 return E_FAIL; | 2443 return E_FAIL; |
2469 | 2444 |
2470 if (!node) | 2445 if (!node) |
2471 return E_INVALIDARG; | 2446 return E_INVALIDARG; |
2472 | 2447 |
2473 if (parent_ && | 2448 if (!parent_ || |
2474 index_in_parent_ >= 0 && | 2449 index_in_parent_ < 0 || |
2475 index_in_parent_ < static_cast<int>(parent_->children().size()) - 1) { | 2450 index_in_parent_ >= static_cast<int>(parent_->children().size()) - 1) { |
2476 *node = parent_->children()[index_in_parent_ + 1]-> | |
2477 ToBrowserAccessibilityWin()->NewReference(); | |
2478 return S_OK; | |
2479 } else { | |
2480 *node = NULL; | 2451 *node = NULL; |
2481 return S_FALSE; | 2452 return S_FALSE; |
2482 } | 2453 } |
2454 | |
2455 *node = parent_->children()[index_in_parent_ + 1]-> | |
2456 ToBrowserAccessibilityWin()->NewReference(); | |
2457 return S_OK; | |
2483 } | 2458 } |
2484 | 2459 |
2485 STDMETHODIMP BrowserAccessibilityWin::get_childAt( | 2460 STDMETHODIMP BrowserAccessibilityWin::get_childAt( |
2486 unsigned int child_index, | 2461 unsigned int child_index, |
2487 ISimpleDOMNode** node) { | 2462 ISimpleDOMNode** node) { |
2488 if (!instance_active_) | 2463 if (!instance_active_) |
2489 return E_FAIL; | 2464 return E_FAIL; |
2490 | 2465 |
2491 if (!node) | 2466 if (!node) |
2492 return E_INVALIDARG; | 2467 return E_INVALIDARG; |
2493 | 2468 |
2494 if (child_index < children_.size()) { | 2469 if (child_index < children_.size()) { |
2495 *node = children_[child_index]->ToBrowserAccessibilityWin()->NewReference(); | |
2496 return S_OK; | |
2497 } else { | |
2498 *node = NULL; | 2470 *node = NULL; |
2499 return S_FALSE; | 2471 return S_FALSE; |
2500 } | 2472 } |
2473 | |
2474 *node = children_[child_index]->ToBrowserAccessibilityWin()->NewReference(); | |
2475 return S_OK; | |
2501 } | 2476 } |
2502 | 2477 |
2503 // | 2478 // |
2504 // ISimpleDOMText methods. | 2479 // ISimpleDOMText methods. |
2505 // | 2480 // |
2506 | 2481 |
2507 STDMETHODIMP BrowserAccessibilityWin::get_domText(BSTR* dom_text) { | 2482 STDMETHODIMP BrowserAccessibilityWin::get_domText(BSTR* dom_text) { |
2508 if (!instance_active_) | 2483 if (!instance_active_) |
2509 return E_FAIL; | 2484 return E_FAIL; |
2510 | 2485 |
2511 if (!dom_text) | 2486 if (!dom_text) |
2512 return E_INVALIDARG; | 2487 return E_INVALIDARG; |
2513 | 2488 |
2514 if (name_.empty()) | 2489 if (name_.empty()) |
2515 return S_FALSE; | 2490 return S_FALSE; |
2516 | 2491 |
2517 *dom_text = SysAllocString(name_.c_str()); | 2492 *dom_text = SysAllocString(name_.c_str()); |
2518 DCHECK(*dom_text); | 2493 DCHECK(*dom_text); |
2519 return S_OK; | 2494 return S_OK; |
2520 } | 2495 } |
2521 | 2496 |
2522 // | 2497 // |
2523 // IServiceProvider methods. | 2498 // IServiceProvider methods. |
2524 // | 2499 // |
2525 | 2500 |
2526 STDMETHODIMP BrowserAccessibilityWin::QueryService( | 2501 STDMETHODIMP BrowserAccessibilityWin::QueryService(REFGUID guidService, |
2527 REFGUID guidService, REFIID riid, void** object) { | 2502 REFIID riid, |
2503 void** object) { | |
2528 if (!instance_active_) | 2504 if (!instance_active_) |
2529 return E_FAIL; | 2505 return E_FAIL; |
2530 | 2506 |
2531 if (guidService == IID_IAccessible || | 2507 if (guidService == IID_IAccessible || |
2532 guidService == IID_IAccessible2 || | 2508 guidService == IID_IAccessible2 || |
2533 guidService == IID_IAccessibleAction || | 2509 guidService == IID_IAccessibleAction || |
2534 guidService == IID_IAccessibleHyperlink || | 2510 guidService == IID_IAccessibleHyperlink || |
2535 guidService == IID_IAccessibleHypertext || | 2511 guidService == IID_IAccessibleHypertext || |
2536 guidService == IID_IAccessibleImage || | 2512 guidService == IID_IAccessibleImage || |
2537 guidService == IID_IAccessibleTable || | 2513 guidService == IID_IAccessibleTable || |
(...skipping 14 matching lines...) Expand all Loading... | |
2552 // All methods in the IAccessibleEx interface are unimplemented. | 2528 // All methods in the IAccessibleEx interface are unimplemented. |
2553 if (riid == IID_IAccessibleEx && | 2529 if (riid == IID_IAccessibleEx && |
2554 base::win::GetVersion() >= base::win::VERSION_WIN8) { | 2530 base::win::GetVersion() >= base::win::VERSION_WIN8) { |
2555 return QueryInterface(riid, object); | 2531 return QueryInterface(riid, object); |
2556 } | 2532 } |
2557 | 2533 |
2558 *object = NULL; | 2534 *object = NULL; |
2559 return E_FAIL; | 2535 return E_FAIL; |
2560 } | 2536 } |
2561 | 2537 |
2562 STDMETHODIMP BrowserAccessibilityWin::GetPatternProvider( | 2538 STDMETHODIMP BrowserAccessibilityWin::GetPatternProvider(PATTERNID id, |
2563 PATTERNID id, IUnknown** provider) { | 2539 IUnknown** provider) { |
2564 DVLOG(1) << "In Function: " | 2540 DVLOG(1) << "In Function: " |
2565 << __FUNCTION__ | 2541 << __FUNCTION__ |
2566 << " for pattern id: " | 2542 << " for pattern id: " |
2567 << id; | 2543 << id; |
2568 if (id == UIA_ValuePatternId || id == UIA_TextPatternId) { | 2544 if (id == UIA_ValuePatternId || id == UIA_TextPatternId) { |
2569 if (IsEditableText()) { | 2545 if (IsEditableText()) { |
2570 // The BrowserAccessibilityManager keeps track of instances when | 2546 // The BrowserAccessibilityManager keeps track of instances when |
2571 // we don't want to show the on-screen keyboard. | 2547 // we don't want to show the on-screen keyboard. |
2572 if (!manager_->IsOSKAllowed(GetGlobalBoundsRect())) | 2548 if (!manager_->IsOSKAllowed(GetGlobalBoundsRect())) |
2573 return E_NOTIMPL; | 2549 return E_NOTIMPL; |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2702 value_ = UTF8ToUTF16(base::DoubleToString(fval)); | 2678 value_ = UTF8ToUTF16(base::DoubleToString(fval)); |
2703 } | 2679 } |
2704 ia2_attributes_.push_back(L"valuetext:" + value_); | 2680 ia2_attributes_.push_back(L"valuetext:" + value_); |
2705 } | 2681 } |
2706 | 2682 |
2707 // Expose table cell index. | 2683 // Expose table cell index. |
2708 if (ia_role_ == ROLE_SYSTEM_CELL) { | 2684 if (ia_role_ == ROLE_SYSTEM_CELL) { |
2709 BrowserAccessibility* table = parent(); | 2685 BrowserAccessibility* table = parent(); |
2710 while (table && table->role() != AccessibilityNodeData::ROLE_TABLE) | 2686 while (table && table->role() != AccessibilityNodeData::ROLE_TABLE) |
2711 table = table->parent(); | 2687 table = table->parent(); |
2712 if (table) { | 2688 DCHECK(table); |
dmazzoni
2012/11/13 03:54:02
This isn't safe; it's possible for a web author to
Peter Kasting
2012/11/13 04:02:08
Then the old code was wrong to NOTREACHED(). NOTR
dmazzoni
2012/11/13 04:12:13
You're right, that was a poor choice. Please elimi
| |
2713 const std::vector<int32>& unique_cell_ids = table->unique_cell_ids(); | 2689 const std::vector<int32>& unique_cell_ids = table->unique_cell_ids(); |
2714 int index = -1; | 2690 for (size_t i = 0; i < unique_cell_ids.size(); ++i) { |
2715 for (size_t i = 0; i < unique_cell_ids.size(); ++i) { | 2691 if (unique_cell_ids[i] == renderer_id_) { |
2716 if (unique_cell_ids[i] == renderer_id_) { | 2692 ia2_attributes_.push_back( |
2717 index = static_cast<int>(i); | 2693 string16(L"table-cell-index:") + base::IntToString16(i)); |
2718 break; | |
2719 } | |
2720 } | 2694 } |
2721 if (index >= 0) { | |
2722 ia2_attributes_.push_back(string16(L"table-cell-index:") + | |
2723 base::IntToString16(index)); | |
2724 } | |
2725 } else { | |
2726 NOTREACHED(); | |
2727 } | 2695 } |
2728 } | 2696 } |
2729 | 2697 |
2730 // The calculation of the accessible name of an element has been | 2698 // The calculation of the accessible name of an element has been |
2731 // standardized in the HTML to Platform Accessibility APIs Implementation | 2699 // standardized in the HTML to Platform Accessibility APIs Implementation |
2732 // Guide (http://www.w3.org/TR/html-aapi/). In order to return the | 2700 // Guide (http://www.w3.org/TR/html-aapi/). In order to return the |
2733 // appropriate accessible name on Windows, we need to apply some logic | 2701 // appropriate accessible name on Windows, we need to apply some logic |
2734 // to the fields we get from WebKit. | 2702 // to the fields we get from WebKit. |
2735 // | 2703 // |
2736 // TODO(dmazzoni): move most of this logic into WebKit. | 2704 // TODO(dmazzoni): move most of this logic into WebKit. |
(...skipping 17 matching lines...) Expand all Loading... | |
2754 GetStringAttribute(AccessibilityNodeData::ATTR_DESCRIPTION, &description); | 2722 GetStringAttribute(AccessibilityNodeData::ATTR_DESCRIPTION, &description); |
2755 GetStringAttribute(AccessibilityNodeData::ATTR_HELP, &help); | 2723 GetStringAttribute(AccessibilityNodeData::ATTR_HELP, &help); |
2756 | 2724 |
2757 // WebKit annoyingly puts the title in the description if there's no other | 2725 // WebKit annoyingly puts the title in the description if there's no other |
2758 // description, which just confuses the rest of the logic. Put it back. | 2726 // description, which just confuses the rest of the logic. Put it back. |
2759 // Now "help" is always the value of the "title" attribute, if present. | 2727 // Now "help" is always the value of the "title" attribute, if present. |
2760 if (GetHtmlAttribute("title", &title_attr) && | 2728 if (GetHtmlAttribute("title", &title_attr) && |
2761 description == title_attr && | 2729 description == title_attr && |
2762 help.empty()) { | 2730 help.empty()) { |
2763 help = description; | 2731 help = description; |
2764 description = L""; | 2732 description.clear(); |
2765 string_attributes_[AccessibilityNodeData::ATTR_DESCRIPTION] = L""; | 2733 string_attributes_[AccessibilityNodeData::ATTR_DESCRIPTION].clear(); |
2766 string_attributes_[AccessibilityNodeData::ATTR_HELP] = help; | 2734 string_attributes_[AccessibilityNodeData::ATTR_HELP] = help; |
2767 } | 2735 } |
2768 | 2736 |
2769 // Now implement the main logic: the descripion should become the name if | 2737 // Now implement the main logic: the descripion should become the name if |
2770 // it's nonempty, and the help should become the description if | 2738 // it's nonempty, and the help should become the description if |
2771 // there's no description - or the name if there's no name or description. | 2739 // there's no description - or the name if there's no name or description. |
2772 if (!description.empty()) { | 2740 if (!description.empty()) { |
2773 name_ = description; | 2741 name_ = description; |
2774 description = L""; | 2742 description.clear(); |
2775 string_attributes_[AccessibilityNodeData::ATTR_DESCRIPTION] = description; | 2743 string_attributes_[AccessibilityNodeData::ATTR_DESCRIPTION] = description; |
2776 } | 2744 } |
2777 if (!help.empty() && description.empty()) { | 2745 if (!help.empty() && description.empty()) { |
2778 description = help; | 2746 description = help; |
2779 string_attributes_[AccessibilityNodeData::ATTR_DESCRIPTION] = help; | 2747 string_attributes_[AccessibilityNodeData::ATTR_DESCRIPTION] = help; |
2780 string_attributes_[AccessibilityNodeData::ATTR_HELP] = L""; | 2748 string_attributes_[AccessibilityNodeData::ATTR_HELP].clear(); |
2781 } | 2749 } |
2782 if (!description.empty() && name_.empty() && !title_elem_id) { | 2750 if (!description.empty() && name_.empty() && !title_elem_id) { |
2783 name_ = description; | 2751 name_ = description; |
2784 description = L""; | 2752 description.clear(); |
2785 string_attributes_[AccessibilityNodeData::ATTR_DESCRIPTION] = L""; | 2753 string_attributes_[AccessibilityNodeData::ATTR_DESCRIPTION].clear(); |
2786 } | 2754 } |
2787 | 2755 |
2788 // If it's a text field, also consider the placeholder. | 2756 // If it's a text field, also consider the placeholder. |
2789 string16 placeholder; | 2757 string16 placeholder; |
2790 if (role_ == AccessibilityNodeData::ROLE_TEXT_FIELD && | 2758 if (role_ == AccessibilityNodeData::ROLE_TEXT_FIELD && |
2791 HasState(AccessibilityNodeData::STATE_FOCUSABLE) && | 2759 HasState(AccessibilityNodeData::STATE_FOCUSABLE) && |
2792 GetHtmlAttribute("placeholder", &placeholder)) { | 2760 GetHtmlAttribute("placeholder", &placeholder)) { |
2793 if (name_.empty() && !title_elem_id) { | 2761 if (name_.empty() && !title_elem_id) { |
2794 name_ = placeholder; | 2762 name_ = placeholder; |
2795 } else if (description.empty()) { | 2763 } else if (description.empty()) { |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2874 if (!first_time_ && ia_state_ != old_ia_state_) { | 2842 if (!first_time_ && ia_state_ != old_ia_state_) { |
2875 // Normally focus events are handled elsewhere, however | 2843 // Normally focus events are handled elsewhere, however |
2876 // focus for managed descendants is platform-specific. | 2844 // focus for managed descendants is platform-specific. |
2877 // Fire a focus event if the focused descendant in a multi-select | 2845 // Fire a focus event if the focused descendant in a multi-select |
2878 // list box changes. | 2846 // list box changes. |
2879 if (role_ == AccessibilityNodeData::ROLE_LISTBOX_OPTION && | 2847 if (role_ == AccessibilityNodeData::ROLE_LISTBOX_OPTION && |
2880 (ia_state_ & STATE_SYSTEM_FOCUSABLE) && | 2848 (ia_state_ & STATE_SYSTEM_FOCUSABLE) && |
2881 (ia_state_ & STATE_SYSTEM_SELECTABLE) && | 2849 (ia_state_ & STATE_SYSTEM_SELECTABLE) && |
2882 (ia_state_ & STATE_SYSTEM_FOCUSED) && | 2850 (ia_state_ & STATE_SYSTEM_FOCUSED) && |
2883 !(old_ia_state_ & STATE_SYSTEM_FOCUSED)) { | 2851 !(old_ia_state_ & STATE_SYSTEM_FOCUSED)) { |
2884 ::NotifyWinEvent(EVENT_OBJECT_FOCUS, | 2852 ::NotifyWinEvent(EVENT_OBJECT_FOCUS, manager_->GetParentView(), |
2885 manager_->GetParentView(), | 2853 OBJID_CLIENT, child_id()); |
2886 OBJID_CLIENT, | |
2887 child_id()); | |
2888 } | 2854 } |
2889 | 2855 |
2890 if ((ia_state_ & STATE_SYSTEM_SELECTED) && | 2856 if ((ia_state_ & STATE_SYSTEM_SELECTED) && |
2891 !(old_ia_state_ & STATE_SYSTEM_SELECTED)) { | 2857 !(old_ia_state_ & STATE_SYSTEM_SELECTED)) { |
2892 ::NotifyWinEvent(EVENT_OBJECT_SELECTIONADD, | 2858 ::NotifyWinEvent(EVENT_OBJECT_SELECTIONADD, manager_->GetParentView(), |
2893 manager_->GetParentView(), | 2859 OBJID_CLIENT, child_id()); |
2894 OBJID_CLIENT, | |
2895 child_id()); | |
2896 } else if (!(ia_state_ & STATE_SYSTEM_SELECTED) && | 2860 } else if (!(ia_state_ & STATE_SYSTEM_SELECTED) && |
2897 (old_ia_state_ & STATE_SYSTEM_SELECTED)) { | 2861 (old_ia_state_ & STATE_SYSTEM_SELECTED)) { |
2898 ::NotifyWinEvent(EVENT_OBJECT_SELECTIONREMOVE, | 2862 ::NotifyWinEvent(EVENT_OBJECT_SELECTIONREMOVE, manager_->GetParentView(), |
2899 manager_->GetParentView(), | 2863 OBJID_CLIENT, child_id()); |
2900 OBJID_CLIENT, | |
2901 child_id()); | |
2902 } | 2864 } |
2903 | 2865 |
2904 old_ia_state_ = ia_state_; | 2866 old_ia_state_ = ia_state_; |
2905 } | 2867 } |
2906 | 2868 |
2907 first_time_ = false; | 2869 first_time_ = false; |
2908 } | 2870 } |
2909 | 2871 |
2910 void BrowserAccessibilityWin::NativeAddReference() { | 2872 void BrowserAccessibilityWin::NativeAddReference() { |
2911 AddRef(); | 2873 AddRef(); |
(...skipping 21 matching lines...) Expand all Loading... | |
2933 if (child_id == CHILDID_SELF) | 2895 if (child_id == CHILDID_SELF) |
2934 return this; | 2896 return this; |
2935 | 2897 |
2936 if (child_id >= 1 && child_id <= static_cast<LONG>(children_.size())) | 2898 if (child_id >= 1 && child_id <= static_cast<LONG>(children_.size())) |
2937 return children_[child_id - 1]->ToBrowserAccessibilityWin(); | 2899 return children_[child_id - 1]->ToBrowserAccessibilityWin(); |
2938 | 2900 |
2939 return manager_->GetFromChildID(child_id)->ToBrowserAccessibilityWin(); | 2901 return manager_->GetFromChildID(child_id)->ToBrowserAccessibilityWin(); |
2940 } | 2902 } |
2941 | 2903 |
2942 HRESULT BrowserAccessibilityWin::GetStringAttributeAsBstr( | 2904 HRESULT BrowserAccessibilityWin::GetStringAttributeAsBstr( |
2943 AccessibilityNodeData::StringAttribute attribute, BSTR* value_bstr) { | 2905 AccessibilityNodeData::StringAttribute attribute, |
2906 BSTR* value_bstr) { | |
2944 string16 str; | 2907 string16 str; |
2945 | 2908 |
2946 if (!GetStringAttribute(attribute, &str)) | 2909 if (!GetStringAttribute(attribute, &str)) |
2947 return S_FALSE; | 2910 return S_FALSE; |
2948 | 2911 |
2949 if (str.empty()) | 2912 if (str.empty()) |
2950 return S_FALSE; | 2913 return S_FALSE; |
2951 | 2914 |
2952 *value_bstr = SysAllocString(str.c_str()); | 2915 *value_bstr = SysAllocString(str.c_str()); |
2953 DCHECK(*value_bstr); | 2916 DCHECK(*value_bstr); |
2954 | 2917 |
2955 return S_OK; | 2918 return S_OK; |
2956 } | 2919 } |
2957 | 2920 |
2958 void BrowserAccessibilityWin::StringAttributeToIA2( | 2921 void BrowserAccessibilityWin::StringAttributeToIA2( |
2959 AccessibilityNodeData::StringAttribute attribute, const char* ia2_attr) { | 2922 AccessibilityNodeData::StringAttribute attribute, |
2923 const char* ia2_attr) { | |
2960 string16 value; | 2924 string16 value; |
2961 if (GetStringAttribute(attribute, &value)) | 2925 if (GetStringAttribute(attribute, &value)) |
2962 ia2_attributes_.push_back(ASCIIToUTF16(ia2_attr) + L":" + value); | 2926 ia2_attributes_.push_back(ASCIIToUTF16(ia2_attr) + L":" + value); |
2963 } | 2927 } |
2964 | 2928 |
2965 void BrowserAccessibilityWin::BoolAttributeToIA2( | 2929 void BrowserAccessibilityWin::BoolAttributeToIA2( |
2966 AccessibilityNodeData::BoolAttribute attribute, const char* ia2_attr) { | 2930 AccessibilityNodeData::BoolAttribute attribute, |
2931 const char* ia2_attr) { | |
2967 bool value; | 2932 bool value; |
2968 if (GetBoolAttribute(attribute, &value)) { | 2933 if (GetBoolAttribute(attribute, &value)) { |
2969 ia2_attributes_.push_back((ASCIIToUTF16(ia2_attr) + L":") + | 2934 ia2_attributes_.push_back((ASCIIToUTF16(ia2_attr) + L":") + |
2970 (value ? L"true" : L"false")); | 2935 (value ? L"true" : L"false")); |
2971 } | 2936 } |
2972 } | 2937 } |
2973 | 2938 |
2974 void BrowserAccessibilityWin::IntAttributeToIA2( | 2939 void BrowserAccessibilityWin::IntAttributeToIA2( |
2975 AccessibilityNodeData::IntAttribute attribute, const char* ia2_attr) { | 2940 AccessibilityNodeData::IntAttribute attribute, |
2941 const char* ia2_attr) { | |
2976 int value; | 2942 int value; |
2977 if (GetIntAttribute(attribute, &value)) | 2943 if (GetIntAttribute(attribute, &value)) |
2978 ia2_attributes_.push_back(ASCIIToUTF16(ia2_attr) + L":" + | 2944 ia2_attributes_.push_back(ASCIIToUTF16(ia2_attr) + L":" + |
2979 base::IntToString16(value)); | 2945 base::IntToString16(value)); |
2980 } | 2946 } |
2981 | 2947 |
2982 const string16& BrowserAccessibilityWin::TextForIAccessibleText() { | 2948 const string16& BrowserAccessibilityWin::TextForIAccessibleText() { |
2983 if (IsEditableText()) { | 2949 if (IsEditableText()) |
2984 return value_; | 2950 return value_; |
2985 } else if (role_ == AccessibilityNodeData::ROLE_STATIC_TEXT) { | 2951 return (role_ == AccessibilityNodeData::ROLE_STATIC_TEXT) ? |
2986 return name_; | 2952 name_ : hypertext_; |
2987 } else { | |
2988 return hypertext_; | |
2989 } | |
2990 } | 2953 } |
2991 | 2954 |
2992 void BrowserAccessibilityWin::HandleSpecialTextOffset( | 2955 void BrowserAccessibilityWin::HandleSpecialTextOffset(const string16& text, |
2993 const string16& text, LONG* offset) { | 2956 LONG* offset) { |
2994 if (*offset == IA2_TEXT_OFFSET_LENGTH) { | 2957 if (*offset == IA2_TEXT_OFFSET_LENGTH) |
2995 *offset = static_cast<LONG>(text.size()); | 2958 *offset = static_cast<LONG>(text.size()); |
2996 } else if (*offset == IA2_TEXT_OFFSET_CARET) { | 2959 else if (*offset == IA2_TEXT_OFFSET_CARET) |
2997 get_caretOffset(offset); | 2960 get_caretOffset(offset); |
2998 } | |
2999 } | 2961 } |
3000 | 2962 |
3001 ui::TextBoundaryType BrowserAccessibilityWin::IA2TextBoundaryToTextBoundary( | 2963 ui::TextBoundaryType BrowserAccessibilityWin::IA2TextBoundaryToTextBoundary( |
3002 IA2TextBoundaryType ia2_boundary) { | 2964 IA2TextBoundaryType ia2_boundary) { |
3003 switch(ia2_boundary) { | 2965 switch(ia2_boundary) { |
3004 case IA2_TEXT_BOUNDARY_CHAR: return ui::CHAR_BOUNDARY; | 2966 case IA2_TEXT_BOUNDARY_CHAR: return ui::CHAR_BOUNDARY; |
3005 case IA2_TEXT_BOUNDARY_WORD: return ui::WORD_BOUNDARY; | 2967 case IA2_TEXT_BOUNDARY_WORD: return ui::WORD_BOUNDARY; |
3006 case IA2_TEXT_BOUNDARY_LINE: return ui::LINE_BOUNDARY; | 2968 case IA2_TEXT_BOUNDARY_LINE: return ui::LINE_BOUNDARY; |
3007 case IA2_TEXT_BOUNDARY_SENTENCE: return ui::SENTENCE_BOUNDARY; | 2969 case IA2_TEXT_BOUNDARY_SENTENCE: return ui::SENTENCE_BOUNDARY; |
3008 case IA2_TEXT_BOUNDARY_PARAGRAPH: return ui::PARAGRAPH_BOUNDARY; | 2970 case IA2_TEXT_BOUNDARY_PARAGRAPH: return ui::PARAGRAPH_BOUNDARY; |
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3511 // The role should always be set. | 3473 // The role should always be set. |
3512 DCHECK(!role_name_.empty() || ia_role_); | 3474 DCHECK(!role_name_.empty() || ia_role_); |
3513 | 3475 |
3514 // If we didn't explicitly set the IAccessible2 role, make it the same | 3476 // If we didn't explicitly set the IAccessible2 role, make it the same |
3515 // as the MSAA role. | 3477 // as the MSAA role. |
3516 if (!ia2_role_) | 3478 if (!ia2_role_) |
3517 ia2_role_ = ia_role_; | 3479 ia2_role_ = ia_role_; |
3518 } | 3480 } |
3519 | 3481 |
3520 } // namespace content | 3482 } // namespace content |
OLD | NEW |