Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(162)

Side by Side Diff: content/browser/accessibility/browser_accessibility_cocoa.mm

Issue 2692173003: Implemented SetSelection for the Web content on Windows. (Closed)
Patch Set: Fixed another compilation error on Windows. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 941 matching lines...) Expand 10 before | Expand all | Expand 10 after
952 } 952 }
953 953
954 // Returns a text marker that points to the last character in the document that 954 // Returns a text marker that points to the last character in the document that
955 // can be selected with VoiceOver. 955 // can be selected with VoiceOver.
956 - (id)endTextMarker { 956 - (id)endTextMarker {
957 const BrowserAccessibility* root = 957 const BrowserAccessibility* root =
958 browserAccessibility_->manager()->GetRoot(); 958 browserAccessibility_->manager()->GetRoot();
959 if (!root) 959 if (!root)
960 return nil; 960 return nil;
961 961
962 AXPlatformPositionInstance position = 962 AXPlatformPositionInstance position = root->CreatePositionAt(0);
963 CreateTextPosition(*root, 0, ui::AX_TEXT_AFFINITY_DOWNSTREAM);
964 return CreateTextMarker(position->CreatePositionAtEndOfAnchor()); 963 return CreateTextMarker(position->CreatePositionAtEndOfAnchor());
965 } 964 }
966 965
967 - (NSNumber*)expanded { 966 - (NSNumber*)expanded {
968 if (![self instanceActive]) 967 if (![self instanceActive])
969 return nil; 968 return nil;
970 return [NSNumber numberWithBool: 969 return [NSNumber numberWithBool:
971 GetState(browserAccessibility_, ui::AX_STATE_EXPANDED)]; 970 GetState(browserAccessibility_, ui::AX_STATE_EXPANDED)];
972 } 971 }
973 972
(...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after
1712 } 1711 }
1713 1712
1714 // Returns a text marker that points to the first character in the document that 1713 // Returns a text marker that points to the first character in the document that
1715 // can be selected with VoiceOver. 1714 // can be selected with VoiceOver.
1716 - (id)startTextMarker { 1715 - (id)startTextMarker {
1717 const BrowserAccessibility* root = 1716 const BrowserAccessibility* root =
1718 browserAccessibility_->manager()->GetRoot(); 1717 browserAccessibility_->manager()->GetRoot();
1719 if (!root) 1718 if (!root)
1720 return nil; 1719 return nil;
1721 1720
1722 AXPlatformPositionInstance position = 1721 AXPlatformPositionInstance position = root->CreatePositionAt(0);
1723 CreateTextPosition(*root, 0, ui::AX_TEXT_AFFINITY_DOWNSTREAM);
1724 return CreateTextMarker(position->CreatePositionAtStartOfAnchor()); 1722 return CreateTextMarker(position->CreatePositionAtStartOfAnchor());
1725 } 1723 }
1726 1724
1727 // Returns a subrole based upon the role. 1725 // Returns a subrole based upon the role.
1728 - (NSString*) subrole { 1726 - (NSString*) subrole {
1729 if (![self instanceActive]) 1727 if (![self instanceActive])
1730 return nil; 1728 return nil;
1731 ui::AXRole browserAccessibilityRole = [self internalRole]; 1729 ui::AXRole browserAccessibilityRole = [self internalRole];
1732 if (browserAccessibilityRole == ui::AX_ROLE_TEXT_FIELD && 1730 if (browserAccessibilityRole == ui::AX_ROLE_TEXT_FIELD &&
1733 GetState(browserAccessibility_, ui::AX_STATE_PROTECTED)) { 1731 GetState(browserAccessibility_, ui::AX_STATE_PROTECTED)) {
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
2121 if ([attribute isEqualToString:@"AXUIElementForTextMarker"]) { 2119 if ([attribute isEqualToString:@"AXUIElementForTextMarker"]) {
2122 AXPlatformPositionInstance position = 2120 AXPlatformPositionInstance position =
2123 CreatePositionFromTextMarker(parameter); 2121 CreatePositionFromTextMarker(parameter);
2124 if (!position->IsNullPosition()) 2122 if (!position->IsNullPosition())
2125 return ToBrowserAccessibilityCocoa(position->GetAnchor()); 2123 return ToBrowserAccessibilityCocoa(position->GetAnchor());
2126 2124
2127 return nil; 2125 return nil;
2128 } 2126 }
2129 2127
2130 if ([attribute isEqualToString:@"AXTextMarkerRangeForUIElement"]) { 2128 if ([attribute isEqualToString:@"AXTextMarkerRangeForUIElement"]) {
2131 AXPlatformPositionInstance startPosition = CreateTextPosition( 2129 AXPlatformPositionInstance startPosition =
2132 *browserAccessibility_, 0, ui::AX_TEXT_AFFINITY_DOWNSTREAM); 2130 browserAccessibility_->CreatePositionAt(0);
2133 AXPlatformPositionInstance endPosition = 2131 AXPlatformPositionInstance endPosition =
2134 startPosition->CreatePositionAtEndOfAnchor(); 2132 startPosition->CreatePositionAtEndOfAnchor();
2135 AXPlatformRange range = 2133 AXPlatformRange range =
2136 AXPlatformRange(std::move(startPosition), std::move(endPosition)); 2134 AXPlatformRange(std::move(startPosition), std::move(endPosition));
2137 return CreateTextMarkerRange(std::move(range)); 2135 return CreateTextMarkerRange(std::move(range));
2138 } 2136 }
2139 2137
2140 if ([attribute isEqualToString:@"AXStringForTextMarkerRange"]) 2138 if ([attribute isEqualToString:@"AXStringForTextMarkerRange"])
2141 return GetTextForTextMarkerRange(parameter); 2139 return GetTextForTextMarkerRange(parameter);
2142 2140
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after
2772 if ([attribute isEqualToString:NSAccessibilityFocusedAttribute]) { 2770 if ([attribute isEqualToString:NSAccessibilityFocusedAttribute]) {
2773 BrowserAccessibilityManager* manager = browserAccessibility_->manager(); 2771 BrowserAccessibilityManager* manager = browserAccessibility_->manager();
2774 NSNumber* focusedNumber = value; 2772 NSNumber* focusedNumber = value;
2775 BOOL focused = [focusedNumber intValue]; 2773 BOOL focused = [focusedNumber intValue];
2776 if (focused) 2774 if (focused)
2777 manager->SetFocus(*browserAccessibility_); 2775 manager->SetFocus(*browserAccessibility_);
2778 } 2776 }
2779 if ([attribute isEqualToString:NSAccessibilitySelectedTextRangeAttribute]) { 2777 if ([attribute isEqualToString:NSAccessibilitySelectedTextRangeAttribute]) {
2780 NSRange range = [(NSValue*)value rangeValue]; 2778 NSRange range = [(NSValue*)value rangeValue];
2781 BrowserAccessibilityManager* manager = browserAccessibility_->manager(); 2779 BrowserAccessibilityManager* manager = browserAccessibility_->manager();
2782 manager->SetTextSelection( 2780 manager->SetSelection(AXPlatformRange(
2783 *browserAccessibility_, range.location, range.location + range.length); 2781 browserAccessibility_->CreatePositionAt(range.location),
2782 browserAccessibility_->CreatePositionAt(NSMaxRange(range))));
2784 } 2783 }
2785 } 2784 }
2786 2785
2787 // Returns the deepest accessibility child that should not be ignored. 2786 // Returns the deepest accessibility child that should not be ignored.
2788 // It is assumed that the hit test has been narrowed down to this object 2787 // It is assumed that the hit test has been narrowed down to this object
2789 // or one of its children, so this will never return nil unless this 2788 // or one of its children, so this will never return nil unless this
2790 // object is invalid. 2789 // object is invalid.
2791 - (id)accessibilityHitTest:(NSPoint)point { 2790 - (id)accessibilityHitTest:(NSPoint)point {
2792 if (![self instanceActive]) 2791 if (![self instanceActive])
2793 return nil; 2792 return nil;
(...skipping 23 matching lines...) Expand all
2817 } 2816 }
2818 2817
2819 - (BOOL)accessibilityNotifiesWhenDestroyed { 2818 - (BOOL)accessibilityNotifiesWhenDestroyed {
2820 // Indicate that BrowserAccessibilityCocoa will post a notification when it's 2819 // Indicate that BrowserAccessibilityCocoa will post a notification when it's
2821 // destroyed (see -detach). This allows VoiceOver to do some internal things 2820 // destroyed (see -detach). This allows VoiceOver to do some internal things
2822 // more efficiently. 2821 // more efficiently.
2823 return YES; 2822 return YES;
2824 } 2823 }
2825 2824
2826 @end 2825 @end
OLDNEW
« no previous file with comments | « content/browser/accessibility/browser_accessibility.cc ('k') | content/browser/accessibility/browser_accessibility_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698