| OLD | NEW |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2014 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 "ios/chrome/browser/ui/omnibox/omnibox_popup_material_view_controller.h" | 5 #import "ios/chrome/browser/ui/omnibox/omnibox_popup_material_view_controller.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/ios/ios_util.h" | 9 #include "base/ios/ios_util.h" |
| 10 #include "base/mac/scoped_cftyperef.h" | 10 #include "base/mac/scoped_cftyperef.h" |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 } | 251 } |
| 252 | 252 |
| 253 // DetailTextLabel and textLabel are fading labels placed in each row. The | 253 // DetailTextLabel and textLabel are fading labels placed in each row. The |
| 254 // textLabel is layed out above the detailTextLabel, and vertically centered | 254 // textLabel is layed out above the detailTextLabel, and vertically centered |
| 255 // if the detailTextLabel is empty. | 255 // if the detailTextLabel is empty. |
| 256 // For the detail text label, we use either the regular detail label, which | 256 // For the detail text label, we use either the regular detail label, which |
| 257 // truncates by fading, or the answer label, which uses UILabel's standard | 257 // truncates by fading, or the answer label, which uses UILabel's standard |
| 258 // truncation by ellipse for the multi-line text sometimes shown in answers. | 258 // truncation by ellipse for the multi-line text sometimes shown in answers. |
| 259 row.detailTruncatingLabel.hidden = answerPresent; | 259 row.detailTruncatingLabel.hidden = answerPresent; |
| 260 row.detailAnswerLabel.hidden = !answerPresent; | 260 row.detailAnswerLabel.hidden = !answerPresent; |
| 261 // URLs have have special layout requirements that need to be invoked here. |
| 262 row.detailTruncatingLabel.displayAsURL = |
| 263 !AutocompleteMatch::IsSearchType(match.type); |
| 261 // TODO(crbug.com/697647): The complexity of managing these two separate | 264 // TODO(crbug.com/697647): The complexity of managing these two separate |
| 262 // labels could probably be encapusulated in the row class if we moved the | 265 // labels could probably be encapusulated in the row class if we moved the |
| 263 // layout logic there. | 266 // layout logic there. |
| 264 UILabel* detailTextLabel = | 267 UILabel* detailTextLabel = |
| 265 answerPresent ? row.detailAnswerLabel : row.detailTruncatingLabel; | 268 answerPresent ? row.detailAnswerLabel : row.detailTruncatingLabel; |
| 266 [detailTextLabel setTextAlignment:_alignment]; | 269 [detailTextLabel setTextAlignment:_alignment]; |
| 267 | 270 |
| 268 // The width must be positive for CGContextRef to be valid. | 271 // The width must be positive for CGContextRef to be valid. |
| 269 CGFloat labelWidth = | 272 CGFloat labelWidth = |
| 270 MAX(40, floorf(row.frame.size.width) - kTextCellLeadingPadding); | 273 MAX(40, floorf(row.frame.size.width) - kTextCellLeadingPadding); |
| (...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 784 // The delete button never disappears if you don't call this after a tap. | 787 // The delete button never disappears if you don't call this after a tap. |
| 785 // It doesn't seem to be required anywhere else. | 788 // It doesn't seem to be required anywhere else. |
| 786 [_rows[indexPath.row] prepareForReuse]; | 789 [_rows[indexPath.row] prepareForReuse]; |
| 787 const AutocompleteMatch& match = | 790 const AutocompleteMatch& match = |
| 788 ((const AutocompleteResult&)_currentResult).match_at(indexPath.row); | 791 ((const AutocompleteResult&)_currentResult).match_at(indexPath.row); |
| 789 _popupView->DeleteMatch(match); | 792 _popupView->DeleteMatch(match); |
| 790 } | 793 } |
| 791 } | 794 } |
| 792 | 795 |
| 793 @end | 796 @end |
| OLD | NEW |