| 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 { NSAccessibilityVisibleCellsAttribute, @"visibleCells" }, | 102 { NSAccessibilityVisibleCellsAttribute, @"visibleCells" }, |
| 103 { NSAccessibilityVisibleChildrenAttribute, @"visibleChildren" }, | 103 { NSAccessibilityVisibleChildrenAttribute, @"visibleChildren" }, |
| 104 { NSAccessibilityVisibleColumnsAttribute, @"visibleColumns" }, | 104 { NSAccessibilityVisibleColumnsAttribute, @"visibleColumns" }, |
| 105 { NSAccessibilityVisibleRowsAttribute, @"visibleRows" }, | 105 { NSAccessibilityVisibleRowsAttribute, @"visibleRows" }, |
| 106 { NSAccessibilityWindowAttribute, @"window" }, | 106 { NSAccessibilityWindowAttribute, @"window" }, |
| 107 { @"AXAccessKey", @"accessKey" }, | 107 { @"AXAccessKey", @"accessKey" }, |
| 108 { @"AXARIAAtomic", @"ariaAtomic" }, | 108 { @"AXARIAAtomic", @"ariaAtomic" }, |
| 109 { @"AXARIABusy", @"ariaBusy" }, | 109 { @"AXARIABusy", @"ariaBusy" }, |
| 110 { @"AXARIALive", @"ariaLive" }, | 110 { @"AXARIALive", @"ariaLive" }, |
| 111 { @"AXARIARelevant", @"ariaRelevant" }, | 111 { @"AXARIARelevant", @"ariaRelevant" }, |
| 112 { @"AXGrabbed", @"grabbed" }, |
| 112 { @"AXInvalid", @"invalid" }, | 113 { @"AXInvalid", @"invalid" }, |
| 113 { @"AXLoaded", @"loaded" }, | 114 { @"AXLoaded", @"loaded" }, |
| 114 { @"AXLoadingProgress", @"loadingProgress" }, | 115 { @"AXLoadingProgress", @"loadingProgress" }, |
| 115 { @"AXPlaceholder", @"placeholder" }, | 116 { @"AXPlaceholder", @"placeholder" }, |
| 116 { @"AXRequired", @"required" }, | 117 { @"AXRequired", @"required" }, |
| 117 { @"AXVisited", @"visited" }, | 118 { @"AXVisited", @"visited" }, |
| 118 }; | 119 }; |
| 119 | 120 |
| 120 NSMutableDictionary* dict = [[NSMutableDictionary alloc] init]; | 121 NSMutableDictionary* dict = [[NSMutableDictionary alloc] init]; |
| 121 const size_t numAttributes = sizeof(attributeToMethodNameContainer) / | 122 const size_t numAttributes = sizeof(attributeToMethodNameContainer) / |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 GetState(browserAccessibility_, ui::AX_STATE_EXPANDED)]; | 337 GetState(browserAccessibility_, ui::AX_STATE_EXPANDED)]; |
| 337 } | 338 } |
| 338 | 339 |
| 339 - (NSNumber*)focused { | 340 - (NSNumber*)focused { |
| 340 BrowserAccessibilityManager* manager = browserAccessibility_->manager(); | 341 BrowserAccessibilityManager* manager = browserAccessibility_->manager(); |
| 341 NSNumber* ret = [NSNumber numberWithBool: | 342 NSNumber* ret = [NSNumber numberWithBool: |
| 342 manager->GetFocus(NULL) == browserAccessibility_]; | 343 manager->GetFocus(NULL) == browserAccessibility_]; |
| 343 return ret; | 344 return ret; |
| 344 } | 345 } |
| 345 | 346 |
| 347 - (NSNumber*)grabbed { |
| 348 bool boolValue = browserAccessibility_->GetBoolAttribute(ui::AX_ATTR_GRABBED); |
| 349 return [NSNumber numberWithBool:boolValue]; |
| 350 } |
| 351 |
| 346 - (id)header { | 352 - (id)header { |
| 347 int headerElementId = -1; | 353 int headerElementId = -1; |
| 348 if ([self internalRole] == ui::AX_ROLE_TABLE || | 354 if ([self internalRole] == ui::AX_ROLE_TABLE || |
| 349 [self internalRole] == ui::AX_ROLE_GRID) { | 355 [self internalRole] == ui::AX_ROLE_GRID) { |
| 350 browserAccessibility_->GetIntAttribute( | 356 browserAccessibility_->GetIntAttribute( |
| 351 ui::AX_ATTR_TABLE_HEADER_ID, &headerElementId); | 357 ui::AX_ATTR_TABLE_HEADER_ID, &headerElementId); |
| 352 } else if ([self internalRole] == ui::AX_ROLE_COLUMN) { | 358 } else if ([self internalRole] == ui::AX_ROLE_COLUMN) { |
| 353 browserAccessibility_->GetIntAttribute( | 359 browserAccessibility_->GetIntAttribute( |
| 354 ui::AX_ATTR_TABLE_COLUMN_HEADER_ID, &headerElementId); | 360 ui::AX_ATTR_TABLE_COLUMN_HEADER_ID, &headerElementId); |
| 355 } else if ([self internalRole] == ui::AX_ROLE_ROW) { | 361 } else if ([self internalRole] == ui::AX_ROLE_ROW) { |
| (...skipping 1023 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1379 [ret addObjectsFromArray:[NSArray arrayWithObjects: | 1385 [ret addObjectsFromArray:[NSArray arrayWithObjects: |
| 1380 @"AXARIAAtomic", | 1386 @"AXARIAAtomic", |
| 1381 nil]]; | 1387 nil]]; |
| 1382 } | 1388 } |
| 1383 if (browserAccessibility_->HasBoolAttribute( | 1389 if (browserAccessibility_->HasBoolAttribute( |
| 1384 ui::AX_ATTR_LIVE_BUSY)) { | 1390 ui::AX_ATTR_LIVE_BUSY)) { |
| 1385 [ret addObjectsFromArray:[NSArray arrayWithObjects: | 1391 [ret addObjectsFromArray:[NSArray arrayWithObjects: |
| 1386 @"AXARIABusy", | 1392 @"AXARIABusy", |
| 1387 nil]]; | 1393 nil]]; |
| 1388 } | 1394 } |
| 1395 // Add aria-grabbed attribute only if it has true. |
| 1396 if (browserAccessibility_->HasBoolAttribute(ui::AX_ATTR_GRABBED)) { |
| 1397 [ret addObjectsFromArray:[NSArray arrayWithObjects: |
| 1398 @"AXGrabbed", |
| 1399 nil]]; |
| 1400 } |
| 1389 | 1401 |
| 1390 //Add expanded attribute only if it has expanded or collapsed state. | 1402 // Add expanded attribute only if it has expanded or collapsed state. |
| 1391 if (GetState(browserAccessibility_, ui::AX_STATE_EXPANDED) || | 1403 if (GetState(browserAccessibility_, ui::AX_STATE_EXPANDED) || |
| 1392 GetState(browserAccessibility_, ui::AX_STATE_COLLAPSED)) { | 1404 GetState(browserAccessibility_, ui::AX_STATE_COLLAPSED)) { |
| 1393 [ret addObjectsFromArray:[NSArray arrayWithObjects: | 1405 [ret addObjectsFromArray:[NSArray arrayWithObjects: |
| 1394 NSAccessibilityExpandedAttribute, | 1406 NSAccessibilityExpandedAttribute, |
| 1395 nil]]; | 1407 nil]]; |
| 1396 } | 1408 } |
| 1397 | 1409 |
| 1398 if (GetState(browserAccessibility_, ui::AX_STATE_VERTICAL) | 1410 if (GetState(browserAccessibility_, ui::AX_STATE_VERTICAL) |
| 1399 || GetState(browserAccessibility_, ui::AX_STATE_HORIZONTAL)) { | 1411 || GetState(browserAccessibility_, ui::AX_STATE_HORIZONTAL)) { |
| 1400 [ret addObjectsFromArray:[NSArray arrayWithObjects: | 1412 [ret addObjectsFromArray:[NSArray arrayWithObjects: |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1565 if (!browserAccessibility_) | 1577 if (!browserAccessibility_) |
| 1566 return [super hash]; | 1578 return [super hash]; |
| 1567 return browserAccessibility_->GetId(); | 1579 return browserAccessibility_->GetId(); |
| 1568 } | 1580 } |
| 1569 | 1581 |
| 1570 - (BOOL)accessibilityShouldUseUniqueId { | 1582 - (BOOL)accessibilityShouldUseUniqueId { |
| 1571 return YES; | 1583 return YES; |
| 1572 } | 1584 } |
| 1573 | 1585 |
| 1574 @end | 1586 @end |
| OLD | NEW |