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

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: 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_->ComputeLineBreaks();
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 928 matching lines...) Expand 10 before | Expand all | Expand 10 after
1965 } 1965 }
1966 1966
1967 // Returns the accessibility value for the given attribute and parameter. If the 1967 // Returns the accessibility value for the given attribute and parameter. If the
1968 // value isn't supported this will return nil. 1968 // value isn't supported this will return nil.
1969 // TODO(nektar): Implement all unimplemented attributes, e.g. text markers. 1969 // TODO(nektar): Implement all unimplemented attributes, e.g. text markers.
1970 - (id)accessibilityAttributeValue:(NSString*)attribute 1970 - (id)accessibilityAttributeValue:(NSString*)attribute
1971 forParameter:(id)parameter { 1971 forParameter:(id)parameter {
1972 if (![self instanceActive]) 1972 if (![self instanceActive])
1973 return nil; 1973 return nil;
1974 1974
1975 const std::vector<int32_t>& line_breaks = 1975 const std::vector<int> line_breaks =
1976 browserAccessibility_->GetIntListAttribute(ui::AX_ATTR_LINE_BREAKS); 1976 browserAccessibility_->ComputeLineBreaks();
1977 base::string16 value = browserAccessibility_->GetValue(); 1977 base::string16 value = browserAccessibility_->GetValue();
1978 int len = static_cast<int>(value.size()); 1978 int len = static_cast<int>(value.size());
1979 1979
1980 if ([attribute isEqualToString: 1980 if ([attribute isEqualToString:
1981 NSAccessibilityStringForRangeParameterizedAttribute]) { 1981 NSAccessibilityStringForRangeParameterizedAttribute]) {
1982 return [self valueForRange:[(NSValue*)parameter rangeValue]]; 1982 return [self valueForRange:[(NSValue*)parameter rangeValue]];
1983 } 1983 }
1984 1984
1985 if ([attribute 1985 if ([attribute
1986 isEqualToString: 1986 isEqualToString:
(...skipping 871 matching lines...) Expand 10 before | Expand all | Expand 10 after
2858 if (![self instanceActive]) 2858 if (![self instanceActive])
2859 return [super hash]; 2859 return [super hash];
2860 return browserAccessibility_->GetId(); 2860 return browserAccessibility_->GetId();
2861 } 2861 }
2862 2862
2863 - (BOOL)accessibilityShouldUseUniqueId { 2863 - (BOOL)accessibilityShouldUseUniqueId {
2864 return YES; 2864 return YES;
2865 } 2865 }
2866 2866
2867 @end 2867 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698