| 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 #import "content/browser/accessibility/browser_accessibility_cocoa.h" | 5 #import "content/browser/accessibility/browser_accessibility_cocoa.h" |
| 6 | 6 |
| 7 #include <execinfo.h> | 7 #include <execinfo.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 #include <string.h> | 10 #include <string.h> |
| (...skipping 864 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 875 std::string basename = | 875 std::string basename = |
| 876 leftIndex != std::string::npos ? url.substr(leftIndex) : url; | 876 leftIndex != std::string::npos ? url.substr(leftIndex) : url; |
| 877 return base::SysUTF8ToNSString(basename); | 877 return base::SysUTF8ToNSString(basename); |
| 878 } | 878 } |
| 879 } | 879 } |
| 880 | 880 |
| 881 // If it's focusable but didn't have any other name or value, compute a name | 881 // If it's focusable but didn't have any other name or value, compute a name |
| 882 // from its descendants. | 882 // from its descendants. |
| 883 base::string16 value = browserAccessibility_->GetValue(); | 883 base::string16 value = browserAccessibility_->GetValue(); |
| 884 if (browserAccessibility_->HasState(ui::AX_STATE_FOCUSABLE) && | 884 if (browserAccessibility_->HasState(ui::AX_STATE_FOCUSABLE) && |
| 885 !browserAccessibility_->IsControl() && | 885 !IsControl(browserAccessibility_->GetRole()) && value.empty() && |
| 886 value.empty() && | |
| 887 [self internalRole] != ui::AX_ROLE_DATE_TIME && | 886 [self internalRole] != ui::AX_ROLE_DATE_TIME && |
| 888 [self internalRole] != ui::AX_ROLE_WEB_AREA && | 887 [self internalRole] != ui::AX_ROLE_WEB_AREA && |
| 889 [self internalRole] != ui::AX_ROLE_ROOT_WEB_AREA) { | 888 [self internalRole] != ui::AX_ROLE_ROOT_WEB_AREA) { |
| 890 return base::SysUTF8ToNSString( | 889 return base::SysUTF8ToNSString( |
| 891 browserAccessibility_->ComputeAccessibleNameFromDescendants()); | 890 browserAccessibility_->ComputeAccessibleNameFromDescendants()); |
| 892 } | 891 } |
| 893 | 892 |
| 894 return @""; | 893 return @""; |
| 895 } | 894 } |
| 896 | 895 |
| (...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1296 } | 1295 } |
| 1297 } | 1296 } |
| 1298 | 1297 |
| 1299 // Returns true if this object should expose its accessible name using | 1298 // Returns true if this object should expose its accessible name using |
| 1300 // AXTitleUIElement rather than AXTitle or AXDescription. We only do | 1299 // AXTitleUIElement rather than AXTitle or AXDescription. We only do |
| 1301 // this if it's a control, if there's a single label, and the label has | 1300 // this if it's a control, if there's a single label, and the label has |
| 1302 // nonempty text. | 1301 // nonempty text. |
| 1303 // internal | 1302 // internal |
| 1304 - (BOOL)shouldExposeTitleUIElement { | 1303 - (BOOL)shouldExposeTitleUIElement { |
| 1305 // VoiceOver ignores TitleUIElement if the element isn't a control. | 1304 // VoiceOver ignores TitleUIElement if the element isn't a control. |
| 1306 if (!browserAccessibility_->IsControl()) | 1305 if (!IsControl(browserAccessibility_->GetRole())) |
| 1307 return false; | 1306 return false; |
| 1308 | 1307 |
| 1309 ui::AXNameFrom nameFrom = static_cast<ui::AXNameFrom>( | 1308 ui::AXNameFrom nameFrom = static_cast<ui::AXNameFrom>( |
| 1310 browserAccessibility_->GetIntAttribute(ui::AX_ATTR_NAME_FROM)); | 1309 browserAccessibility_->GetIntAttribute(ui::AX_ATTR_NAME_FROM)); |
| 1311 if (nameFrom != ui::AX_NAME_FROM_RELATED_ELEMENT) | 1310 if (nameFrom != ui::AX_NAME_FROM_RELATED_ELEMENT) |
| 1312 return false; | 1311 return false; |
| 1313 | 1312 |
| 1314 std::vector<int32_t> labelledby_ids = | 1313 std::vector<int32_t> labelledby_ids = |
| 1315 browserAccessibility_->GetIntListAttribute(ui::AX_ATTR_LABELLEDBY_IDS); | 1314 browserAccessibility_->GetIntListAttribute(ui::AX_ATTR_LABELLEDBY_IDS); |
| 1316 if (labelledby_ids.size() != 1) | 1315 if (labelledby_ids.size() != 1) |
| (...skipping 1182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2499 return nil; | 2498 return nil; |
| 2500 | 2499 |
| 2501 NSMutableArray* actions = [NSMutableArray | 2500 NSMutableArray* actions = [NSMutableArray |
| 2502 arrayWithObjects:NSAccessibilityShowMenuAction, | 2501 arrayWithObjects:NSAccessibilityShowMenuAction, |
| 2503 NSAccessibilityScrollToVisibleAction, nil]; | 2502 NSAccessibilityScrollToVisibleAction, nil]; |
| 2504 | 2503 |
| 2505 // VoiceOver expects the "press" action to be first. | 2504 // VoiceOver expects the "press" action to be first. |
| 2506 if (browserAccessibility_->IsClickable()) | 2505 if (browserAccessibility_->IsClickable()) |
| 2507 [actions insertObject:NSAccessibilityPressAction atIndex:0]; | 2506 [actions insertObject:NSAccessibilityPressAction atIndex:0]; |
| 2508 | 2507 |
| 2509 if (browserAccessibility_->IsMenuRelated()) | 2508 if (IsMenuRelated(browserAccessibility_->GetRole())) |
| 2510 [actions addObject:NSAccessibilityCancelAction]; | 2509 [actions addObject:NSAccessibilityCancelAction]; |
| 2511 | 2510 |
| 2512 if ([self internalRole] == ui::AX_ROLE_SLIDER) { | 2511 if ([self internalRole] == ui::AX_ROLE_SLIDER) { |
| 2513 [actions addObjectsFromArray:@[ | 2512 [actions addObjectsFromArray:@[ |
| 2514 NSAccessibilityIncrementAction, NSAccessibilityDecrementAction | 2513 NSAccessibilityIncrementAction, NSAccessibilityDecrementAction |
| 2515 ]]; | 2514 ]]; |
| 2516 } | 2515 } |
| 2517 | 2516 |
| 2518 return actions; | 2517 return actions; |
| 2519 } | 2518 } |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2883 } | 2882 } |
| 2884 | 2883 |
| 2885 - (BOOL)accessibilityNotifiesWhenDestroyed { | 2884 - (BOOL)accessibilityNotifiesWhenDestroyed { |
| 2886 // Indicate that BrowserAccessibilityCocoa will post a notification when it's | 2885 // Indicate that BrowserAccessibilityCocoa will post a notification when it's |
| 2887 // destroyed (see -detach). This allows VoiceOver to do some internal things | 2886 // destroyed (see -detach). This allows VoiceOver to do some internal things |
| 2888 // more efficiently. | 2887 // more efficiently. |
| 2889 return YES; | 2888 return YES; |
| 2890 } | 2889 } |
| 2891 | 2890 |
| 2892 @end | 2891 @end |
| OLD | NEW |