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; |
| 461 target->GetStringAttribute(AccessibilityNodeData::ATTR_NAME, &name_str); | |
| 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) { |
|
aboxhall
2013/08/07 17:16:09
Does this block belong in GetValueText() as well?
dmazzoni
2013/08/07 17:48:18
Possibly, but that would be a change in functional
| |
| 572 int r, g, b; | |
| 573 GetIntAttribute(AccessibilityNodeData::ATTR_COLOR_VALUE_RED, &r); | |
| 574 GetIntAttribute(AccessibilityNodeData::ATTR_COLOR_VALUE_GREEN, &g); | |
| 575 GetIntAttribute(AccessibilityNodeData::ATTR_COLOR_VALUE_BLUE, &b); | |
| 576 string16 value_text; | |
| 577 value_text = base::IntToString16((r * 100) / 255) + L"% red " + | |
| 578 base::IntToString16((g * 100) / 255) + L"% green " + | |
| 579 base::IntToString16((b * 100) / 255) + L"% blue"; | |
| 580 *value = SysAllocString(value_text.c_str()); | |
| 581 DCHECK(*value); | |
| 582 return S_OK; | |
| 583 } | |
| 584 | |
| 585 return target->GetStringAttributeAsBstr( | |
| 586 AccessibilityNodeData::ATTR_VALUE, value); | |
| 564 } | 587 } |
| 565 | 588 |
| 566 STDMETHODIMP BrowserAccessibilityWin::get_accHelpTopic(BSTR* help_file, | 589 STDMETHODIMP BrowserAccessibilityWin::get_accHelpTopic(BSTR* help_file, |
| 567 VARIANT var_id, | 590 VARIANT var_id, |
| 568 LONG* topic_id) { | 591 LONG* topic_id) { |
| 569 return E_NOTIMPL; | 592 return E_NOTIMPL; |
| 570 } | 593 } |
| 571 | 594 |
| 572 STDMETHODIMP BrowserAccessibilityWin::get_accSelection(VARIANT* selected) { | 595 STDMETHODIMP BrowserAccessibilityWin::get_accSelection(VARIANT* selected) { |
| 573 if (!instance_active_) | 596 if (!instance_active_) |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1007 !GetIntAttribute( | 1030 !GetIntAttribute( |
| 1008 AccessibilityNodeData::ATTR_TABLE_ROW_COUNT, &rows) || | 1031 AccessibilityNodeData::ATTR_TABLE_ROW_COUNT, &rows) || |
| 1009 columns <= 0 || | 1032 columns <= 0 || |
| 1010 rows <= 0) { | 1033 rows <= 0) { |
| 1011 return S_FALSE; | 1034 return S_FALSE; |
| 1012 } | 1035 } |
| 1013 | 1036 |
| 1014 if (row < 0 || row >= rows || column < 0 || column >= columns) | 1037 if (row < 0 || row >= rows || column < 0 || column >= columns) |
| 1015 return E_INVALIDARG; | 1038 return E_INVALIDARG; |
| 1016 | 1039 |
| 1017 DCHECK_EQ(columns * rows, static_cast<int>(cell_ids_.size())); | 1040 const std::vector<int32>& cell_ids = GetIntListAttribute( |
| 1041 AccessibilityNodeData::ATTR_CELL_IDS); | |
| 1042 DCHECK_EQ(columns * rows, static_cast<int>(cell_ids.size())); | |
| 1018 | 1043 |
| 1019 int cell_id = cell_ids_[row * columns + column]; | 1044 int cell_id = cell_ids[row * columns + column]; |
| 1020 BrowserAccessibilityWin* cell = GetFromRendererID(cell_id); | 1045 BrowserAccessibilityWin* cell = GetFromRendererID(cell_id); |
| 1021 if (cell) { | 1046 if (cell) { |
| 1022 *accessible = static_cast<IAccessible*>(cell->NewReference()); | 1047 *accessible = static_cast<IAccessible*>(cell->NewReference()); |
| 1023 return S_OK; | 1048 return S_OK; |
| 1024 } | 1049 } |
| 1025 | 1050 |
| 1026 *accessible = NULL; | 1051 *accessible = NULL; |
| 1027 return E_INVALIDARG; | 1052 return E_INVALIDARG; |
| 1028 } | 1053 } |
| 1029 | 1054 |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 1054 !GetIntAttribute( | 1079 !GetIntAttribute( |
| 1055 AccessibilityNodeData::ATTR_TABLE_ROW_COUNT, &rows) || | 1080 AccessibilityNodeData::ATTR_TABLE_ROW_COUNT, &rows) || |
| 1056 columns <= 0 || | 1081 columns <= 0 || |
| 1057 rows <= 0) { | 1082 rows <= 0) { |
| 1058 return S_FALSE; | 1083 return S_FALSE; |
| 1059 } | 1084 } |
| 1060 | 1085 |
| 1061 if (row < 0 || row >= rows || column < 0 || column >= columns) | 1086 if (row < 0 || row >= rows || column < 0 || column >= columns) |
| 1062 return E_INVALIDARG; | 1087 return E_INVALIDARG; |
| 1063 | 1088 |
| 1064 DCHECK_EQ(columns * rows, static_cast<int>(cell_ids_.size())); | 1089 const std::vector<int32>& cell_ids = GetIntListAttribute( |
| 1065 int cell_id = cell_ids_[row * columns + column]; | 1090 AccessibilityNodeData::ATTR_CELL_IDS); |
| 1066 for (size_t i = 0; i < unique_cell_ids_.size(); ++i) { | 1091 const std::vector<int32>& unique_cell_ids = GetIntListAttribute( |
| 1067 if (unique_cell_ids_[i] == cell_id) { | 1092 AccessibilityNodeData::ATTR_UNIQUE_CELL_IDS); |
| 1093 DCHECK_EQ(columns * rows, static_cast<int>(cell_ids.size())); | |
| 1094 int cell_id = cell_ids[row * columns + column]; | |
| 1095 for (size_t i = 0; i < unique_cell_ids.size(); ++i) { | |
| 1096 if (unique_cell_ids[i] == cell_id) { | |
| 1068 *cell_index = (long)i; | 1097 *cell_index = (long)i; |
| 1069 return S_OK; | 1098 return S_OK; |
| 1070 } | 1099 } |
| 1071 } | 1100 } |
| 1072 | 1101 |
| 1073 return S_FALSE; | 1102 return S_FALSE; |
| 1074 } | 1103 } |
| 1075 | 1104 |
| 1076 STDMETHODIMP BrowserAccessibilityWin::get_columnDescription(long column, | 1105 STDMETHODIMP BrowserAccessibilityWin::get_columnDescription(long column, |
| 1077 BSTR* description) { | 1106 BSTR* description) { |
| 1078 if (!instance_active_) | 1107 if (!instance_active_) |
| 1079 return E_FAIL; | 1108 return E_FAIL; |
| 1080 | 1109 |
| 1081 if (!description) | 1110 if (!description) |
| 1082 return E_INVALIDARG; | 1111 return E_INVALIDARG; |
| 1083 | 1112 |
| 1084 int columns; | 1113 int columns; |
| 1085 int rows; | 1114 int rows; |
| 1086 if (!GetIntAttribute( | 1115 if (!GetIntAttribute( |
| 1087 AccessibilityNodeData::ATTR_TABLE_COLUMN_COUNT, &columns) || | 1116 AccessibilityNodeData::ATTR_TABLE_COLUMN_COUNT, &columns) || |
| 1088 !GetIntAttribute(AccessibilityNodeData::ATTR_TABLE_ROW_COUNT, &rows) || | 1117 !GetIntAttribute(AccessibilityNodeData::ATTR_TABLE_ROW_COUNT, &rows) || |
| 1089 columns <= 0 || | 1118 columns <= 0 || |
| 1090 rows <= 0) { | 1119 rows <= 0) { |
| 1091 return S_FALSE; | 1120 return S_FALSE; |
| 1092 } | 1121 } |
| 1093 | 1122 |
| 1094 if (column < 0 || column >= columns) | 1123 if (column < 0 || column >= columns) |
| 1095 return E_INVALIDARG; | 1124 return E_INVALIDARG; |
| 1096 | 1125 |
| 1126 const std::vector<int32>& cell_ids = GetIntListAttribute( | |
| 1127 AccessibilityNodeData::ATTR_CELL_IDS); | |
| 1097 for (int i = 0; i < rows; ++i) { | 1128 for (int i = 0; i < rows; ++i) { |
| 1098 int cell_id = cell_ids_[i * columns + column]; | 1129 int cell_id = cell_ids[i * columns + column]; |
| 1099 BrowserAccessibilityWin* cell = static_cast<BrowserAccessibilityWin*>( | 1130 BrowserAccessibilityWin* cell = static_cast<BrowserAccessibilityWin*>( |
| 1100 manager_->GetFromRendererID(cell_id)); | 1131 manager_->GetFromRendererID(cell_id)); |
| 1101 if (cell && cell->role_ == AccessibilityNodeData::ROLE_COLUMN_HEADER) { | 1132 if (cell && cell->role_ == AccessibilityNodeData::ROLE_COLUMN_HEADER) { |
| 1102 if (cell->name_.size() > 0) { | 1133 string16 cell_name; |
| 1103 *description = SysAllocString(cell->name_.c_str()); | 1134 cell->GetStringAttribute(AccessibilityNodeData::ATTR_NAME, &cell_name); |
| 1135 if (cell_name.size() > 0) { | |
| 1136 *description = SysAllocString(cell_name.c_str()); | |
| 1104 return S_OK; | 1137 return S_OK; |
| 1105 } | 1138 } |
| 1106 | 1139 |
| 1107 return cell->GetStringAttributeAsBstr( | 1140 return cell->GetStringAttributeAsBstr( |
| 1108 AccessibilityNodeData::ATTR_DESCRIPTION, description); | 1141 AccessibilityNodeData::ATTR_DESCRIPTION, description); |
| 1109 } | 1142 } |
| 1110 } | 1143 } |
| 1111 | 1144 |
| 1112 return S_FALSE; | 1145 return S_FALSE; |
| 1113 } | 1146 } |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 1128 AccessibilityNodeData::ATTR_TABLE_COLUMN_COUNT, &columns) || | 1161 AccessibilityNodeData::ATTR_TABLE_COLUMN_COUNT, &columns) || |
| 1129 !GetIntAttribute(AccessibilityNodeData::ATTR_TABLE_ROW_COUNT, &rows) || | 1162 !GetIntAttribute(AccessibilityNodeData::ATTR_TABLE_ROW_COUNT, &rows) || |
| 1130 columns <= 0 || | 1163 columns <= 0 || |
| 1131 rows <= 0) { | 1164 rows <= 0) { |
| 1132 return S_FALSE; | 1165 return S_FALSE; |
| 1133 } | 1166 } |
| 1134 | 1167 |
| 1135 if (row < 0 || row >= rows || column < 0 || column >= columns) | 1168 if (row < 0 || row >= rows || column < 0 || column >= columns) |
| 1136 return E_INVALIDARG; | 1169 return E_INVALIDARG; |
| 1137 | 1170 |
| 1138 int cell_id = cell_ids_[row * columns + column]; | 1171 const std::vector<int32>& cell_ids = GetIntListAttribute( |
| 1172 AccessibilityNodeData::ATTR_CELL_IDS); | |
| 1173 int cell_id = cell_ids[row * columns + column]; | |
| 1139 BrowserAccessibilityWin* cell = static_cast<BrowserAccessibilityWin*>( | 1174 BrowserAccessibilityWin* cell = static_cast<BrowserAccessibilityWin*>( |
| 1140 manager_->GetFromRendererID(cell_id)); | 1175 manager_->GetFromRendererID(cell_id)); |
| 1141 int colspan; | 1176 int colspan; |
| 1142 if (cell && | 1177 if (cell && |
| 1143 cell->GetIntAttribute( | 1178 cell->GetIntAttribute( |
| 1144 AccessibilityNodeData::ATTR_TABLE_CELL_COLUMN_SPAN, &colspan) && | 1179 AccessibilityNodeData::ATTR_TABLE_CELL_COLUMN_SPAN, &colspan) && |
| 1145 colspan >= 1) { | 1180 colspan >= 1) { |
| 1146 *n_columns_spanned = colspan; | 1181 *n_columns_spanned = colspan; |
| 1147 return S_OK; | 1182 return S_OK; |
| 1148 } | 1183 } |
| 1149 | 1184 |
| 1150 return S_FALSE; | 1185 return S_FALSE; |
| 1151 } | 1186 } |
| 1152 | 1187 |
| 1153 STDMETHODIMP BrowserAccessibilityWin::get_columnHeader( | 1188 STDMETHODIMP BrowserAccessibilityWin::get_columnHeader( |
| 1154 IAccessibleTable** accessible_table, | 1189 IAccessibleTable** accessible_table, |
| 1155 long* starting_row_index) { | 1190 long* starting_row_index) { |
| 1156 // TODO(dmazzoni): implement | 1191 // TODO(dmazzoni): implement |
| 1157 return E_NOTIMPL; | 1192 return E_NOTIMPL; |
| 1158 } | 1193 } |
| 1159 | 1194 |
| 1160 STDMETHODIMP BrowserAccessibilityWin::get_columnIndex(long cell_index, | 1195 STDMETHODIMP BrowserAccessibilityWin::get_columnIndex(long cell_index, |
| 1161 long* column_index) { | 1196 long* column_index) { |
| 1162 if (!instance_active_) | 1197 if (!instance_active_) |
| 1163 return E_FAIL; | 1198 return E_FAIL; |
| 1164 | 1199 |
| 1165 if (!column_index) | 1200 if (!column_index) |
| 1166 return E_INVALIDARG; | 1201 return E_INVALIDARG; |
| 1167 | 1202 |
| 1168 int cell_id_count = static_cast<int>(unique_cell_ids_.size()); | 1203 const std::vector<int32>& unique_cell_ids = GetIntListAttribute( |
| 1204 AccessibilityNodeData::ATTR_UNIQUE_CELL_IDS); | |
| 1205 int cell_id_count = static_cast<int>(unique_cell_ids.size()); | |
| 1169 if (cell_index < 0) | 1206 if (cell_index < 0) |
| 1170 return E_INVALIDARG; | 1207 return E_INVALIDARG; |
| 1171 if (cell_index >= cell_id_count) | 1208 if (cell_index >= cell_id_count) |
| 1172 return S_FALSE; | 1209 return S_FALSE; |
| 1173 | 1210 |
| 1174 int cell_id = unique_cell_ids_[cell_index]; | 1211 int cell_id = unique_cell_ids[cell_index]; |
| 1175 BrowserAccessibilityWin* cell = | 1212 BrowserAccessibilityWin* cell = |
| 1176 manager_->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin(); | 1213 manager_->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin(); |
| 1177 int col_index; | 1214 int col_index; |
| 1178 if (cell && | 1215 if (cell && |
| 1179 cell->GetIntAttribute( | 1216 cell->GetIntAttribute( |
| 1180 AccessibilityNodeData::ATTR_TABLE_CELL_COLUMN_INDEX, &col_index)) { | 1217 AccessibilityNodeData::ATTR_TABLE_CELL_COLUMN_INDEX, &col_index)) { |
| 1181 *column_index = col_index; | 1218 *column_index = col_index; |
| 1182 return S_OK; | 1219 return S_OK; |
| 1183 } | 1220 } |
| 1184 | 1221 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1266 AccessibilityNodeData::ATTR_TABLE_COLUMN_COUNT, &columns) || | 1303 AccessibilityNodeData::ATTR_TABLE_COLUMN_COUNT, &columns) || |
| 1267 !GetIntAttribute(AccessibilityNodeData::ATTR_TABLE_ROW_COUNT, &rows) || | 1304 !GetIntAttribute(AccessibilityNodeData::ATTR_TABLE_ROW_COUNT, &rows) || |
| 1268 columns <= 0 || | 1305 columns <= 0 || |
| 1269 rows <= 0) { | 1306 rows <= 0) { |
| 1270 return S_FALSE; | 1307 return S_FALSE; |
| 1271 } | 1308 } |
| 1272 | 1309 |
| 1273 if (row < 0 || row >= rows) | 1310 if (row < 0 || row >= rows) |
| 1274 return E_INVALIDARG; | 1311 return E_INVALIDARG; |
| 1275 | 1312 |
| 1313 const std::vector<int32>& cell_ids = GetIntListAttribute( | |
| 1314 AccessibilityNodeData::ATTR_CELL_IDS); | |
| 1276 for (int i = 0; i < columns; ++i) { | 1315 for (int i = 0; i < columns; ++i) { |
| 1277 int cell_id = cell_ids_[row * columns + i]; | 1316 int cell_id = cell_ids[row * columns + i]; |
| 1278 BrowserAccessibilityWin* cell = | 1317 BrowserAccessibilityWin* cell = |
| 1279 manager_->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin(); | 1318 manager_->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin(); |
| 1280 if (cell && cell->role_ == AccessibilityNodeData::ROLE_ROW_HEADER) { | 1319 if (cell && cell->role_ == AccessibilityNodeData::ROLE_ROW_HEADER) { |
| 1281 if (cell->name_.size() > 0) { | 1320 string16 cell_name; |
| 1282 *description = SysAllocString(cell->name_.c_str()); | 1321 cell->GetStringAttribute(AccessibilityNodeData::ATTR_NAME, &cell_name); |
| 1322 if (cell_name.size() > 0) { | |
| 1323 *description = SysAllocString(cell_name.c_str()); | |
| 1283 return S_OK; | 1324 return S_OK; |
| 1284 } | 1325 } |
| 1285 | 1326 |
| 1286 return cell->GetStringAttributeAsBstr( | 1327 return cell->GetStringAttributeAsBstr( |
| 1287 AccessibilityNodeData::ATTR_DESCRIPTION, description); | 1328 AccessibilityNodeData::ATTR_DESCRIPTION, description); |
| 1288 } | 1329 } |
| 1289 } | 1330 } |
| 1290 | 1331 |
| 1291 return S_FALSE; | 1332 return S_FALSE; |
| 1292 } | 1333 } |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 1306 AccessibilityNodeData::ATTR_TABLE_COLUMN_COUNT, &columns) || | 1347 AccessibilityNodeData::ATTR_TABLE_COLUMN_COUNT, &columns) || |
| 1307 !GetIntAttribute(AccessibilityNodeData::ATTR_TABLE_ROW_COUNT, &rows) || | 1348 !GetIntAttribute(AccessibilityNodeData::ATTR_TABLE_ROW_COUNT, &rows) || |
| 1308 columns <= 0 || | 1349 columns <= 0 || |
| 1309 rows <= 0) { | 1350 rows <= 0) { |
| 1310 return S_FALSE; | 1351 return S_FALSE; |
| 1311 } | 1352 } |
| 1312 | 1353 |
| 1313 if (row < 0 || row >= rows || column < 0 || column >= columns) | 1354 if (row < 0 || row >= rows || column < 0 || column >= columns) |
| 1314 return E_INVALIDARG; | 1355 return E_INVALIDARG; |
| 1315 | 1356 |
| 1316 int cell_id = cell_ids_[row * columns + column]; | 1357 const std::vector<int32>& cell_ids = GetIntListAttribute( |
| 1358 AccessibilityNodeData::ATTR_CELL_IDS); | |
| 1359 int cell_id = cell_ids[row * columns + column]; | |
| 1317 BrowserAccessibilityWin* cell = | 1360 BrowserAccessibilityWin* cell = |
| 1318 manager_->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin(); | 1361 manager_->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin(); |
| 1319 int rowspan; | 1362 int rowspan; |
| 1320 if (cell && | 1363 if (cell && |
| 1321 cell->GetIntAttribute( | 1364 cell->GetIntAttribute( |
| 1322 AccessibilityNodeData::ATTR_TABLE_CELL_ROW_SPAN, &rowspan) && | 1365 AccessibilityNodeData::ATTR_TABLE_CELL_ROW_SPAN, &rowspan) && |
| 1323 rowspan >= 1) { | 1366 rowspan >= 1) { |
| 1324 *n_rows_spanned = rowspan; | 1367 *n_rows_spanned = rowspan; |
| 1325 return S_OK; | 1368 return S_OK; |
| 1326 } | 1369 } |
| 1327 | 1370 |
| 1328 return S_FALSE; | 1371 return S_FALSE; |
| 1329 } | 1372 } |
| 1330 | 1373 |
| 1331 STDMETHODIMP BrowserAccessibilityWin::get_rowHeader( | 1374 STDMETHODIMP BrowserAccessibilityWin::get_rowHeader( |
| 1332 IAccessibleTable** accessible_table, | 1375 IAccessibleTable** accessible_table, |
| 1333 long* starting_column_index) { | 1376 long* starting_column_index) { |
| 1334 // TODO(dmazzoni): implement | 1377 // TODO(dmazzoni): implement |
| 1335 return E_NOTIMPL; | 1378 return E_NOTIMPL; |
| 1336 } | 1379 } |
| 1337 | 1380 |
| 1338 STDMETHODIMP BrowserAccessibilityWin::get_rowIndex(long cell_index, | 1381 STDMETHODIMP BrowserAccessibilityWin::get_rowIndex(long cell_index, |
| 1339 long* row_index) { | 1382 long* row_index) { |
| 1340 if (!instance_active_) | 1383 if (!instance_active_) |
| 1341 return E_FAIL; | 1384 return E_FAIL; |
| 1342 | 1385 |
| 1343 if (!row_index) | 1386 if (!row_index) |
| 1344 return E_INVALIDARG; | 1387 return E_INVALIDARG; |
| 1345 | 1388 |
| 1346 int cell_id_count = static_cast<int>(unique_cell_ids_.size()); | 1389 const std::vector<int32>& unique_cell_ids = GetIntListAttribute( |
| 1390 AccessibilityNodeData::ATTR_UNIQUE_CELL_IDS); | |
| 1391 int cell_id_count = static_cast<int>(unique_cell_ids.size()); | |
| 1347 if (cell_index < 0) | 1392 if (cell_index < 0) |
| 1348 return E_INVALIDARG; | 1393 return E_INVALIDARG; |
| 1349 if (cell_index >= cell_id_count) | 1394 if (cell_index >= cell_id_count) |
| 1350 return S_FALSE; | 1395 return S_FALSE; |
| 1351 | 1396 |
| 1352 int cell_id = unique_cell_ids_[cell_index]; | 1397 int cell_id = unique_cell_ids[cell_index]; |
| 1353 BrowserAccessibilityWin* cell = | 1398 BrowserAccessibilityWin* cell = |
| 1354 manager_->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin(); | 1399 manager_->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin(); |
| 1355 int cell_row_index; | 1400 int cell_row_index; |
| 1356 if (cell && | 1401 if (cell && |
| 1357 cell->GetIntAttribute( | 1402 cell->GetIntAttribute( |
| 1358 AccessibilityNodeData::ATTR_TABLE_CELL_ROW_INDEX, &cell_row_index)) { | 1403 AccessibilityNodeData::ATTR_TABLE_CELL_ROW_INDEX, &cell_row_index)) { |
| 1359 *row_index = cell_row_index; | 1404 *row_index = cell_row_index; |
| 1360 return S_OK; | 1405 return S_OK; |
| 1361 } | 1406 } |
| 1362 | 1407 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1463 long* column, | 1508 long* column, |
| 1464 long* row_extents, | 1509 long* row_extents, |
| 1465 long* column_extents, | 1510 long* column_extents, |
| 1466 boolean* is_selected) { | 1511 boolean* is_selected) { |
| 1467 if (!instance_active_) | 1512 if (!instance_active_) |
| 1468 return E_FAIL; | 1513 return E_FAIL; |
| 1469 | 1514 |
| 1470 if (!row || !column || !row_extents || !column_extents || !is_selected) | 1515 if (!row || !column || !row_extents || !column_extents || !is_selected) |
| 1471 return E_INVALIDARG; | 1516 return E_INVALIDARG; |
| 1472 | 1517 |
| 1473 int cell_id_count = static_cast<int>(unique_cell_ids_.size()); | 1518 const std::vector<int32>& unique_cell_ids = GetIntListAttribute( |
| 1519 AccessibilityNodeData::ATTR_UNIQUE_CELL_IDS); | |
| 1520 int cell_id_count = static_cast<int>(unique_cell_ids.size()); | |
| 1474 if (index < 0) | 1521 if (index < 0) |
| 1475 return E_INVALIDARG; | 1522 return E_INVALIDARG; |
| 1476 if (index >= cell_id_count) | 1523 if (index >= cell_id_count) |
| 1477 return S_FALSE; | 1524 return S_FALSE; |
| 1478 | 1525 |
| 1479 int cell_id = unique_cell_ids_[index]; | 1526 int cell_id = unique_cell_ids[index]; |
| 1480 BrowserAccessibilityWin* cell = | 1527 BrowserAccessibilityWin* cell = |
| 1481 manager_->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin(); | 1528 manager_->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin(); |
| 1482 int rowspan; | 1529 int rowspan; |
| 1483 int colspan; | 1530 int colspan; |
| 1484 if (cell && | 1531 if (cell && |
| 1485 cell->GetIntAttribute( | 1532 cell->GetIntAttribute( |
| 1486 AccessibilityNodeData::ATTR_TABLE_CELL_ROW_SPAN, &rowspan) && | 1533 AccessibilityNodeData::ATTR_TABLE_CELL_ROW_SPAN, &rowspan) && |
| 1487 cell->GetIntAttribute( | 1534 cell->GetIntAttribute( |
| 1488 AccessibilityNodeData::ATTR_TABLE_CELL_COLUMN_SPAN, &colspan) && | 1535 AccessibilityNodeData::ATTR_TABLE_CELL_COLUMN_SPAN, &colspan) && |
| 1489 rowspan >= 1 && | 1536 rowspan >= 1 && |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1603 int rows; | 1650 int rows; |
| 1604 if (!table->GetIntAttribute( | 1651 if (!table->GetIntAttribute( |
| 1605 AccessibilityNodeData::ATTR_TABLE_COLUMN_COUNT, &columns) || | 1652 AccessibilityNodeData::ATTR_TABLE_COLUMN_COUNT, &columns) || |
| 1606 !table->GetIntAttribute( | 1653 !table->GetIntAttribute( |
| 1607 AccessibilityNodeData::ATTR_TABLE_ROW_COUNT, &rows)) { | 1654 AccessibilityNodeData::ATTR_TABLE_ROW_COUNT, &rows)) { |
| 1608 return S_FALSE; | 1655 return S_FALSE; |
| 1609 } | 1656 } |
| 1610 if (columns <= 0 || rows <= 0 || column < 0 || column >= columns) | 1657 if (columns <= 0 || rows <= 0 || column < 0 || column >= columns) |
| 1611 return S_FALSE; | 1658 return S_FALSE; |
| 1612 | 1659 |
| 1660 const std::vector<int32>& cell_ids = table->GetIntListAttribute( | |
| 1661 AccessibilityNodeData::ATTR_CELL_IDS); | |
| 1662 | |
| 1613 for (int i = 0; i < rows; ++i) { | 1663 for (int i = 0; i < rows; ++i) { |
| 1614 int cell_id = table->cell_ids()[i * columns + column]; | 1664 int cell_id = cell_ids[i * columns + column]; |
| 1615 BrowserAccessibilityWin* cell = | 1665 BrowserAccessibilityWin* cell = |
| 1616 manager_->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin(); | 1666 manager_->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin(); |
| 1617 if (cell && cell->role_ == AccessibilityNodeData::ROLE_COLUMN_HEADER) | 1667 if (cell && cell->role_ == AccessibilityNodeData::ROLE_COLUMN_HEADER) |
| 1618 (*n_column_header_cells)++; | 1668 (*n_column_header_cells)++; |
| 1619 } | 1669 } |
| 1620 | 1670 |
| 1621 *cell_accessibles = static_cast<IUnknown**>(CoTaskMemAlloc( | 1671 *cell_accessibles = static_cast<IUnknown**>(CoTaskMemAlloc( |
| 1622 (*n_column_header_cells) * sizeof(cell_accessibles[0]))); | 1672 (*n_column_header_cells) * sizeof(cell_accessibles[0]))); |
| 1623 int index = 0; | 1673 int index = 0; |
| 1624 for (int i = 0; i < rows; ++i) { | 1674 for (int i = 0; i < rows; ++i) { |
| 1625 int cell_id = table->cell_ids()[i * columns + column]; | 1675 int cell_id = cell_ids[i * columns + column]; |
| 1626 BrowserAccessibilityWin* cell = | 1676 BrowserAccessibilityWin* cell = |
| 1627 manager_->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin(); | 1677 manager_->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin(); |
| 1628 if (cell && cell->role_ == AccessibilityNodeData::ROLE_COLUMN_HEADER) { | 1678 if (cell && cell->role_ == AccessibilityNodeData::ROLE_COLUMN_HEADER) { |
| 1629 (*cell_accessibles)[index] = | 1679 (*cell_accessibles)[index] = |
| 1630 static_cast<IAccessible*>(cell->NewReference()); | 1680 static_cast<IAccessible*>(cell->NewReference()); |
| 1631 ++index; | 1681 ++index; |
| 1632 } | 1682 } |
| 1633 } | 1683 } |
| 1634 | 1684 |
| 1635 return S_OK; | 1685 return S_OK; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1699 int rows; | 1749 int rows; |
| 1700 if (!table->GetIntAttribute( | 1750 if (!table->GetIntAttribute( |
| 1701 AccessibilityNodeData::ATTR_TABLE_COLUMN_COUNT, &columns) || | 1751 AccessibilityNodeData::ATTR_TABLE_COLUMN_COUNT, &columns) || |
| 1702 !table->GetIntAttribute( | 1752 !table->GetIntAttribute( |
| 1703 AccessibilityNodeData::ATTR_TABLE_ROW_COUNT, &rows)) { | 1753 AccessibilityNodeData::ATTR_TABLE_ROW_COUNT, &rows)) { |
| 1704 return S_FALSE; | 1754 return S_FALSE; |
| 1705 } | 1755 } |
| 1706 if (columns <= 0 || rows <= 0 || row < 0 || row >= rows) | 1756 if (columns <= 0 || rows <= 0 || row < 0 || row >= rows) |
| 1707 return S_FALSE; | 1757 return S_FALSE; |
| 1708 | 1758 |
| 1759 const std::vector<int32>& cell_ids = table->GetIntListAttribute( | |
| 1760 AccessibilityNodeData::ATTR_CELL_IDS); | |
| 1761 | |
| 1709 for (int i = 0; i < columns; ++i) { | 1762 for (int i = 0; i < columns; ++i) { |
| 1710 int cell_id = table->cell_ids()[row * columns + i]; | 1763 int cell_id = cell_ids[row * columns + i]; |
| 1711 BrowserAccessibilityWin* cell = | 1764 BrowserAccessibilityWin* cell = |
| 1712 manager_->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin(); | 1765 manager_->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin(); |
| 1713 if (cell && cell->role_ == AccessibilityNodeData::ROLE_ROW_HEADER) | 1766 if (cell && cell->role_ == AccessibilityNodeData::ROLE_ROW_HEADER) |
| 1714 (*n_row_header_cells)++; | 1767 (*n_row_header_cells)++; |
| 1715 } | 1768 } |
| 1716 | 1769 |
| 1717 *cell_accessibles = static_cast<IUnknown**>(CoTaskMemAlloc( | 1770 *cell_accessibles = static_cast<IUnknown**>(CoTaskMemAlloc( |
| 1718 (*n_row_header_cells) * sizeof(cell_accessibles[0]))); | 1771 (*n_row_header_cells) * sizeof(cell_accessibles[0]))); |
| 1719 int index = 0; | 1772 int index = 0; |
| 1720 for (int i = 0; i < columns; ++i) { | 1773 for (int i = 0; i < columns; ++i) { |
| 1721 int cell_id = table->cell_ids()[row * columns + i]; | 1774 int cell_id = cell_ids[row * columns + i]; |
| 1722 BrowserAccessibilityWin* cell = | 1775 BrowserAccessibilityWin* cell = |
| 1723 manager_->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin(); | 1776 manager_->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin(); |
| 1724 if (cell && cell->role_ == AccessibilityNodeData::ROLE_ROW_HEADER) { | 1777 if (cell && cell->role_ == AccessibilityNodeData::ROLE_ROW_HEADER) { |
| 1725 (*cell_accessibles)[index] = | 1778 (*cell_accessibles)[index] = |
| 1726 static_cast<IAccessible*>(cell->NewReference()); | 1779 static_cast<IAccessible*>(cell->NewReference()); |
| 1727 ++index; | 1780 ++index; |
| 1728 } | 1781 } |
| 1729 } | 1782 } |
| 1730 | 1783 |
| 1731 return S_OK; | 1784 return S_OK; |
| (...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2333 return E_INVALIDARG; | 2386 return E_INVALIDARG; |
| 2334 } | 2387 } |
| 2335 | 2388 |
| 2336 string16 tag; | 2389 string16 tag; |
| 2337 if (GetStringAttribute(AccessibilityNodeData::ATTR_HTML_TAG, &tag)) | 2390 if (GetStringAttribute(AccessibilityNodeData::ATTR_HTML_TAG, &tag)) |
| 2338 *node_name = SysAllocString(tag.c_str()); | 2391 *node_name = SysAllocString(tag.c_str()); |
| 2339 else | 2392 else |
| 2340 *node_name = NULL; | 2393 *node_name = NULL; |
| 2341 | 2394 |
| 2342 *name_space_id = 0; | 2395 *name_space_id = 0; |
| 2343 *node_value = SysAllocString(value_.c_str()); | 2396 GetStringAttributeAsBstr(AccessibilityNodeData::ATTR_VALUE, node_value); |
| 2344 *num_children = children_.size(); | 2397 *num_children = children_.size(); |
| 2345 *unique_id = unique_id_win_; | 2398 *unique_id = unique_id_win_; |
| 2346 | 2399 |
| 2347 if (ia_role_ == ROLE_SYSTEM_DOCUMENT) { | 2400 if (ia_role_ == ROLE_SYSTEM_DOCUMENT) { |
| 2348 *node_type = NODETYPE_DOCUMENT; | 2401 *node_type = NODETYPE_DOCUMENT; |
| 2349 } else if (ia_role_ == ROLE_SYSTEM_TEXT && | 2402 } else if (ia_role_ == ROLE_SYSTEM_TEXT && |
| 2350 ((ia2_state_ & IA2_STATE_EDITABLE) == 0)) { | 2403 ((ia2_state_ & IA2_STATE_EDITABLE) == 0)) { |
| 2351 *node_type = NODETYPE_TEXT; | 2404 *node_type = NODETYPE_TEXT; |
| 2352 } else { | 2405 } else { |
| 2353 *node_type = NODETYPE_ELEMENT; | 2406 *node_type = NODETYPE_ELEMENT; |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 2366 return E_FAIL; | 2419 return E_FAIL; |
| 2367 | 2420 |
| 2368 if (!attrib_names || !name_space_id || !attrib_values || !num_attribs) | 2421 if (!attrib_names || !name_space_id || !attrib_values || !num_attribs) |
| 2369 return E_INVALIDARG; | 2422 return E_INVALIDARG; |
| 2370 | 2423 |
| 2371 *num_attribs = max_attribs; | 2424 *num_attribs = max_attribs; |
| 2372 if (*num_attribs > html_attributes_.size()) | 2425 if (*num_attribs > html_attributes_.size()) |
| 2373 *num_attribs = html_attributes_.size(); | 2426 *num_attribs = html_attributes_.size(); |
| 2374 | 2427 |
| 2375 for (unsigned short i = 0; i < *num_attribs; ++i) { | 2428 for (unsigned short i = 0; i < *num_attribs; ++i) { |
| 2376 attrib_names[i] = SysAllocString(html_attributes_[i].first.c_str()); | 2429 attrib_names[i] = SysAllocString( |
| 2430 UTF8ToUTF16(html_attributes_[i].first).c_str()); | |
| 2377 name_space_id[i] = 0; | 2431 name_space_id[i] = 0; |
| 2378 attrib_values[i] = SysAllocString(html_attributes_[i].second.c_str()); | 2432 attrib_values[i] = SysAllocString( |
| 2433 UTF8ToUTF16(html_attributes_[i].second).c_str()); | |
| 2379 } | 2434 } |
| 2380 return S_OK; | 2435 return S_OK; |
| 2381 } | 2436 } |
| 2382 | 2437 |
| 2383 STDMETHODIMP BrowserAccessibilityWin::get_attributesForNames( | 2438 STDMETHODIMP BrowserAccessibilityWin::get_attributesForNames( |
| 2384 unsigned short num_attribs, | 2439 unsigned short num_attribs, |
| 2385 BSTR* attrib_names, | 2440 BSTR* attrib_names, |
| 2386 short* name_space_id, | 2441 short* name_space_id, |
| 2387 BSTR* attrib_values) { | 2442 BSTR* attrib_values) { |
| 2388 if (!instance_active_) | 2443 if (!instance_active_) |
| 2389 return E_FAIL; | 2444 return E_FAIL; |
| 2390 | 2445 |
| 2391 if (!attrib_names || !name_space_id || !attrib_values) | 2446 if (!attrib_names || !name_space_id || !attrib_values) |
| 2392 return E_INVALIDARG; | 2447 return E_INVALIDARG; |
| 2393 | 2448 |
| 2394 for (unsigned short i = 0; i < num_attribs; ++i) { | 2449 for (unsigned short i = 0; i < num_attribs; ++i) { |
| 2395 name_space_id[i] = 0; | 2450 name_space_id[i] = 0; |
| 2396 bool found = false; | 2451 bool found = false; |
| 2397 string16 name = (LPCWSTR)attrib_names[i]; | 2452 std::string name = UTF16ToUTF8((LPCWSTR)attrib_names[i]); |
| 2398 for (unsigned int j = 0; j < html_attributes_.size(); ++j) { | 2453 for (unsigned int j = 0; j < html_attributes_.size(); ++j) { |
| 2399 if (html_attributes_[j].first == name) { | 2454 if (html_attributes_[j].first == name) { |
| 2400 attrib_values[i] = SysAllocString(html_attributes_[j].second.c_str()); | 2455 attrib_values[i] = SysAllocString( |
| 2456 UTF8ToUTF16(html_attributes_[j].second).c_str()); | |
| 2401 found = true; | 2457 found = true; |
| 2402 break; | 2458 break; |
| 2403 } | 2459 } |
| 2404 } | 2460 } |
| 2405 if (!found) { | 2461 if (!found) { |
| 2406 attrib_values[i] = NULL; | 2462 attrib_values[i] = NULL; |
| 2407 } | 2463 } |
| 2408 } | 2464 } |
| 2409 return S_OK; | 2465 return S_OK; |
| 2410 } | 2466 } |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2572 // ISimpleDOMText methods. | 2628 // ISimpleDOMText methods. |
| 2573 // | 2629 // |
| 2574 | 2630 |
| 2575 STDMETHODIMP BrowserAccessibilityWin::get_domText(BSTR* dom_text) { | 2631 STDMETHODIMP BrowserAccessibilityWin::get_domText(BSTR* dom_text) { |
| 2576 if (!instance_active_) | 2632 if (!instance_active_) |
| 2577 return E_FAIL; | 2633 return E_FAIL; |
| 2578 | 2634 |
| 2579 if (!dom_text) | 2635 if (!dom_text) |
| 2580 return E_INVALIDARG; | 2636 return E_INVALIDARG; |
| 2581 | 2637 |
| 2582 if (name_.empty()) | 2638 return GetStringAttributeAsBstr( |
| 2583 return S_FALSE; | 2639 AccessibilityNodeData::ATTR_NAME, dom_text); |
| 2584 | |
| 2585 *dom_text = SysAllocString(name_.c_str()); | |
| 2586 DCHECK(*dom_text); | |
| 2587 return S_OK; | |
| 2588 } | 2640 } |
| 2589 | 2641 |
| 2590 // | 2642 // |
| 2591 // IServiceProvider methods. | 2643 // IServiceProvider methods. |
| 2592 // | 2644 // |
| 2593 | 2645 |
| 2594 STDMETHODIMP BrowserAccessibilityWin::QueryService(REFGUID guidService, | 2646 STDMETHODIMP BrowserAccessibilityWin::QueryService(REFGUID guidService, |
| 2595 REFIID riid, | 2647 REFIID riid, |
| 2596 void** object) { | 2648 void** object) { |
| 2597 if (!instance_active_) | 2649 if (!instance_active_) |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2766 "container-relevant"); | 2818 "container-relevant"); |
| 2767 BoolAttributeToIA2(AccessibilityNodeData::ATTR_CONTAINER_LIVE_ATOMIC, | 2819 BoolAttributeToIA2(AccessibilityNodeData::ATTR_CONTAINER_LIVE_ATOMIC, |
| 2768 "container-atomic"); | 2820 "container-atomic"); |
| 2769 BoolAttributeToIA2(AccessibilityNodeData::ATTR_CONTAINER_LIVE_BUSY, | 2821 BoolAttributeToIA2(AccessibilityNodeData::ATTR_CONTAINER_LIVE_BUSY, |
| 2770 "container-busy"); | 2822 "container-busy"); |
| 2771 | 2823 |
| 2772 // Expose slider value. | 2824 // Expose slider value. |
| 2773 if (ia_role_ == ROLE_SYSTEM_PROGRESSBAR || | 2825 if (ia_role_ == ROLE_SYSTEM_PROGRESSBAR || |
| 2774 ia_role_ == ROLE_SYSTEM_SCROLLBAR || | 2826 ia_role_ == ROLE_SYSTEM_SCROLLBAR || |
| 2775 ia_role_ == ROLE_SYSTEM_SLIDER) { | 2827 ia_role_ == ROLE_SYSTEM_SLIDER) { |
| 2776 float fval; | 2828 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
I guess this was never doing anything, but should
dmazzoni
2013/08/07 17:48:18
It's just being moved.
The main reason I moved it
| |
| 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 } | 2829 } |
| 2795 | 2830 |
| 2796 // Expose table cell index. | 2831 // Expose table cell index. |
| 2797 if (ia_role_ == ROLE_SYSTEM_CELL) { | 2832 if (ia_role_ == ROLE_SYSTEM_CELL) { |
| 2798 BrowserAccessibility* table = parent(); | 2833 BrowserAccessibility* table = parent(); |
| 2799 while (table && table->role() != AccessibilityNodeData::ROLE_TABLE) | 2834 while (table && table->role() != AccessibilityNodeData::ROLE_TABLE) |
| 2800 table = table->parent(); | 2835 table = table->parent(); |
| 2801 if (table) { | 2836 if (table) { |
| 2802 const std::vector<int32>& unique_cell_ids = table->unique_cell_ids(); | 2837 const std::vector<int32>& unique_cell_ids = table->GetIntListAttribute( |
| 2838 AccessibilityNodeData::ATTR_UNIQUE_CELL_IDS); | |
| 2803 for (size_t i = 0; i < unique_cell_ids.size(); ++i) { | 2839 for (size_t i = 0; i < unique_cell_ids.size(); ++i) { |
| 2804 if (unique_cell_ids[i] == renderer_id_) { | 2840 if (unique_cell_ids[i] == renderer_id_) { |
| 2805 ia2_attributes_.push_back( | 2841 ia2_attributes_.push_back( |
| 2806 string16(L"table-cell-index:") + base::IntToString16(i)); | 2842 string16(L"table-cell-index:") + base::IntToString16(i)); |
| 2807 } | 2843 } |
| 2808 } | 2844 } |
| 2809 } | 2845 } |
| 2810 } | 2846 } |
| 2811 | 2847 |
| 2812 // The calculation of the accessible name of an element has been | 2848 // 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 | 2859 // title ui element: a reference to a <label> element on the same |
| 2824 // page that labels this node. | 2860 // page that labels this node. |
| 2825 // description: accessible labels that override the default name: | 2861 // description: accessible labels that override the default name: |
| 2826 // aria-label or aria-labelledby or aria-describedby | 2862 // aria-label or aria-labelledby or aria-describedby |
| 2827 // help: the value of the "title" attribute | 2863 // help: the value of the "title" attribute |
| 2828 // | 2864 // |
| 2829 // On Windows, the logic we apply lets some fields take precedence and | 2865 // On Windows, the logic we apply lets some fields take precedence and |
| 2830 // always returns the primary name in "name" and the secondary name, | 2866 // always returns the primary name in "name" and the secondary name, |
| 2831 // if any, in "description". | 2867 // if any, in "description". |
| 2832 | 2868 |
| 2833 string16 description, help, title_attr; | 2869 std::string name, value, description, help, title_attr; |
| 2834 int title_elem_id = 0; | 2870 int title_elem_id = 0; |
| 2835 GetIntAttribute(AccessibilityNodeData::ATTR_TITLE_UI_ELEMENT, &title_elem_id); | 2871 GetStringAttribute(AccessibilityNodeData::ATTR_NAME, &name); |
| 2836 GetStringAttribute(AccessibilityNodeData::ATTR_DESCRIPTION, &description); | 2872 GetStringAttribute(AccessibilityNodeData::ATTR_DESCRIPTION, &description); |
| 2837 GetStringAttribute(AccessibilityNodeData::ATTR_HELP, &help); | 2873 GetStringAttribute(AccessibilityNodeData::ATTR_HELP, &help); |
| 2874 GetIntAttribute(AccessibilityNodeData::ATTR_TITLE_UI_ELEMENT, &title_elem_id); | |
| 2838 | 2875 |
| 2839 // WebKit annoyingly puts the title in the description if there's no other | 2876 // 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. | 2877 // 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. | 2878 // Now "help" is always the value of the "title" attribute, if present. |
| 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 GetStringAttribute(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() && |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after 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 string16 name; |
| 2970 child->GetStringAttribute(AccessibilityNodeData::ATTR_NAME, &name); | |
| 2971 hypertext_ += name; | |
| 2935 } else { | 2972 } else { |
| 2936 hyperlink_offset_to_index_[hypertext_.size()] = hyperlinks_.size(); | 2973 hyperlink_offset_to_index_[hypertext_.size()] = hyperlinks_.size(); |
| 2937 hypertext_ += kEmbeddedCharacter; | 2974 hypertext_ += kEmbeddedCharacter; |
| 2938 hyperlinks_.push_back(i); | 2975 hyperlinks_.push_back(i); |
| 2939 } | 2976 } |
| 2940 } | 2977 } |
| 2941 DCHECK_EQ(hyperlink_offset_to_index_.size(), hyperlinks_.size()); | 2978 DCHECK_EQ(hyperlink_offset_to_index_.size(), hyperlinks_.size()); |
| 2942 | 2979 |
| 2943 // Fire an event when an alert first appears. | 2980 // Fire an event when an alert first appears. |
| 2944 if (role_ == AccessibilityNodeData::ROLE_ALERT && first_time_) | 2981 if (role_ == AccessibilityNodeData::ROLE_ALERT && first_time_) |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3067 | 3104 |
| 3068 void BrowserAccessibilityWin::IntAttributeToIA2( | 3105 void BrowserAccessibilityWin::IntAttributeToIA2( |
| 3069 AccessibilityNodeData::IntAttribute attribute, | 3106 AccessibilityNodeData::IntAttribute attribute, |
| 3070 const char* ia2_attr) { | 3107 const char* ia2_attr) { |
| 3071 int value; | 3108 int value; |
| 3072 if (GetIntAttribute(attribute, &value)) | 3109 if (GetIntAttribute(attribute, &value)) |
| 3073 ia2_attributes_.push_back(ASCIIToUTF16(ia2_attr) + L":" + | 3110 ia2_attributes_.push_back(ASCIIToUTF16(ia2_attr) + L":" + |
| 3074 base::IntToString16(value)); | 3111 base::IntToString16(value)); |
| 3075 } | 3112 } |
| 3076 | 3113 |
| 3077 const string16& BrowserAccessibilityWin::TextForIAccessibleText() { | 3114 string16 BrowserAccessibilityWin::GetValueText() { |
|
aboxhall
2013/07/31 18:34:47
Where is this method used?
dmazzoni
2013/08/06 17:36:34
It's private, it's called by both get_accValue, an
| |
| 3115 float fval; | |
| 3116 string16 value; | |
| 3117 GetStringAttribute(AccessibilityNodeData::ATTR_VALUE, &value); | |
| 3118 if (value.empty() && | |
| 3119 GetFloatAttribute(AccessibilityNodeData::ATTR_VALUE_FOR_RANGE, &fval)) { | |
| 3120 value = UTF8ToUTF16(base::DoubleToString(fval)); | |
| 3121 } | |
| 3122 return value; | |
| 3123 } | |
| 3124 | |
| 3125 string16 BrowserAccessibilityWin::TextForIAccessibleText() { | |
| 3126 string16 name, value; | |
| 3127 GetStringAttribute(AccessibilityNodeData::ATTR_NAME, &name); | |
| 3128 GetStringAttribute(AccessibilityNodeData::ATTR_VALUE, &value); | |
| 3078 if (IsEditableText()) | 3129 if (IsEditableText()) |
| 3079 return value_; | 3130 return value; |
| 3080 return (role_ == AccessibilityNodeData::ROLE_STATIC_TEXT) ? | 3131 return (role_ == AccessibilityNodeData::ROLE_STATIC_TEXT) ? |
| 3081 name_ : hypertext_; | 3132 name : hypertext_; |
| 3082 } | 3133 } |
| 3083 | 3134 |
| 3084 void BrowserAccessibilityWin::HandleSpecialTextOffset(const string16& text, | 3135 void BrowserAccessibilityWin::HandleSpecialTextOffset(const string16& text, |
| 3085 LONG* offset) { | 3136 LONG* offset) { |
| 3086 if (*offset == IA2_TEXT_OFFSET_LENGTH) | 3137 if (*offset == IA2_TEXT_OFFSET_LENGTH) |
| 3087 *offset = static_cast<LONG>(text.size()); | 3138 *offset = static_cast<LONG>(text.size()); |
| 3088 else if (*offset == IA2_TEXT_OFFSET_CARET) | 3139 else if (*offset == IA2_TEXT_OFFSET_CARET) |
| 3089 get_caretOffset(offset); | 3140 get_caretOffset(offset); |
| 3090 } | 3141 } |
| 3091 | 3142 |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 3104 } | 3155 } |
| 3105 } | 3156 } |
| 3106 | 3157 |
| 3107 LONG BrowserAccessibilityWin::FindBoundary( | 3158 LONG BrowserAccessibilityWin::FindBoundary( |
| 3108 const string16& text, | 3159 const string16& text, |
| 3109 IA2TextBoundaryType ia2_boundary, | 3160 IA2TextBoundaryType ia2_boundary, |
| 3110 LONG start_offset, | 3161 LONG start_offset, |
| 3111 ui::TextBoundaryDirection direction) { | 3162 ui::TextBoundaryDirection direction) { |
| 3112 HandleSpecialTextOffset(text, &start_offset); | 3163 HandleSpecialTextOffset(text, &start_offset); |
| 3113 ui::TextBoundaryType boundary = IA2TextBoundaryToTextBoundary(ia2_boundary); | 3164 ui::TextBoundaryType boundary = IA2TextBoundaryToTextBoundary(ia2_boundary); |
| 3165 const std::vector<int32>& line_breaks = GetIntListAttribute( | |
| 3166 AccessibilityNodeData::ATTR_LINE_BREAKS); | |
| 3114 return ui::FindAccessibleTextBoundary( | 3167 return ui::FindAccessibleTextBoundary( |
| 3115 text, line_breaks_, boundary, start_offset, direction); | 3168 text, line_breaks, boundary, start_offset, direction); |
| 3116 } | 3169 } |
| 3117 | 3170 |
| 3118 BrowserAccessibilityWin* BrowserAccessibilityWin::GetFromRendererID( | 3171 BrowserAccessibilityWin* BrowserAccessibilityWin::GetFromRendererID( |
| 3119 int32 renderer_id) { | 3172 int32 renderer_id) { |
| 3120 return manager_->GetFromRendererID(renderer_id)->ToBrowserAccessibilityWin(); | 3173 return manager_->GetFromRendererID(renderer_id)->ToBrowserAccessibilityWin(); |
| 3121 } | 3174 } |
| 3122 | 3175 |
| 3123 void BrowserAccessibilityWin::InitRoleAndState() { | 3176 void BrowserAccessibilityWin::InitRoleAndState() { |
| 3124 ia_state_ = 0; | 3177 ia_state_ = 0; |
| 3125 ia2_state_ = IA2_STATE_OPAQUE; | 3178 ia2_state_ = IA2_STATE_OPAQUE; |
| (...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3617 // The role should always be set. | 3670 // The role should always be set. |
| 3618 DCHECK(!role_name_.empty() || ia_role_); | 3671 DCHECK(!role_name_.empty() || ia_role_); |
| 3619 | 3672 |
| 3620 // If we didn't explicitly set the IAccessible2 role, make it the same | 3673 // If we didn't explicitly set the IAccessible2 role, make it the same |
| 3621 // as the MSAA role. | 3674 // as the MSAA role. |
| 3622 if (!ia2_role_) | 3675 if (!ia2_role_) |
| 3623 ia2_role_ = ia_role_; | 3676 ia2_role_ = ia_role_; |
| 3624 } | 3677 } |
| 3625 | 3678 |
| 3626 } // namespace content | 3679 } // namespace content |
| OLD | NEW |