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 <execinfo.h> | 5 #include <execinfo.h> |
6 | 6 |
7 #import "content/browser/accessibility/browser_accessibility_cocoa.h" | 7 #import "content/browser/accessibility/browser_accessibility_cocoa.h" |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 | 10 |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
280 { NSAccessibilityVisibleCellsAttribute, @"visibleCells" }, | 280 { NSAccessibilityVisibleCellsAttribute, @"visibleCells" }, |
281 { NSAccessibilityVisibleColumnsAttribute, @"visibleColumns" }, | 281 { NSAccessibilityVisibleColumnsAttribute, @"visibleColumns" }, |
282 { NSAccessibilityVisibleRowsAttribute, @"visibleRows" }, | 282 { NSAccessibilityVisibleRowsAttribute, @"visibleRows" }, |
283 { NSAccessibilityWindowAttribute, @"window" }, | 283 { NSAccessibilityWindowAttribute, @"window" }, |
284 { @"AXAccessKey", @"accessKey" }, | 284 { @"AXAccessKey", @"accessKey" }, |
285 { @"AXARIAAtomic", @"ariaAtomic" }, | 285 { @"AXARIAAtomic", @"ariaAtomic" }, |
286 { @"AXARIABusy", @"ariaBusy" }, | 286 { @"AXARIABusy", @"ariaBusy" }, |
287 { @"AXARIALive", @"ariaLive" }, | 287 { @"AXARIALive", @"ariaLive" }, |
288 { @"AXARIARelevant", @"ariaRelevant" }, | 288 { @"AXARIARelevant", @"ariaRelevant" }, |
289 { @"AXInvalid", @"invalid" }, | 289 { @"AXInvalid", @"invalid" }, |
290 { @"AXLinkedUIElements", @"linkedUIElements" }, | |
David Tseng
2014/03/12 00:30:56
This is a native OS X attribute,s o let's use
NSAc
aboxhall
2014/03/12 17:50:47
Done.
| |
290 { @"AXLoaded", @"loaded" }, | 291 { @"AXLoaded", @"loaded" }, |
291 { @"AXLoadingProgress", @"loadingProgress" }, | 292 { @"AXLoadingProgress", @"loadingProgress" }, |
292 { @"AXRequired", @"required" }, | 293 { @"AXRequired", @"required" }, |
293 { @"AXVisited", @"visited" }, | 294 { @"AXVisited", @"visited" }, |
294 }; | 295 }; |
295 | 296 |
296 NSMutableDictionary* dict = [[NSMutableDictionary alloc] init]; | 297 NSMutableDictionary* dict = [[NSMutableDictionary alloc] init]; |
297 const size_t numAttributes = sizeof(attributeToMethodNameContainer) / | 298 const size_t numAttributes = sizeof(attributeToMethodNameContainer) / |
298 sizeof(attributeToMethodNameContainer[0]); | 299 sizeof(attributeToMethodNameContainer[0]); |
299 for (size_t i = 0; i < numAttributes; ++i) { | 300 for (size_t i = 0; i < numAttributes; ++i) { |
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
844 | 845 |
845 - (id)titleUIElement { | 846 - (id)titleUIElement { |
846 int titleElementId; | 847 int titleElementId; |
847 if (browserAccessibility_->GetIntAttribute( | 848 if (browserAccessibility_->GetIntAttribute( |
848 ui::AX_ATTR_TITLE_UI_ELEMENT, &titleElementId)) { | 849 ui::AX_ATTR_TITLE_UI_ELEMENT, &titleElementId)) { |
849 BrowserAccessibility* titleElement = | 850 BrowserAccessibility* titleElement = |
850 browserAccessibility_->manager()->GetFromRendererID(titleElementId); | 851 browserAccessibility_->manager()->GetFromRendererID(titleElementId); |
851 if (titleElement) | 852 if (titleElement) |
852 return titleElement->ToBrowserAccessibilityCocoa(); | 853 return titleElement->ToBrowserAccessibilityCocoa(); |
853 } | 854 } |
855 std::vector<int32> labelledby_ids = | |
856 browserAccessibility_->GetIntListAttribute(ui::AX_ATTR_LABELLEDBY_IDS); | |
857 if (labelledby_ids.size() == 1) { | |
David Tseng
2014/03/12 00:30:56
This is an interesting case.
Mac, unfortunately,
aboxhall
2014/03/12 17:50:47
I don't completely follow, sorry. The spec says:
I
David Tseng
2014/03/12 18:30:17
No; this is Mac specific:
NSString *const NSAccess
aboxhall
2014/03/12 20:51:47
Added TODO as discussed.
| |
858 BrowserAccessibility* titleElement = | |
859 browserAccessibility_->manager()->GetFromRendererID(labelledby_ids[0]); | |
860 if (titleElement) | |
861 return titleElement->ToBrowserAccessibilityCocoa(); | |
862 } | |
863 | |
854 return nil; | 864 return nil; |
855 } | 865 } |
856 | 866 |
867 - (NSArray*)linkedUIElements { | |
David Tseng
2014/03/12 00:30:56
Keep these methods sorted.
aboxhall
2014/03/12 17:50:47
Done.
| |
868 NSMutableArray* ret = [[[NSMutableArray alloc] init] autorelease]; | |
869 const std::vector<int32>& ownsIds = | |
870 browserAccessibility_->GetIntListAttribute(ui::AX_ATTR_OWNS_IDS); | |
dmazzoni
2014/03/11 23:37:52
These are all analogous, maybe a helper function t
aboxhall
2014/03/12 17:50:47
Done.
| |
871 for (size_t i = 0; i < ownsIds.size(); ++i) { | |
872 BrowserAccessibility* ownsElement = | |
873 browserAccessibility_->manager()->GetFromRendererID(ownsIds[i]); | |
874 if (ownsElement) | |
875 [ret addObject:ownsElement->ToBrowserAccessibilityCocoa()]; | |
876 } | |
877 const std::vector<int32>& controlsIds = | |
878 browserAccessibility_->GetIntListAttribute(ui::AX_ATTR_CONTROLS_IDS); | |
879 for (size_t i = 0; i < controlsIds.size(); ++i) { | |
880 BrowserAccessibility* controlsElement = | |
881 browserAccessibility_->manager()->GetFromRendererID(controlsIds[i]); | |
882 if (controlsElement) | |
883 [ret addObject:controlsElement->ToBrowserAccessibilityCocoa()]; | |
884 } | |
885 const std::vector<int32>& flowtoIds = | |
886 browserAccessibility_->GetIntListAttribute(ui::AX_ATTR_FLOWTO_IDS); | |
887 for (size_t i = 0; i < flowtoIds.size(); ++i) { | |
888 BrowserAccessibility* flowtoElement = | |
889 browserAccessibility_->manager()->GetFromRendererID(flowtoIds[i]); | |
890 if (flowtoElement) | |
891 [ret addObject:flowtoElement->ToBrowserAccessibilityCocoa()]; | |
892 } | |
893 if ([ret count] == 0) | |
894 return nil; | |
895 return ret; | |
896 } | |
897 | |
857 - (NSString*)url { | 898 - (NSString*)url { |
858 StringAttribute urlAttribute = | 899 StringAttribute urlAttribute = |
859 [[self role] isEqualToString:@"AXWebArea"] ? | 900 [[self role] isEqualToString:@"AXWebArea"] ? |
860 ui::AX_ATTR_DOC_URL : | 901 ui::AX_ATTR_DOC_URL : |
861 ui::AX_ATTR_URL; | 902 ui::AX_ATTR_URL; |
862 return NSStringForStringAttribute(browserAccessibility_, urlAttribute); | 903 return NSStringForStringAttribute(browserAccessibility_, urlAttribute); |
863 } | 904 } |
864 | 905 |
865 - (id)value { | 906 - (id)value { |
866 // WebCore uses an attachmentView to get the below behavior. | 907 // WebCore uses an attachmentView to get the below behavior. |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1250 NSAccessibilitySubroleAttribute, | 1291 NSAccessibilitySubroleAttribute, |
1251 NSAccessibilityTitleAttribute, | 1292 NSAccessibilityTitleAttribute, |
1252 NSAccessibilityTopLevelUIElementAttribute, | 1293 NSAccessibilityTopLevelUIElementAttribute, |
1253 NSAccessibilityValueAttribute, | 1294 NSAccessibilityValueAttribute, |
1254 NSAccessibilityWindowAttribute, | 1295 NSAccessibilityWindowAttribute, |
1255 NSAccessibilityURLAttribute, | 1296 NSAccessibilityURLAttribute, |
1256 @"AXAccessKey", | 1297 @"AXAccessKey", |
1257 @"AXInvalid", | 1298 @"AXInvalid", |
1258 @"AXRequired", | 1299 @"AXRequired", |
1259 @"AXVisited", | 1300 @"AXVisited", |
1301 @"AXLinkedUIElements", | |
David Tseng
2014/03/12 00:30:56
Ditto.
aboxhall
2014/03/12 17:50:47
Done.
aboxhall
2014/03/12 17:50:47
Done.
| |
1260 nil]; | 1302 nil]; |
1261 | 1303 |
1262 // Specific role attributes. | 1304 // Specific role attributes. |
1263 NSString* role = [self role]; | 1305 NSString* role = [self role]; |
1264 NSString* subrole = [self subrole]; | 1306 NSString* subrole = [self subrole]; |
1265 if ([role isEqualToString:NSAccessibilityTableRole] || | 1307 if ([role isEqualToString:NSAccessibilityTableRole] || |
1266 [role isEqualToString:NSAccessibilityGridRole]) { | 1308 [role isEqualToString:NSAccessibilityGridRole]) { |
1267 [ret addObjectsFromArray:[NSArray arrayWithObjects: | 1309 [ret addObjectsFromArray:[NSArray arrayWithObjects: |
1268 NSAccessibilityColumnsAttribute, | 1310 NSAccessibilityColumnsAttribute, |
1269 NSAccessibilityVisibleColumnsAttribute, | 1311 NSAccessibilityVisibleColumnsAttribute, |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1349 } | 1391 } |
1350 if (browserAccessibility_->HasStringAttribute( | 1392 if (browserAccessibility_->HasStringAttribute( |
1351 ui::AX_ATTR_CONTAINER_LIVE_STATUS)) { | 1393 ui::AX_ATTR_CONTAINER_LIVE_STATUS)) { |
1352 [ret addObjectsFromArray:[NSArray arrayWithObjects: | 1394 [ret addObjectsFromArray:[NSArray arrayWithObjects: |
1353 @"AXARIAAtomic", | 1395 @"AXARIAAtomic", |
1354 @"AXARIABusy", | 1396 @"AXARIABusy", |
1355 nil]]; | 1397 nil]]; |
1356 } | 1398 } |
1357 | 1399 |
1358 // Title UI Element. | 1400 // Title UI Element. |
1359 if (browserAccessibility_->HasIntAttribute( | 1401 if (browserAccessibility_->HasIntAttribute(ui::AX_ATTR_TITLE_UI_ELEMENT) || |
1360 ui::AX_ATTR_TITLE_UI_ELEMENT)) { | 1402 browserAccessibility_->HasIntListAttribute(ui::AX_ATTR_LABELLEDBY_IDS)) { |
David Tseng
2014/03/12 00:30:56
Technically, only if there's exactly one labelled
aboxhall
2014/03/12 17:50:47
True. I'll change it, but would there be an issue
David Tseng
2014/03/12 18:30:17
Well, a client could request the attributes suppor
| |
1361 [ret addObjectsFromArray:[NSArray arrayWithObjects: | 1403 [ret addObjectsFromArray:[NSArray arrayWithObjects: |
1362 NSAccessibilityTitleUIElementAttribute, | 1404 NSAccessibilityTitleUIElementAttribute, |
1363 nil]]; | 1405 nil]]; |
1364 } | 1406 } |
1365 | 1407 |
1366 return ret; | 1408 return ret; |
1367 } | 1409 } |
1368 | 1410 |
1369 // Returns the index of the child in this objects array of children. | 1411 // Returns the index of the child in this objects array of children. |
1370 - (NSUInteger)accessibilityGetIndexOf:(id)child { | 1412 - (NSUInteger)accessibilityGetIndexOf:(id)child { |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1499 return [super hash]; | 1541 return [super hash]; |
1500 return browserAccessibility_->renderer_id(); | 1542 return browserAccessibility_->renderer_id(); |
1501 } | 1543 } |
1502 | 1544 |
1503 - (BOOL)accessibilityShouldUseUniqueId { | 1545 - (BOOL)accessibilityShouldUseUniqueId { |
1504 return YES; | 1546 return YES; |
1505 } | 1547 } |
1506 | 1548 |
1507 @end | 1549 @end |
1508 | 1550 |
OLD | NEW |