| 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 <algorithm> | 10 #include <algorithm> |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 BrowserAccessibilityWin* target = GetTargetFromChildID(start); | 316 BrowserAccessibilityWin* target = GetTargetFromChildID(start); |
| 317 if (!target) | 317 if (!target) |
| 318 return E_INVALIDARG; | 318 return E_INVALIDARG; |
| 319 | 319 |
| 320 if ((nav_dir == NAVDIR_LASTCHILD || nav_dir == NAVDIR_FIRSTCHILD) && | 320 if ((nav_dir == NAVDIR_LASTCHILD || nav_dir == NAVDIR_FIRSTCHILD) && |
| 321 start.lVal != CHILDID_SELF) { | 321 start.lVal != CHILDID_SELF) { |
| 322 // MSAA states that navigating to first/last child can only be from self. | 322 // MSAA states that navigating to first/last child can only be from self. |
| 323 return E_INVALIDARG; | 323 return E_INVALIDARG; |
| 324 } | 324 } |
| 325 | 325 |
| 326 uint32 child_count = target->PlatformChildCount(); | 326 uint32_t child_count = target->PlatformChildCount(); |
| 327 | 327 |
| 328 BrowserAccessibility* result = NULL; | 328 BrowserAccessibility* result = NULL; |
| 329 switch (nav_dir) { | 329 switch (nav_dir) { |
| 330 case NAVDIR_DOWN: | 330 case NAVDIR_DOWN: |
| 331 case NAVDIR_UP: | 331 case NAVDIR_UP: |
| 332 case NAVDIR_LEFT: | 332 case NAVDIR_LEFT: |
| 333 case NAVDIR_RIGHT: | 333 case NAVDIR_RIGHT: |
| 334 // These directions are not implemented, matching Mozilla and IE. | 334 // These directions are not implemented, matching Mozilla and IE. |
| 335 return E_NOTIMPL; | 335 return E_NOTIMPL; |
| 336 case NAVDIR_FIRSTCHILD: | 336 case NAVDIR_FIRSTCHILD: |
| (...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1099 !GetIntAttribute( | 1099 !GetIntAttribute( |
| 1100 ui::AX_ATTR_TABLE_ROW_COUNT, &rows) || | 1100 ui::AX_ATTR_TABLE_ROW_COUNT, &rows) || |
| 1101 columns <= 0 || | 1101 columns <= 0 || |
| 1102 rows <= 0) { | 1102 rows <= 0) { |
| 1103 return S_FALSE; | 1103 return S_FALSE; |
| 1104 } | 1104 } |
| 1105 | 1105 |
| 1106 if (row < 0 || row >= rows || column < 0 || column >= columns) | 1106 if (row < 0 || row >= rows || column < 0 || column >= columns) |
| 1107 return E_INVALIDARG; | 1107 return E_INVALIDARG; |
| 1108 | 1108 |
| 1109 const std::vector<int32>& cell_ids = GetIntListAttribute( | 1109 const std::vector<int32_t>& cell_ids = |
| 1110 ui::AX_ATTR_CELL_IDS); | 1110 GetIntListAttribute(ui::AX_ATTR_CELL_IDS); |
| 1111 DCHECK_EQ(columns * rows, static_cast<int>(cell_ids.size())); | 1111 DCHECK_EQ(columns * rows, static_cast<int>(cell_ids.size())); |
| 1112 | 1112 |
| 1113 int cell_id = cell_ids[row * columns + column]; | 1113 int cell_id = cell_ids[row * columns + column]; |
| 1114 BrowserAccessibilityWin* cell = GetFromID(cell_id); | 1114 BrowserAccessibilityWin* cell = GetFromID(cell_id); |
| 1115 if (cell) { | 1115 if (cell) { |
| 1116 *accessible = static_cast<IAccessible*>(cell->NewReference()); | 1116 *accessible = static_cast<IAccessible*>(cell->NewReference()); |
| 1117 return S_OK; | 1117 return S_OK; |
| 1118 } | 1118 } |
| 1119 | 1119 |
| 1120 *accessible = NULL; | 1120 *accessible = NULL; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1148 !GetIntAttribute( | 1148 !GetIntAttribute( |
| 1149 ui::AX_ATTR_TABLE_ROW_COUNT, &rows) || | 1149 ui::AX_ATTR_TABLE_ROW_COUNT, &rows) || |
| 1150 columns <= 0 || | 1150 columns <= 0 || |
| 1151 rows <= 0) { | 1151 rows <= 0) { |
| 1152 return S_FALSE; | 1152 return S_FALSE; |
| 1153 } | 1153 } |
| 1154 | 1154 |
| 1155 if (row < 0 || row >= rows || column < 0 || column >= columns) | 1155 if (row < 0 || row >= rows || column < 0 || column >= columns) |
| 1156 return E_INVALIDARG; | 1156 return E_INVALIDARG; |
| 1157 | 1157 |
| 1158 const std::vector<int32>& cell_ids = GetIntListAttribute( | 1158 const std::vector<int32_t>& cell_ids = |
| 1159 ui::AX_ATTR_CELL_IDS); | 1159 GetIntListAttribute(ui::AX_ATTR_CELL_IDS); |
| 1160 const std::vector<int32>& unique_cell_ids = GetIntListAttribute( | 1160 const std::vector<int32_t>& unique_cell_ids = |
| 1161 ui::AX_ATTR_UNIQUE_CELL_IDS); | 1161 GetIntListAttribute(ui::AX_ATTR_UNIQUE_CELL_IDS); |
| 1162 DCHECK_EQ(columns * rows, static_cast<int>(cell_ids.size())); | 1162 DCHECK_EQ(columns * rows, static_cast<int>(cell_ids.size())); |
| 1163 int cell_id = cell_ids[row * columns + column]; | 1163 int cell_id = cell_ids[row * columns + column]; |
| 1164 for (size_t i = 0; i < unique_cell_ids.size(); ++i) { | 1164 for (size_t i = 0; i < unique_cell_ids.size(); ++i) { |
| 1165 if (unique_cell_ids[i] == cell_id) { | 1165 if (unique_cell_ids[i] == cell_id) { |
| 1166 *cell_index = (long)i; | 1166 *cell_index = (long)i; |
| 1167 return S_OK; | 1167 return S_OK; |
| 1168 } | 1168 } |
| 1169 } | 1169 } |
| 1170 | 1170 |
| 1171 return S_FALSE; | 1171 return S_FALSE; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1185 ui::AX_ATTR_TABLE_COLUMN_COUNT, &columns) || | 1185 ui::AX_ATTR_TABLE_COLUMN_COUNT, &columns) || |
| 1186 !GetIntAttribute(ui::AX_ATTR_TABLE_ROW_COUNT, &rows) || | 1186 !GetIntAttribute(ui::AX_ATTR_TABLE_ROW_COUNT, &rows) || |
| 1187 columns <= 0 || | 1187 columns <= 0 || |
| 1188 rows <= 0) { | 1188 rows <= 0) { |
| 1189 return S_FALSE; | 1189 return S_FALSE; |
| 1190 } | 1190 } |
| 1191 | 1191 |
| 1192 if (column < 0 || column >= columns) | 1192 if (column < 0 || column >= columns) |
| 1193 return E_INVALIDARG; | 1193 return E_INVALIDARG; |
| 1194 | 1194 |
| 1195 const std::vector<int32>& cell_ids = GetIntListAttribute( | 1195 const std::vector<int32_t>& cell_ids = |
| 1196 ui::AX_ATTR_CELL_IDS); | 1196 GetIntListAttribute(ui::AX_ATTR_CELL_IDS); |
| 1197 for (int i = 0; i < rows; ++i) { | 1197 for (int i = 0; i < rows; ++i) { |
| 1198 int cell_id = cell_ids[i * columns + column]; | 1198 int cell_id = cell_ids[i * columns + column]; |
| 1199 BrowserAccessibilityWin* cell = static_cast<BrowserAccessibilityWin*>( | 1199 BrowserAccessibilityWin* cell = static_cast<BrowserAccessibilityWin*>( |
| 1200 manager()->GetFromID(cell_id)); | 1200 manager()->GetFromID(cell_id)); |
| 1201 if (cell && cell->GetRole() == ui::AX_ROLE_COLUMN_HEADER) { | 1201 if (cell && cell->GetRole() == ui::AX_ROLE_COLUMN_HEADER) { |
| 1202 base::string16 cell_name = cell->GetString16Attribute( | 1202 base::string16 cell_name = cell->GetString16Attribute( |
| 1203 ui::AX_ATTR_NAME); | 1203 ui::AX_ATTR_NAME); |
| 1204 if (cell_name.size() > 0) { | 1204 if (cell_name.size() > 0) { |
| 1205 *description = SysAllocString(cell_name.c_str()); | 1205 *description = SysAllocString(cell_name.c_str()); |
| 1206 return S_OK; | 1206 return S_OK; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1232 ui::AX_ATTR_TABLE_COLUMN_COUNT, &columns) || | 1232 ui::AX_ATTR_TABLE_COLUMN_COUNT, &columns) || |
| 1233 !GetIntAttribute(ui::AX_ATTR_TABLE_ROW_COUNT, &rows) || | 1233 !GetIntAttribute(ui::AX_ATTR_TABLE_ROW_COUNT, &rows) || |
| 1234 columns <= 0 || | 1234 columns <= 0 || |
| 1235 rows <= 0) { | 1235 rows <= 0) { |
| 1236 return S_FALSE; | 1236 return S_FALSE; |
| 1237 } | 1237 } |
| 1238 | 1238 |
| 1239 if (row < 0 || row >= rows || column < 0 || column >= columns) | 1239 if (row < 0 || row >= rows || column < 0 || column >= columns) |
| 1240 return E_INVALIDARG; | 1240 return E_INVALIDARG; |
| 1241 | 1241 |
| 1242 const std::vector<int32>& cell_ids = GetIntListAttribute( | 1242 const std::vector<int32_t>& cell_ids = |
| 1243 ui::AX_ATTR_CELL_IDS); | 1243 GetIntListAttribute(ui::AX_ATTR_CELL_IDS); |
| 1244 int cell_id = cell_ids[row * columns + column]; | 1244 int cell_id = cell_ids[row * columns + column]; |
| 1245 BrowserAccessibilityWin* cell = static_cast<BrowserAccessibilityWin*>( | 1245 BrowserAccessibilityWin* cell = static_cast<BrowserAccessibilityWin*>( |
| 1246 manager()->GetFromID(cell_id)); | 1246 manager()->GetFromID(cell_id)); |
| 1247 int colspan; | 1247 int colspan; |
| 1248 if (cell && | 1248 if (cell && |
| 1249 cell->GetIntAttribute( | 1249 cell->GetIntAttribute( |
| 1250 ui::AX_ATTR_TABLE_CELL_COLUMN_SPAN, &colspan) && | 1250 ui::AX_ATTR_TABLE_CELL_COLUMN_SPAN, &colspan) && |
| 1251 colspan >= 1) { | 1251 colspan >= 1) { |
| 1252 *n_columns_spanned = colspan; | 1252 *n_columns_spanned = colspan; |
| 1253 return S_OK; | 1253 return S_OK; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1264 } | 1264 } |
| 1265 | 1265 |
| 1266 STDMETHODIMP BrowserAccessibilityWin::get_columnIndex(long cell_index, | 1266 STDMETHODIMP BrowserAccessibilityWin::get_columnIndex(long cell_index, |
| 1267 long* column_index) { | 1267 long* column_index) { |
| 1268 if (!instance_active()) | 1268 if (!instance_active()) |
| 1269 return E_FAIL; | 1269 return E_FAIL; |
| 1270 | 1270 |
| 1271 if (!column_index) | 1271 if (!column_index) |
| 1272 return E_INVALIDARG; | 1272 return E_INVALIDARG; |
| 1273 | 1273 |
| 1274 const std::vector<int32>& unique_cell_ids = GetIntListAttribute( | 1274 const std::vector<int32_t>& unique_cell_ids = |
| 1275 ui::AX_ATTR_UNIQUE_CELL_IDS); | 1275 GetIntListAttribute(ui::AX_ATTR_UNIQUE_CELL_IDS); |
| 1276 int cell_id_count = static_cast<int>(unique_cell_ids.size()); | 1276 int cell_id_count = static_cast<int>(unique_cell_ids.size()); |
| 1277 if (cell_index < 0) | 1277 if (cell_index < 0) |
| 1278 return E_INVALIDARG; | 1278 return E_INVALIDARG; |
| 1279 if (cell_index >= cell_id_count) | 1279 if (cell_index >= cell_id_count) |
| 1280 return S_FALSE; | 1280 return S_FALSE; |
| 1281 | 1281 |
| 1282 int cell_id = unique_cell_ids[cell_index]; | 1282 int cell_id = unique_cell_ids[cell_index]; |
| 1283 BrowserAccessibilityWin* cell = | 1283 BrowserAccessibilityWin* cell = |
| 1284 manager()->GetFromID(cell_id)->ToBrowserAccessibilityWin(); | 1284 manager()->GetFromID(cell_id)->ToBrowserAccessibilityWin(); |
| 1285 int col_index; | 1285 int col_index; |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1374 ui::AX_ATTR_TABLE_COLUMN_COUNT, &columns) || | 1374 ui::AX_ATTR_TABLE_COLUMN_COUNT, &columns) || |
| 1375 !GetIntAttribute(ui::AX_ATTR_TABLE_ROW_COUNT, &rows) || | 1375 !GetIntAttribute(ui::AX_ATTR_TABLE_ROW_COUNT, &rows) || |
| 1376 columns <= 0 || | 1376 columns <= 0 || |
| 1377 rows <= 0) { | 1377 rows <= 0) { |
| 1378 return S_FALSE; | 1378 return S_FALSE; |
| 1379 } | 1379 } |
| 1380 | 1380 |
| 1381 if (row < 0 || row >= rows) | 1381 if (row < 0 || row >= rows) |
| 1382 return E_INVALIDARG; | 1382 return E_INVALIDARG; |
| 1383 | 1383 |
| 1384 const std::vector<int32>& cell_ids = GetIntListAttribute( | 1384 const std::vector<int32_t>& cell_ids = |
| 1385 ui::AX_ATTR_CELL_IDS); | 1385 GetIntListAttribute(ui::AX_ATTR_CELL_IDS); |
| 1386 for (int i = 0; i < columns; ++i) { | 1386 for (int i = 0; i < columns; ++i) { |
| 1387 int cell_id = cell_ids[row * columns + i]; | 1387 int cell_id = cell_ids[row * columns + i]; |
| 1388 BrowserAccessibilityWin* cell = | 1388 BrowserAccessibilityWin* cell = |
| 1389 manager()->GetFromID(cell_id)->ToBrowserAccessibilityWin(); | 1389 manager()->GetFromID(cell_id)->ToBrowserAccessibilityWin(); |
| 1390 if (cell && cell->GetRole() == ui::AX_ROLE_ROW_HEADER) { | 1390 if (cell && cell->GetRole() == ui::AX_ROLE_ROW_HEADER) { |
| 1391 base::string16 cell_name = cell->GetString16Attribute( | 1391 base::string16 cell_name = cell->GetString16Attribute( |
| 1392 ui::AX_ATTR_NAME); | 1392 ui::AX_ATTR_NAME); |
| 1393 if (cell_name.size() > 0) { | 1393 if (cell_name.size() > 0) { |
| 1394 *description = SysAllocString(cell_name.c_str()); | 1394 *description = SysAllocString(cell_name.c_str()); |
| 1395 return S_OK; | 1395 return S_OK; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1420 ui::AX_ATTR_TABLE_COLUMN_COUNT, &columns) || | 1420 ui::AX_ATTR_TABLE_COLUMN_COUNT, &columns) || |
| 1421 !GetIntAttribute(ui::AX_ATTR_TABLE_ROW_COUNT, &rows) || | 1421 !GetIntAttribute(ui::AX_ATTR_TABLE_ROW_COUNT, &rows) || |
| 1422 columns <= 0 || | 1422 columns <= 0 || |
| 1423 rows <= 0) { | 1423 rows <= 0) { |
| 1424 return S_FALSE; | 1424 return S_FALSE; |
| 1425 } | 1425 } |
| 1426 | 1426 |
| 1427 if (row < 0 || row >= rows || column < 0 || column >= columns) | 1427 if (row < 0 || row >= rows || column < 0 || column >= columns) |
| 1428 return E_INVALIDARG; | 1428 return E_INVALIDARG; |
| 1429 | 1429 |
| 1430 const std::vector<int32>& cell_ids = GetIntListAttribute( | 1430 const std::vector<int32_t>& cell_ids = |
| 1431 ui::AX_ATTR_CELL_IDS); | 1431 GetIntListAttribute(ui::AX_ATTR_CELL_IDS); |
| 1432 int cell_id = cell_ids[row * columns + column]; | 1432 int cell_id = cell_ids[row * columns + column]; |
| 1433 BrowserAccessibilityWin* cell = | 1433 BrowserAccessibilityWin* cell = |
| 1434 manager()->GetFromID(cell_id)->ToBrowserAccessibilityWin(); | 1434 manager()->GetFromID(cell_id)->ToBrowserAccessibilityWin(); |
| 1435 int rowspan; | 1435 int rowspan; |
| 1436 if (cell && | 1436 if (cell && |
| 1437 cell->GetIntAttribute( | 1437 cell->GetIntAttribute( |
| 1438 ui::AX_ATTR_TABLE_CELL_ROW_SPAN, &rowspan) && | 1438 ui::AX_ATTR_TABLE_CELL_ROW_SPAN, &rowspan) && |
| 1439 rowspan >= 1) { | 1439 rowspan >= 1) { |
| 1440 *n_rows_spanned = rowspan; | 1440 *n_rows_spanned = rowspan; |
| 1441 return S_OK; | 1441 return S_OK; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1452 } | 1452 } |
| 1453 | 1453 |
| 1454 STDMETHODIMP BrowserAccessibilityWin::get_rowIndex(long cell_index, | 1454 STDMETHODIMP BrowserAccessibilityWin::get_rowIndex(long cell_index, |
| 1455 long* row_index) { | 1455 long* row_index) { |
| 1456 if (!instance_active()) | 1456 if (!instance_active()) |
| 1457 return E_FAIL; | 1457 return E_FAIL; |
| 1458 | 1458 |
| 1459 if (!row_index) | 1459 if (!row_index) |
| 1460 return E_INVALIDARG; | 1460 return E_INVALIDARG; |
| 1461 | 1461 |
| 1462 const std::vector<int32>& unique_cell_ids = GetIntListAttribute( | 1462 const std::vector<int32_t>& unique_cell_ids = |
| 1463 ui::AX_ATTR_UNIQUE_CELL_IDS); | 1463 GetIntListAttribute(ui::AX_ATTR_UNIQUE_CELL_IDS); |
| 1464 int cell_id_count = static_cast<int>(unique_cell_ids.size()); | 1464 int cell_id_count = static_cast<int>(unique_cell_ids.size()); |
| 1465 if (cell_index < 0) | 1465 if (cell_index < 0) |
| 1466 return E_INVALIDARG; | 1466 return E_INVALIDARG; |
| 1467 if (cell_index >= cell_id_count) | 1467 if (cell_index >= cell_id_count) |
| 1468 return S_FALSE; | 1468 return S_FALSE; |
| 1469 | 1469 |
| 1470 int cell_id = unique_cell_ids[cell_index]; | 1470 int cell_id = unique_cell_ids[cell_index]; |
| 1471 BrowserAccessibilityWin* cell = | 1471 BrowserAccessibilityWin* cell = |
| 1472 manager()->GetFromID(cell_id)->ToBrowserAccessibilityWin(); | 1472 manager()->GetFromID(cell_id)->ToBrowserAccessibilityWin(); |
| 1473 int cell_row_index; | 1473 int cell_row_index; |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1581 long* column, | 1581 long* column, |
| 1582 long* row_extents, | 1582 long* row_extents, |
| 1583 long* column_extents, | 1583 long* column_extents, |
| 1584 boolean* is_selected) { | 1584 boolean* is_selected) { |
| 1585 if (!instance_active()) | 1585 if (!instance_active()) |
| 1586 return E_FAIL; | 1586 return E_FAIL; |
| 1587 | 1587 |
| 1588 if (!row || !column || !row_extents || !column_extents || !is_selected) | 1588 if (!row || !column || !row_extents || !column_extents || !is_selected) |
| 1589 return E_INVALIDARG; | 1589 return E_INVALIDARG; |
| 1590 | 1590 |
| 1591 const std::vector<int32>& unique_cell_ids = GetIntListAttribute( | 1591 const std::vector<int32_t>& unique_cell_ids = |
| 1592 ui::AX_ATTR_UNIQUE_CELL_IDS); | 1592 GetIntListAttribute(ui::AX_ATTR_UNIQUE_CELL_IDS); |
| 1593 int cell_id_count = static_cast<int>(unique_cell_ids.size()); | 1593 int cell_id_count = static_cast<int>(unique_cell_ids.size()); |
| 1594 if (index < 0) | 1594 if (index < 0) |
| 1595 return E_INVALIDARG; | 1595 return E_INVALIDARG; |
| 1596 if (index >= cell_id_count) | 1596 if (index >= cell_id_count) |
| 1597 return S_FALSE; | 1597 return S_FALSE; |
| 1598 | 1598 |
| 1599 int cell_id = unique_cell_ids[index]; | 1599 int cell_id = unique_cell_ids[index]; |
| 1600 BrowserAccessibilityWin* cell = | 1600 BrowserAccessibilityWin* cell = |
| 1601 manager()->GetFromID(cell_id)->ToBrowserAccessibilityWin(); | 1601 manager()->GetFromID(cell_id)->ToBrowserAccessibilityWin(); |
| 1602 int rowspan; | 1602 int rowspan; |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1744 int rows; | 1744 int rows; |
| 1745 if (!table->GetIntAttribute( | 1745 if (!table->GetIntAttribute( |
| 1746 ui::AX_ATTR_TABLE_COLUMN_COUNT, &columns) || | 1746 ui::AX_ATTR_TABLE_COLUMN_COUNT, &columns) || |
| 1747 !table->GetIntAttribute( | 1747 !table->GetIntAttribute( |
| 1748 ui::AX_ATTR_TABLE_ROW_COUNT, &rows)) { | 1748 ui::AX_ATTR_TABLE_ROW_COUNT, &rows)) { |
| 1749 return S_FALSE; | 1749 return S_FALSE; |
| 1750 } | 1750 } |
| 1751 if (columns <= 0 || rows <= 0 || column < 0 || column >= columns) | 1751 if (columns <= 0 || rows <= 0 || column < 0 || column >= columns) |
| 1752 return S_FALSE; | 1752 return S_FALSE; |
| 1753 | 1753 |
| 1754 const std::vector<int32>& cell_ids = table->GetIntListAttribute( | 1754 const std::vector<int32_t>& cell_ids = |
| 1755 ui::AX_ATTR_CELL_IDS); | 1755 table->GetIntListAttribute(ui::AX_ATTR_CELL_IDS); |
| 1756 | 1756 |
| 1757 for (int i = 0; i < rows; ++i) { | 1757 for (int i = 0; i < rows; ++i) { |
| 1758 int cell_id = cell_ids[i * columns + column]; | 1758 int cell_id = cell_ids[i * columns + column]; |
| 1759 BrowserAccessibilityWin* cell = | 1759 BrowserAccessibilityWin* cell = |
| 1760 manager()->GetFromID(cell_id)->ToBrowserAccessibilityWin(); | 1760 manager()->GetFromID(cell_id)->ToBrowserAccessibilityWin(); |
| 1761 if (cell && cell->GetRole() == ui::AX_ROLE_COLUMN_HEADER) | 1761 if (cell && cell->GetRole() == ui::AX_ROLE_COLUMN_HEADER) |
| 1762 (*n_column_header_cells)++; | 1762 (*n_column_header_cells)++; |
| 1763 } | 1763 } |
| 1764 | 1764 |
| 1765 *cell_accessibles = static_cast<IUnknown**>(CoTaskMemAlloc( | 1765 *cell_accessibles = static_cast<IUnknown**>(CoTaskMemAlloc( |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1842 int rows; | 1842 int rows; |
| 1843 if (!table->GetIntAttribute( | 1843 if (!table->GetIntAttribute( |
| 1844 ui::AX_ATTR_TABLE_COLUMN_COUNT, &columns) || | 1844 ui::AX_ATTR_TABLE_COLUMN_COUNT, &columns) || |
| 1845 !table->GetIntAttribute( | 1845 !table->GetIntAttribute( |
| 1846 ui::AX_ATTR_TABLE_ROW_COUNT, &rows)) { | 1846 ui::AX_ATTR_TABLE_ROW_COUNT, &rows)) { |
| 1847 return S_FALSE; | 1847 return S_FALSE; |
| 1848 } | 1848 } |
| 1849 if (columns <= 0 || rows <= 0 || row < 0 || row >= rows) | 1849 if (columns <= 0 || rows <= 0 || row < 0 || row >= rows) |
| 1850 return S_FALSE; | 1850 return S_FALSE; |
| 1851 | 1851 |
| 1852 const std::vector<int32>& cell_ids = table->GetIntListAttribute( | 1852 const std::vector<int32_t>& cell_ids = |
| 1853 ui::AX_ATTR_CELL_IDS); | 1853 table->GetIntListAttribute(ui::AX_ATTR_CELL_IDS); |
| 1854 | 1854 |
| 1855 for (int i = 0; i < columns; ++i) { | 1855 for (int i = 0; i < columns; ++i) { |
| 1856 int cell_id = cell_ids[row * columns + i]; | 1856 int cell_id = cell_ids[row * columns + i]; |
| 1857 BrowserAccessibility* cell = manager()->GetFromID(cell_id); | 1857 BrowserAccessibility* cell = manager()->GetFromID(cell_id); |
| 1858 if (cell && cell->GetRole() == ui::AX_ROLE_ROW_HEADER) | 1858 if (cell && cell->GetRole() == ui::AX_ROLE_ROW_HEADER) |
| 1859 (*n_row_header_cells)++; | 1859 (*n_row_header_cells)++; |
| 1860 } | 1860 } |
| 1861 | 1861 |
| 1862 *cell_accessibles = static_cast<IUnknown**>(CoTaskMemAlloc( | 1862 *cell_accessibles = static_cast<IUnknown**>(CoTaskMemAlloc( |
| 1863 (*n_row_header_cells) * sizeof(cell_accessibles[0]))); | 1863 (*n_row_header_cells) * sizeof(cell_accessibles[0]))); |
| (...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2396 IAccessibleHyperlink** hyperlink) { | 2396 IAccessibleHyperlink** hyperlink) { |
| 2397 if (!instance_active()) | 2397 if (!instance_active()) |
| 2398 return E_FAIL; | 2398 return E_FAIL; |
| 2399 | 2399 |
| 2400 if (!hyperlink || | 2400 if (!hyperlink || |
| 2401 index < 0 || | 2401 index < 0 || |
| 2402 index >= static_cast<long>(hyperlinks().size())) { | 2402 index >= static_cast<long>(hyperlinks().size())) { |
| 2403 return E_INVALIDARG; | 2403 return E_INVALIDARG; |
| 2404 } | 2404 } |
| 2405 | 2405 |
| 2406 int32 id = hyperlinks()[index]; | 2406 int32_t id = hyperlinks()[index]; |
| 2407 BrowserAccessibilityWin* child = | 2407 BrowserAccessibilityWin* child = |
| 2408 manager()->GetFromID(id)->ToBrowserAccessibilityWin(); | 2408 manager()->GetFromID(id)->ToBrowserAccessibilityWin(); |
| 2409 if (child) { | 2409 if (child) { |
| 2410 *hyperlink = static_cast<IAccessibleHyperlink*>(child->NewReference()); | 2410 *hyperlink = static_cast<IAccessibleHyperlink*>(child->NewReference()); |
| 2411 return S_OK; | 2411 return S_OK; |
| 2412 } | 2412 } |
| 2413 | 2413 |
| 2414 return E_FAIL; | 2414 return E_FAIL; |
| 2415 } | 2415 } |
| 2416 | 2416 |
| 2417 STDMETHODIMP BrowserAccessibilityWin::get_hyperlinkIndex( | 2417 STDMETHODIMP BrowserAccessibilityWin::get_hyperlinkIndex( |
| 2418 long char_index, | 2418 long char_index, |
| 2419 long* hyperlink_index) { | 2419 long* hyperlink_index) { |
| 2420 if (!instance_active()) | 2420 if (!instance_active()) |
| 2421 return E_FAIL; | 2421 return E_FAIL; |
| 2422 | 2422 |
| 2423 if (!hyperlink_index) | 2423 if (!hyperlink_index) |
| 2424 return E_INVALIDARG; | 2424 return E_INVALIDARG; |
| 2425 | 2425 |
| 2426 if (char_index < 0 || | 2426 if (char_index < 0 || |
| 2427 char_index >= static_cast<long>(hypertext().size())) { | 2427 char_index >= static_cast<long>(hypertext().size())) { |
| 2428 return E_INVALIDARG; | 2428 return E_INVALIDARG; |
| 2429 } | 2429 } |
| 2430 | 2430 |
| 2431 std::map<int32, int32>::iterator it = | 2431 std::map<int32_t, int32_t>::iterator it = |
| 2432 hyperlink_offset_to_index().find(char_index); | 2432 hyperlink_offset_to_index().find(char_index); |
| 2433 if (it == hyperlink_offset_to_index().end()) { | 2433 if (it == hyperlink_offset_to_index().end()) { |
| 2434 *hyperlink_index = -1; | 2434 *hyperlink_index = -1; |
| 2435 return S_FALSE; | 2435 return S_FALSE; |
| 2436 } | 2436 } |
| 2437 | 2437 |
| 2438 *hyperlink_index = it->second; | 2438 *hyperlink_index = it->second; |
| 2439 return S_OK; | 2439 return S_OK; |
| 2440 } | 2440 } |
| 2441 | 2441 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2493 return S_OK; | 2493 return S_OK; |
| 2494 } | 2494 } |
| 2495 | 2495 |
| 2496 STDMETHODIMP BrowserAccessibilityWin::get_startIndex(long* index) { | 2496 STDMETHODIMP BrowserAccessibilityWin::get_startIndex(long* index) { |
| 2497 if (!instance_active() || !IsHyperlink()) | 2497 if (!instance_active() || !IsHyperlink()) |
| 2498 return E_FAIL; | 2498 return E_FAIL; |
| 2499 | 2499 |
| 2500 if (!index) | 2500 if (!index) |
| 2501 return E_INVALIDARG; | 2501 return E_INVALIDARG; |
| 2502 | 2502 |
| 2503 int32 hypertext_offset = 0; | 2503 int32_t hypertext_offset = 0; |
| 2504 const auto parent = GetParent(); | 2504 const auto parent = GetParent(); |
| 2505 if (parent) { | 2505 if (parent) { |
| 2506 hypertext_offset = | 2506 hypertext_offset = |
| 2507 parent->ToBrowserAccessibilityWin()->GetHypertextOffsetFromChild(*this); | 2507 parent->ToBrowserAccessibilityWin()->GetHypertextOffsetFromChild(*this); |
| 2508 } | 2508 } |
| 2509 *index = static_cast<LONG>(hypertext_offset); | 2509 *index = static_cast<LONG>(hypertext_offset); |
| 2510 return S_OK; | 2510 return S_OK; |
| 2511 } | 2511 } |
| 2512 | 2512 |
| 2513 STDMETHODIMP BrowserAccessibilityWin::get_endIndex(long* index) { | 2513 STDMETHODIMP BrowserAccessibilityWin::get_endIndex(long* index) { |
| (...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3205 // | 3205 // |
| 3206 | 3206 |
| 3207 // static | 3207 // static |
| 3208 HRESULT WINAPI BrowserAccessibilityWin::InternalQueryInterface( | 3208 HRESULT WINAPI BrowserAccessibilityWin::InternalQueryInterface( |
| 3209 void* this_ptr, | 3209 void* this_ptr, |
| 3210 const _ATL_INTMAP_ENTRY* entries, | 3210 const _ATL_INTMAP_ENTRY* entries, |
| 3211 REFIID iid, | 3211 REFIID iid, |
| 3212 void** object) { | 3212 void** object) { |
| 3213 BrowserAccessibilityWin* accessibility = | 3213 BrowserAccessibilityWin* accessibility = |
| 3214 reinterpret_cast<BrowserAccessibilityWin*>(this_ptr); | 3214 reinterpret_cast<BrowserAccessibilityWin*>(this_ptr); |
| 3215 int32 ia_role = accessibility->ia_role(); | 3215 int32_t ia_role = accessibility->ia_role(); |
| 3216 if (iid == IID_IAccessibleImage) { | 3216 if (iid == IID_IAccessibleImage) { |
| 3217 if (ia_role != ROLE_SYSTEM_GRAPHIC) { | 3217 if (ia_role != ROLE_SYSTEM_GRAPHIC) { |
| 3218 *object = NULL; | 3218 *object = NULL; |
| 3219 return E_NOINTERFACE; | 3219 return E_NOINTERFACE; |
| 3220 } | 3220 } |
| 3221 } else if (iid == IID_IAccessibleTable || iid == IID_IAccessibleTable2) { | 3221 } else if (iid == IID_IAccessibleTable || iid == IID_IAccessibleTable2) { |
| 3222 if (ia_role != ROLE_SYSTEM_TABLE) { | 3222 if (ia_role != ROLE_SYSTEM_TABLE) { |
| 3223 *object = NULL; | 3223 *object = NULL; |
| 3224 return E_NOINTERFACE; | 3224 return E_NOINTERFACE; |
| 3225 } | 3225 } |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3305 "container-atomic"); | 3305 "container-atomic"); |
| 3306 BoolAttributeToIA2(ui::AX_ATTR_CONTAINER_LIVE_BUSY, | 3306 BoolAttributeToIA2(ui::AX_ATTR_CONTAINER_LIVE_BUSY, |
| 3307 "container-busy"); | 3307 "container-busy"); |
| 3308 | 3308 |
| 3309 // Expose table cell index. | 3309 // Expose table cell index. |
| 3310 if (IsCellOrTableHeaderRole()) { | 3310 if (IsCellOrTableHeaderRole()) { |
| 3311 BrowserAccessibility* table = GetParent(); | 3311 BrowserAccessibility* table = GetParent(); |
| 3312 while (table && table->GetRole() != ui::AX_ROLE_TABLE) | 3312 while (table && table->GetRole() != ui::AX_ROLE_TABLE) |
| 3313 table = table->GetParent(); | 3313 table = table->GetParent(); |
| 3314 if (table) { | 3314 if (table) { |
| 3315 const std::vector<int32>& unique_cell_ids = table->GetIntListAttribute( | 3315 const std::vector<int32_t>& unique_cell_ids = |
| 3316 ui::AX_ATTR_UNIQUE_CELL_IDS); | 3316 table->GetIntListAttribute(ui::AX_ATTR_UNIQUE_CELL_IDS); |
| 3317 for (size_t i = 0; i < unique_cell_ids.size(); ++i) { | 3317 for (size_t i = 0; i < unique_cell_ids.size(); ++i) { |
| 3318 if (unique_cell_ids[i] == GetId()) { | 3318 if (unique_cell_ids[i] == GetId()) { |
| 3319 win_attributes_->ia2_attributes.push_back( | 3319 win_attributes_->ia2_attributes.push_back( |
| 3320 base::string16(L"table-cell-index:") + base::IntToString16(i)); | 3320 base::string16(L"table-cell-index:") + base::IntToString16(i)); |
| 3321 } | 3321 } |
| 3322 } | 3322 } |
| 3323 } | 3323 } |
| 3324 } | 3324 } |
| 3325 | 3325 |
| 3326 // Expose invalid state for form controls and elements with aria-invalid. | 3326 // Expose invalid state for form controls and elements with aria-invalid. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 3355 win_attributes_->ia2_attributes.push_back(L"invalid:true"); | 3355 win_attributes_->ia2_attributes.push_back(L"invalid:true"); |
| 3356 } | 3356 } |
| 3357 } | 3357 } |
| 3358 break; | 3358 break; |
| 3359 default: | 3359 default: |
| 3360 NOTREACHED(); | 3360 NOTREACHED(); |
| 3361 } | 3361 } |
| 3362 } | 3362 } |
| 3363 | 3363 |
| 3364 // Expose row or column header sort direction. | 3364 // Expose row or column header sort direction. |
| 3365 int32 sort_direction; | 3365 int32_t sort_direction; |
| 3366 if ((ia_role() == ROLE_SYSTEM_COLUMNHEADER || | 3366 if ((ia_role() == ROLE_SYSTEM_COLUMNHEADER || |
| 3367 ia_role() == ROLE_SYSTEM_ROWHEADER) && | 3367 ia_role() == ROLE_SYSTEM_ROWHEADER) && |
| 3368 GetIntAttribute(ui::AX_ATTR_SORT_DIRECTION, &sort_direction)) { | 3368 GetIntAttribute(ui::AX_ATTR_SORT_DIRECTION, &sort_direction)) { |
| 3369 switch (sort_direction) { | 3369 switch (sort_direction) { |
| 3370 case ui::AX_SORT_DIRECTION_UNSORTED: | 3370 case ui::AX_SORT_DIRECTION_UNSORTED: |
| 3371 win_attributes_->ia2_attributes.push_back(L"sort:none"); | 3371 win_attributes_->ia2_attributes.push_back(L"sort:none"); |
| 3372 break; | 3372 break; |
| 3373 case ui::AX_SORT_DIRECTION_ASCENDING: | 3373 case ui::AX_SORT_DIRECTION_ASCENDING: |
| 3374 win_attributes_->ia2_attributes.push_back(L"sort:ascending"); | 3374 win_attributes_->ia2_attributes.push_back(L"sort:ascending"); |
| 3375 break; | 3375 break; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3439 // the character index of each embedded object character to the id of the | 3439 // the character index of each embedded object character to the id of the |
| 3440 // child object it points to. | 3440 // child object it points to. |
| 3441 for (unsigned int i = 0; i < PlatformChildCount(); ++i) { | 3441 for (unsigned int i = 0; i < PlatformChildCount(); ++i) { |
| 3442 BrowserAccessibilityWin* child = | 3442 BrowserAccessibilityWin* child = |
| 3443 PlatformGetChild(i)->ToBrowserAccessibilityWin(); | 3443 PlatformGetChild(i)->ToBrowserAccessibilityWin(); |
| 3444 DCHECK(child); | 3444 DCHECK(child); |
| 3445 // Similar to Firefox, we don't expose text-only objects in IA2 hypertext. | 3445 // Similar to Firefox, we don't expose text-only objects in IA2 hypertext. |
| 3446 if (child->IsTextOnlyObject()) { | 3446 if (child->IsTextOnlyObject()) { |
| 3447 win_attributes_->hypertext += child->name(); | 3447 win_attributes_->hypertext += child->name(); |
| 3448 } else { | 3448 } else { |
| 3449 int32 char_offset = hypertext().size(); | 3449 int32_t char_offset = hypertext().size(); |
| 3450 int32 child_id = child->GetId(); | 3450 int32_t child_id = child->GetId(); |
| 3451 int32 index = hyperlinks().size(); | 3451 int32_t index = hyperlinks().size(); |
| 3452 win_attributes_->hyperlink_offset_to_index[char_offset] = index; | 3452 win_attributes_->hyperlink_offset_to_index[char_offset] = index; |
| 3453 win_attributes_->hyperlinks.push_back(child_id); | 3453 win_attributes_->hyperlinks.push_back(child_id); |
| 3454 win_attributes_->hypertext += kEmbeddedCharacter; | 3454 win_attributes_->hypertext += kEmbeddedCharacter; |
| 3455 } | 3455 } |
| 3456 } | 3456 } |
| 3457 } | 3457 } |
| 3458 | 3458 |
| 3459 void BrowserAccessibilityWin::UpdateStep3FireEvents(bool is_subtree_creation) { | 3459 void BrowserAccessibilityWin::UpdateStep3FireEvents(bool is_subtree_creation) { |
| 3460 BrowserAccessibilityManagerWin* manager = | 3460 BrowserAccessibilityManagerWin* manager = |
| 3461 this->manager()->ToBrowserAccessibilityManagerWin(); | 3461 this->manager()->ToBrowserAccessibilityManagerWin(); |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3658 const char* ia2_attr) { | 3658 const char* ia2_attr) { |
| 3659 int value; | 3659 int value; |
| 3660 if (GetIntAttribute(attribute, &value)) { | 3660 if (GetIntAttribute(attribute, &value)) { |
| 3661 win_attributes_->ia2_attributes.push_back( | 3661 win_attributes_->ia2_attributes.push_back( |
| 3662 base::ASCIIToUTF16(ia2_attr) + L":" + | 3662 base::ASCIIToUTF16(ia2_attr) + L":" + |
| 3663 base::IntToString16(value)); | 3663 base::IntToString16(value)); |
| 3664 } | 3664 } |
| 3665 } | 3665 } |
| 3666 | 3666 |
| 3667 bool BrowserAccessibilityWin::IsHyperlink() const { | 3667 bool BrowserAccessibilityWin::IsHyperlink() const { |
| 3668 int32 hyperlink_index = -1; | 3668 int32_t hyperlink_index = -1; |
| 3669 const auto parent = GetParent(); | 3669 const auto parent = GetParent(); |
| 3670 if (parent) { | 3670 if (parent) { |
| 3671 hyperlink_index = | 3671 hyperlink_index = |
| 3672 parent->ToBrowserAccessibilityWin()->GetHyperlinkIndexFromChild(*this); | 3672 parent->ToBrowserAccessibilityWin()->GetHyperlinkIndexFromChild(*this); |
| 3673 } | 3673 } |
| 3674 | 3674 |
| 3675 if (hyperlink_index >= 0) | 3675 if (hyperlink_index >= 0) |
| 3676 return true; | 3676 return true; |
| 3677 return false; | 3677 return false; |
| 3678 } | 3678 } |
| 3679 | 3679 |
| 3680 int32 BrowserAccessibilityWin::GetHyperlinkIndexFromChild( | 3680 int32_t BrowserAccessibilityWin::GetHyperlinkIndexFromChild( |
| 3681 const BrowserAccessibilityWin& child) const { | 3681 const BrowserAccessibilityWin& child) const { |
| 3682 if (hyperlinks().empty()) | 3682 if (hyperlinks().empty()) |
| 3683 return -1; | 3683 return -1; |
| 3684 | 3684 |
| 3685 auto iterator = std::find( | 3685 auto iterator = std::find( |
| 3686 hyperlinks().begin(), hyperlinks().end(), child.GetId()); | 3686 hyperlinks().begin(), hyperlinks().end(), child.GetId()); |
| 3687 if (iterator == hyperlinks().end()) | 3687 if (iterator == hyperlinks().end()) |
| 3688 return -1; | 3688 return -1; |
| 3689 | 3689 |
| 3690 return static_cast<int32>(iterator - hyperlinks().begin()); | 3690 return static_cast<int32_t>(iterator - hyperlinks().begin()); |
| 3691 } | 3691 } |
| 3692 | 3692 |
| 3693 int32 BrowserAccessibilityWin::GetHypertextOffsetFromHyperlinkIndex( | 3693 int32_t BrowserAccessibilityWin::GetHypertextOffsetFromHyperlinkIndex( |
| 3694 int32 hyperlink_index) const { | 3694 int32_t hyperlink_index) const { |
| 3695 for (auto& offset_index : hyperlink_offset_to_index()) { | 3695 for (auto& offset_index : hyperlink_offset_to_index()) { |
| 3696 if (offset_index.second == hyperlink_index) | 3696 if (offset_index.second == hyperlink_index) |
| 3697 return offset_index.first; | 3697 return offset_index.first; |
| 3698 } | 3698 } |
| 3699 | 3699 |
| 3700 return -1; | 3700 return -1; |
| 3701 } | 3701 } |
| 3702 | 3702 |
| 3703 int32 BrowserAccessibilityWin::GetHypertextOffsetFromChild( | 3703 int32_t BrowserAccessibilityWin::GetHypertextOffsetFromChild( |
| 3704 const BrowserAccessibilityWin& child) const { | 3704 const BrowserAccessibilityWin& child) const { |
| 3705 DCHECK(child.GetParent() == this); | 3705 DCHECK(child.GetParent() == this); |
| 3706 | 3706 |
| 3707 // Handle the case when we are dealing with a direct text-only child. | 3707 // Handle the case when we are dealing with a direct text-only child. |
| 3708 // (Note that this object might be a platform leaf, e.g. an ARIA searchbox, | 3708 // (Note that this object might be a platform leaf, e.g. an ARIA searchbox, |
| 3709 // and so InternalChild... functions need to be used. Also, direct text-only | 3709 // and so InternalChild... functions need to be used. Also, direct text-only |
| 3710 // children should not be present at tree roots and so no cross-tree traversal | 3710 // children should not be present at tree roots and so no cross-tree traversal |
| 3711 // is necessary.) | 3711 // is necessary.) |
| 3712 if (child.IsTextOnlyObject()) { | 3712 if (child.IsTextOnlyObject()) { |
| 3713 int32 hypertextOffset = 0; | 3713 int32_t hypertextOffset = 0; |
| 3714 int32 index_in_parent = child.GetIndexInParent(); | 3714 int32_t index_in_parent = child.GetIndexInParent(); |
| 3715 DCHECK_GE(index_in_parent, 0); | 3715 DCHECK_GE(index_in_parent, 0); |
| 3716 DCHECK_LT(index_in_parent, static_cast<int32>(InternalChildCount())); | 3716 DCHECK_LT(index_in_parent, static_cast<int32_t>(InternalChildCount())); |
| 3717 for (uint32 i = 0; i < static_cast<uint32>(index_in_parent); ++i) { | 3717 for (uint32_t i = 0; i < static_cast<uint32_t>(index_in_parent); ++i) { |
| 3718 const BrowserAccessibilityWin* sibling = | 3718 const BrowserAccessibilityWin* sibling = |
| 3719 InternalGetChild(i)->ToBrowserAccessibilityWin(); | 3719 InternalGetChild(i)->ToBrowserAccessibilityWin(); |
| 3720 DCHECK(sibling); | 3720 DCHECK(sibling); |
| 3721 if (sibling->IsTextOnlyObject()) | 3721 if (sibling->IsTextOnlyObject()) |
| 3722 hypertextOffset += sibling->hypertext().length(); | 3722 hypertextOffset += sibling->hypertext().length(); |
| 3723 else | 3723 else |
| 3724 ++hypertextOffset; | 3724 ++hypertextOffset; |
| 3725 } | 3725 } |
| 3726 return hypertextOffset; | 3726 return hypertextOffset; |
| 3727 } | 3727 } |
| 3728 | 3728 |
| 3729 int32 hyperlink_index = GetHyperlinkIndexFromChild(child); | 3729 int32_t hyperlink_index = GetHyperlinkIndexFromChild(child); |
| 3730 if (hyperlink_index < 0) | 3730 if (hyperlink_index < 0) |
| 3731 return -1; | 3731 return -1; |
| 3732 | 3732 |
| 3733 return GetHypertextOffsetFromHyperlinkIndex(hyperlink_index); | 3733 return GetHypertextOffsetFromHyperlinkIndex(hyperlink_index); |
| 3734 } | 3734 } |
| 3735 | 3735 |
| 3736 int32 BrowserAccessibilityWin::GetHypertextOffsetFromDescendant( | 3736 int32_t BrowserAccessibilityWin::GetHypertextOffsetFromDescendant( |
| 3737 const BrowserAccessibilityWin& descendant) const { | 3737 const BrowserAccessibilityWin& descendant) const { |
| 3738 auto parent_object = descendant.GetParent()->ToBrowserAccessibilityWin(); | 3738 auto parent_object = descendant.GetParent()->ToBrowserAccessibilityWin(); |
| 3739 auto current_object = const_cast<BrowserAccessibilityWin*>(&descendant); | 3739 auto current_object = const_cast<BrowserAccessibilityWin*>(&descendant); |
| 3740 while (parent_object && parent_object != this) { | 3740 while (parent_object && parent_object != this) { |
| 3741 current_object = parent_object; | 3741 current_object = parent_object; |
| 3742 parent_object = current_object->GetParent()->ToBrowserAccessibilityWin(); | 3742 parent_object = current_object->GetParent()->ToBrowserAccessibilityWin(); |
| 3743 } | 3743 } |
| 3744 if (!parent_object) | 3744 if (!parent_object) |
| 3745 return -1; | 3745 return -1; |
| 3746 | 3746 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 3760 // Either 0 or text_length should be returned depending on the direction that | 3760 // Either 0 or text_length should be returned depending on the direction that |
| 3761 // one needs to travel to find the endpoint. | 3761 // one needs to travel to find the endpoint. |
| 3762 | 3762 |
| 3763 // Case 1. | 3763 // Case 1. |
| 3764 // | 3764 // |
| 3765 // IsDescendantOf includes the case when endpoint_object == this. | 3765 // IsDescendantOf includes the case when endpoint_object == this. |
| 3766 if (IsDescendantOf(&endpoint_object)) | 3766 if (IsDescendantOf(&endpoint_object)) |
| 3767 return endpoint_offset; | 3767 return endpoint_offset; |
| 3768 | 3768 |
| 3769 const BrowserAccessibility* common_parent = this; | 3769 const BrowserAccessibility* common_parent = this; |
| 3770 int32 index_in_common_parent = GetIndexInParent(); | 3770 int32_t index_in_common_parent = GetIndexInParent(); |
| 3771 while (common_parent && !endpoint_object.IsDescendantOf(common_parent)) { | 3771 while (common_parent && !endpoint_object.IsDescendantOf(common_parent)) { |
| 3772 index_in_common_parent = common_parent->GetIndexInParent(); | 3772 index_in_common_parent = common_parent->GetIndexInParent(); |
| 3773 common_parent = common_parent->GetParent(); | 3773 common_parent = common_parent->GetParent(); |
| 3774 } | 3774 } |
| 3775 if (!common_parent) | 3775 if (!common_parent) |
| 3776 return -1; | 3776 return -1; |
| 3777 | 3777 |
| 3778 DCHECK_GE(index_in_common_parent, 0); | 3778 DCHECK_GE(index_in_common_parent, 0); |
| 3779 DCHECK(!(common_parent->IsTextOnlyObject())); | 3779 DCHECK(!(common_parent->IsTextOnlyObject())); |
| 3780 | 3780 |
| 3781 // Case 2. | 3781 // Case 2. |
| 3782 // | 3782 // |
| 3783 // We already checked in case 1 if our endpoint is inside this object. | 3783 // We already checked in case 1 if our endpoint is inside this object. |
| 3784 // We can safely assume that it is a descendant or in a completely different | 3784 // We can safely assume that it is a descendant or in a completely different |
| 3785 // part of the tree. | 3785 // part of the tree. |
| 3786 if (common_parent == this) { | 3786 if (common_parent == this) { |
| 3787 int32 hypertext_offset = GetHypertextOffsetFromDescendant(endpoint_object); | 3787 int32_t hypertext_offset = |
| 3788 GetHypertextOffsetFromDescendant(endpoint_object); |
| 3788 if (endpoint_object.GetParent() == this && | 3789 if (endpoint_object.GetParent() == this && |
| 3789 endpoint_object.IsTextOnlyObject()) { | 3790 endpoint_object.IsTextOnlyObject()) { |
| 3790 hypertext_offset += endpoint_offset; | 3791 hypertext_offset += endpoint_offset; |
| 3791 } | 3792 } |
| 3792 | 3793 |
| 3793 return hypertext_offset; | 3794 return hypertext_offset; |
| 3794 } | 3795 } |
| 3795 | 3796 |
| 3796 // Case 3. | 3797 // Case 3. |
| 3797 // | 3798 // |
| 3798 // We can safely assume that the endpoint is in another part of the tree or | 3799 // We can safely assume that the endpoint is in another part of the tree or |
| 3799 // at common parent, and that this object is a descendant of common parent. | 3800 // at common parent, and that this object is a descendant of common parent. |
| 3800 int32 endpoint_index_in_common_parent = -1; | 3801 int32_t endpoint_index_in_common_parent = -1; |
| 3801 for (uint32 i = 0; i < common_parent->InternalChildCount(); ++i) { | 3802 for (uint32_t i = 0; i < common_parent->InternalChildCount(); ++i) { |
| 3802 const BrowserAccessibility* child = common_parent->InternalGetChild(i); | 3803 const BrowserAccessibility* child = common_parent->InternalGetChild(i); |
| 3803 DCHECK(child); | 3804 DCHECK(child); |
| 3804 if (endpoint_object.IsDescendantOf(child)) { | 3805 if (endpoint_object.IsDescendantOf(child)) { |
| 3805 endpoint_index_in_common_parent = child->GetIndexInParent(); | 3806 endpoint_index_in_common_parent = child->GetIndexInParent(); |
| 3806 break; | 3807 break; |
| 3807 } | 3808 } |
| 3808 } | 3809 } |
| 3809 DCHECK_GE(endpoint_index_in_common_parent, 0); | 3810 DCHECK_GE(endpoint_index_in_common_parent, 0); |
| 3810 | 3811 |
| 3811 if (endpoint_index_in_common_parent < index_in_common_parent) | 3812 if (endpoint_index_in_common_parent < index_in_common_parent) |
| 3812 return 0; | 3813 return 0; |
| 3813 if (endpoint_index_in_common_parent > index_in_common_parent) | 3814 if (endpoint_index_in_common_parent > index_in_common_parent) |
| 3814 return hypertext().length(); | 3815 return hypertext().length(); |
| 3815 | 3816 |
| 3816 NOTREACHED(); | 3817 NOTREACHED(); |
| 3817 return -1; | 3818 return -1; |
| 3818 } | 3819 } |
| 3819 | 3820 |
| 3820 int BrowserAccessibilityWin::GetSelectionAnchor() const { | 3821 int BrowserAccessibilityWin::GetSelectionAnchor() const { |
| 3821 int32 anchor_id = manager()->GetTreeData().sel_anchor_object_id; | 3822 int32_t anchor_id = manager()->GetTreeData().sel_anchor_object_id; |
| 3822 const auto anchor_object = | 3823 const auto anchor_object = |
| 3823 manager()->GetFromID(anchor_id)->ToBrowserAccessibilityWin(); | 3824 manager()->GetFromID(anchor_id)->ToBrowserAccessibilityWin(); |
| 3824 if (!anchor_object) | 3825 if (!anchor_object) |
| 3825 return -1; | 3826 return -1; |
| 3826 | 3827 |
| 3827 int anchor_offset = manager()->GetTreeData().sel_anchor_offset; | 3828 int anchor_offset = manager()->GetTreeData().sel_anchor_offset; |
| 3828 return GetHypertextOffsetFromEndpoint(*anchor_object, anchor_offset); | 3829 return GetHypertextOffsetFromEndpoint(*anchor_object, anchor_offset); |
| 3829 } | 3830 } |
| 3830 | 3831 |
| 3831 int BrowserAccessibilityWin::GetSelectionFocus() const { | 3832 int BrowserAccessibilityWin::GetSelectionFocus() const { |
| 3832 int32 focus_id = manager()->GetTreeData().sel_focus_object_id; | 3833 int32_t focus_id = manager()->GetTreeData().sel_focus_object_id; |
| 3833 const auto focus_object = | 3834 const auto focus_object = |
| 3834 manager()->GetFromID(focus_id)->ToBrowserAccessibilityWin(); | 3835 manager()->GetFromID(focus_id)->ToBrowserAccessibilityWin(); |
| 3835 if (!focus_object) | 3836 if (!focus_object) |
| 3836 return -1; | 3837 return -1; |
| 3837 | 3838 |
| 3838 int focus_offset = manager()->GetTreeData().sel_focus_offset; | 3839 int focus_offset = manager()->GetTreeData().sel_focus_offset; |
| 3839 return GetHypertextOffsetFromEndpoint(*focus_object, focus_offset); | 3840 return GetHypertextOffsetFromEndpoint(*focus_object, focus_offset); |
| 3840 } | 3841 } |
| 3841 | 3842 |
| 3842 void BrowserAccessibilityWin::GetSelectionOffsets( | 3843 void BrowserAccessibilityWin::GetSelectionOffsets( |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3920 // characters directly. | 3921 // characters directly. |
| 3921 base::char16 old_ch = old_win_attributes_->hypertext[old_char_index]; | 3922 base::char16 old_ch = old_win_attributes_->hypertext[old_char_index]; |
| 3922 base::char16 new_ch = win_attributes_->hypertext[new_char_index]; | 3923 base::char16 new_ch = win_attributes_->hypertext[new_char_index]; |
| 3923 if (old_ch != new_ch) | 3924 if (old_ch != new_ch) |
| 3924 return false; | 3925 return false; |
| 3925 if (old_ch == new_ch && new_ch != kEmbeddedCharacter) | 3926 if (old_ch == new_ch && new_ch != kEmbeddedCharacter) |
| 3926 return true; | 3927 return true; |
| 3927 | 3928 |
| 3928 // If it's an embedded character, they're only identical if the child id | 3929 // If it's an embedded character, they're only identical if the child id |
| 3929 // the hyperlink points to is the same. | 3930 // the hyperlink points to is the same. |
| 3930 std::map<int32, int32>& old_offset_to_index = | 3931 std::map<int32_t, int32_t>& old_offset_to_index = |
| 3931 old_win_attributes_->hyperlink_offset_to_index; | 3932 old_win_attributes_->hyperlink_offset_to_index; |
| 3932 std::vector<int32>& old_hyperlinks = old_win_attributes_->hyperlinks; | 3933 std::vector<int32_t>& old_hyperlinks = old_win_attributes_->hyperlinks; |
| 3933 int32 old_hyperlinks_count = static_cast<int32>(old_hyperlinks.size()); | 3934 int32_t old_hyperlinks_count = static_cast<int32_t>(old_hyperlinks.size()); |
| 3934 std::map<int32, int32>::iterator iter; | 3935 std::map<int32_t, int32_t>::iterator iter; |
| 3935 iter = old_offset_to_index.find(old_char_index); | 3936 iter = old_offset_to_index.find(old_char_index); |
| 3936 int old_index = (iter != old_offset_to_index.end()) ? iter->second : -1; | 3937 int old_index = (iter != old_offset_to_index.end()) ? iter->second : -1; |
| 3937 int old_child_id = (old_index >= 0 && old_index < old_hyperlinks_count) ? | 3938 int old_child_id = (old_index >= 0 && old_index < old_hyperlinks_count) ? |
| 3938 old_hyperlinks[old_index] : -1; | 3939 old_hyperlinks[old_index] : -1; |
| 3939 | 3940 |
| 3940 std::map<int32, int32>& new_offset_to_index = | 3941 std::map<int32_t, int32_t>& new_offset_to_index = |
| 3941 win_attributes_->hyperlink_offset_to_index; | 3942 win_attributes_->hyperlink_offset_to_index; |
| 3942 std::vector<int32>& new_hyperlinks = win_attributes_->hyperlinks; | 3943 std::vector<int32_t>& new_hyperlinks = win_attributes_->hyperlinks; |
| 3943 int32 new_hyperlinks_count = static_cast<int32>(new_hyperlinks.size()); | 3944 int32_t new_hyperlinks_count = static_cast<int32_t>(new_hyperlinks.size()); |
| 3944 iter = new_offset_to_index.find(new_char_index); | 3945 iter = new_offset_to_index.find(new_char_index); |
| 3945 int new_index = (iter != new_offset_to_index.end()) ? iter->second : -1; | 3946 int new_index = (iter != new_offset_to_index.end()) ? iter->second : -1; |
| 3946 int new_child_id = (new_index >= 0 && new_index < new_hyperlinks_count) ? | 3947 int new_child_id = (new_index >= 0 && new_index < new_hyperlinks_count) ? |
| 3947 new_hyperlinks[new_index] : -1; | 3948 new_hyperlinks[new_index] : -1; |
| 3948 | 3949 |
| 3949 return old_child_id == new_child_id; | 3950 return old_child_id == new_child_id; |
| 3950 } | 3951 } |
| 3951 | 3952 |
| 3952 void BrowserAccessibilityWin::ComputeHypertextRemovedAndInserted( | 3953 void BrowserAccessibilityWin::ComputeHypertextRemovedAndInserted( |
| 3953 int* start, int* old_len, int* new_len) { | 3954 int* start, int* old_len, int* new_len) { |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4014 LONG BrowserAccessibilityWin::FindBoundary( | 4015 LONG BrowserAccessibilityWin::FindBoundary( |
| 4015 const base::string16& text, | 4016 const base::string16& text, |
| 4016 IA2TextBoundaryType ia2_boundary, | 4017 IA2TextBoundaryType ia2_boundary, |
| 4017 LONG start_offset, | 4018 LONG start_offset, |
| 4018 ui::TextBoundaryDirection direction) { | 4019 ui::TextBoundaryDirection direction) { |
| 4019 HandleSpecialTextOffset(text, &start_offset); | 4020 HandleSpecialTextOffset(text, &start_offset); |
| 4020 if (ia2_boundary == IA2_TEXT_BOUNDARY_WORD && IsSimpleTextControl()) | 4021 if (ia2_boundary == IA2_TEXT_BOUNDARY_WORD && IsSimpleTextControl()) |
| 4021 return GetWordStartBoundary(static_cast<int>(start_offset), direction); | 4022 return GetWordStartBoundary(static_cast<int>(start_offset), direction); |
| 4022 | 4023 |
| 4023 ui::TextBoundaryType boundary = IA2TextBoundaryToTextBoundary(ia2_boundary); | 4024 ui::TextBoundaryType boundary = IA2TextBoundaryToTextBoundary(ia2_boundary); |
| 4024 const std::vector<int32>& line_breaks = GetIntListAttribute( | 4025 const std::vector<int32_t>& line_breaks = |
| 4025 ui::AX_ATTR_LINE_BREAKS); | 4026 GetIntListAttribute(ui::AX_ATTR_LINE_BREAKS); |
| 4026 return ui::FindAccessibleTextBoundary( | 4027 return ui::FindAccessibleTextBoundary( |
| 4027 text, line_breaks, boundary, start_offset, direction); | 4028 text, line_breaks, boundary, start_offset, direction); |
| 4028 } | 4029 } |
| 4029 | 4030 |
| 4030 BrowserAccessibilityWin* BrowserAccessibilityWin::GetFromID(int32 id) { | 4031 BrowserAccessibilityWin* BrowserAccessibilityWin::GetFromID(int32_t id) { |
| 4031 return manager()->GetFromID(id)->ToBrowserAccessibilityWin(); | 4032 return manager()->GetFromID(id)->ToBrowserAccessibilityWin(); |
| 4032 } | 4033 } |
| 4033 | 4034 |
| 4034 bool BrowserAccessibilityWin::IsListBoxOptionOrMenuListOption() { | 4035 bool BrowserAccessibilityWin::IsListBoxOptionOrMenuListOption() { |
| 4035 if (!GetParent()) | 4036 if (!GetParent()) |
| 4036 return false; | 4037 return false; |
| 4037 | 4038 |
| 4038 int32 role = GetRole(); | 4039 int32_t role = GetRole(); |
| 4039 int32 parent_role = GetParent()->GetRole(); | 4040 int32_t parent_role = GetParent()->GetRole(); |
| 4040 | 4041 |
| 4041 if (role == ui::AX_ROLE_LIST_BOX_OPTION && | 4042 if (role == ui::AX_ROLE_LIST_BOX_OPTION && |
| 4042 parent_role == ui::AX_ROLE_LIST_BOX) { | 4043 parent_role == ui::AX_ROLE_LIST_BOX) { |
| 4043 return true; | 4044 return true; |
| 4044 } | 4045 } |
| 4045 | 4046 |
| 4046 if (role == ui::AX_ROLE_MENU_LIST_OPTION && | 4047 if (role == ui::AX_ROLE_MENU_LIST_OPTION && |
| 4047 parent_role == ui::AX_ROLE_MENU_LIST_POPUP) { | 4048 parent_role == ui::AX_ROLE_MENU_LIST_POPUP) { |
| 4048 return true; | 4049 return true; |
| 4049 } | 4050 } |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4113 win_attributes_->ia2_attributes.push_back(L"text-input-type:" + type); | 4114 win_attributes_->ia2_attributes.push_back(L"text-input-type:" + type); |
| 4114 } | 4115 } |
| 4115 } | 4116 } |
| 4116 | 4117 |
| 4117 void BrowserAccessibilityWin::AddRelations( | 4118 void BrowserAccessibilityWin::AddRelations( |
| 4118 ui::AXIntListAttribute src_attr, | 4119 ui::AXIntListAttribute src_attr, |
| 4119 const base::string16& iaccessiblerelation_type) { | 4120 const base::string16& iaccessiblerelation_type) { |
| 4120 if (!HasIntListAttribute(src_attr)) | 4121 if (!HasIntListAttribute(src_attr)) |
| 4121 return; | 4122 return; |
| 4122 | 4123 |
| 4123 const std::vector<int32>& ids = GetIntListAttribute(src_attr); | 4124 const std::vector<int32_t>& ids = GetIntListAttribute(src_attr); |
| 4124 for (size_t i = 0; i < ids.size(); ++i) { | 4125 for (size_t i = 0; i < ids.size(); ++i) { |
| 4125 CComObject<BrowserAccessibilityRelation>* relation; | 4126 CComObject<BrowserAccessibilityRelation>* relation; |
| 4126 HRESULT hr = CComObject<BrowserAccessibilityRelation>::CreateInstance( | 4127 HRESULT hr = CComObject<BrowserAccessibilityRelation>::CreateInstance( |
| 4127 &relation); | 4128 &relation); |
| 4128 DCHECK(SUCCEEDED(hr)); | 4129 DCHECK(SUCCEEDED(hr)); |
| 4129 relation->AddRef(); | 4130 relation->AddRef(); |
| 4130 relation->Initialize(this, iaccessiblerelation_type); | 4131 relation->Initialize(this, iaccessiblerelation_type); |
| 4131 relation->AddTarget(ids[i]); | 4132 relation->AddTarget(ids[i]); |
| 4132 relations_.push_back(relation); | 4133 relations_.push_back(relation); |
| 4133 } | 4134 } |
| 4134 } | 4135 } |
| 4135 | 4136 |
| 4136 void BrowserAccessibilityWin::InitRoleAndState() { | 4137 void BrowserAccessibilityWin::InitRoleAndState() { |
| 4137 int32 ia_role = 0; | 4138 int32_t ia_role = 0; |
| 4138 int32 ia_state = 0; | 4139 int32_t ia_state = 0; |
| 4139 base::string16 role_name; | 4140 base::string16 role_name; |
| 4140 int32 ia2_role = 0; | 4141 int32_t ia2_role = 0; |
| 4141 int32 ia2_state = IA2_STATE_OPAQUE; | 4142 int32_t ia2_state = IA2_STATE_OPAQUE; |
| 4142 | 4143 |
| 4143 if (HasState(ui::AX_STATE_BUSY)) | 4144 if (HasState(ui::AX_STATE_BUSY)) |
| 4144 ia_state |= STATE_SYSTEM_BUSY; | 4145 ia_state |= STATE_SYSTEM_BUSY; |
| 4145 if (HasState(ui::AX_STATE_CHECKED)) | 4146 if (HasState(ui::AX_STATE_CHECKED)) |
| 4146 ia_state |= STATE_SYSTEM_CHECKED; | 4147 ia_state |= STATE_SYSTEM_CHECKED; |
| 4147 if (HasState(ui::AX_STATE_COLLAPSED)) | 4148 if (HasState(ui::AX_STATE_COLLAPSED)) |
| 4148 ia_state |= STATE_SYSTEM_COLLAPSED; | 4149 ia_state |= STATE_SYSTEM_COLLAPSED; |
| 4149 if (HasState(ui::AX_STATE_EXPANDED)) | 4150 if (HasState(ui::AX_STATE_EXPANDED)) |
| 4150 ia_state |= STATE_SYSTEM_EXPANDED; | 4151 ia_state |= STATE_SYSTEM_EXPANDED; |
| 4151 if (HasState(ui::AX_STATE_FOCUSABLE)) | 4152 if (HasState(ui::AX_STATE_FOCUSABLE)) |
| (...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4680 ia2_role = ia_role; | 4681 ia2_role = ia_role; |
| 4681 | 4682 |
| 4682 win_attributes_->ia_role = ia_role; | 4683 win_attributes_->ia_role = ia_role; |
| 4683 win_attributes_->ia_state = ia_state; | 4684 win_attributes_->ia_state = ia_state; |
| 4684 win_attributes_->role_name = role_name; | 4685 win_attributes_->role_name = role_name; |
| 4685 win_attributes_->ia2_role = ia2_role; | 4686 win_attributes_->ia2_role = ia2_role; |
| 4686 win_attributes_->ia2_state = ia2_state; | 4687 win_attributes_->ia2_state = ia2_state; |
| 4687 } | 4688 } |
| 4688 | 4689 |
| 4689 } // namespace content | 4690 } // namespace content |
| OLD | NEW |