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

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

Issue 1579863003: Convert Pass()→std::move() for Mac build. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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
« no previous file with comments | « components/wifi/wifi_test.cc ('k') | content/browser/child_process_launcher.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "content/browser/accessibility/accessibility_tree_formatter.h" 5 #include "content/browser/accessibility/accessibility_tree_formatter.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 8
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 50
51 BrowserAccessibilityCocoa* cocoa_node = 51 BrowserAccessibilityCocoa* cocoa_node =
52 const_cast<BrowserAccessibility*>(&node)->ToBrowserAccessibilityCocoa(); 52 const_cast<BrowserAccessibility*>(&node)->ToBrowserAccessibilityCocoa();
53 NSPoint node_position = [[cocoa_node position] pointValue]; 53 NSPoint node_position = [[cocoa_node position] pointValue];
54 NSSize node_size = [[cocoa_node size] sizeValue]; 54 NSSize node_size = [[cocoa_node size] sizeValue];
55 55
56 position->SetInteger(kXCoordDictAttr, 56 position->SetInteger(kXCoordDictAttr,
57 static_cast<int>(node_position.x - root_left)); 57 static_cast<int>(node_position.x - root_left));
58 position->SetInteger(kYCoordDictAttr, 58 position->SetInteger(kYCoordDictAttr,
59 static_cast<int>(-node_position.y - node_size.height - root_top)); 59 static_cast<int>(-node_position.y - node_size.height - root_top));
60 return position.Pass(); 60 return position;
61 } 61 }
62 62
63 scoped_ptr<base::DictionaryValue> 63 scoped_ptr<base::DictionaryValue>
64 PopulateSize(const BrowserAccessibilityCocoa* cocoa_node) { 64 PopulateSize(const BrowserAccessibilityCocoa* cocoa_node) {
65 scoped_ptr<base::DictionaryValue> size(new base::DictionaryValue); 65 scoped_ptr<base::DictionaryValue> size(new base::DictionaryValue);
66 NSSize node_size = [[cocoa_node size] sizeValue]; 66 NSSize node_size = [[cocoa_node size] sizeValue];
67 size->SetInteger(kHeightDictAttr, static_cast<int>(node_size.height)); 67 size->SetInteger(kHeightDictAttr, static_cast<int>(node_size.height));
68 size->SetInteger(kWidthDictAttr, static_cast<int>(node_size.width)); 68 size->SetInteger(kWidthDictAttr, static_cast<int>(node_size.width));
69 return size.Pass(); 69 return size;
70 } 70 }
71 71
72 scoped_ptr<base::DictionaryValue> PopulateRange(NSRange range) { 72 scoped_ptr<base::DictionaryValue> PopulateRange(NSRange range) {
73 scoped_ptr<base::DictionaryValue> rangeDict(new base::DictionaryValue); 73 scoped_ptr<base::DictionaryValue> rangeDict(new base::DictionaryValue);
74 rangeDict->SetInteger(kRangeLocDictAttr, static_cast<int>(range.location)); 74 rangeDict->SetInteger(kRangeLocDictAttr, static_cast<int>(range.location));
75 rangeDict->SetInteger(kRangeLenDictAttr, static_cast<int>(range.length)); 75 rangeDict->SetInteger(kRangeLenDictAttr, static_cast<int>(range.length));
76 return rangeDict.Pass(); 76 return rangeDict;
77 } 77 }
78 78
79 // Returns true if |value| is an NSValue containing a NSRange. 79 // Returns true if |value| is an NSValue containing a NSRange.
80 bool IsRangeValue(id value) { 80 bool IsRangeValue(id value) {
81 if (![value isKindOfClass:[NSValue class]]) 81 if (![value isKindOfClass:[NSValue class]])
82 return false; 82 return false;
83 return 0 == strcmp([value objCType], @encode(NSRange)); 83 return 0 == strcmp([value objCType], @encode(NSRange));
84 } 84 }
85 85
86 scoped_ptr<base::Value> PopulateObject(id value); 86 scoped_ptr<base::Value> PopulateObject(id value);
87 87
88 scoped_ptr<base::ListValue> PopulateArray(NSArray* array) { 88 scoped_ptr<base::ListValue> PopulateArray(NSArray* array) {
89 scoped_ptr<base::ListValue> list(new base::ListValue); 89 scoped_ptr<base::ListValue> list(new base::ListValue);
90 for (NSUInteger i = 0; i < [array count]; i++) 90 for (NSUInteger i = 0; i < [array count]; i++)
91 list->Append(PopulateObject([array objectAtIndex:i]).release()); 91 list->Append(PopulateObject([array objectAtIndex:i]).release());
92 return list.Pass(); 92 return list;
93 } 93 }
94 94
95 scoped_ptr<base::StringValue> StringForBrowserAccessibility( 95 scoped_ptr<base::StringValue> StringForBrowserAccessibility(
96 BrowserAccessibilityCocoa* obj) { 96 BrowserAccessibilityCocoa* obj) {
97 NSMutableArray* tokens = [[NSMutableArray alloc] init]; 97 NSMutableArray* tokens = [[NSMutableArray alloc] init];
98 98
99 // Always include the role 99 // Always include the role
100 id role = [obj role]; 100 id role = [obj role];
101 [tokens addObject:role]; 101 [tokens addObject:role];
102 102
(...skipping 13 matching lines...) Expand all
116 if (description && ![description isEqual:@""]) { 116 if (description && ![description isEqual:@""]) {
117 [tokens addObject:description]; 117 [tokens addObject:description];
118 } else if (title && ![title isEqual:@""]) { 118 } else if (title && ![title isEqual:@""]) {
119 [tokens addObject:title]; 119 [tokens addObject:title];
120 } else if (value && ![value isEqual:@""]) { 120 } else if (value && ![value isEqual:@""]) {
121 [tokens addObject:value]; 121 [tokens addObject:value];
122 } 122 }
123 123
124 NSString* result = [tokens componentsJoinedByString:@" "]; 124 NSString* result = [tokens componentsJoinedByString:@" "];
125 return scoped_ptr<base::StringValue>( 125 return scoped_ptr<base::StringValue>(
126 new base::StringValue(SysNSStringToUTF16(result))).Pass(); 126 new base::StringValue(SysNSStringToUTF16(result)));
127 } 127 }
128 128
129 scoped_ptr<base::Value> PopulateObject(id value) { 129 scoped_ptr<base::Value> PopulateObject(id value) {
130 if ([value isKindOfClass:[NSArray class]]) 130 if ([value isKindOfClass:[NSArray class]])
131 return scoped_ptr<base::Value>(PopulateArray((NSArray*) value)); 131 return scoped_ptr<base::Value>(PopulateArray((NSArray*) value));
132 if (IsRangeValue(value)) 132 if (IsRangeValue(value))
133 return scoped_ptr<base::Value>(PopulateRange([value rangeValue])); 133 return scoped_ptr<base::Value>(PopulateRange([value rangeValue]));
134 if ([value isKindOfClass:[BrowserAccessibilityCocoa class]]) { 134 if ([value isKindOfClass:[BrowserAccessibilityCocoa class]]) {
135 std::string str; 135 std::string str;
136 StringForBrowserAccessibility(value)->GetAsString(&str); 136 StringForBrowserAccessibility(value)->GetAsString(&str);
137 return scoped_ptr<base::Value>(StringForBrowserAccessibility( 137 return scoped_ptr<base::Value>(StringForBrowserAccessibility(
138 (BrowserAccessibilityCocoa*) value)); 138 (BrowserAccessibilityCocoa*) value));
139 } 139 }
140 140
141 return scoped_ptr<base::Value>( 141 return scoped_ptr<base::Value>(new base::StringValue(
142 new base::StringValue( 142 SysNSStringToUTF16([NSString stringWithFormat:@"%@", value])));
143 SysNSStringToUTF16([NSString stringWithFormat:@"%@", value]))).Pass();
144 } 143 }
145 144
146 NSArray* BuildAllAttributesArray() { 145 NSArray* BuildAllAttributesArray() {
147 NSArray* array = [NSArray arrayWithObjects: 146 NSArray* array = [NSArray arrayWithObjects:
148 NSAccessibilityRoleDescriptionAttribute, 147 NSAccessibilityRoleDescriptionAttribute,
149 NSAccessibilityTitleAttribute, 148 NSAccessibilityTitleAttribute,
150 NSAccessibilityValueAttribute, 149 NSAccessibilityValueAttribute,
151 NSAccessibilityMinValueAttribute, 150 NSAccessibilityMinValueAttribute,
152 NSAccessibilityMaxValueAttribute, 151 NSAccessibilityMaxValueAttribute,
153 NSAccessibilityValueDescriptionAttribute, 152 NSAccessibilityValueDescriptionAttribute,
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 330
332 const string AccessibilityTreeFormatterMac::GetAllowString() { 331 const string AccessibilityTreeFormatterMac::GetAllowString() {
333 return "@MAC-ALLOW:"; 332 return "@MAC-ALLOW:";
334 } 333 }
335 334
336 const string AccessibilityTreeFormatterMac::GetDenyString() { 335 const string AccessibilityTreeFormatterMac::GetDenyString() {
337 return "@MAC-DENY:"; 336 return "@MAC-DENY:";
338 } 337 }
339 338
340 } // namespace content 339 } // namespace content
OLDNEW
« no previous file with comments | « components/wifi/wifi_test.cc ('k') | content/browser/child_process_launcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698