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

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

Issue 2301833005: Get rid of AX_LINE_BREAKS attribute to improve performance. (Closed)
Patch Set: More automation fixes. Created 4 years, 3 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 #include <execinfo.h> 5 #include <execinfo.h>
6 #include <stddef.h> 6 #include <stddef.h>
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #import "content/browser/accessibility/browser_accessibility_cocoa.h" 9 #import "content/browser/accessibility/browser_accessibility_cocoa.h"
10 10
(...skipping 1004 matching lines...) Expand 10 before | Expand all | Expand 10 after
1015 if (!browserAccessibility_->GetIntAttribute(ui::AX_ATTR_TEXT_SEL_START, 1015 if (!browserAccessibility_->GetIntAttribute(ui::AX_ATTR_TEXT_SEL_START,
1016 &selStart) || 1016 &selStart) ||
1017 !browserAccessibility_->GetIntAttribute(ui::AX_ATTR_TEXT_SEL_END, 1017 !browserAccessibility_->GetIntAttribute(ui::AX_ATTR_TEXT_SEL_END,
1018 &selEnd)) { 1018 &selEnd)) {
1019 return nil; 1019 return nil;
1020 } 1020 }
1021 1021
1022 if (selStart > selEnd) 1022 if (selStart > selEnd)
1023 std::swap(selStart, selEnd); 1023 std::swap(selStart, selEnd);
1024 1024
1025 const std::vector<int32_t>& line_breaks = 1025 const std::vector<int> line_breaks =
1026 browserAccessibility_->GetIntListAttribute(ui::AX_ATTR_LINE_BREAKS); 1026 browserAccessibility_->GetLineStartOffsets();
1027 for (int i = 0; i < static_cast<int>(line_breaks.size()); ++i) { 1027 for (int i = 0; i < static_cast<int>(line_breaks.size()); ++i) {
1028 if (line_breaks[i] > selStart) 1028 if (line_breaks[i] > selStart)
1029 return [NSNumber numberWithInt:i]; 1029 return [NSNumber numberWithInt:i];
1030 } 1030 }
1031 1031
1032 return [NSNumber numberWithInt:static_cast<int>(line_breaks.size())]; 1032 return [NSNumber numberWithInt:static_cast<int>(line_breaks.size())];
1033 } 1033 }
1034 1034
1035 // Returns whether or not this node should be ignored in the 1035 // Returns whether or not this node should be ignored in the
1036 // accessibility tree. 1036 // accessibility tree.
(...skipping 930 matching lines...) Expand 10 before | Expand all | Expand 10 after
1967 } 1967 }
1968 1968
1969 // Returns the accessibility value for the given attribute and parameter. If the 1969 // Returns the accessibility value for the given attribute and parameter. If the
1970 // value isn't supported this will return nil. 1970 // value isn't supported this will return nil.
1971 // TODO(nektar): Implement all unimplemented attributes, e.g. text markers. 1971 // TODO(nektar): Implement all unimplemented attributes, e.g. text markers.
1972 - (id)accessibilityAttributeValue:(NSString*)attribute 1972 - (id)accessibilityAttributeValue:(NSString*)attribute
1973 forParameter:(id)parameter { 1973 forParameter:(id)parameter {
1974 if (![self instanceActive]) 1974 if (![self instanceActive])
1975 return nil; 1975 return nil;
1976 1976
1977 const std::vector<int32_t>& line_breaks = 1977 const std::vector<int> line_breaks =
1978 browserAccessibility_->GetIntListAttribute(ui::AX_ATTR_LINE_BREAKS); 1978 browserAccessibility_->GetLineStartOffsets();
1979 base::string16 value = browserAccessibility_->GetValue(); 1979 base::string16 value = browserAccessibility_->GetValue();
1980 int len = static_cast<int>(value.size()); 1980 int len = static_cast<int>(value.size());
1981 1981
1982 if ([attribute isEqualToString: 1982 if ([attribute isEqualToString:
1983 NSAccessibilityStringForRangeParameterizedAttribute]) { 1983 NSAccessibilityStringForRangeParameterizedAttribute]) {
1984 return [self valueForRange:[(NSValue*)parameter rangeValue]]; 1984 return [self valueForRange:[(NSValue*)parameter rangeValue]];
1985 } 1985 }
1986 1986
1987 if ([attribute 1987 if ([attribute
1988 isEqualToString: 1988 isEqualToString:
(...skipping 871 matching lines...) Expand 10 before | Expand all | Expand 10 after
2860 if (![self instanceActive]) 2860 if (![self instanceActive])
2861 return [super hash]; 2861 return [super hash];
2862 return browserAccessibility_->GetId(); 2862 return browserAccessibility_->GetId();
2863 } 2863 }
2864 2864
2865 - (BOOL)accessibilityShouldUseUniqueId { 2865 - (BOOL)accessibilityShouldUseUniqueId {
2866 return YES; 2866 return YES;
2867 } 2867 }
2868 2868
2869 @end 2869 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698