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

Side by Side Diff: chrome/browser/ui/cocoa/omnibox/omnibox_popup_matrix.mm

Issue 2221613002: [Mac] Fix hacker_case problems in Omnibox source. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 | « chrome/browser/ui/cocoa/omnibox/omnibox_popup_cell.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/ui/cocoa/omnibox/omnibox_popup_matrix.h" 5 #import "chrome/browser/ui/cocoa/omnibox/omnibox_popup_matrix.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/mac/foundation_util.h" 8 #include "base/mac/foundation_util.h"
9 #import "chrome/browser/ui/cocoa/omnibox/omnibox_popup_cell.h" 9 #import "chrome/browser/ui/cocoa/omnibox/omnibox_popup_cell.h"
10 #include "chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.h" 10 #include "chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.h"
(...skipping 15 matching lines...) Expand all
26 @end 26 @end
27 27
28 @implementation OmniboxPopupTableController 28 @implementation OmniboxPopupTableController
29 29
30 - (instancetype)initWithMatchResults:(const AutocompleteResult&)result 30 - (instancetype)initWithMatchResults:(const AutocompleteResult&)result
31 tableView:(OmniboxPopupMatrix*)tableView 31 tableView:(OmniboxPopupMatrix*)tableView
32 popupView:(const OmniboxPopupViewMac&)popupView 32 popupView:(const OmniboxPopupViewMac&)popupView
33 answerImage:(NSImage*)answerImage { 33 answerImage:(NSImage*)answerImage {
34 base::scoped_nsobject<NSMutableArray> array([[NSMutableArray alloc] init]); 34 base::scoped_nsobject<NSMutableArray> array([[NSMutableArray alloc] init]);
35 BOOL isDarkTheme = [tableView hasDarkTheme]; 35 BOOL isDarkTheme = [tableView hasDarkTheme];
36 CGFloat max_match_contents_width = 0.0f; 36 CGFloat maxMatchContentsWidth = 0.0f;
37 CGFloat contentsOffset = -1.0f; 37 CGFloat contentsOffset = -1.0f;
38 for (const AutocompleteMatch& match : result) { 38 for (const AutocompleteMatch& match : result) {
39 if (match.type == AutocompleteMatchType::SEARCH_SUGGEST_TAIL && 39 if (match.type == AutocompleteMatchType::SEARCH_SUGGEST_TAIL &&
40 contentsOffset < 0.0f) 40 contentsOffset < 0.0f)
41 contentsOffset = [OmniboxPopupCell computeContentsOffset:match]; 41 contentsOffset = [OmniboxPopupCell computeContentsOffset:match];
42 base::scoped_nsobject<OmniboxPopupCellData> cellData( 42 base::scoped_nsobject<OmniboxPopupCellData> cellData(
43 [[OmniboxPopupCellData alloc] 43 [[OmniboxPopupCellData alloc]
44 initWithMatch:match 44 initWithMatch:match
45 contentsOffset:contentsOffset 45 contentsOffset:contentsOffset
46 image:popupView.ImageForMatch(match) 46 image:popupView.ImageForMatch(match)
47 answerImage:(match.answer ? answerImage : nil) 47 answerImage:(match.answer ? answerImage : nil)
48 forDarkTheme:isDarkTheme]); 48 forDarkTheme:isDarkTheme]);
49 if (isDarkTheme) 49 if (isDarkTheme)
50 [cellData setIncognitoImage:popupView.ImageForMatch(match)]; 50 [cellData setIncognitoImage:popupView.ImageForMatch(match)];
51 [array addObject:cellData]; 51 [array addObject:cellData];
52 if (match.type == AutocompleteMatchType::SEARCH_SUGGEST_TAIL) { 52 if (match.type == AutocompleteMatchType::SEARCH_SUGGEST_TAIL) {
53 max_match_contents_width = 53 maxMatchContentsWidth =
54 std::max(max_match_contents_width, [cellData getMatchContentsWidth]); 54 std::max(maxMatchContentsWidth, [cellData getMatchContentsWidth]);
55 } 55 }
56 } 56 }
57 57
58 [tableView setMaxMatchContentsWidth:max_match_contents_width]; 58 [tableView setMaxMatchContentsWidth:maxMatchContentsWidth];
59 return [self initWithArray:array]; 59 return [self initWithArray:array];
60 } 60 }
61 61
62 - (instancetype)initWithArray:(NSArray*)array { 62 - (instancetype)initWithArray:(NSArray*)array {
63 if ((self = [super init])) { 63 if ((self = [super init])) {
64 hoveredIndex_ = -1; 64 hoveredIndex_ = -1;
65 array_.reset([array copy]); 65 array_.reset([array copy]);
66 } 66 }
67 return self; 67 return self;
68 } 68 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 NSRect rowRect = [tableView rectOfColumn:0]; 113 NSRect rowRect = [tableView rectOfColumn:0];
114 OmniboxPopupCellData* cellData = 114 OmniboxPopupCellData* cellData =
115 base::mac::ObjCCastStrict<OmniboxPopupCellData>( 115 base::mac::ObjCCastStrict<OmniboxPopupCellData>(
116 [array_ objectAtIndex:row]); 116 [array_ objectAtIndex:row]);
117 // Subtract any Material Design padding and/or icon. 117 // Subtract any Material Design padding and/or icon.
118 rowRect.size.width = [OmniboxPopupCell getContentAreaWidth:rowRect] - 118 rowRect.size.width = [OmniboxPopupCell getContentAreaWidth:rowRect] -
119 [matrix contentLeftPadding]; 119 [matrix contentLeftPadding];
120 NSAttributedString* text = [cellData description]; 120 NSAttributedString* text = [cellData description];
121 // Provide no more than 3 lines of space. 121 // Provide no more than 3 lines of space.
122 rowRect.size.height = 122 rowRect.size.height =
123 std::min(3, [cellData max_lines]) * [text size].height; 123 std::min(3, [cellData maxLines]) * [text size].height;
124 NSRect textRect = 124 NSRect textRect =
125 [text boundingRectWithSize:rowRect.size 125 [text boundingRectWithSize:rowRect.size
126 options:NSStringDrawingUsesLineFragmentOrigin | 126 options:NSStringDrawingUsesLineFragmentOrigin |
127 NSStringDrawingTruncatesLastVisibleLine]; 127 NSStringDrawingTruncatesLastVisibleLine];
128 // Add a little padding or it looks cramped. 128 // Add a little padding or it looks cramped.
129 int heightProvided = textRect.size.height + 2; 129 int heightProvided = textRect.size.height + 2;
130 height += heightProvided; 130 height += heightProvided;
131 } 131 }
132 return height; 132 return height;
133 } 133 }
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 [self selectRowIndex:row]; 314 [self selectRowIndex:row];
315 if (row != -1) { 315 if (row != -1) {
316 DCHECK(observer_); 316 DCHECK(observer_);
317 observer_->OnMatrixRowSelected(self, row); 317 observer_->OnMatrixRowSelected(self, row);
318 return YES; 318 return YES;
319 } 319 }
320 return NO; 320 return NO;
321 } 321 }
322 322
323 @end 323 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/omnibox/omnibox_popup_cell.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698