 Chromium Code Reviews
 Chromium Code Reviews Issue 2967493005:
  Use MSAA_Role directly from BrowserAccessibility.  (Closed)
    
  
    Issue 2967493005:
  Use MSAA_Role directly from BrowserAccessibility.  (Closed) 
  | OLD | NEW | 
|---|---|
| 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 1171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1182 } | 1182 } | 
| 1183 | 1183 | 
| 1184 *object = nullptr; | 1184 *object = nullptr; | 
| 1185 return E_FAIL; | 1185 return E_FAIL; | 
| 1186 } | 1186 } | 
| 1187 | 1187 | 
| 1188 // | 1188 // | 
| 1189 // Private member functions. | 1189 // Private member functions. | 
| 1190 // | 1190 // | 
| 1191 int AXPlatformNodeWin::MSAARole() { | 1191 int AXPlatformNodeWin::MSAARole() { | 
| 1192 // If this is a web area for a presentational iframe, give it a role of | |
| 1193 // something other than DOCUMENT so that the fact that it's a separate doc | |
| 1194 // is not exposed to AT. | |
| 1195 if (IsWebAreaForPresentationalIframe()) { | |
| 1196 return ROLE_SYSTEM_GROUPING; | |
| 1197 } | |
| 1198 | |
| 1192 switch (GetData().role) { | 1199 switch (GetData().role) { | 
| 1193 case ui::AX_ROLE_ALERT: | 1200 case ui::AX_ROLE_ALERT: | 
| 1194 return ROLE_SYSTEM_ALERT; | 1201 return ROLE_SYSTEM_ALERT; | 
| 1195 | 1202 | 
| 1196 case ui::AX_ROLE_ALERT_DIALOG: | 1203 case ui::AX_ROLE_ALERT_DIALOG: | 
| 1197 return ROLE_SYSTEM_DIALOG; | 1204 return ROLE_SYSTEM_DIALOG; | 
| 1198 | 1205 | 
| 1199 case ui::AX_ROLE_ANCHOR: | 1206 case ui::AX_ROLE_ANCHOR: | 
| 1200 return ROLE_SYSTEM_LINK; | 1207 return ROLE_SYSTEM_LINK; | 
| 1201 | 1208 | 
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1360 | 1367 | 
| 1361 case ui::AX_ROLE_MENU_ITEM_RADIO: | 1368 case ui::AX_ROLE_MENU_ITEM_RADIO: | 
| 1362 return ROLE_SYSTEM_MENUITEM; | 1369 return ROLE_SYSTEM_MENUITEM; | 
| 1363 | 1370 | 
| 1364 case ui::AX_ROLE_MENU_LIST_POPUP: | 1371 case ui::AX_ROLE_MENU_LIST_POPUP: | 
| 1365 return ROLE_SYSTEM_LIST; | 1372 return ROLE_SYSTEM_LIST; | 
| 1366 | 1373 | 
| 1367 case ui::AX_ROLE_MENU_LIST_OPTION: | 1374 case ui::AX_ROLE_MENU_LIST_OPTION: | 
| 1368 return ROLE_SYSTEM_LISTITEM; | 1375 return ROLE_SYSTEM_LISTITEM; | 
| 1369 | 1376 | 
| 1377 case ui::AX_ROLE_METER: | |
| 1378 return ROLE_SYSTEM_PROGRESSBAR; | |
| 1379 | |
| 1370 case ui::AX_ROLE_NAVIGATION: | 1380 case ui::AX_ROLE_NAVIGATION: | 
| 1371 return ROLE_SYSTEM_GROUPING; | 1381 return ROLE_SYSTEM_GROUPING; | 
| 1372 | 1382 | 
| 1373 case ui::AX_ROLE_NOTE: | 1383 case ui::AX_ROLE_NOTE: | 
| 1374 return ROLE_SYSTEM_GROUPING; | 1384 return ROLE_SYSTEM_GROUPING; | 
| 1375 | 1385 | 
| 1376 case ui::AX_ROLE_OUTLINE: | 1386 case ui::AX_ROLE_OUTLINE: | 
| 1377 return ROLE_SYSTEM_OUTLINE; | 1387 return ROLE_SYSTEM_OUTLINE; | 
| 1378 | 1388 | 
| 1379 case ui::AX_ROLE_POP_UP_BUTTON: { | 1389 case ui::AX_ROLE_POP_UP_BUTTON: { | 
| (...skipping 17 matching lines...) Expand all Loading... | |
| 1397 case ui::AX_ROLE_REGION: { | 1407 case ui::AX_ROLE_REGION: { | 
| 1398 std::string html_tag = GetData().GetStringAttribute(ui::AX_ATTR_HTML_TAG); | 1408 std::string html_tag = GetData().GetStringAttribute(ui::AX_ATTR_HTML_TAG); | 
| 1399 if (html_tag == "section") | 1409 if (html_tag == "section") | 
| 1400 return ROLE_SYSTEM_GROUPING; | 1410 return ROLE_SYSTEM_GROUPING; | 
| 1401 return ROLE_SYSTEM_PANE; | 1411 return ROLE_SYSTEM_PANE; | 
| 1402 } | 1412 } | 
| 1403 | 1413 | 
| 1404 case ui::AX_ROLE_ROW: { | 1414 case ui::AX_ROLE_ROW: { | 
| 1405 // Role changes depending on whether row is inside a treegrid | 1415 // Role changes depending on whether row is inside a treegrid | 
| 1406 // https://www.w3.org/TR/core-aam-1.1/#role-map-row | 1416 // https://www.w3.org/TR/core-aam-1.1/#role-map-row | 
| 1407 auto* container = FromNativeViewAccessible(GetParent()); | 1417 return IsInTreeGrid() ? ROLE_SYSTEM_OUTLINEITEM : ROLE_SYSTEM_ROW; | 
| 1408 if (container && container->GetData().role == ui::AX_ROLE_GROUP) { | |
| 1409 // If parent was a rowgroup, we need to look at the grandparent | |
| 1410 container = FromNativeViewAccessible(container->GetParent()); | |
| 1411 } | |
| 1412 | |
| 1413 if (!container) | |
| 1414 return ROLE_SYSTEM_ROW; | |
| 1415 | |
| 1416 return ROLE_SYSTEM_OUTLINEITEM; | |
| 1417 } | 1418 } | 
| 1418 | 1419 | 
| 1419 case ui::AX_ROLE_ROW_HEADER: | 1420 case ui::AX_ROLE_ROW_HEADER: | 
| 1420 return ROLE_SYSTEM_ROWHEADER; | 1421 return ROLE_SYSTEM_ROWHEADER; | 
| 1421 | 1422 | 
| 1422 case ui::AX_ROLE_RUBY: | 1423 case ui::AX_ROLE_RUBY: | 
| 1423 return ROLE_SYSTEM_TEXT; | 1424 return ROLE_SYSTEM_TEXT; | 
| 1424 | 1425 | 
| 1425 case ui::AX_ROLE_RULER: | 1426 case ui::AX_ROLE_RULER: | 
| 1426 return ROLE_SYSTEM_CLIENT; | 1427 return ROLE_SYSTEM_CLIENT; | 
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1506 | 1507 | 
| 1507 case ui::AX_ROLE_LINE_BREAK: | 1508 case ui::AX_ROLE_LINE_BREAK: | 
| 1508 return ROLE_SYSTEM_WHITESPACE; | 1509 return ROLE_SYSTEM_WHITESPACE; | 
| 1509 | 1510 | 
| 1510 case ui::AX_ROLE_VIDEO: | 1511 case ui::AX_ROLE_VIDEO: | 
| 1511 return ROLE_SYSTEM_GROUPING; | 1512 return ROLE_SYSTEM_GROUPING; | 
| 1512 | 1513 | 
| 1513 case ui::AX_ROLE_WINDOW: | 1514 case ui::AX_ROLE_WINDOW: | 
| 1514 return ROLE_SYSTEM_WINDOW; | 1515 return ROLE_SYSTEM_WINDOW; | 
| 1515 | 1516 | 
| 1516 // TODO(dmazzoni): figure out the proper MSAA role for roles not called out | 1517 // TODO(dmazzoni): figure out the proper MSAA role for roles listed below. | 
| 1517 // here. | 1518 case AX_ROLE_BLOCKQUOTE: | 
| 1518 default: | 1519 case AX_ROLE_BUTTON_DROP_DOWN: | 
| 1520 case AX_ROLE_CARET: | |
| 1521 case AX_ROLE_CLIENT: | |
| 1522 case AX_ROLE_DEFINITION: | |
| 1523 case AX_ROLE_DESKTOP: | |
| 1524 case AX_ROLE_DIRECTORY: | |
| 1525 case AX_ROLE_FIGCAPTION: | |
| 1526 case AX_ROLE_FOOTER: | |
| 1527 case AX_ROLE_FORM: | |
| 1528 case AX_ROLE_IGNORED: | |
| 1529 case AX_ROLE_IMAGE_MAP: | |
| 1530 case AX_ROLE_INLINE_TEXT_BOX: | |
| 1531 case AX_ROLE_LOCATION_BAR: | |
| 1532 case AX_ROLE_LOG: | |
| 1533 case AX_ROLE_NONE: | |
| 1534 case AX_ROLE_PANE: | |
| 1535 case AX_ROLE_PARAGRAPH: | |
| 1536 case AX_ROLE_PRESENTATIONAL: | |
| 1537 case AX_ROLE_SEAMLESS_WEB_AREA: | |
| 1538 case AX_ROLE_SLIDER_THUMB: | |
| 1539 case AX_ROLE_SWITCH: | |
| 1540 case AX_ROLE_TAB_GROUP: | |
| 1541 case AX_ROLE_TITLE_BAR: | |
| 1542 case AX_ROLE_UNKNOWN: | |
| 1543 case AX_ROLE_WEB_VIEW: | |
| 1519 return ROLE_SYSTEM_CLIENT; | 1544 return ROLE_SYSTEM_CLIENT; | 
| 1520 } | 1545 } | 
| 1546 | |
| 1547 NOTREACHED(); | |
| 1548 return ROLE_SYSTEM_CLIENT; | |
| 1521 } | 1549 } | 
| 1522 | 1550 | 
| 1523 std::string AXPlatformNodeWin::StringOverrideForMSAARole() { | 1551 std::string AXPlatformNodeWin::StringOverrideForMSAARole() { | 
| 1524 std::string html_tag = GetData().GetStringAttribute(ui::AX_ATTR_HTML_TAG); | 1552 std::string html_tag = GetData().GetStringAttribute(ui::AX_ATTR_HTML_TAG); | 
| 1525 | 1553 | 
| 1526 switch (GetData().role) { | 1554 switch (GetData().role) { | 
| 1527 case ui::AX_ROLE_BLOCKQUOTE: | 1555 case ui::AX_ROLE_BLOCKQUOTE: | 
| 1528 case ui::AX_ROLE_DEFINITION: | 1556 case ui::AX_ROLE_DEFINITION: | 
| 1529 case ui::AX_ROLE_IMAGE_MAP: | 1557 case ui::AX_ROLE_IMAGE_MAP: | 
| 1530 return html_tag; | 1558 return html_tag; | 
| (...skipping 26 matching lines...) Expand all Loading... | |
| 1557 case ui::AX_ROLE_SWITCH: | 1585 case ui::AX_ROLE_SWITCH: | 
| 1558 return "switch"; | 1586 return "switch"; | 
| 1559 | 1587 | 
| 1560 default: | 1588 default: | 
| 1561 return ""; | 1589 return ""; | 
| 1562 } | 1590 } | 
| 1563 | 1591 | 
| 1564 return ""; | 1592 return ""; | 
| 1565 } | 1593 } | 
| 1566 | 1594 | 
| 1595 bool AXPlatformNodeWin::IsWebAreaForPresentationalIframe() { | |
| 1596 if (GetData().role != ui::AX_ROLE_WEB_AREA && | |
| 1597 GetData().role != ui::AX_ROLE_ROOT_WEB_AREA) { | |
| 1598 return false; | |
| 1599 } | |
| 1600 | |
| 1601 auto* parent = FromNativeViewAccessible(GetParent()); | |
| 1602 if (!parent) | |
| 1603 return false; | |
| 1604 | |
| 1605 return parent->GetData().role == ui::AX_ROLE_IFRAME_PRESENTATIONAL; | |
| 1606 } | |
| 1607 | |
| 1567 bool AXPlatformNodeWin::ShouldNodeHaveReadonlyState( | 1608 bool AXPlatformNodeWin::ShouldNodeHaveReadonlyState( | 
| 1568 const AXNodeData& data) const { | 1609 const AXNodeData& data) const { | 
| 1569 if (data.GetBoolAttribute(ui::AX_ATTR_ARIA_READONLY)) | 1610 if (data.GetBoolAttribute(ui::AX_ATTR_ARIA_READONLY)) | 
| 1570 return true; | 1611 return true; | 
| 1571 | 1612 | 
| 1572 if (!data.HasState(ui::AX_STATE_READ_ONLY)) | 1613 if (!data.HasState(ui::AX_STATE_READ_ONLY)) | 
| 1573 return false; | 1614 return false; | 
| 1574 | 1615 | 
| 1575 switch (data.role) { | 1616 switch (data.role) { | 
| 1576 case ui::AX_ROLE_ARTICLE: | 1617 case ui::AX_ROLE_ARTICLE: | 
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1884 return nullptr; | 1925 return nullptr; | 
| 1885 | 1926 | 
| 1886 AXPlatformNodeBase* base = | 1927 AXPlatformNodeBase* base = | 
| 1887 FromNativeViewAccessible(node->GetNativeViewAccessible()); | 1928 FromNativeViewAccessible(node->GetNativeViewAccessible()); | 
| 1888 if (base && !IsDescendant(base)) | 1929 if (base && !IsDescendant(base)) | 
| 1889 base = nullptr; | 1930 base = nullptr; | 
| 1890 | 1931 | 
| 1891 return static_cast<AXPlatformNodeWin*>(base); | 1932 return static_cast<AXPlatformNodeWin*>(base); | 
| 1892 } | 1933 } | 
| 1893 | 1934 | 
| 1935 bool AXPlatformNodeWin::IsInTreeGrid() { | |
| 1936 auto* container = FromNativeViewAccessible(GetParent()); | |
| 1937 | |
| 1938 if (container && container->GetData().role == ui::AX_ROLE_GROUP) { | |
| 1939 // If parent was a rowgroup, we need to look at the grandparent | |
| 
dmazzoni
2017/07/06 22:48:28
nit: move comment above and get rid of {}
 
dougt
2017/07/11 17:37:44
Done.
 | |
| 1940 container = FromNativeViewAccessible(container->GetParent()); | |
| 1941 } | |
| 1942 | |
| 1943 if (!container) { | |
| 
dmazzoni
2017/07/06 22:48:28
nit: remove {}
 
dougt
2017/07/11 17:37:44
Done.
 | |
| 1944 return false; | |
| 1945 } | |
| 1946 | |
| 1947 return container->GetData().role == ui::AX_ROLE_TREE_GRID; | |
| 1948 } | |
| 1949 | |
| 1894 } // namespace ui | 1950 } // namespace ui | 
| OLD | NEW |