OLD | NEW |
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 Loading... |
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]; |
110 if ([[array_ objectAtIndex:row] isAnswer]) { | 112 BOOL isDoubleLine = !isAnswer && base::FeatureList::IsEnabled( |
| 113 omnibox::kUIExperimentVerticalLayout); |
| 114 CGFloat height = |
| 115 [OmniboxPopupCell getContentTextHeightForDoubleLine:isDoubleLine]; |
| 116 |
| 117 if (isAnswer) { |
111 OmniboxPopupMatrix* matrix = | 118 OmniboxPopupMatrix* matrix = |
112 base::mac::ObjCCastStrict<OmniboxPopupMatrix>(tableView); | 119 base::mac::ObjCCastStrict<OmniboxPopupMatrix>(tableView); |
113 NSRect rowRect = [tableView rectOfColumn:0]; | 120 NSRect rowRect = [tableView rectOfColumn:0]; |
114 OmniboxPopupCellData* cellData = | 121 OmniboxPopupCellData* cellData = |
115 base::mac::ObjCCastStrict<OmniboxPopupCellData>( | 122 base::mac::ObjCCastStrict<OmniboxPopupCellData>( |
116 [array_ objectAtIndex:row]); | 123 [array_ objectAtIndex:row]); |
117 // Subtract any Material Design padding and/or icon. | 124 // Subtract any Material Design padding and/or icon. |
118 rowRect.size.width = [OmniboxPopupCell getContentAreaWidth:rowRect] - | 125 rowRect.size.width = [OmniboxPopupCell getContentAreaWidth:rowRect] - |
119 [matrix contentLeftPadding]; | 126 [matrix contentLeftPadding]; |
120 NSAttributedString* text = [cellData description]; | 127 NSAttributedString* text = [cellData description]; |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 [self selectRowIndex:row]; | 321 [self selectRowIndex:row]; |
315 if (row != -1) { | 322 if (row != -1) { |
316 DCHECK(observer_); | 323 DCHECK(observer_); |
317 observer_->OnMatrixRowSelected(self, row); | 324 observer_->OnMatrixRowSelected(self, row); |
318 return YES; | 325 return YES; |
319 } | 326 } |
320 return NO; | 327 return NO; |
321 } | 328 } |
322 | 329 |
323 @end | 330 @end |
OLD | NEW |