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