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

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

Issue 2906893004: Omnibox UI Experiments: Port Vertical Layout experiment to Mac Cocoa. (Closed)
Patch Set: fix camel case Created 3 years, 6 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 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/feature_list.h"
7 #include "base/logging.h" 8 #include "base/logging.h"
8 #include "base/mac/foundation_util.h" 9 #include "base/mac/foundation_util.h"
9 #import "chrome/browser/ui/cocoa/omnibox/omnibox_popup_cell.h" 10 #import "chrome/browser/ui/cocoa/omnibox/omnibox_popup_cell.h"
10 #include "chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.h" 11 #include "chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.h"
11 #include "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h" 12 #include "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h"
12 #include "components/omnibox/browser/autocomplete_result.h" 13 #include "components/omnibox/browser/autocomplete_result.h"
14 #include "components/omnibox/browser/omnibox_field_trial.h"
13 15
14 namespace { 16 namespace {
15 17
16 // NSEvent -buttonNumber for middle mouse button. 18 // NSEvent -buttonNumber for middle mouse button.
17 const NSInteger kMiddleButtonNumber = 2; 19 const NSInteger kMiddleButtonNumber = 2;
18 20
19 } // namespace 21 } // namespace
20 22
21 @interface OmniboxPopupMatrix () 23 @interface OmniboxPopupMatrix ()
22 - (OmniboxPopupTableController*)controller; 24 - (OmniboxPopupTableController*)controller;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 101
100 - (NSInteger)highlightedRow { 102 - (NSInteger)highlightedRow {
101 return hoveredIndex_; 103 return hoveredIndex_;
102 } 104 }
103 105
104 - (void)setHighlightedRow:(NSInteger)rowIndex { 106 - (void)setHighlightedRow:(NSInteger)rowIndex {
105 hoveredIndex_ = rowIndex; 107 hoveredIndex_ = rowIndex;
106 } 108 }
107 109
108 - (CGFloat)tableView:(NSTableView*)tableView heightOfRow:(NSInteger)row { 110 - (CGFloat)tableView:(NSTableView*)tableView heightOfRow:(NSInteger)row {
109 CGFloat height = [OmniboxPopupCell getContentTextHeight]; 111 bool isAnswer = [[array_ objectAtIndex:row] isAnswer];
groby-ooo-7-16 2017/05/31 00:14:51 BOOL, please :)
tommycli 2017/05/31 18:20:40 Done.
110 if ([[array_ objectAtIndex:row] isAnswer]) { 112 bool isTwoLine = !isAnswer && base::FeatureList::IsEnabled(
groby-ooo-7-16 2017/05/31 00:14:51 isDoubleLine or usesTwoLines, please. (isTwoLine s
tommycli 2017/05/31 18:20:40 Done.
113 omnibox::kUIExperimentVerticalLayout);
114 CGFloat height = [OmniboxPopupCell getContentTextHeight:isTwoLine];
115
116 if (isAnswer) {
111 OmniboxPopupMatrix* matrix = 117 OmniboxPopupMatrix* matrix =
112 base::mac::ObjCCastStrict<OmniboxPopupMatrix>(tableView); 118 base::mac::ObjCCastStrict<OmniboxPopupMatrix>(tableView);
113 NSRect rowRect = [tableView rectOfColumn:0]; 119 NSRect rowRect = [tableView rectOfColumn:0];
114 OmniboxPopupCellData* cellData = 120 OmniboxPopupCellData* cellData =
115 base::mac::ObjCCastStrict<OmniboxPopupCellData>( 121 base::mac::ObjCCastStrict<OmniboxPopupCellData>(
116 [array_ objectAtIndex:row]); 122 [array_ objectAtIndex:row]);
117 // Subtract any Material Design padding and/or icon. 123 // Subtract any Material Design padding and/or icon.
118 rowRect.size.width = [OmniboxPopupCell getContentAreaWidth:rowRect] - 124 rowRect.size.width = [OmniboxPopupCell getContentAreaWidth:rowRect] -
119 [matrix contentLeftPadding]; 125 [matrix contentLeftPadding];
120 NSAttributedString* text = [cellData description]; 126 NSAttributedString* text = [cellData description];
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 [self selectRowIndex:row]; 320 [self selectRowIndex:row];
315 if (row != -1) { 321 if (row != -1) {
316 DCHECK(observer_); 322 DCHECK(observer_);
317 observer_->OnMatrixRowSelected(self, row); 323 observer_->OnMatrixRowSelected(self, row);
318 return YES; 324 return YES;
319 } 325 }
320 return NO; 326 return NO;
321 } 327 }
322 328
323 @end 329 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698