Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: ui/accessibility/platform/ax_platform_node_win.cc

Issue 2969113002: Forward BrowserAccessibilityWin table APIs to AXPlatformNodeWin. (Closed)
Patch Set: Rename 4X4 to 3X3. Off by one! Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 <atlbase.h> 5 #include <atlbase.h>
6 #include <atlcom.h> 6 #include <atlcom.h>
7 #include <limits.h> 7 #include <limits.h>
8 #include <oleacc.h> 8 #include <oleacc.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 947 matching lines...) Expand 10 before | Expand all | Expand 10 after
958 } 958 }
959 STDMETHODIMP AXPlatformNodeWin::get_locale(IA2Locale* locale) { 959 STDMETHODIMP AXPlatformNodeWin::get_locale(IA2Locale* locale) {
960 return E_NOTIMPL; 960 return E_NOTIMPL;
961 } 961 }
962 STDMETHODIMP AXPlatformNodeWin::get_accessibleWithCaret(IUnknown** accessible, 962 STDMETHODIMP AXPlatformNodeWin::get_accessibleWithCaret(IUnknown** accessible,
963 long* caret_offset) { 963 long* caret_offset) {
964 return E_NOTIMPL; 964 return E_NOTIMPL;
965 } 965 }
966 966
967 // 967 //
968 // IAccessibleTable methods.
969 //
970
971 STDMETHODIMP AXPlatformNodeWin::get_accessibleAt(long row,
972 long column,
973 IUnknown** accessible) {
974 if (!accessible)
975 return E_INVALIDARG;
976
977 AXPlatformNodeBase* cell =
978 GetTableCell(static_cast<int>(row), static_cast<int>(column));
979 if (cell) {
980 auto* node_win = static_cast<AXPlatformNodeWin*>(cell);
981 node_win->AddRef();
982
983 *accessible = static_cast<IAccessible*>(node_win);
984 return S_OK;
985 }
986
987 *accessible = nullptr;
988 return E_INVALIDARG;
989 }
990
991 STDMETHODIMP AXPlatformNodeWin::get_caption(IUnknown** accessible) {
992 if (!accessible)
993 return E_INVALIDARG;
994
995 // TODO(dmazzoni): implement
996 *accessible = nullptr;
997 return S_FALSE;
998 }
999
1000 STDMETHODIMP AXPlatformNodeWin::get_childIndex(long row,
1001 long column,
1002 long* cell_index) {
1003 if (!cell_index)
1004 return E_INVALIDARG;
1005
1006 auto* cell = GetTableCell(static_cast<int>(row), static_cast<int>(column));
1007 if (cell) {
1008 *cell_index = static_cast<LONG>(cell->GetTableCellIndex());
1009 return S_OK;
1010 }
1011
1012 *cell_index = 0;
1013 return E_INVALIDARG;
1014 }
1015
1016 STDMETHODIMP AXPlatformNodeWin::get_columnDescription(long column,
1017 BSTR* description) {
1018 if (!description)
1019 return E_INVALIDARG;
1020
1021 int columns = GetTableColumnCount();
1022 if (column < 0 || column >= columns)
1023 return E_INVALIDARG;
1024
1025 int rows = GetTableRowCount();
1026 if (rows <= 0) {
1027 *description = nullptr;
1028 return S_FALSE;
1029 }
1030
1031 for (int i = 0; i < rows; ++i) {
1032 auto* cell = GetTableCell(i, column);
1033 if (cell && cell->GetData().role == ui::AX_ROLE_COLUMN_HEADER) {
1034 base::string16 cell_name = cell->GetString16Attribute(ui::AX_ATTR_NAME);
1035 if (cell_name.size() > 0) {
1036 *description = SysAllocString(cell_name.c_str());
1037 return S_OK;
1038 }
1039
1040 cell_name = cell->GetString16Attribute(ui::AX_ATTR_DESCRIPTION);
1041 if (cell_name.size() > 0) {
1042 *description = SysAllocString(cell_name.c_str());
1043 return S_OK;
1044 }
1045 }
1046 }
1047
1048 *description = nullptr;
1049 return S_FALSE;
1050 }
1051
1052 STDMETHODIMP AXPlatformNodeWin::get_columnExtentAt(long row,
1053 long column,
1054 long* n_columns_spanned) {
1055 if (!n_columns_spanned)
1056 return E_INVALIDARG;
1057
1058 auto* cell = GetTableCell(static_cast<int>(row), static_cast<int>(column));
1059 if (!cell)
1060 return E_INVALIDARG;
1061
1062 *n_columns_spanned = cell->GetTableColumnSpan();
1063 return S_OK;
1064 }
1065
1066 STDMETHODIMP AXPlatformNodeWin::get_columnHeader(
1067 IAccessibleTable** accessible_table,
1068 long* starting_row_index) {
1069 // TODO(dmazzoni): implement
1070 return E_NOTIMPL;
1071 }
1072
1073 STDMETHODIMP AXPlatformNodeWin::get_columnIndex(long cell_index,
1074 long* column_index) {
1075 if (!column_index)
1076 return E_INVALIDARG;
1077
1078 auto* cell = GetTableCell(cell_index);
1079 if (!cell)
1080 return E_INVALIDARG;
1081 *column_index = cell->GetTableColumn();
1082 return S_OK;
1083 }
1084
1085 STDMETHODIMP AXPlatformNodeWin::get_nColumns(long* column_count) {
1086 if (!column_count)
1087 return E_INVALIDARG;
1088
1089 *column_count = GetTableColumnCount();
1090 return S_OK;
1091 }
1092
1093 STDMETHODIMP AXPlatformNodeWin::get_nRows(long* row_count) {
1094 if (!row_count)
1095 return E_INVALIDARG;
1096
1097 *row_count = GetTableRowCount();
1098 return S_OK;
1099 }
1100
1101 STDMETHODIMP AXPlatformNodeWin::get_nSelectedChildren(long* cell_count) {
1102 if (!cell_count)
1103 return E_INVALIDARG;
1104
1105 // TODO(dmazzoni): add support for selected cells/rows/columns in tables.
1106 *cell_count = 0;
1107 return S_FALSE;
1108 }
1109
1110 STDMETHODIMP AXPlatformNodeWin::get_nSelectedColumns(long* column_count) {
1111 if (!column_count)
1112 return E_INVALIDARG;
1113
1114 *column_count = 0;
1115 return S_FALSE;
1116 }
1117
1118 STDMETHODIMP AXPlatformNodeWin::get_nSelectedRows(long* row_count) {
1119 if (!row_count)
1120 return E_INVALIDARG;
1121
1122 *row_count = 0;
1123 return S_FALSE;
1124 }
1125
1126 STDMETHODIMP AXPlatformNodeWin::get_rowDescription(long row,
1127 BSTR* description) {
1128 if (!description)
1129 return E_INVALIDARG;
1130
1131 if (row < 0 || row >= GetTableRowCount())
1132 return E_INVALIDARG;
1133
1134 int columns = GetTableColumnCount();
1135 if (columns <= 0) {
1136 *description = nullptr;
1137 return S_FALSE;
1138 }
1139
1140 for (int i = 0; i < columns; ++i) {
1141 auto* cell = GetTableCell(row, i);
1142 if (cell && cell->GetData().role == ui::AX_ROLE_ROW_HEADER) {
1143 base::string16 cell_name = cell->GetString16Attribute(ui::AX_ATTR_NAME);
1144 if (cell_name.size() > 0) {
1145 *description = SysAllocString(cell_name.c_str());
1146 return S_OK;
1147 }
1148 cell_name = cell->GetString16Attribute(ui::AX_ATTR_DESCRIPTION);
1149 if (cell_name.size() > 0) {
1150 *description = SysAllocString(cell_name.c_str());
1151 return S_OK;
1152 }
1153 }
1154 }
1155
1156 *description = nullptr;
1157 return S_FALSE;
1158 }
1159
1160 STDMETHODIMP AXPlatformNodeWin::get_rowExtentAt(long row,
1161 long column,
1162 long* n_rows_spanned) {
1163 if (!n_rows_spanned)
1164 return E_INVALIDARG;
1165
1166 auto* cell = GetTableCell(row, column);
1167 if (!cell)
1168 return E_INVALIDARG;
1169
1170 *n_rows_spanned = GetTableRowSpan();
1171 return S_OK;
1172 }
1173
1174 STDMETHODIMP AXPlatformNodeWin::get_rowHeader(
1175 IAccessibleTable** accessible_table,
1176 long* starting_column_index) {
1177 // TODO(dmazzoni): implement
1178 return E_NOTIMPL;
1179 }
1180
1181 STDMETHODIMP AXPlatformNodeWin::get_rowIndex(long cell_index, long* row_index) {
1182 if (!row_index)
1183 return E_INVALIDARG;
1184
1185 auto* cell = GetTableCell(cell_index);
1186 if (!cell)
1187 return E_INVALIDARG;
1188
1189 *row_index = cell->GetTableRow();
1190 return S_OK;
1191 }
1192
1193 STDMETHODIMP AXPlatformNodeWin::get_selectedChildren(long max_children,
1194 long** children,
1195 long* n_children) {
1196 if (!children || !n_children)
1197 return E_INVALIDARG;
1198
1199 // TODO(dmazzoni): Implement this.
1200 *n_children = 0;
1201 return S_FALSE;
1202 }
1203
1204 STDMETHODIMP AXPlatformNodeWin::get_selectedColumns(long max_columns,
1205 long** columns,
1206 long* n_columns) {
1207 if (!columns || !n_columns)
1208 return E_INVALIDARG;
1209
1210 // TODO(dmazzoni): Implement this.
1211 *n_columns = 0;
1212 return S_FALSE;
1213 }
1214
1215 STDMETHODIMP AXPlatformNodeWin::get_selectedRows(long max_rows,
1216 long** rows,
1217 long* n_rows) {
1218 if (!rows || !n_rows)
1219 return E_INVALIDARG;
1220
1221 // TODO(dmazzoni): Implement this.
1222 *n_rows = 0;
1223 return S_FALSE;
1224 }
1225
1226 STDMETHODIMP AXPlatformNodeWin::get_summary(IUnknown** accessible) {
1227 if (!accessible)
1228 return E_INVALIDARG;
1229
1230 // TODO(dmazzoni): implement
1231 *accessible = nullptr;
1232 return S_FALSE;
1233 }
1234
1235 STDMETHODIMP AXPlatformNodeWin::get_isColumnSelected(long column,
1236 boolean* is_selected) {
1237 if (!is_selected)
1238 return E_INVALIDARG;
1239
1240 // TODO(dmazzoni): Implement this.
1241 *is_selected = false;
1242 return S_OK;
1243 }
1244
1245 STDMETHODIMP AXPlatformNodeWin::get_isRowSelected(long row,
1246 boolean* is_selected) {
1247 if (!is_selected)
1248 return E_INVALIDARG;
1249
1250 // TODO(dmazzoni): Implement this.
1251 *is_selected = false;
1252 return S_OK;
1253 }
1254
1255 STDMETHODIMP AXPlatformNodeWin::get_isSelected(long row,
1256 long column,
1257 boolean* is_selected) {
1258 if (!is_selected)
1259 return E_INVALIDARG;
1260
1261 // TODO(dmazzoni): Implement this.
1262 *is_selected = false;
1263 return S_OK;
1264 }
1265
1266 STDMETHODIMP AXPlatformNodeWin::get_rowColumnExtentsAtIndex(
1267 long index,
1268 long* row,
1269 long* column,
1270 long* row_extents,
1271 long* column_extents,
1272 boolean* is_selected) {
1273 if (!row || !column || !row_extents || !column_extents || !is_selected)
1274 return E_INVALIDARG;
1275
1276 auto* cell = GetTableCell(index);
1277 if (!cell)
1278 return E_INVALIDARG;
1279
1280 *row = cell->GetTableRow();
1281 *column = cell->GetTableColumn();
1282 *row_extents = GetTableRowSpan();
1283 *column_extents = GetTableColumnSpan();
1284 *is_selected = false; // Not supported.
1285
1286 return S_OK;
1287 }
1288
1289 STDMETHODIMP AXPlatformNodeWin::selectRow(long row) {
1290 return E_NOTIMPL;
1291 }
1292
1293 STDMETHODIMP AXPlatformNodeWin::selectColumn(long column) {
1294 return E_NOTIMPL;
1295 }
1296
1297 STDMETHODIMP AXPlatformNodeWin::unselectRow(long row) {
1298 return E_NOTIMPL;
1299 }
1300
1301 STDMETHODIMP AXPlatformNodeWin::unselectColumn(long column) {
1302 return E_NOTIMPL;
1303 }
1304
1305 STDMETHODIMP
1306 AXPlatformNodeWin::get_modelChange(IA2TableModelChange* model_change) {
1307 return E_NOTIMPL;
1308 }
1309
1310 //
1311 // IAccessibleTable2 methods.
1312 //
1313
1314 STDMETHODIMP AXPlatformNodeWin::get_cellAt(long row,
1315 long column,
1316 IUnknown** cell) {
1317 if (!cell)
1318 return E_INVALIDARG;
1319
1320 AXPlatformNodeBase* table_cell =
1321 GetTableCell(static_cast<int>(row), static_cast<int>(column));
1322 if (table_cell) {
1323 auto* node_win = static_cast<AXPlatformNodeWin*>(table_cell);
1324 node_win->AddRef();
1325 *cell = static_cast<IAccessible*>(node_win);
1326 return S_OK;
1327 }
1328
1329 *cell = nullptr;
1330 return E_INVALIDARG;
1331 }
1332
1333 STDMETHODIMP AXPlatformNodeWin::get_nSelectedCells(long* cell_count) {
1334 return get_nSelectedChildren(cell_count);
1335 }
1336
1337 STDMETHODIMP AXPlatformNodeWin::get_selectedCells(IUnknown*** cells,
1338 long* n_selected_cells) {
1339 if (!cells || !n_selected_cells)
1340 return E_INVALIDARG;
1341
1342 // TODO(dmazzoni): Implement this.
1343 *n_selected_cells = 0;
1344 return S_OK;
1345 }
1346
1347 STDMETHODIMP AXPlatformNodeWin::get_selectedColumns(long** columns,
1348 long* n_columns) {
1349 if (!columns || !n_columns)
1350 return E_INVALIDARG;
1351
1352 // TODO(dmazzoni): Implement this.
1353 *n_columns = 0;
1354 return S_OK;
1355 }
1356
1357 STDMETHODIMP AXPlatformNodeWin::get_selectedRows(long** rows, long* n_rows) {
1358 if (!rows || !n_rows)
1359 return E_INVALIDARG;
1360
1361 // TODO(dmazzoni): Implement this.
1362 *n_rows = 0;
1363 return S_OK;
1364 }
1365
1366 //
1367 // IAccessibleTableCell methods.
1368 //
1369
1370 STDMETHODIMP AXPlatformNodeWin::get_columnExtent(long* n_columns_spanned) {
1371 if (!n_columns_spanned)
1372 return E_INVALIDARG;
1373
1374 *n_columns_spanned = GetTableColumnSpan();
1375 return S_OK;
1376 }
1377
1378 STDMETHODIMP AXPlatformNodeWin::get_columnHeaderCells(
1379 IUnknown*** cell_accessibles,
1380 long* n_column_header_cells) {
1381 if (!cell_accessibles || !n_column_header_cells)
1382 return E_INVALIDARG;
1383
1384 *n_column_header_cells = 0;
1385 auto* table = GetTable();
1386 if (!table) {
1387 NOTREACHED();
1388 return S_FALSE;
1389 }
1390
1391 int column = GetTableColumn();
1392 int columns = GetTableColumnCount();
1393 int rows = GetTableRowCount();
1394 if (columns <= 0 || rows <= 0 || column < 0 || column >= columns)
1395 return S_FALSE;
1396
1397 for (int i = 0; i < rows; ++i) {
1398 auto* cell = GetTableCell(i, column);
1399 if (cell && cell->GetData().role == ui::AX_ROLE_COLUMN_HEADER)
1400 (*n_column_header_cells)++;
1401 }
1402
1403 *cell_accessibles = static_cast<IUnknown**>(
1404 CoTaskMemAlloc((*n_column_header_cells) * sizeof(cell_accessibles[0])));
1405 int index = 0;
1406 for (int i = 0; i < rows; ++i) {
1407 AXPlatformNodeBase* cell = GetTableCell(i, column);
1408 if (cell && cell->GetData().role == ui::AX_ROLE_COLUMN_HEADER) {
1409 auto* node_win = static_cast<AXPlatformNodeWin*>(cell);
1410 node_win->AddRef();
1411
1412 (*cell_accessibles)[index] = static_cast<IAccessible*>(node_win);
1413 ++index;
1414 }
1415 }
1416
1417 return S_OK;
1418 }
1419
1420 STDMETHODIMP AXPlatformNodeWin::get_columnIndex(long* column_index) {
1421 if (!column_index)
1422 return E_INVALIDARG;
1423
1424 *column_index = GetTableColumn();
1425 return S_OK;
1426 }
1427
1428 STDMETHODIMP AXPlatformNodeWin::get_rowExtent(long* n_rows_spanned) {
1429 if (!n_rows_spanned)
1430 return E_INVALIDARG;
1431
1432 *n_rows_spanned = GetTableRowSpan();
1433 return S_OK;
1434 }
1435
1436 STDMETHODIMP AXPlatformNodeWin::get_rowHeaderCells(IUnknown*** cell_accessibles,
1437 long* n_row_header_cells) {
1438 if (!cell_accessibles || !n_row_header_cells)
1439 return E_INVALIDARG;
1440
1441 *n_row_header_cells = 0;
1442 auto* table = GetTable();
1443 if (!table) {
1444 NOTREACHED();
1445 return S_FALSE;
1446 }
1447
1448 int row = GetTableRow();
1449 int columns = GetTableColumnCount();
1450 int rows = GetTableRowCount();
1451 if (columns <= 0 || rows <= 0 || row < 0 || row >= rows)
1452 return S_FALSE;
1453
1454 for (int i = 0; i < columns; ++i) {
1455 auto* cell = GetTableCell(row, i);
1456 if (cell && cell->GetData().role == ui::AX_ROLE_ROW_HEADER)
1457 (*n_row_header_cells)++;
1458 }
1459
1460 *cell_accessibles = static_cast<IUnknown**>(
1461 CoTaskMemAlloc((*n_row_header_cells) * sizeof(cell_accessibles[0])));
1462 int index = 0;
1463 for (int i = 0; i < columns; ++i) {
1464 AXPlatformNodeBase* cell = GetTableCell(row, i);
1465 if (cell && cell->GetData().role == ui::AX_ROLE_ROW_HEADER) {
1466 auto* node_win = static_cast<AXPlatformNodeWin*>(cell);
1467 node_win->AddRef();
1468
1469 (*cell_accessibles)[index] = static_cast<IAccessible*>(node_win);
1470 ++index;
1471 }
1472 }
1473
1474 return S_OK;
1475 }
1476
1477 STDMETHODIMP AXPlatformNodeWin::get_rowIndex(long* row_index) {
1478 if (!row_index)
1479 return E_INVALIDARG;
1480
1481 *row_index = GetTableRow();
1482 return S_OK;
1483 }
1484
1485 STDMETHODIMP AXPlatformNodeWin::get_isSelected(boolean* is_selected) {
1486 if (!is_selected)
1487 return E_INVALIDARG;
1488
1489 *is_selected = false;
1490 return S_OK;
1491 }
1492
1493 STDMETHODIMP AXPlatformNodeWin::get_rowColumnExtents(long* row_index,
1494 long* column_index,
1495 long* row_extents,
1496 long* column_extents,
1497 boolean* is_selected) {
1498 if (!row_index || !column_index || !row_extents || !column_extents ||
1499 !is_selected) {
1500 return E_INVALIDARG;
1501 }
1502
1503 *row_index = GetTableRow();
1504 *column_index = GetTableColumn();
1505 *row_extents = GetTableRowSpan();
1506 *column_extents = GetTableColumnSpan();
1507 *is_selected = false; // Not supported.
1508
1509 return S_OK;
1510 }
1511
1512 STDMETHODIMP AXPlatformNodeWin::get_table(IUnknown** table) {
1513 if (!table)
1514 return E_INVALIDARG;
1515
1516 auto* find_table = GetTable();
1517 if (!find_table) {
1518 *table = nullptr;
1519 return S_FALSE;
1520 }
1521
1522 // The IAccessibleTable interface is still on the AXPlatformNodeWin
1523 // class.
1524 auto* node_win = static_cast<AXPlatformNodeWin*>(find_table);
1525 node_win->AddRef();
1526
1527 *table = static_cast<IAccessibleTable*>(node_win);
1528 return S_OK;
1529 }
1530
1531 //
968 // IAccessibleText 1532 // IAccessibleText
969 // 1533 //
970 1534
971 STDMETHODIMP AXPlatformNodeWin::get_nCharacters(LONG* n_characters) { 1535 STDMETHODIMP AXPlatformNodeWin::get_nCharacters(LONG* n_characters) {
972 COM_OBJECT_VALIDATE_1_ARG(n_characters); 1536 COM_OBJECT_VALIDATE_1_ARG(n_characters);
973 base::string16 text = TextForIAccessibleText(); 1537 base::string16 text = TextForIAccessibleText();
974 *n_characters = static_cast<LONG>(text.size()); 1538 *n_characters = static_cast<LONG>(text.size());
975 1539
976 return S_OK; 1540 return S_OK;
977 } 1541 }
(...skipping 963 matching lines...) Expand 10 before | Expand all | Expand 10 after
1941 2505
1942 AXPlatformNodeBase* base = 2506 AXPlatformNodeBase* base =
1943 FromNativeViewAccessible(node->GetNativeViewAccessible()); 2507 FromNativeViewAccessible(node->GetNativeViewAccessible());
1944 if (base && !IsDescendant(base)) 2508 if (base && !IsDescendant(base))
1945 base = nullptr; 2509 base = nullptr;
1946 2510
1947 return static_cast<AXPlatformNodeWin*>(base); 2511 return static_cast<AXPlatformNodeWin*>(base);
1948 } 2512 }
1949 2513
1950 } // namespace ui 2514 } // namespace ui
OLDNEW
« no previous file with comments | « ui/accessibility/platform/ax_platform_node_win.h ('k') | ui/accessibility/platform/ax_platform_node_win_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698