| 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 740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 751 [ret addObject:rowElement->ToBrowserAccessibilityCocoa()]; | 751 [ret addObject:rowElement->ToBrowserAccessibilityCocoa()]; |
| 752 } | 752 } |
| 753 } | 753 } |
| 754 | 754 |
| 755 return ret; | 755 return ret; |
| 756 } | 756 } |
| 757 | 757 |
| 758 - (NSArray*)selectedChildren { | 758 - (NSArray*)selectedChildren { |
| 759 NSMutableArray* ret = [[[NSMutableArray alloc] init] autorelease]; | 759 NSMutableArray* ret = [[[NSMutableArray alloc] init] autorelease]; |
| 760 | 760 |
| 761 BrowserAccessibilityManager* manager = browserAccessibility_->manager(); | 761 // If it's not multiselectable, try to skip iterating over the |
| 762 BrowserAccessibility* focusedChild = | 762 // children. |
| 763 manager->GetFocus(browserAccessibility_); | 763 if (!GetState(browserAccessibility_, ui::AX_STATE_MULTISELECTABLE)) { |
| 764 if (focusedChild && focusedChild != browserAccessibility_) { | |
| 765 // First try the focused child. | 764 // First try the focused child. |
| 766 [ret addObject:focusedChild->ToBrowserAccessibilityCocoa()]; | 765 BrowserAccessibilityManager* manager = browserAccessibility_->manager(); |
| 767 } else { | 766 BrowserAccessibility* focusedChild = |
| 767 manager->GetFocus(browserAccessibility_); |
| 768 if (focusedChild && focusedChild != browserAccessibility_) { |
| 769 [ret addObject:focusedChild->ToBrowserAccessibilityCocoa()]; |
| 770 return ret; |
| 771 } |
| 772 |
| 768 // Next try the active descendant. | 773 // Next try the active descendant. |
| 769 int activeDescendantId; | 774 int activeDescendantId; |
| 770 if (browserAccessibility_->GetIntAttribute( | 775 if (browserAccessibility_->GetIntAttribute( |
| 771 ui::AX_ATTR_ACTIVEDESCENDANT_ID, &activeDescendantId)) { | 776 ui::AX_ATTR_ACTIVEDESCENDANT_ID, &activeDescendantId)) { |
| 772 BrowserAccessibility* activeDescendant = | 777 BrowserAccessibility* activeDescendant = |
| 773 manager->GetFromID(activeDescendantId); | 778 manager->GetFromID(activeDescendantId); |
| 774 if (activeDescendant) | 779 if (activeDescendant) { |
| 775 [ret addObject:activeDescendant->ToBrowserAccessibilityCocoa()]; | 780 [ret addObject:activeDescendant->ToBrowserAccessibilityCocoa()]; |
| 776 } else { | 781 return ret; |
| 777 // Otherwise return any children with the "selected" state, which | |
| 778 // may come from aria-selected. | |
| 779 uint32 childCount = browserAccessibility_->PlatformChildCount(); | |
| 780 for (uint32 index = 0; index < childCount; ++index) { | |
| 781 BrowserAccessibility* child = | |
| 782 browserAccessibility_->PlatformGetChild(index); | |
| 783 if (child->HasState(ui::AX_STATE_SELECTED)) | |
| 784 [ret addObject:child->ToBrowserAccessibilityCocoa()]; | |
| 785 } | 782 } |
| 786 } | 783 } |
| 787 } | 784 } |
| 788 | 785 |
| 786 // If it's multiselectable or if the previous attempts failed, |
| 787 // return any children with the "selected" state, which may |
| 788 // come from aria-selected. |
| 789 uint32 childCount = browserAccessibility_->PlatformChildCount(); |
| 790 for (uint32 index = 0; index < childCount; ++index) { |
| 791 BrowserAccessibility* child = |
| 792 browserAccessibility_->PlatformGetChild(index); |
| 793 if (child->HasState(ui::AX_STATE_SELECTED)) |
| 794 [ret addObject:child->ToBrowserAccessibilityCocoa()]; |
| 795 } |
| 796 |
| 789 return ret; | 797 return ret; |
| 790 } | 798 } |
| 791 | 799 |
| 792 // Returns the size of this object. | 800 // Returns the size of this object. |
| 793 - (NSValue*)size { | 801 - (NSValue*)size { |
| 794 gfx::Rect bounds = browserAccessibility_->GetLocalBoundsRect(); | 802 gfx::Rect bounds = browserAccessibility_->GetLocalBoundsRect(); |
| 795 return [NSValue valueWithSize:NSMakeSize(bounds.width(), bounds.height())]; | 803 return [NSValue valueWithSize:NSMakeSize(bounds.width(), bounds.height())]; |
| 796 } | 804 } |
| 797 | 805 |
| 798 - (NSString*)sortDirection { | 806 - (NSString*)sortDirection { |
| (...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1624 if (!browserAccessibility_) | 1632 if (!browserAccessibility_) |
| 1625 return [super hash]; | 1633 return [super hash]; |
| 1626 return browserAccessibility_->GetId(); | 1634 return browserAccessibility_->GetId(); |
| 1627 } | 1635 } |
| 1628 | 1636 |
| 1629 - (BOOL)accessibilityShouldUseUniqueId { | 1637 - (BOOL)accessibilityShouldUseUniqueId { |
| 1630 return YES; | 1638 return YES; |
| 1631 } | 1639 } |
| 1632 | 1640 |
| 1633 @end | 1641 @end |
| OLD | NEW |