Chromium Code Reviews| 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 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 450 if (!instance_active_) | 450 if (!instance_active_) |
| 451 return E_FAIL; | 451 return E_FAIL; |
| 452 | 452 |
| 453 if (!name) | 453 if (!name) |
| 454 return E_INVALIDARG; | 454 return E_INVALIDARG; |
| 455 | 455 |
| 456 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); | 456 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); |
| 457 if (!target) | 457 if (!target) |
| 458 return E_INVALIDARG; | 458 return E_INVALIDARG; |
| 459 | 459 |
| 460 string16 name_str = target->name_; | 460 std::string name_str = target->GetStringAttribute( |
| 461 AccessibilityNodeData::ATTR_NAME); | |
| 461 | 462 |
| 462 // If the name is empty, see if it's labeled by another element. | 463 // If the name is empty, see if it's labeled by another element. |
| 463 if (name_str.empty()) { | 464 if (name_str.empty()) { |
| 464 int title_elem_id; | 465 int title_elem_id; |
| 465 if (target->GetIntAttribute(AccessibilityNodeData::ATTR_TITLE_UI_ELEMENT, | 466 if (target->GetIntAttribute(AccessibilityNodeData::ATTR_TITLE_UI_ELEMENT, |
| 466 &title_elem_id)) { | 467 &title_elem_id)) { |
| 467 BrowserAccessibility* title_elem = | 468 BrowserAccessibility* title_elem = |
| 468 manager_->GetFromRendererID(title_elem_id); | 469 manager_->GetFromRendererID(title_elem_id); |
| 469 if (title_elem) | 470 if (title_elem) |
| 470 name_str = title_elem->GetTextRecursive(); | 471 name_str = title_elem->GetTextRecursive(); |
| 471 } | 472 } |
| 472 } | 473 } |
| 473 | 474 |
| 474 if (name_str.empty()) | 475 if (name_str.empty()) |
| 475 return S_FALSE; | 476 return S_FALSE; |
| 476 | 477 |
| 477 *name = SysAllocString(name_str.c_str()); | 478 *name = SysAllocString(UTF8ToUTF16(name_str).c_str()); |
| 478 | 479 |
| 479 DCHECK(*name); | 480 DCHECK(*name); |
| 480 return S_OK; | 481 return S_OK; |
| 481 } | 482 } |
| 482 | 483 |
| 483 STDMETHODIMP BrowserAccessibilityWin::get_accParent(IDispatch** disp_parent) { | 484 STDMETHODIMP BrowserAccessibilityWin::get_accParent(IDispatch** disp_parent) { |
| 484 if (!instance_active_) | 485 if (!instance_active_) |
| 485 return E_FAIL; | 486 return E_FAIL; |
| 486 | 487 |
| 487 if (!disp_parent) | 488 if (!disp_parent) |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 550 if (!instance_active_) | 551 if (!instance_active_) |
| 551 return E_FAIL; | 552 return E_FAIL; |
| 552 | 553 |
| 553 if (!value) | 554 if (!value) |
| 554 return E_INVALIDARG; | 555 return E_INVALIDARG; |
| 555 | 556 |
| 556 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); | 557 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); |
| 557 if (!target) | 558 if (!target) |
| 558 return E_INVALIDARG; | 559 return E_INVALIDARG; |
| 559 | 560 |
| 560 *value = SysAllocString(target->value_.c_str()); | 561 if (ia_role_ == ROLE_SYSTEM_PROGRESSBAR || |
| 562 ia_role_ == ROLE_SYSTEM_SCROLLBAR || | |
| 563 ia_role_ == ROLE_SYSTEM_SLIDER) { | |
| 564 string16 value_text = GetValueText(); | |
| 565 *value = SysAllocString(value_text.c_str()); | |
| 566 DCHECK(*value); | |
| 567 return S_OK; | |
| 568 } | |
| 561 | 569 |
| 562 DCHECK(*value); | 570 // Expose color well value. |
| 563 return S_OK; | 571 if (ia2_role_ == IA2_ROLE_COLOR_CHOOSER) { |
| 572 int r = GetIntAttribute(AccessibilityNodeData::ATTR_COLOR_VALUE_RED); | |
| 573 int g = GetIntAttribute(AccessibilityNodeData::ATTR_COLOR_VALUE_GREEN); | |
| 574 int b = GetIntAttribute(AccessibilityNodeData::ATTR_COLOR_VALUE_BLUE); | |
| 575 string16 value_text; | |
| 576 value_text = base::IntToString16((r * 100) / 255) + L"% red " + | |
| 577 base::IntToString16((g * 100) / 255) + L"% green " + | |
| 578 base::IntToString16((b * 100) / 255) + L"% blue"; | |
| 579 *value = SysAllocString(value_text.c_str()); | |
| 580 DCHECK(*value); | |
| 581 return S_OK; | |
| 582 } | |
| 583 | |
| 584 return target->GetStringAttributeAsBstr( | |
| 585 AccessibilityNodeData::ATTR_VALUE, value); | |
| 564 } | 586 } |
| 565 | 587 |
| 566 STDMETHODIMP BrowserAccessibilityWin::get_accHelpTopic(BSTR* help_file, | 588 STDMETHODIMP BrowserAccessibilityWin::get_accHelpTopic(BSTR* help_file, |
| 567 VARIANT var_id, | 589 VARIANT var_id, |
| 568 LONG* topic_id) { | 590 LONG* topic_id) { |
| 569 return E_NOTIMPL; | 591 return E_NOTIMPL; |
| 570 } | 592 } |
| 571 | 593 |
| 572 STDMETHODIMP BrowserAccessibilityWin::get_accSelection(VARIANT* selected) { | 594 STDMETHODIMP BrowserAccessibilityWin::get_accSelection(VARIANT* selected) { |
| 573 if (!instance_active_) | 595 if (!instance_active_) |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1007 !GetIntAttribute( | 1029 !GetIntAttribute( |
| 1008 AccessibilityNodeData::ATTR_TABLE_ROW_COUNT, &rows) || | 1030 AccessibilityNodeData::ATTR_TABLE_ROW_COUNT, &rows) || |
| 1009 columns <= 0 || | 1031 columns <= 0 || |
| 1010 rows <= 0) { | 1032 rows <= 0) { |
| 1011 return S_FALSE; | 1033 return S_FALSE; |
| 1012 } | 1034 } |
| 1013 | 1035 |
| 1014 if (row < 0 || row >= rows || column < 0 || column >= columns) | 1036 if (row < 0 || row >= rows || column < 0 || column >= columns) |
| 1015 return E_INVALIDARG; | 1037 return E_INVALIDARG; |
| 1016 | 1038 |
| 1017 DCHECK_EQ(columns * rows, static_cast<int>(cell_ids_.size())); | 1039 const std::vector<int32>& cell_ids = GetIntListAttribute( |
| 1040 AccessibilityNodeData::ATTR_CELL_IDS); | |
| 1041 DCHECK_EQ(columns * rows, static_cast<int>(cell_ids.size())); | |
| 1018 | 1042 |
| 1019 int cell_id = cell_ids_[row * columns + column]; | 1043 int cell_id = cell_ids[row * columns + column]; |
| 1020 BrowserAccessibilityWin* cell = GetFromRendererID(cell_id); | 1044 BrowserAccessibilityWin* cell = GetFromRendererID(cell_id); |
| 1021 if (cell) { | 1045 if (cell) { |
| 1022 *accessible = static_cast<IAccessible*>(cell->NewReference()); | 1046 *accessible = static_cast<IAccessible*>(cell->NewReference()); |
| 1023 return S_OK; | 1047 return S_OK; |
| 1024 } | 1048 } |
| 1025 | 1049 |
| 1026 *accessible = NULL; | 1050 *accessible = NULL; |
| 1027 return E_INVALIDARG; | 1051 return E_INVALIDARG; |
| 1028 } | 1052 } |
| 1029 | 1053 |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 1054 !GetIntAttribute( | 1078 !GetIntAttribute( |
| 1055 AccessibilityNodeData::ATTR_TABLE_ROW_COUNT, &rows) || | 1079 AccessibilityNodeData::ATTR_TABLE_ROW_COUNT, &rows) || |
| 1056 columns <= 0 || | 1080 columns <= 0 || |
| 1057 rows <= 0) { | 1081 rows <= 0) { |
| 1058 return S_FALSE; | 1082 return S_FALSE; |
| 1059 } | 1083 } |
| 1060 | 1084 |
| 1061 if (row < 0 || row >= rows || column < 0 || column >= columns) | 1085 if (row < 0 || row >= rows || column < 0 || column >= columns) |
| 1062 return E_INVALIDARG; | 1086 return E_INVALIDARG; |
| 1063 | 1087 |
| 1064 DCHECK_EQ(columns * rows, static_cast<int>(cell_ids_.size())); | 1088 const std::vector<int32>& cell_ids = GetIntListAttribute( |
| 1065 int cell_id = cell_ids_[row * columns + column]; | 1089 AccessibilityNodeData::ATTR_CELL_IDS); |
| 1066 for (size_t i = 0; i < unique_cell_ids_.size(); ++i) { | 1090 const std::vector<int32>& unique_cell_ids = GetIntListAttribute( |
| 1067 if (unique_cell_ids_[i] == cell_id) { | 1091 AccessibilityNodeData::ATTR_UNIQUE_CELL_IDS); |
| 1092 DCHECK_EQ(columns * rows, static_cast<int>(cell_ids.size())); | |
| 1093 int cell_id = cell_ids[row * columns + column]; | |
| 1094 for (size_t i = 0; i < unique_cell_ids.size(); ++i) { | |
| 1095 if (unique_cell_ids[i] == cell_id) { | |
| 1068 *cell_index = (long)i; | 1096 *cell_index = (long)i; |
| 1069 return S_OK; | 1097 return S_OK; |
| 1070 } | 1098 } |
| 1071 } | 1099 } |
| 1072 | 1100 |
| 1073 return S_FALSE; | 1101 return S_FALSE; |
| 1074 } | 1102 } |
| 1075 | 1103 |
| 1076 STDMETHODIMP BrowserAccessibilityWin::get_columnDescription(long column, | 1104 STDMETHODIMP BrowserAccessibilityWin::get_columnDescription(long column, |
| 1077 BSTR* description) { | 1105 BSTR* description) { |
| 1078 if (!instance_active_) | 1106 if (!instance_active_) |
| 1079 return E_FAIL; | 1107 return E_FAIL; |
| 1080 | 1108 |
| 1081 if (!description) | 1109 if (!description) |
| 1082 return E_INVALIDARG; | 1110 return E_INVALIDARG; |
| 1083 | 1111 |
| 1084 int columns; | 1112 int columns; |
| 1085 int rows; | 1113 int rows; |
| 1086 if (!GetIntAttribute( | 1114 if (!GetIntAttribute( |
| 1087 AccessibilityNodeData::ATTR_TABLE_COLUMN_COUNT, &columns) || | 1115 AccessibilityNodeData::ATTR_TABLE_COLUMN_COUNT, &columns) || |
| 1088 !GetIntAttribute(AccessibilityNodeData::ATTR_TABLE_ROW_COUNT, &rows) || | 1116 !GetIntAttribute(AccessibilityNodeData::ATTR_TABLE_ROW_COUNT, &rows) || |
| 1089 columns <= 0 || | 1117 columns <= 0 || |
| 1090 rows <= 0) { | 1118 rows <= 0) { |
| 1091 return S_FALSE; | 1119 return S_FALSE; |
| 1092 } | 1120 } |
| 1093 | 1121 |
| 1094 if (column < 0 || column >= columns) | 1122 if (column < 0 || column >= columns) |
| 1095 return E_INVALIDARG; | 1123 return E_INVALIDARG; |
| 1096 | 1124 |
| 1125 const std::vector<int32>& cell_ids = GetIntListAttribute( | |
| 1126 AccessibilityNodeData::ATTR_CELL_IDS); | |
| 1097 for (int i = 0; i < rows; ++i) { | 1127 for (int i = 0; i < rows; ++i) { |
| 1098 int cell_id = cell_ids_[i * columns + column]; | 1128 int cell_id = cell_ids[i * columns + column]; |
| 1099 BrowserAccessibilityWin* cell = static_cast<BrowserAccessibilityWin*>( | 1129 BrowserAccessibilityWin* cell = static_cast<BrowserAccessibilityWin*>( |
| 1100 manager_->GetFromRendererID(cell_id)); | 1130 manager_->GetFromRendererID(cell_id)); |
| 1101 if (cell && cell->role_ == AccessibilityNodeData::ROLE_COLUMN_HEADER) { | 1131 if (cell && cell->role_ == AccessibilityNodeData::ROLE_COLUMN_HEADER) { |
| 1102 if (cell->name_.size() > 0) { | 1132 string16 cell_name = cell->GetString16Attribute( |
| 1103 *description = SysAllocString(cell->name_.c_str()); | 1133 AccessibilityNodeData::ATTR_NAME); |
| 1134 if (cell_name.size() > 0) { | |
| 1135 *description = SysAllocString(cell_name.c_str()); | |
| 1104 return S_OK; | 1136 return S_OK; |
| 1105 } | 1137 } |
| 1106 | 1138 |
| 1107 return cell->GetStringAttributeAsBstr( | 1139 return cell->GetStringAttributeAsBstr( |
| 1108 AccessibilityNodeData::ATTR_DESCRIPTION, description); | 1140 AccessibilityNodeData::ATTR_DESCRIPTION, description); |
| 1109 } | 1141 } |
| 1110 } | 1142 } |
| 1111 | 1143 |
| 1112 return S_FALSE; | 1144 return S_FALSE; |
| 1113 } | 1145 } |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 1128 AccessibilityNodeData::ATTR_TABLE_COLUMN_COUNT, &columns) || | 1160 AccessibilityNodeData::ATTR_TABLE_COLUMN_COUNT, &columns) || |
| 1129 !GetIntAttribute(AccessibilityNodeData::ATTR_TABLE_ROW_COUNT, &rows) || | 1161 !GetIntAttribute(AccessibilityNodeData::ATTR_TABLE_ROW_COUNT, &rows) || |
| 1130 columns <= 0 || | 1162 columns <= 0 || |
| 1131 rows <= 0) { | 1163 rows <= 0) { |
| 1132 return S_FALSE; | 1164 return S_FALSE; |
| 1133 } | 1165 } |
| 1134 | 1166 |
| 1135 if (row < 0 || row >= rows || column < 0 || column >= columns) | 1167 if (row < 0 || row >= rows || column < 0 || column >= columns) |
| 1136 return E_INVALIDARG; | 1168 return E_INVALIDARG; |
| 1137 | 1169 |
| 1138 int cell_id = cell_ids_[row * columns + column]; | 1170 const std::vector<int32>& cell_ids = GetIntListAttribute( |
| 1171 AccessibilityNodeData::ATTR_CELL_IDS); | |
| 1172 int cell_id = cell_ids[row * columns + column]; | |
| 1139 BrowserAccessibilityWin* cell = static_cast<BrowserAccessibilityWin*>( | 1173 BrowserAccessibilityWin* cell = static_cast<BrowserAccessibilityWin*>( |
| 1140 manager_->GetFromRendererID(cell_id)); | 1174 manager_->GetFromRendererID(cell_id)); |
| 1141 int colspan; | 1175 int colspan; |
| 1142 if (cell && | 1176 if (cell && |
| 1143 cell->GetIntAttribute( | 1177 cell->GetIntAttribute( |
| 1144 AccessibilityNodeData::ATTR_TABLE_CELL_COLUMN_SPAN, &colspan) && | 1178 AccessibilityNodeData::ATTR_TABLE_CELL_COLUMN_SPAN, &colspan) && |
| 1145 colspan >= 1) { | 1179 colspan >= 1) { |
| 1146 *n_columns_spanned = colspan; | 1180 *n_columns_spanned = colspan; |
| 1147 return S_OK; | 1181 return S_OK; |
| 1148 } | 1182 } |
| 1149 | 1183 |
| 1150 return S_FALSE; | 1184 return S_FALSE; |
| 1151 } | 1185 } |
| 1152 | 1186 |
| 1153 STDMETHODIMP BrowserAccessibilityWin::get_columnHeader( | 1187 STDMETHODIMP BrowserAccessibilityWin::get_columnHeader( |
| 1154 IAccessibleTable** accessible_table, | 1188 IAccessibleTable** accessible_table, |
| 1155 long* starting_row_index) { | 1189 long* starting_row_index) { |
| 1156 // TODO(dmazzoni): implement | 1190 // TODO(dmazzoni): implement |
| 1157 return E_NOTIMPL; | 1191 return E_NOTIMPL; |
| 1158 } | 1192 } |
| 1159 | 1193 |
| 1160 STDMETHODIMP BrowserAccessibilityWin::get_columnIndex(long cell_index, | 1194 STDMETHODIMP BrowserAccessibilityWin::get_columnIndex(long cell_index, |
| 1161 long* column_index) { | 1195 long* column_index) { |
| 1162 if (!instance_active_) | 1196 if (!instance_active_) |
| 1163 return E_FAIL; | 1197 return E_FAIL; |
| 1164 | 1198 |
| 1165 if (!column_index) | 1199 if (!column_index) |
| 1166 return E_INVALIDARG; | 1200 return E_INVALIDARG; |
| 1167 | 1201 |
| 1168 int cell_id_count = static_cast<int>(unique_cell_ids_.size()); | 1202 const std::vector<int32>& unique_cell_ids = GetIntListAttribute( |
| 1203 AccessibilityNodeData::ATTR_UNIQUE_CELL_IDS); | |
| 1204 int cell_id_count = static_cast<int>(unique_cell_ids.size()); | |
| 1169 if (cell_index < 0) | 1205 if (cell_index < 0) |
| 1170 return E_INVALIDARG; | 1206 return E_INVALIDARG; |
| 1171 if (cell_index >= cell_id_count) | 1207 if (cell_index >= cell_id_count) |
| 1172 return S_FALSE; | 1208 return S_FALSE; |
| 1173 | 1209 |
| 1174 int cell_id = unique_cell_ids_[cell_index]; | 1210 int cell_id = unique_cell_ids[cell_index]; |
| 1175 BrowserAccessibilityWin* cell = | 1211 BrowserAccessibilityWin* cell = |
| 1176 manager_->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin(); | 1212 manager_->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin(); |
| 1177 int col_index; | 1213 int col_index; |
| 1178 if (cell && | 1214 if (cell && |
| 1179 cell->GetIntAttribute( | 1215 cell->GetIntAttribute( |
| 1180 AccessibilityNodeData::ATTR_TABLE_CELL_COLUMN_INDEX, &col_index)) { | 1216 AccessibilityNodeData::ATTR_TABLE_CELL_COLUMN_INDEX, &col_index)) { |
| 1181 *column_index = col_index; | 1217 *column_index = col_index; |
| 1182 return S_OK; | 1218 return S_OK; |
| 1183 } | 1219 } |
| 1184 | 1220 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1266 AccessibilityNodeData::ATTR_TABLE_COLUMN_COUNT, &columns) || | 1302 AccessibilityNodeData::ATTR_TABLE_COLUMN_COUNT, &columns) || |
| 1267 !GetIntAttribute(AccessibilityNodeData::ATTR_TABLE_ROW_COUNT, &rows) || | 1303 !GetIntAttribute(AccessibilityNodeData::ATTR_TABLE_ROW_COUNT, &rows) || |
| 1268 columns <= 0 || | 1304 columns <= 0 || |
| 1269 rows <= 0) { | 1305 rows <= 0) { |
| 1270 return S_FALSE; | 1306 return S_FALSE; |
| 1271 } | 1307 } |
| 1272 | 1308 |
| 1273 if (row < 0 || row >= rows) | 1309 if (row < 0 || row >= rows) |
| 1274 return E_INVALIDARG; | 1310 return E_INVALIDARG; |
| 1275 | 1311 |
| 1312 const std::vector<int32>& cell_ids = GetIntListAttribute( | |
| 1313 AccessibilityNodeData::ATTR_CELL_IDS); | |
| 1276 for (int i = 0; i < columns; ++i) { | 1314 for (int i = 0; i < columns; ++i) { |
| 1277 int cell_id = cell_ids_[row * columns + i]; | 1315 int cell_id = cell_ids[row * columns + i]; |
| 1278 BrowserAccessibilityWin* cell = | 1316 BrowserAccessibilityWin* cell = |
| 1279 manager_->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin(); | 1317 manager_->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin(); |
| 1280 if (cell && cell->role_ == AccessibilityNodeData::ROLE_ROW_HEADER) { | 1318 if (cell && cell->role_ == AccessibilityNodeData::ROLE_ROW_HEADER) { |
| 1281 if (cell->name_.size() > 0) { | 1319 string16 cell_name = cell->GetString16Attribute( |
| 1282 *description = SysAllocString(cell->name_.c_str()); | 1320 AccessibilityNodeData::ATTR_NAME); |
| 1321 if (cell_name.size() > 0) { | |
| 1322 *description = SysAllocString(cell_name.c_str()); | |
| 1283 return S_OK; | 1323 return S_OK; |
| 1284 } | 1324 } |
| 1285 | 1325 |
| 1286 return cell->GetStringAttributeAsBstr( | 1326 return cell->GetStringAttributeAsBstr( |
| 1287 AccessibilityNodeData::ATTR_DESCRIPTION, description); | 1327 AccessibilityNodeData::ATTR_DESCRIPTION, description); |
| 1288 } | 1328 } |
| 1289 } | 1329 } |
| 1290 | 1330 |
| 1291 return S_FALSE; | 1331 return S_FALSE; |
| 1292 } | 1332 } |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 1306 AccessibilityNodeData::ATTR_TABLE_COLUMN_COUNT, &columns) || | 1346 AccessibilityNodeData::ATTR_TABLE_COLUMN_COUNT, &columns) || |
| 1307 !GetIntAttribute(AccessibilityNodeData::ATTR_TABLE_ROW_COUNT, &rows) || | 1347 !GetIntAttribute(AccessibilityNodeData::ATTR_TABLE_ROW_COUNT, &rows) || |
| 1308 columns <= 0 || | 1348 columns <= 0 || |
| 1309 rows <= 0) { | 1349 rows <= 0) { |
| 1310 return S_FALSE; | 1350 return S_FALSE; |
| 1311 } | 1351 } |
| 1312 | 1352 |
| 1313 if (row < 0 || row >= rows || column < 0 || column >= columns) | 1353 if (row < 0 || row >= rows || column < 0 || column >= columns) |
| 1314 return E_INVALIDARG; | 1354 return E_INVALIDARG; |
| 1315 | 1355 |
| 1316 int cell_id = cell_ids_[row * columns + column]; | 1356 const std::vector<int32>& cell_ids = GetIntListAttribute( |
| 1357 AccessibilityNodeData::ATTR_CELL_IDS); | |
| 1358 int cell_id = cell_ids[row * columns + column]; | |
| 1317 BrowserAccessibilityWin* cell = | 1359 BrowserAccessibilityWin* cell = |
| 1318 manager_->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin(); | 1360 manager_->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin(); |
| 1319 int rowspan; | 1361 int rowspan; |
| 1320 if (cell && | 1362 if (cell && |
| 1321 cell->GetIntAttribute( | 1363 cell->GetIntAttribute( |
| 1322 AccessibilityNodeData::ATTR_TABLE_CELL_ROW_SPAN, &rowspan) && | 1364 AccessibilityNodeData::ATTR_TABLE_CELL_ROW_SPAN, &rowspan) && |
| 1323 rowspan >= 1) { | 1365 rowspan >= 1) { |
| 1324 *n_rows_spanned = rowspan; | 1366 *n_rows_spanned = rowspan; |
| 1325 return S_OK; | 1367 return S_OK; |
| 1326 } | 1368 } |
| 1327 | 1369 |
| 1328 return S_FALSE; | 1370 return S_FALSE; |
| 1329 } | 1371 } |
| 1330 | 1372 |
| 1331 STDMETHODIMP BrowserAccessibilityWin::get_rowHeader( | 1373 STDMETHODIMP BrowserAccessibilityWin::get_rowHeader( |
| 1332 IAccessibleTable** accessible_table, | 1374 IAccessibleTable** accessible_table, |
| 1333 long* starting_column_index) { | 1375 long* starting_column_index) { |
| 1334 // TODO(dmazzoni): implement | 1376 // TODO(dmazzoni): implement |
| 1335 return E_NOTIMPL; | 1377 return E_NOTIMPL; |
| 1336 } | 1378 } |
| 1337 | 1379 |
| 1338 STDMETHODIMP BrowserAccessibilityWin::get_rowIndex(long cell_index, | 1380 STDMETHODIMP BrowserAccessibilityWin::get_rowIndex(long cell_index, |
| 1339 long* row_index) { | 1381 long* row_index) { |
| 1340 if (!instance_active_) | 1382 if (!instance_active_) |
| 1341 return E_FAIL; | 1383 return E_FAIL; |
| 1342 | 1384 |
| 1343 if (!row_index) | 1385 if (!row_index) |
| 1344 return E_INVALIDARG; | 1386 return E_INVALIDARG; |
| 1345 | 1387 |
| 1346 int cell_id_count = static_cast<int>(unique_cell_ids_.size()); | 1388 const std::vector<int32>& unique_cell_ids = GetIntListAttribute( |
| 1389 AccessibilityNodeData::ATTR_UNIQUE_CELL_IDS); | |
| 1390 int cell_id_count = static_cast<int>(unique_cell_ids.size()); | |
| 1347 if (cell_index < 0) | 1391 if (cell_index < 0) |
| 1348 return E_INVALIDARG; | 1392 return E_INVALIDARG; |
| 1349 if (cell_index >= cell_id_count) | 1393 if (cell_index >= cell_id_count) |
| 1350 return S_FALSE; | 1394 return S_FALSE; |
| 1351 | 1395 |
| 1352 int cell_id = unique_cell_ids_[cell_index]; | 1396 int cell_id = unique_cell_ids[cell_index]; |
| 1353 BrowserAccessibilityWin* cell = | 1397 BrowserAccessibilityWin* cell = |
| 1354 manager_->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin(); | 1398 manager_->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin(); |
| 1355 int cell_row_index; | 1399 int cell_row_index; |
| 1356 if (cell && | 1400 if (cell && |
| 1357 cell->GetIntAttribute( | 1401 cell->GetIntAttribute( |
| 1358 AccessibilityNodeData::ATTR_TABLE_CELL_ROW_INDEX, &cell_row_index)) { | 1402 AccessibilityNodeData::ATTR_TABLE_CELL_ROW_INDEX, &cell_row_index)) { |
| 1359 *row_index = cell_row_index; | 1403 *row_index = cell_row_index; |
| 1360 return S_OK; | 1404 return S_OK; |
| 1361 } | 1405 } |
| 1362 | 1406 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1463 long* column, | 1507 long* column, |
| 1464 long* row_extents, | 1508 long* row_extents, |
| 1465 long* column_extents, | 1509 long* column_extents, |
| 1466 boolean* is_selected) { | 1510 boolean* is_selected) { |
| 1467 if (!instance_active_) | 1511 if (!instance_active_) |
| 1468 return E_FAIL; | 1512 return E_FAIL; |
| 1469 | 1513 |
| 1470 if (!row || !column || !row_extents || !column_extents || !is_selected) | 1514 if (!row || !column || !row_extents || !column_extents || !is_selected) |
| 1471 return E_INVALIDARG; | 1515 return E_INVALIDARG; |
| 1472 | 1516 |
| 1473 int cell_id_count = static_cast<int>(unique_cell_ids_.size()); | 1517 const std::vector<int32>& unique_cell_ids = GetIntListAttribute( |
| 1518 AccessibilityNodeData::ATTR_UNIQUE_CELL_IDS); | |
| 1519 int cell_id_count = static_cast<int>(unique_cell_ids.size()); | |
| 1474 if (index < 0) | 1520 if (index < 0) |
| 1475 return E_INVALIDARG; | 1521 return E_INVALIDARG; |
| 1476 if (index >= cell_id_count) | 1522 if (index >= cell_id_count) |
| 1477 return S_FALSE; | 1523 return S_FALSE; |
| 1478 | 1524 |
| 1479 int cell_id = unique_cell_ids_[index]; | 1525 int cell_id = unique_cell_ids[index]; |
| 1480 BrowserAccessibilityWin* cell = | 1526 BrowserAccessibilityWin* cell = |
| 1481 manager_->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin(); | 1527 manager_->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin(); |
| 1482 int rowspan; | 1528 int rowspan; |
| 1483 int colspan; | 1529 int colspan; |
| 1484 if (cell && | 1530 if (cell && |
| 1485 cell->GetIntAttribute( | 1531 cell->GetIntAttribute( |
| 1486 AccessibilityNodeData::ATTR_TABLE_CELL_ROW_SPAN, &rowspan) && | 1532 AccessibilityNodeData::ATTR_TABLE_CELL_ROW_SPAN, &rowspan) && |
| 1487 cell->GetIntAttribute( | 1533 cell->GetIntAttribute( |
| 1488 AccessibilityNodeData::ATTR_TABLE_CELL_COLUMN_SPAN, &colspan) && | 1534 AccessibilityNodeData::ATTR_TABLE_CELL_COLUMN_SPAN, &colspan) && |
| 1489 rowspan >= 1 && | 1535 rowspan >= 1 && |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1603 int rows; | 1649 int rows; |
| 1604 if (!table->GetIntAttribute( | 1650 if (!table->GetIntAttribute( |
| 1605 AccessibilityNodeData::ATTR_TABLE_COLUMN_COUNT, &columns) || | 1651 AccessibilityNodeData::ATTR_TABLE_COLUMN_COUNT, &columns) || |
| 1606 !table->GetIntAttribute( | 1652 !table->GetIntAttribute( |
| 1607 AccessibilityNodeData::ATTR_TABLE_ROW_COUNT, &rows)) { | 1653 AccessibilityNodeData::ATTR_TABLE_ROW_COUNT, &rows)) { |
| 1608 return S_FALSE; | 1654 return S_FALSE; |
| 1609 } | 1655 } |
| 1610 if (columns <= 0 || rows <= 0 || column < 0 || column >= columns) | 1656 if (columns <= 0 || rows <= 0 || column < 0 || column >= columns) |
| 1611 return S_FALSE; | 1657 return S_FALSE; |
| 1612 | 1658 |
| 1659 const std::vector<int32>& cell_ids = table->GetIntListAttribute( | |
| 1660 AccessibilityNodeData::ATTR_CELL_IDS); | |
| 1661 | |
| 1613 for (int i = 0; i < rows; ++i) { | 1662 for (int i = 0; i < rows; ++i) { |
| 1614 int cell_id = table->cell_ids()[i * columns + column]; | 1663 int cell_id = cell_ids[i * columns + column]; |
| 1615 BrowserAccessibilityWin* cell = | 1664 BrowserAccessibilityWin* cell = |
| 1616 manager_->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin(); | 1665 manager_->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin(); |
| 1617 if (cell && cell->role_ == AccessibilityNodeData::ROLE_COLUMN_HEADER) | 1666 if (cell && cell->role_ == AccessibilityNodeData::ROLE_COLUMN_HEADER) |
| 1618 (*n_column_header_cells)++; | 1667 (*n_column_header_cells)++; |
| 1619 } | 1668 } |
| 1620 | 1669 |
| 1621 *cell_accessibles = static_cast<IUnknown**>(CoTaskMemAlloc( | 1670 *cell_accessibles = static_cast<IUnknown**>(CoTaskMemAlloc( |
| 1622 (*n_column_header_cells) * sizeof(cell_accessibles[0]))); | 1671 (*n_column_header_cells) * sizeof(cell_accessibles[0]))); |
| 1623 int index = 0; | 1672 int index = 0; |
| 1624 for (int i = 0; i < rows; ++i) { | 1673 for (int i = 0; i < rows; ++i) { |
| 1625 int cell_id = table->cell_ids()[i * columns + column]; | 1674 int cell_id = cell_ids[i * columns + column]; |
| 1626 BrowserAccessibilityWin* cell = | 1675 BrowserAccessibilityWin* cell = |
| 1627 manager_->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin(); | 1676 manager_->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin(); |
| 1628 if (cell && cell->role_ == AccessibilityNodeData::ROLE_COLUMN_HEADER) { | 1677 if (cell && cell->role_ == AccessibilityNodeData::ROLE_COLUMN_HEADER) { |
| 1629 (*cell_accessibles)[index] = | 1678 (*cell_accessibles)[index] = |
| 1630 static_cast<IAccessible*>(cell->NewReference()); | 1679 static_cast<IAccessible*>(cell->NewReference()); |
| 1631 ++index; | 1680 ++index; |
| 1632 } | 1681 } |
| 1633 } | 1682 } |
| 1634 | 1683 |
| 1635 return S_OK; | 1684 return S_OK; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1699 int rows; | 1748 int rows; |
| 1700 if (!table->GetIntAttribute( | 1749 if (!table->GetIntAttribute( |
| 1701 AccessibilityNodeData::ATTR_TABLE_COLUMN_COUNT, &columns) || | 1750 AccessibilityNodeData::ATTR_TABLE_COLUMN_COUNT, &columns) || |
| 1702 !table->GetIntAttribute( | 1751 !table->GetIntAttribute( |
| 1703 AccessibilityNodeData::ATTR_TABLE_ROW_COUNT, &rows)) { | 1752 AccessibilityNodeData::ATTR_TABLE_ROW_COUNT, &rows)) { |
| 1704 return S_FALSE; | 1753 return S_FALSE; |
| 1705 } | 1754 } |
| 1706 if (columns <= 0 || rows <= 0 || row < 0 || row >= rows) | 1755 if (columns <= 0 || rows <= 0 || row < 0 || row >= rows) |
| 1707 return S_FALSE; | 1756 return S_FALSE; |
| 1708 | 1757 |
| 1758 const std::vector<int32>& cell_ids = table->GetIntListAttribute( | |
| 1759 AccessibilityNodeData::ATTR_CELL_IDS); | |
| 1760 | |
| 1709 for (int i = 0; i < columns; ++i) { | 1761 for (int i = 0; i < columns; ++i) { |
| 1710 int cell_id = table->cell_ids()[row * columns + i]; | 1762 int cell_id = cell_ids[row * columns + i]; |
| 1711 BrowserAccessibilityWin* cell = | 1763 BrowserAccessibilityWin* cell = |
| 1712 manager_->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin(); | 1764 manager_->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin(); |
| 1713 if (cell && cell->role_ == AccessibilityNodeData::ROLE_ROW_HEADER) | 1765 if (cell && cell->role_ == AccessibilityNodeData::ROLE_ROW_HEADER) |
| 1714 (*n_row_header_cells)++; | 1766 (*n_row_header_cells)++; |
| 1715 } | 1767 } |
| 1716 | 1768 |
| 1717 *cell_accessibles = static_cast<IUnknown**>(CoTaskMemAlloc( | 1769 *cell_accessibles = static_cast<IUnknown**>(CoTaskMemAlloc( |
| 1718 (*n_row_header_cells) * sizeof(cell_accessibles[0]))); | 1770 (*n_row_header_cells) * sizeof(cell_accessibles[0]))); |
| 1719 int index = 0; | 1771 int index = 0; |
| 1720 for (int i = 0; i < columns; ++i) { | 1772 for (int i = 0; i < columns; ++i) { |
| 1721 int cell_id = table->cell_ids()[row * columns + i]; | 1773 int cell_id = cell_ids[row * columns + i]; |
| 1722 BrowserAccessibilityWin* cell = | 1774 BrowserAccessibilityWin* cell = |
| 1723 manager_->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin(); | 1775 manager_->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin(); |
| 1724 if (cell && cell->role_ == AccessibilityNodeData::ROLE_ROW_HEADER) { | 1776 if (cell && cell->role_ == AccessibilityNodeData::ROLE_ROW_HEADER) { |
| 1725 (*cell_accessibles)[index] = | 1777 (*cell_accessibles)[index] = |
| 1726 static_cast<IAccessible*>(cell->NewReference()); | 1778 static_cast<IAccessible*>(cell->NewReference()); |
| 1727 ++index; | 1779 ++index; |
| 1728 } | 1780 } |
| 1729 } | 1781 } |
| 1730 | 1782 |
| 1731 return S_OK; | 1783 return S_OK; |
| (...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2327 unsigned short* node_type) { | 2379 unsigned short* node_type) { |
| 2328 if (!instance_active_) | 2380 if (!instance_active_) |
| 2329 return E_FAIL; | 2381 return E_FAIL; |
| 2330 | 2382 |
| 2331 if (!node_name || !name_space_id || !node_value || !num_children || | 2383 if (!node_name || !name_space_id || !node_value || !num_children || |
| 2332 !unique_id || !node_type) { | 2384 !unique_id || !node_type) { |
| 2333 return E_INVALIDARG; | 2385 return E_INVALIDARG; |
| 2334 } | 2386 } |
| 2335 | 2387 |
| 2336 string16 tag; | 2388 string16 tag; |
| 2337 if (GetStringAttribute(AccessibilityNodeData::ATTR_HTML_TAG, &tag)) | 2389 if (GetString16Attribute(AccessibilityNodeData::ATTR_HTML_TAG, &tag)) |
| 2338 *node_name = SysAllocString(tag.c_str()); | 2390 *node_name = SysAllocString(tag.c_str()); |
| 2339 else | 2391 else |
| 2340 *node_name = NULL; | 2392 *node_name = NULL; |
| 2341 | 2393 |
| 2342 *name_space_id = 0; | 2394 *name_space_id = 0; |
| 2343 *node_value = SysAllocString(value_.c_str()); | 2395 GetStringAttributeAsBstr(AccessibilityNodeData::ATTR_VALUE, node_value); |
| 2344 *num_children = children_.size(); | 2396 *num_children = children_.size(); |
| 2345 *unique_id = unique_id_win_; | 2397 *unique_id = unique_id_win_; |
| 2346 | 2398 |
| 2347 if (ia_role_ == ROLE_SYSTEM_DOCUMENT) { | 2399 if (ia_role_ == ROLE_SYSTEM_DOCUMENT) { |
| 2348 *node_type = NODETYPE_DOCUMENT; | 2400 *node_type = NODETYPE_DOCUMENT; |
| 2349 } else if (ia_role_ == ROLE_SYSTEM_TEXT && | 2401 } else if (ia_role_ == ROLE_SYSTEM_TEXT && |
| 2350 ((ia2_state_ & IA2_STATE_EDITABLE) == 0)) { | 2402 ((ia2_state_ & IA2_STATE_EDITABLE) == 0)) { |
| 2351 *node_type = NODETYPE_TEXT; | 2403 *node_type = NODETYPE_TEXT; |
| 2352 } else { | 2404 } else { |
| 2353 *node_type = NODETYPE_ELEMENT; | 2405 *node_type = NODETYPE_ELEMENT; |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 2366 return E_FAIL; | 2418 return E_FAIL; |
| 2367 | 2419 |
| 2368 if (!attrib_names || !name_space_id || !attrib_values || !num_attribs) | 2420 if (!attrib_names || !name_space_id || !attrib_values || !num_attribs) |
| 2369 return E_INVALIDARG; | 2421 return E_INVALIDARG; |
| 2370 | 2422 |
| 2371 *num_attribs = max_attribs; | 2423 *num_attribs = max_attribs; |
| 2372 if (*num_attribs > html_attributes_.size()) | 2424 if (*num_attribs > html_attributes_.size()) |
| 2373 *num_attribs = html_attributes_.size(); | 2425 *num_attribs = html_attributes_.size(); |
| 2374 | 2426 |
| 2375 for (unsigned short i = 0; i < *num_attribs; ++i) { | 2427 for (unsigned short i = 0; i < *num_attribs; ++i) { |
| 2376 attrib_names[i] = SysAllocString(html_attributes_[i].first.c_str()); | 2428 attrib_names[i] = SysAllocString( |
| 2429 UTF8ToUTF16(html_attributes_[i].first).c_str()); | |
| 2377 name_space_id[i] = 0; | 2430 name_space_id[i] = 0; |
| 2378 attrib_values[i] = SysAllocString(html_attributes_[i].second.c_str()); | 2431 attrib_values[i] = SysAllocString( |
| 2432 UTF8ToUTF16(html_attributes_[i].second).c_str()); | |
| 2379 } | 2433 } |
| 2380 return S_OK; | 2434 return S_OK; |
| 2381 } | 2435 } |
| 2382 | 2436 |
| 2383 STDMETHODIMP BrowserAccessibilityWin::get_attributesForNames( | 2437 STDMETHODIMP BrowserAccessibilityWin::get_attributesForNames( |
| 2384 unsigned short num_attribs, | 2438 unsigned short num_attribs, |
| 2385 BSTR* attrib_names, | 2439 BSTR* attrib_names, |
| 2386 short* name_space_id, | 2440 short* name_space_id, |
| 2387 BSTR* attrib_values) { | 2441 BSTR* attrib_values) { |
| 2388 if (!instance_active_) | 2442 if (!instance_active_) |
| 2389 return E_FAIL; | 2443 return E_FAIL; |
| 2390 | 2444 |
| 2391 if (!attrib_names || !name_space_id || !attrib_values) | 2445 if (!attrib_names || !name_space_id || !attrib_values) |
| 2392 return E_INVALIDARG; | 2446 return E_INVALIDARG; |
| 2393 | 2447 |
| 2394 for (unsigned short i = 0; i < num_attribs; ++i) { | 2448 for (unsigned short i = 0; i < num_attribs; ++i) { |
| 2395 name_space_id[i] = 0; | 2449 name_space_id[i] = 0; |
| 2396 bool found = false; | 2450 bool found = false; |
| 2397 string16 name = (LPCWSTR)attrib_names[i]; | 2451 std::string name = UTF16ToUTF8((LPCWSTR)attrib_names[i]); |
| 2398 for (unsigned int j = 0; j < html_attributes_.size(); ++j) { | 2452 for (unsigned int j = 0; j < html_attributes_.size(); ++j) { |
| 2399 if (html_attributes_[j].first == name) { | 2453 if (html_attributes_[j].first == name) { |
| 2400 attrib_values[i] = SysAllocString(html_attributes_[j].second.c_str()); | 2454 attrib_values[i] = SysAllocString( |
| 2455 UTF8ToUTF16(html_attributes_[j].second).c_str()); | |
| 2401 found = true; | 2456 found = true; |
| 2402 break; | 2457 break; |
| 2403 } | 2458 } |
| 2404 } | 2459 } |
| 2405 if (!found) { | 2460 if (!found) { |
| 2406 attrib_values[i] = NULL; | 2461 attrib_values[i] = NULL; |
| 2407 } | 2462 } |
| 2408 } | 2463 } |
| 2409 return S_OK; | 2464 return S_OK; |
| 2410 } | 2465 } |
| 2411 | 2466 |
| 2412 STDMETHODIMP BrowserAccessibilityWin::get_computedStyle( | 2467 STDMETHODIMP BrowserAccessibilityWin::get_computedStyle( |
| 2413 unsigned short max_style_properties, | 2468 unsigned short max_style_properties, |
| 2414 boolean use_alternate_view, | 2469 boolean use_alternate_view, |
| 2415 BSTR* style_properties, | 2470 BSTR* style_properties, |
| 2416 BSTR* style_values, | 2471 BSTR* style_values, |
| 2417 unsigned short *num_style_properties) { | 2472 unsigned short *num_style_properties) { |
| 2418 if (!instance_active_) | 2473 if (!instance_active_) |
| 2419 return E_FAIL; | 2474 return E_FAIL; |
| 2420 | 2475 |
| 2421 if (!style_properties || !style_values) | 2476 if (!style_properties || !style_values) |
| 2422 return E_INVALIDARG; | 2477 return E_INVALIDARG; |
| 2423 | 2478 |
| 2424 // We only cache a single style property for now: DISPLAY | 2479 // We only cache a single style property for now: DISPLAY |
| 2425 | 2480 |
| 2426 string16 display; | 2481 string16 display; |
| 2427 if (max_style_properties == 0 || | 2482 if (max_style_properties == 0 || |
| 2428 !GetStringAttribute(AccessibilityNodeData::ATTR_DISPLAY, &display)) { | 2483 !GetString16Attribute(AccessibilityNodeData::ATTR_DISPLAY, &display)) { |
| 2429 *num_style_properties = 0; | 2484 *num_style_properties = 0; |
| 2430 return S_OK; | 2485 return S_OK; |
| 2431 } | 2486 } |
| 2432 | 2487 |
| 2433 *num_style_properties = 1; | 2488 *num_style_properties = 1; |
| 2434 style_properties[0] = SysAllocString(L"display"); | 2489 style_properties[0] = SysAllocString(L"display"); |
| 2435 style_values[0] = SysAllocString(display.c_str()); | 2490 style_values[0] = SysAllocString(display.c_str()); |
| 2436 | 2491 |
| 2437 return S_OK; | 2492 return S_OK; |
| 2438 } | 2493 } |
| 2439 | 2494 |
| 2440 STDMETHODIMP BrowserAccessibilityWin::get_computedStyleForProperties( | 2495 STDMETHODIMP BrowserAccessibilityWin::get_computedStyleForProperties( |
| 2441 unsigned short num_style_properties, | 2496 unsigned short num_style_properties, |
| 2442 boolean use_alternate_view, | 2497 boolean use_alternate_view, |
| 2443 BSTR* style_properties, | 2498 BSTR* style_properties, |
| 2444 BSTR* style_values) { | 2499 BSTR* style_values) { |
| 2445 if (!instance_active_) | 2500 if (!instance_active_) |
| 2446 return E_FAIL; | 2501 return E_FAIL; |
| 2447 | 2502 |
| 2448 if (!style_properties || !style_values) | 2503 if (!style_properties || !style_values) |
| 2449 return E_INVALIDARG; | 2504 return E_INVALIDARG; |
| 2450 | 2505 |
| 2451 // We only cache a single style property for now: DISPLAY | 2506 // We only cache a single style property for now: DISPLAY |
| 2452 | 2507 |
| 2453 for (unsigned short i = 0; i < num_style_properties; ++i) { | 2508 for (unsigned short i = 0; i < num_style_properties; ++i) { |
| 2454 string16 name = (LPCWSTR)style_properties[i]; | 2509 string16 name = (LPCWSTR)style_properties[i]; |
| 2455 StringToLowerASCII(&name); | 2510 StringToLowerASCII(&name); |
| 2456 if (name == L"display") { | 2511 if (name == L"display") { |
| 2457 string16 display; | 2512 string16 display = GetString16Attribute( |
| 2458 GetStringAttribute(AccessibilityNodeData::ATTR_DISPLAY, &display); | 2513 AccessibilityNodeData::ATTR_DISPLAY); |
| 2459 style_values[i] = SysAllocString(display.c_str()); | 2514 style_values[i] = SysAllocString(display.c_str()); |
| 2460 } else { | 2515 } else { |
| 2461 style_values[i] = NULL; | 2516 style_values[i] = NULL; |
| 2462 } | 2517 } |
| 2463 } | 2518 } |
| 2464 | 2519 |
| 2465 return S_OK; | 2520 return S_OK; |
| 2466 } | 2521 } |
| 2467 | 2522 |
| 2468 STDMETHODIMP BrowserAccessibilityWin::scrollTo(boolean placeTopLeft) { | 2523 STDMETHODIMP BrowserAccessibilityWin::scrollTo(boolean placeTopLeft) { |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2572 // ISimpleDOMText methods. | 2627 // ISimpleDOMText methods. |
| 2573 // | 2628 // |
| 2574 | 2629 |
| 2575 STDMETHODIMP BrowserAccessibilityWin::get_domText(BSTR* dom_text) { | 2630 STDMETHODIMP BrowserAccessibilityWin::get_domText(BSTR* dom_text) { |
| 2576 if (!instance_active_) | 2631 if (!instance_active_) |
| 2577 return E_FAIL; | 2632 return E_FAIL; |
| 2578 | 2633 |
| 2579 if (!dom_text) | 2634 if (!dom_text) |
| 2580 return E_INVALIDARG; | 2635 return E_INVALIDARG; |
| 2581 | 2636 |
| 2582 if (name_.empty()) | 2637 return GetStringAttributeAsBstr( |
| 2583 return S_FALSE; | 2638 AccessibilityNodeData::ATTR_NAME, dom_text); |
| 2584 | |
| 2585 *dom_text = SysAllocString(name_.c_str()); | |
| 2586 DCHECK(*dom_text); | |
| 2587 return S_OK; | |
| 2588 } | 2639 } |
| 2589 | 2640 |
| 2590 // | 2641 // |
| 2591 // IServiceProvider methods. | 2642 // IServiceProvider methods. |
| 2592 // | 2643 // |
| 2593 | 2644 |
| 2594 STDMETHODIMP BrowserAccessibilityWin::QueryService(REFGUID guidService, | 2645 STDMETHODIMP BrowserAccessibilityWin::QueryService(REFGUID guidService, |
| 2595 REFIID riid, | 2646 REFIID riid, |
| 2596 void** object) { | 2647 void** object) { |
| 2597 if (!instance_active_) | 2648 if (!instance_active_) |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2766 "container-relevant"); | 2817 "container-relevant"); |
| 2767 BoolAttributeToIA2(AccessibilityNodeData::ATTR_CONTAINER_LIVE_ATOMIC, | 2818 BoolAttributeToIA2(AccessibilityNodeData::ATTR_CONTAINER_LIVE_ATOMIC, |
| 2768 "container-atomic"); | 2819 "container-atomic"); |
| 2769 BoolAttributeToIA2(AccessibilityNodeData::ATTR_CONTAINER_LIVE_BUSY, | 2820 BoolAttributeToIA2(AccessibilityNodeData::ATTR_CONTAINER_LIVE_BUSY, |
| 2770 "container-busy"); | 2821 "container-busy"); |
| 2771 | 2822 |
| 2772 // Expose slider value. | 2823 // Expose slider value. |
| 2773 if (ia_role_ == ROLE_SYSTEM_PROGRESSBAR || | 2824 if (ia_role_ == ROLE_SYSTEM_PROGRESSBAR || |
| 2774 ia_role_ == ROLE_SYSTEM_SCROLLBAR || | 2825 ia_role_ == ROLE_SYSTEM_SCROLLBAR || |
| 2775 ia_role_ == ROLE_SYSTEM_SLIDER) { | 2826 ia_role_ == ROLE_SYSTEM_SLIDER) { |
| 2776 float fval; | 2827 ia2_attributes_.push_back(L"valuetext:" + GetValueText()); |
| 2777 if (value_.empty() && | |
| 2778 GetFloatAttribute(AccessibilityNodeData::ATTR_VALUE_FOR_RANGE, &fval)) { | |
| 2779 // TODO(dmazzoni): Use ICU to localize this? | |
| 2780 value_ = UTF8ToUTF16(base::DoubleToString(fval)); | |
| 2781 } | |
| 2782 ia2_attributes_.push_back(L"valuetext:" + value_); | |
| 2783 } | |
| 2784 | |
| 2785 // Expose color well value. | |
| 2786 if (ia2_role_ == IA2_ROLE_COLOR_CHOOSER) { | |
|
aboxhall
2013/08/07 17:16:09
Why does this no longer expose the color well valu
dmazzoni
2013/08/07 17:48:18
Just moved this code, didn't delete it. See other
| |
| 2787 int r, g, b; | |
| 2788 GetIntAttribute(AccessibilityNodeData::ATTR_COLOR_VALUE_RED, &r); | |
| 2789 GetIntAttribute(AccessibilityNodeData::ATTR_COLOR_VALUE_GREEN, &g); | |
| 2790 GetIntAttribute(AccessibilityNodeData::ATTR_COLOR_VALUE_BLUE, &b); | |
| 2791 value_ = base::IntToString16((r * 100) / 255) + L"% red " + | |
| 2792 base::IntToString16((g * 100) / 255) + L"% green " + | |
| 2793 base::IntToString16((b * 100) / 255) + L"% blue"; | |
| 2794 } | 2828 } |
| 2795 | 2829 |
| 2796 // Expose table cell index. | 2830 // Expose table cell index. |
| 2797 if (ia_role_ == ROLE_SYSTEM_CELL) { | 2831 if (ia_role_ == ROLE_SYSTEM_CELL) { |
| 2798 BrowserAccessibility* table = parent(); | 2832 BrowserAccessibility* table = parent(); |
| 2799 while (table && table->role() != AccessibilityNodeData::ROLE_TABLE) | 2833 while (table && table->role() != AccessibilityNodeData::ROLE_TABLE) |
| 2800 table = table->parent(); | 2834 table = table->parent(); |
| 2801 if (table) { | 2835 if (table) { |
| 2802 const std::vector<int32>& unique_cell_ids = table->unique_cell_ids(); | 2836 const std::vector<int32>& unique_cell_ids = table->GetIntListAttribute( |
| 2837 AccessibilityNodeData::ATTR_UNIQUE_CELL_IDS); | |
| 2803 for (size_t i = 0; i < unique_cell_ids.size(); ++i) { | 2838 for (size_t i = 0; i < unique_cell_ids.size(); ++i) { |
| 2804 if (unique_cell_ids[i] == renderer_id_) { | 2839 if (unique_cell_ids[i] == renderer_id_) { |
| 2805 ia2_attributes_.push_back( | 2840 ia2_attributes_.push_back( |
| 2806 string16(L"table-cell-index:") + base::IntToString16(i)); | 2841 string16(L"table-cell-index:") + base::IntToString16(i)); |
| 2807 } | 2842 } |
| 2808 } | 2843 } |
| 2809 } | 2844 } |
| 2810 } | 2845 } |
| 2811 | 2846 |
| 2812 // The calculation of the accessible name of an element has been | 2847 // The calculation of the accessible name of an element has been |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 2823 // title ui element: a reference to a <label> element on the same | 2858 // title ui element: a reference to a <label> element on the same |
| 2824 // page that labels this node. | 2859 // page that labels this node. |
| 2825 // description: accessible labels that override the default name: | 2860 // description: accessible labels that override the default name: |
| 2826 // aria-label or aria-labelledby or aria-describedby | 2861 // aria-label or aria-labelledby or aria-describedby |
| 2827 // help: the value of the "title" attribute | 2862 // help: the value of the "title" attribute |
| 2828 // | 2863 // |
| 2829 // On Windows, the logic we apply lets some fields take precedence and | 2864 // On Windows, the logic we apply lets some fields take precedence and |
| 2830 // always returns the primary name in "name" and the secondary name, | 2865 // always returns the primary name in "name" and the secondary name, |
| 2831 // if any, in "description". | 2866 // if any, in "description". |
| 2832 | 2867 |
| 2833 string16 description, help, title_attr; | 2868 int title_elem_id = GetIntAttribute( |
| 2834 int title_elem_id = 0; | 2869 AccessibilityNodeData::ATTR_TITLE_UI_ELEMENT); |
| 2835 GetIntAttribute(AccessibilityNodeData::ATTR_TITLE_UI_ELEMENT, &title_elem_id); | 2870 std::string name = GetStringAttribute(AccessibilityNodeData::ATTR_NAME); |
| 2836 GetStringAttribute(AccessibilityNodeData::ATTR_DESCRIPTION, &description); | 2871 std::string help = GetStringAttribute(AccessibilityNodeData::ATTR_HELP); |
| 2837 GetStringAttribute(AccessibilityNodeData::ATTR_HELP, &help); | 2872 std::string description = GetStringAttribute( |
| 2873 AccessibilityNodeData::ATTR_DESCRIPTION); | |
| 2838 | 2874 |
| 2839 // WebKit annoyingly puts the title in the description if there's no other | 2875 // WebKit annoyingly puts the title in the description if there's no other |
| 2840 // description, which just confuses the rest of the logic. Put it back. | 2876 // description, which just confuses the rest of the logic. Put it back. |
| 2841 // Now "help" is always the value of the "title" attribute, if present. | 2877 // Now "help" is always the value of the "title" attribute, if present. |
| 2878 std::string title_attr; | |
| 2842 if (GetHtmlAttribute("title", &title_attr) && | 2879 if (GetHtmlAttribute("title", &title_attr) && |
| 2843 description == title_attr && | 2880 description == title_attr && |
| 2844 help.empty()) { | 2881 help.empty()) { |
| 2845 help = description; | 2882 help = description; |
| 2846 description.clear(); | 2883 description.clear(); |
| 2847 string_attributes_[AccessibilityNodeData::ATTR_DESCRIPTION].clear(); | |
| 2848 string_attributes_[AccessibilityNodeData::ATTR_HELP] = help; | |
| 2849 } | 2884 } |
| 2850 | 2885 |
| 2851 // Now implement the main logic: the descripion should become the name if | 2886 // Now implement the main logic: the descripion should become the name if |
| 2852 // it's nonempty, and the help should become the description if | 2887 // it's nonempty, and the help should become the description if |
| 2853 // there's no description - or the name if there's no name or description. | 2888 // there's no description - or the name if there's no name or description. |
| 2854 if (!description.empty()) { | 2889 if (!description.empty()) { |
| 2855 name_ = description; | 2890 name = description; |
| 2856 description.clear(); | 2891 description.clear(); |
| 2857 string_attributes_[AccessibilityNodeData::ATTR_DESCRIPTION] = description; | |
| 2858 } | 2892 } |
| 2859 if (!help.empty() && description.empty()) { | 2893 if (!help.empty() && description.empty()) { |
| 2860 description = help; | 2894 description = help; |
| 2861 string_attributes_[AccessibilityNodeData::ATTR_DESCRIPTION] = help; | 2895 help.clear(); |
| 2862 string_attributes_[AccessibilityNodeData::ATTR_HELP].clear(); | |
| 2863 } | 2896 } |
| 2864 if (!description.empty() && name_.empty() && !title_elem_id) { | 2897 if (!description.empty() && name_.empty() && !title_elem_id) { |
| 2865 name_ = description; | 2898 name = description; |
| 2866 description.clear(); | 2899 description.clear(); |
| 2867 string_attributes_[AccessibilityNodeData::ATTR_DESCRIPTION].clear(); | |
| 2868 } | 2900 } |
| 2869 | 2901 |
| 2870 // If it's a text field, also consider the placeholder. | 2902 // If it's a text field, also consider the placeholder. |
| 2871 string16 placeholder; | 2903 std::string placeholder; |
| 2872 if (role_ == AccessibilityNodeData::ROLE_TEXT_FIELD && | 2904 if (role_ == AccessibilityNodeData::ROLE_TEXT_FIELD && |
| 2873 HasState(AccessibilityNodeData::STATE_FOCUSABLE) && | 2905 HasState(AccessibilityNodeData::STATE_FOCUSABLE) && |
| 2874 GetHtmlAttribute("placeholder", &placeholder)) { | 2906 GetHtmlAttribute("placeholder", &placeholder)) { |
| 2875 if (name_.empty() && !title_elem_id) { | 2907 if (name_.empty() && !title_elem_id) { |
| 2876 name_ = placeholder; | 2908 name = placeholder; |
| 2877 } else if (description.empty()) { | 2909 } else if (description.empty()) { |
| 2878 description = placeholder; | 2910 description = placeholder; |
| 2879 string_attributes_[AccessibilityNodeData::ATTR_DESCRIPTION] = description; | |
| 2880 } | 2911 } |
| 2881 } | 2912 } |
| 2882 | 2913 |
| 2914 SetStringAttribute(AccessibilityNodeData::ATTR_NAME, name); | |
| 2915 SetStringAttribute(AccessibilityNodeData::ATTR_DESCRIPTION, description); | |
| 2916 SetStringAttribute(AccessibilityNodeData::ATTR_HELP, help); | |
| 2917 | |
| 2883 // On Windows, the value of a document should be its url. | 2918 // On Windows, the value of a document should be its url. |
| 2884 if (role_ == AccessibilityNodeData::ROLE_ROOT_WEB_AREA || | 2919 if (role_ == AccessibilityNodeData::ROLE_ROOT_WEB_AREA || |
| 2885 role_ == AccessibilityNodeData::ROLE_WEB_AREA) { | 2920 role_ == AccessibilityNodeData::ROLE_WEB_AREA) { |
| 2886 GetStringAttribute(AccessibilityNodeData::ATTR_DOC_URL, &value_); | 2921 GetString16Attribute(AccessibilityNodeData::ATTR_DOC_URL, &value_); |
| 2887 } | 2922 } |
| 2888 | 2923 |
| 2889 // For certain roles (listbox option, static text, and list marker) | 2924 // For certain roles (listbox option, static text, and list marker) |
| 2890 // WebKit stores the main accessible text in the "value" - swap it so | 2925 // WebKit stores the main accessible text in the "value" - swap it so |
| 2891 // that it's the "name". | 2926 // that it's the "name". |
| 2892 if (name_.empty() && | 2927 if (name_.empty() && |
| 2893 (role_ == AccessibilityNodeData::ROLE_LISTBOX_OPTION || | 2928 (role_ == AccessibilityNodeData::ROLE_LISTBOX_OPTION || |
| 2894 role_ == AccessibilityNodeData::ROLE_STATIC_TEXT || | 2929 role_ == AccessibilityNodeData::ROLE_STATIC_TEXT || |
| 2895 role_ == AccessibilityNodeData::ROLE_LIST_MARKER)) { | 2930 role_ == AccessibilityNodeData::ROLE_LIST_MARKER)) { |
| 2896 name_.swap(value_); | 2931 name_.swap(value_); |
| 2897 } | 2932 } |
| 2898 | 2933 |
| 2899 // If this doesn't have a value and is linked then set its value to the url | 2934 // If this doesn't have a value and is linked then set its value to the url |
| 2900 // attribute. This allows screen readers to read an empty link's destination. | 2935 // attribute. This allows screen readers to read an empty link's destination. |
| 2901 string16 url; | 2936 string16 url; |
| 2902 if (value_.empty() && (ia_state_ & STATE_SYSTEM_LINKED)) | 2937 if (value_.empty() && (ia_state_ & STATE_SYSTEM_LINKED)) |
| 2903 GetStringAttribute(AccessibilityNodeData::ATTR_URL, &value_); | 2938 GetString16Attribute(AccessibilityNodeData::ATTR_URL, &value_); |
| 2904 | 2939 |
| 2905 // Clear any old relationships between this node and other nodes. | 2940 // Clear any old relationships between this node and other nodes. |
| 2906 for (size_t i = 0; i < relations_.size(); ++i) | 2941 for (size_t i = 0; i < relations_.size(); ++i) |
| 2907 relations_[i]->Release(); | 2942 relations_[i]->Release(); |
| 2908 relations_.clear(); | 2943 relations_.clear(); |
| 2909 | 2944 |
| 2910 // Handle title UI element. | 2945 // Handle title UI element. |
| 2911 if (title_elem_id) { | 2946 if (title_elem_id) { |
| 2912 // Add a labelled by relationship. | 2947 // Add a labelled by relationship. |
| 2913 CComObject<BrowserAccessibilityRelation>* relation; | 2948 CComObject<BrowserAccessibilityRelation>* relation; |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 2924 void BrowserAccessibilityWin::PostInitialize() { | 2959 void BrowserAccessibilityWin::PostInitialize() { |
| 2925 BrowserAccessibility::PostInitialize(); | 2960 BrowserAccessibility::PostInitialize(); |
| 2926 | 2961 |
| 2927 // Construct the hypertext for this node. | 2962 // Construct the hypertext for this node. |
| 2928 hyperlink_offset_to_index_.clear(); | 2963 hyperlink_offset_to_index_.clear(); |
| 2929 hyperlinks_.clear(); | 2964 hyperlinks_.clear(); |
| 2930 hypertext_.clear(); | 2965 hypertext_.clear(); |
| 2931 for (unsigned int i = 0; i < children().size(); ++i) { | 2966 for (unsigned int i = 0; i < children().size(); ++i) { |
| 2932 BrowserAccessibility* child = children()[i]; | 2967 BrowserAccessibility* child = children()[i]; |
| 2933 if (child->role() == AccessibilityNodeData::ROLE_STATIC_TEXT) { | 2968 if (child->role() == AccessibilityNodeData::ROLE_STATIC_TEXT) { |
| 2934 hypertext_ += child->name(); | 2969 hypertext_ += |
| 2970 child->GetString16Attribute(AccessibilityNodeData::ATTR_NAME); | |
| 2935 } else { | 2971 } else { |
| 2936 hyperlink_offset_to_index_[hypertext_.size()] = hyperlinks_.size(); | 2972 hyperlink_offset_to_index_[hypertext_.size()] = hyperlinks_.size(); |
| 2937 hypertext_ += kEmbeddedCharacter; | 2973 hypertext_ += kEmbeddedCharacter; |
| 2938 hyperlinks_.push_back(i); | 2974 hyperlinks_.push_back(i); |
| 2939 } | 2975 } |
| 2940 } | 2976 } |
| 2941 DCHECK_EQ(hyperlink_offset_to_index_.size(), hyperlinks_.size()); | 2977 DCHECK_EQ(hyperlink_offset_to_index_.size(), hyperlinks_.size()); |
| 2942 | 2978 |
| 2943 // Fire an event when an alert first appears. | 2979 // Fire an event when an alert first appears. |
| 2944 if (role_ == AccessibilityNodeData::ROLE_ALERT && first_time_) | 2980 if (role_ == AccessibilityNodeData::ROLE_ALERT && first_time_) |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3028 | 3064 |
| 3029 return manager_->ToBrowserAccessibilityManagerWin()-> | 3065 return manager_->ToBrowserAccessibilityManagerWin()-> |
| 3030 GetFromUniqueIdWin(child_id); | 3066 GetFromUniqueIdWin(child_id); |
| 3031 } | 3067 } |
| 3032 | 3068 |
| 3033 HRESULT BrowserAccessibilityWin::GetStringAttributeAsBstr( | 3069 HRESULT BrowserAccessibilityWin::GetStringAttributeAsBstr( |
| 3034 AccessibilityNodeData::StringAttribute attribute, | 3070 AccessibilityNodeData::StringAttribute attribute, |
| 3035 BSTR* value_bstr) { | 3071 BSTR* value_bstr) { |
| 3036 string16 str; | 3072 string16 str; |
| 3037 | 3073 |
| 3038 if (!GetStringAttribute(attribute, &str)) | 3074 if (!GetString16Attribute(attribute, &str)) |
| 3039 return S_FALSE; | 3075 return S_FALSE; |
| 3040 | 3076 |
| 3041 if (str.empty()) | 3077 if (str.empty()) |
| 3042 return S_FALSE; | 3078 return S_FALSE; |
| 3043 | 3079 |
| 3044 *value_bstr = SysAllocString(str.c_str()); | 3080 *value_bstr = SysAllocString(str.c_str()); |
| 3045 DCHECK(*value_bstr); | 3081 DCHECK(*value_bstr); |
| 3046 | 3082 |
| 3047 return S_OK; | 3083 return S_OK; |
| 3048 } | 3084 } |
| 3049 | 3085 |
| 3050 void BrowserAccessibilityWin::StringAttributeToIA2( | 3086 void BrowserAccessibilityWin::StringAttributeToIA2( |
| 3051 AccessibilityNodeData::StringAttribute attribute, | 3087 AccessibilityNodeData::StringAttribute attribute, |
| 3052 const char* ia2_attr) { | 3088 const char* ia2_attr) { |
| 3053 string16 value; | 3089 string16 value; |
| 3054 if (GetStringAttribute(attribute, &value)) | 3090 if (GetString16Attribute(attribute, &value)) |
| 3055 ia2_attributes_.push_back(ASCIIToUTF16(ia2_attr) + L":" + value); | 3091 ia2_attributes_.push_back(ASCIIToUTF16(ia2_attr) + L":" + value); |
| 3056 } | 3092 } |
| 3057 | 3093 |
| 3058 void BrowserAccessibilityWin::BoolAttributeToIA2( | 3094 void BrowserAccessibilityWin::BoolAttributeToIA2( |
| 3059 AccessibilityNodeData::BoolAttribute attribute, | 3095 AccessibilityNodeData::BoolAttribute attribute, |
| 3060 const char* ia2_attr) { | 3096 const char* ia2_attr) { |
| 3061 bool value; | 3097 bool value; |
| 3062 if (GetBoolAttribute(attribute, &value)) { | 3098 if (GetBoolAttribute(attribute, &value)) { |
| 3063 ia2_attributes_.push_back((ASCIIToUTF16(ia2_attr) + L":") + | 3099 ia2_attributes_.push_back((ASCIIToUTF16(ia2_attr) + L":") + |
| 3064 (value ? L"true" : L"false")); | 3100 (value ? L"true" : L"false")); |
| 3065 } | 3101 } |
| 3066 } | 3102 } |
| 3067 | 3103 |
| 3068 void BrowserAccessibilityWin::IntAttributeToIA2( | 3104 void BrowserAccessibilityWin::IntAttributeToIA2( |
| 3069 AccessibilityNodeData::IntAttribute attribute, | 3105 AccessibilityNodeData::IntAttribute attribute, |
| 3070 const char* ia2_attr) { | 3106 const char* ia2_attr) { |
| 3071 int value; | 3107 int value; |
| 3072 if (GetIntAttribute(attribute, &value)) | 3108 if (GetIntAttribute(attribute, &value)) { |
| 3073 ia2_attributes_.push_back(ASCIIToUTF16(ia2_attr) + L":" + | 3109 ia2_attributes_.push_back(ASCIIToUTF16(ia2_attr) + L":" + |
| 3074 base::IntToString16(value)); | 3110 base::IntToString16(value)); |
| 3111 } | |
| 3075 } | 3112 } |
| 3076 | 3113 |
| 3077 const string16& BrowserAccessibilityWin::TextForIAccessibleText() { | 3114 string16 BrowserAccessibilityWin::GetValueText() { |
| 3115 float fval; | |
| 3116 string16 value = GetString16Attribute(AccessibilityNodeData::ATTR_VALUE); | |
| 3117 if (value.empty() && | |
| 3118 GetFloatAttribute(AccessibilityNodeData::ATTR_VALUE_FOR_RANGE, &fval)) { | |
| 3119 value = UTF8ToUTF16(base::DoubleToString(fval)); | |
| 3120 } | |
| 3121 return value; | |
| 3122 } | |
| 3123 | |
| 3124 string16 BrowserAccessibilityWin::TextForIAccessibleText() { | |
| 3125 string16 name = GetString16Attribute(AccessibilityNodeData::ATTR_NAME); | |
| 3126 string16 value = GetString16Attribute(AccessibilityNodeData::ATTR_VALUE); | |
| 3078 if (IsEditableText()) | 3127 if (IsEditableText()) |
| 3079 return value_; | 3128 return value; |
| 3080 return (role_ == AccessibilityNodeData::ROLE_STATIC_TEXT) ? | 3129 return (role_ == AccessibilityNodeData::ROLE_STATIC_TEXT) ? |
| 3081 name_ : hypertext_; | 3130 name : hypertext_; |
| 3082 } | 3131 } |
| 3083 | 3132 |
| 3084 void BrowserAccessibilityWin::HandleSpecialTextOffset(const string16& text, | 3133 void BrowserAccessibilityWin::HandleSpecialTextOffset(const string16& text, |
| 3085 LONG* offset) { | 3134 LONG* offset) { |
| 3086 if (*offset == IA2_TEXT_OFFSET_LENGTH) | 3135 if (*offset == IA2_TEXT_OFFSET_LENGTH) |
| 3087 *offset = static_cast<LONG>(text.size()); | 3136 *offset = static_cast<LONG>(text.size()); |
| 3088 else if (*offset == IA2_TEXT_OFFSET_CARET) | 3137 else if (*offset == IA2_TEXT_OFFSET_CARET) |
| 3089 get_caretOffset(offset); | 3138 get_caretOffset(offset); |
| 3090 } | 3139 } |
| 3091 | 3140 |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 3104 } | 3153 } |
| 3105 } | 3154 } |
| 3106 | 3155 |
| 3107 LONG BrowserAccessibilityWin::FindBoundary( | 3156 LONG BrowserAccessibilityWin::FindBoundary( |
| 3108 const string16& text, | 3157 const string16& text, |
| 3109 IA2TextBoundaryType ia2_boundary, | 3158 IA2TextBoundaryType ia2_boundary, |
| 3110 LONG start_offset, | 3159 LONG start_offset, |
| 3111 ui::TextBoundaryDirection direction) { | 3160 ui::TextBoundaryDirection direction) { |
| 3112 HandleSpecialTextOffset(text, &start_offset); | 3161 HandleSpecialTextOffset(text, &start_offset); |
| 3113 ui::TextBoundaryType boundary = IA2TextBoundaryToTextBoundary(ia2_boundary); | 3162 ui::TextBoundaryType boundary = IA2TextBoundaryToTextBoundary(ia2_boundary); |
| 3163 const std::vector<int32>& line_breaks = GetIntListAttribute( | |
| 3164 AccessibilityNodeData::ATTR_LINE_BREAKS); | |
| 3114 return ui::FindAccessibleTextBoundary( | 3165 return ui::FindAccessibleTextBoundary( |
| 3115 text, line_breaks_, boundary, start_offset, direction); | 3166 text, line_breaks, boundary, start_offset, direction); |
| 3116 } | 3167 } |
| 3117 | 3168 |
| 3118 BrowserAccessibilityWin* BrowserAccessibilityWin::GetFromRendererID( | 3169 BrowserAccessibilityWin* BrowserAccessibilityWin::GetFromRendererID( |
| 3119 int32 renderer_id) { | 3170 int32 renderer_id) { |
| 3120 return manager_->GetFromRendererID(renderer_id)->ToBrowserAccessibilityWin(); | 3171 return manager_->GetFromRendererID(renderer_id)->ToBrowserAccessibilityWin(); |
| 3121 } | 3172 } |
| 3122 | 3173 |
| 3123 void BrowserAccessibilityWin::InitRoleAndState() { | 3174 void BrowserAccessibilityWin::InitRoleAndState() { |
| 3124 ia_state_ = 0; | 3175 ia_state_ = 0; |
| 3125 ia2_state_ = IA2_STATE_OPAQUE; | 3176 ia2_state_ = IA2_STATE_OPAQUE; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3177 // WebKit marks everything as readonly unless it's editable text, so if it's | 3228 // WebKit marks everything as readonly unless it's editable text, so if it's |
| 3178 // not readonly, mark it as editable now. The final computation of the | 3229 // not readonly, mark it as editable now. The final computation of the |
| 3179 // READONLY state for MSAA is below, after the switch. | 3230 // READONLY state for MSAA is below, after the switch. |
| 3180 if (!HasState(AccessibilityNodeData::STATE_READONLY)) | 3231 if (!HasState(AccessibilityNodeData::STATE_READONLY)) |
| 3181 ia2_state_ |= IA2_STATE_EDITABLE; | 3232 ia2_state_ |= IA2_STATE_EDITABLE; |
| 3182 | 3233 |
| 3183 string16 invalid; | 3234 string16 invalid; |
| 3184 if (GetHtmlAttribute("aria-invalid", &invalid)) | 3235 if (GetHtmlAttribute("aria-invalid", &invalid)) |
| 3185 ia2_state_ |= IA2_STATE_INVALID_ENTRY; | 3236 ia2_state_ |= IA2_STATE_INVALID_ENTRY; |
| 3186 | 3237 |
| 3187 bool mixed = false; | 3238 if (GetBoolAttribute(AccessibilityNodeData::ATTR_BUTTON_MIXED)) |
| 3188 GetBoolAttribute(AccessibilityNodeData::ATTR_BUTTON_MIXED, &mixed); | |
| 3189 if (mixed) | |
| 3190 ia_state_ |= STATE_SYSTEM_MIXED; | 3239 ia_state_ |= STATE_SYSTEM_MIXED; |
| 3191 | 3240 |
| 3192 bool editable = false; | 3241 if (GetBoolAttribute(AccessibilityNodeData::ATTR_CAN_SET_VALUE)) |
| 3193 GetBoolAttribute(AccessibilityNodeData::ATTR_CAN_SET_VALUE, &editable); | |
| 3194 if (editable) | |
| 3195 ia2_state_ |= IA2_STATE_EDITABLE; | 3242 ia2_state_ |= IA2_STATE_EDITABLE; |
| 3196 | 3243 |
| 3197 string16 html_tag; | 3244 string16 html_tag = GetString16Attribute( |
|
aboxhall
2013/08/07 17:16:09
Nit: fits in 80 chars
dmazzoni
2013/08/07 17:48:18
81 according to my editor
aboxhall
2013/08/07 20:22:05
Oops, left out the indent :) (And below.)
| |
| 3198 GetStringAttribute(AccessibilityNodeData::ATTR_HTML_TAG, &html_tag); | 3245 AccessibilityNodeData::ATTR_HTML_TAG); |
| 3199 ia_role_ = 0; | 3246 ia_role_ = 0; |
| 3200 ia2_role_ = 0; | 3247 ia2_role_ = 0; |
| 3201 switch (role_) { | 3248 switch (role_) { |
| 3202 case AccessibilityNodeData::ROLE_ALERT: | 3249 case AccessibilityNodeData::ROLE_ALERT: |
| 3203 ia_role_ = ROLE_SYSTEM_ALERT; | 3250 ia_role_ = ROLE_SYSTEM_ALERT; |
| 3204 break; | 3251 break; |
| 3205 case AccessibilityNodeData::ROLE_ALERT_DIALOG: | 3252 case AccessibilityNodeData::ROLE_ALERT_DIALOG: |
| 3206 ia_role_ = ROLE_SYSTEM_DIALOG; | 3253 ia_role_ = ROLE_SYSTEM_DIALOG; |
| 3207 break; | 3254 break; |
| 3208 case AccessibilityNodeData::ROLE_APPLICATION: | 3255 case AccessibilityNodeData::ROLE_APPLICATION: |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3300 break; | 3347 break; |
| 3301 case AccessibilityNodeData::ROLE_FOOTER: | 3348 case AccessibilityNodeData::ROLE_FOOTER: |
| 3302 ia_role_ = IA2_ROLE_FOOTER; | 3349 ia_role_ = IA2_ROLE_FOOTER; |
| 3303 ia_state_ |= STATE_SYSTEM_READONLY; | 3350 ia_state_ |= STATE_SYSTEM_READONLY; |
| 3304 break; | 3351 break; |
| 3305 case AccessibilityNodeData::ROLE_GRID: | 3352 case AccessibilityNodeData::ROLE_GRID: |
| 3306 ia_role_ = ROLE_SYSTEM_TABLE; | 3353 ia_role_ = ROLE_SYSTEM_TABLE; |
| 3307 ia_state_ |= STATE_SYSTEM_READONLY; | 3354 ia_state_ |= STATE_SYSTEM_READONLY; |
| 3308 break; | 3355 break; |
| 3309 case AccessibilityNodeData::ROLE_GROUP: { | 3356 case AccessibilityNodeData::ROLE_GROUP: { |
| 3310 string16 aria_role; | 3357 string16 aria_role = GetString16Attribute( |
|
aboxhall
2013/08/07 17:16:09
Does this work? You're passing in &aria_role at th
dmazzoni
2013/08/07 17:48:18
You're right, this was totally wrong.
| |
| 3311 GetStringAttribute(AccessibilityNodeData::ATTR_ROLE, &aria_role); | 3358 AccessibilityNodeData::ATTR_ROLE, &aria_role); |
| 3312 if (aria_role == L"group" || html_tag == L"fieldset") { | 3359 if (aria_role == L"group" || html_tag == L"fieldset") { |
| 3313 ia_role_ = ROLE_SYSTEM_GROUPING; | 3360 ia_role_ = ROLE_SYSTEM_GROUPING; |
| 3314 } else if (html_tag == L"li") { | 3361 } else if (html_tag == L"li") { |
| 3315 ia_role_ = ROLE_SYSTEM_LISTITEM; | 3362 ia_role_ = ROLE_SYSTEM_LISTITEM; |
| 3316 } else { | 3363 } else { |
| 3317 if (html_tag.empty()) | 3364 if (html_tag.empty()) |
| 3318 role_name_ = L"div"; | 3365 role_name_ = L"div"; |
| 3319 else | 3366 else |
| 3320 role_name_ = html_tag; | 3367 role_name_ = html_tag; |
| 3321 ia2_role_ = IA2_ROLE_SECTION; | 3368 ia2_role_ = IA2_ROLE_SECTION; |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3500 case AccessibilityNodeData::ROLE_SPLITTER: | 3547 case AccessibilityNodeData::ROLE_SPLITTER: |
| 3501 ia_role_ = ROLE_SYSTEM_SEPARATOR; | 3548 ia_role_ = ROLE_SYSTEM_SEPARATOR; |
| 3502 break; | 3549 break; |
| 3503 case AccessibilityNodeData::ROLE_SVG_ROOT: | 3550 case AccessibilityNodeData::ROLE_SVG_ROOT: |
| 3504 ia_role_ = ROLE_SYSTEM_GRAPHIC; | 3551 ia_role_ = ROLE_SYSTEM_GRAPHIC; |
| 3505 break; | 3552 break; |
| 3506 case AccessibilityNodeData::ROLE_TAB: | 3553 case AccessibilityNodeData::ROLE_TAB: |
| 3507 ia_role_ = ROLE_SYSTEM_PAGETAB; | 3554 ia_role_ = ROLE_SYSTEM_PAGETAB; |
| 3508 break; | 3555 break; |
| 3509 case AccessibilityNodeData::ROLE_TABLE: { | 3556 case AccessibilityNodeData::ROLE_TABLE: { |
| 3510 string16 aria_role; | 3557 string16 aria_role = GetString16Attribute( |
|
aboxhall
2013/08/07 17:16:09
Nit: fits in 80 chars.
| |
| 3511 GetStringAttribute(AccessibilityNodeData::ATTR_ROLE, &aria_role); | 3558 AccessibilityNodeData::ATTR_ROLE); |
| 3512 if (aria_role == L"treegrid") { | 3559 if (aria_role == L"treegrid") { |
| 3513 ia_role_ = ROLE_SYSTEM_OUTLINE; | 3560 ia_role_ = ROLE_SYSTEM_OUTLINE; |
| 3514 } else { | 3561 } else { |
| 3515 ia_role_ = ROLE_SYSTEM_TABLE; | 3562 ia_role_ = ROLE_SYSTEM_TABLE; |
| 3516 ia_state_ |= STATE_SYSTEM_READONLY; | 3563 ia_state_ |= STATE_SYSTEM_READONLY; |
| 3517 } | 3564 } |
| 3518 break; | 3565 break; |
| 3519 } | 3566 } |
| 3520 case AccessibilityNodeData::ROLE_TABLE_HEADER_CONTAINER: | 3567 case AccessibilityNodeData::ROLE_TABLE_HEADER_CONTAINER: |
| 3521 ia_role_ = ROLE_SYSTEM_GROUPING; | 3568 ia_role_ = ROLE_SYSTEM_GROUPING; |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3602 // We always set the READONLY state for elements that have the | 3649 // We always set the READONLY state for elements that have the |
| 3603 // aria-readonly attribute and for a few roles (in the switch above). | 3650 // aria-readonly attribute and for a few roles (in the switch above). |
| 3604 // We clear the READONLY state on focusable controls and on a document. | 3651 // We clear the READONLY state on focusable controls and on a document. |
| 3605 // Everything else, the majority of objects, do not have this state set. | 3652 // Everything else, the majority of objects, do not have this state set. |
| 3606 if (HasState(AccessibilityNodeData::STATE_FOCUSABLE) && | 3653 if (HasState(AccessibilityNodeData::STATE_FOCUSABLE) && |
| 3607 ia_role_ != ROLE_SYSTEM_DOCUMENT) { | 3654 ia_role_ != ROLE_SYSTEM_DOCUMENT) { |
| 3608 ia_state_ &= ~(STATE_SYSTEM_READONLY); | 3655 ia_state_ &= ~(STATE_SYSTEM_READONLY); |
| 3609 } | 3656 } |
| 3610 if (!HasState(AccessibilityNodeData::STATE_READONLY)) | 3657 if (!HasState(AccessibilityNodeData::STATE_READONLY)) |
| 3611 ia_state_ &= ~(STATE_SYSTEM_READONLY); | 3658 ia_state_ &= ~(STATE_SYSTEM_READONLY); |
| 3612 bool aria_readonly = false; | 3659 if (GetBoolAttribute(AccessibilityNodeData::ATTR_ARIA_READONLY)) |
| 3613 GetBoolAttribute(AccessibilityNodeData::ATTR_ARIA_READONLY, &aria_readonly); | |
| 3614 if (aria_readonly) | |
| 3615 ia_state_ |= STATE_SYSTEM_READONLY; | 3660 ia_state_ |= STATE_SYSTEM_READONLY; |
| 3616 | 3661 |
| 3617 // The role should always be set. | 3662 // The role should always be set. |
| 3618 DCHECK(!role_name_.empty() || ia_role_); | 3663 DCHECK(!role_name_.empty() || ia_role_); |
| 3619 | 3664 |
| 3620 // If we didn't explicitly set the IAccessible2 role, make it the same | 3665 // If we didn't explicitly set the IAccessible2 role, make it the same |
| 3621 // as the MSAA role. | 3666 // as the MSAA role. |
| 3622 if (!ia2_role_) | 3667 if (!ia2_role_) |
| 3623 ia2_role_ = ia_role_; | 3668 ia2_role_ = ia_role_; |
| 3624 } | 3669 } |
| 3625 | 3670 |
| 3626 } // namespace content | 3671 } // namespace content |
| OLD | NEW |