Chromium Code Reviews| 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_cell.h" | 5 #import "chrome/browser/ui/cocoa/omnibox/omnibox_popup_cell.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <cmath> | 10 #include <cmath> |
| 11 | 11 |
| 12 #include "base/i18n/rtl.h" | 12 #include "base/i18n/rtl.h" |
| 13 #include "base/mac/foundation_util.h" | 13 #include "base/mac/foundation_util.h" |
| 14 #include "base/mac/objc_property_releaser.h" | |
| 14 #include "base/mac/scoped_nsobject.h" | 15 #include "base/mac/scoped_nsobject.h" |
| 15 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
| 16 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
| 17 #include "base/strings/sys_string_conversions.h" | 18 #include "base/strings/sys_string_conversions.h" |
| 18 #include "base/strings/utf_string_conversions.h" | 19 #include "base/strings/utf_string_conversions.h" |
| 19 #include "chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.h" | 20 #include "chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.h" |
| 20 #include "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h" | 21 #include "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h" |
| 21 #import "chrome/browser/ui/cocoa/themed_window.h" | 22 #import "chrome/browser/ui/cocoa/themed_window.h" |
| 22 #include "chrome/grit/generated_resources.h" | 23 #include "chrome/grit/generated_resources.h" |
| 23 #include "components/omnibox/browser/omnibox_popup_model.h" | 24 #include "components/omnibox/browser/omnibox_popup_model.h" |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 388 value:DimTextColor(is_dark_theme) | 389 value:DimTextColor(is_dark_theme) |
| 389 range:range]; | 390 range:range]; |
| 390 } | 391 } |
| 391 } | 392 } |
| 392 | 393 |
| 393 return attributedString; | 394 return attributedString; |
| 394 } | 395 } |
| 395 | 396 |
| 396 } // namespace | 397 } // namespace |
| 397 | 398 |
| 399 @interface OmniboxPopupCellData () { | |
| 400 @private | |
|
Robert Sesek
2016/08/11 19:05:35
@private not necessary here, but harmless
erikchen
2016/08/11 19:17:12
Done.
| |
| 401 base::mac::ObjCPropertyReleaser propertyReleaser_OmniboxPopupCellData_; | |
| 402 } | |
| 403 @end | |
| 404 | |
| 398 @interface OmniboxPopupCell () | 405 @interface OmniboxPopupCell () |
| 399 - (CGFloat)drawMatchPart:(NSAttributedString*)attributedString | 406 - (CGFloat)drawMatchPart:(NSAttributedString*)attributedString |
| 400 withFrame:(NSRect)cellFrame | 407 withFrame:(NSRect)cellFrame |
| 401 origin:(NSPoint)origin | 408 origin:(NSPoint)origin |
| 402 withMaxWidth:(int)maxWidth | 409 withMaxWidth:(int)maxWidth |
| 403 forDarkTheme:(BOOL)isDarkTheme; | 410 forDarkTheme:(BOOL)isDarkTheme; |
| 404 - (CGFloat)drawMatchPrefixWithFrame:(NSRect)cellFrame | 411 - (CGFloat)drawMatchPrefixWithFrame:(NSRect)cellFrame |
| 405 tableView:(OmniboxPopupMatrix*)tableView | 412 tableView:(OmniboxPopupMatrix*)tableView |
| 406 withContentsMaxWidth:(int*)contentsMaxWidth | 413 withContentsMaxWidth:(int*)contentsMaxWidth |
| 407 forDarkTheme:(BOOL)isDarkTheme; | 414 forDarkTheme:(BOOL)isDarkTheme; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 458 contents_ = [CreateClassifiedAttributedString( | 465 contents_ = [CreateClassifiedAttributedString( |
| 459 match.contents, ContentTextColor(isDarkTheme), match.contents_class, | 466 match.contents, ContentTextColor(isDarkTheme), match.contents_class, |
| 460 isDarkTheme) retain]; | 467 isDarkTheme) retain]; |
| 461 if (!match.description.empty()) { | 468 if (!match.description.empty()) { |
| 462 description_ = [CreateClassifiedAttributedString( | 469 description_ = [CreateClassifiedAttributedString( |
| 463 match.description, DimTextColor(isDarkTheme), | 470 match.description, DimTextColor(isDarkTheme), |
| 464 match.description_class, isDarkTheme) retain]; | 471 match.description_class, isDarkTheme) retain]; |
| 465 } | 472 } |
| 466 maxLines_ = 1; | 473 maxLines_ = 1; |
| 467 } | 474 } |
| 475 propertyReleaser_OmniboxPopupCellData_.Init(self, | |
| 476 [OmniboxPopupCellData class]); | |
| 468 } | 477 } |
| 469 return self; | 478 return self; |
| 470 } | 479 } |
| 471 | 480 |
| 472 - (void)dealloc { | |
| 473 [incognitoImage_ release]; | |
| 474 [super dealloc]; | |
| 475 } | |
| 476 | |
| 477 - (instancetype)copyWithZone:(NSZone*)zone { | 481 - (instancetype)copyWithZone:(NSZone*)zone { |
| 478 return [self retain]; | 482 return [self retain]; |
| 479 } | 483 } |
| 480 | 484 |
| 481 - (CGFloat)getMatchContentsWidth { | 485 - (CGFloat)getMatchContentsWidth { |
| 482 return [contents_ size].width; | 486 return [contents_ size].width; |
| 483 } | 487 } |
| 484 | 488 |
| 485 @end | 489 @end |
| 486 | 490 |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 736 base::string16 raw_separator = | 740 base::string16 raw_separator = |
| 737 l10n_util::GetStringUTF16(IDS_AUTOCOMPLETE_MATCH_DESCRIPTION_SEPARATOR); | 741 l10n_util::GetStringUTF16(IDS_AUTOCOMPLETE_MATCH_DESCRIPTION_SEPARATOR); |
| 738 return CreateAttributedString(raw_separator, DimTextColor(isDarkTheme)); | 742 return CreateAttributedString(raw_separator, DimTextColor(isDarkTheme)); |
| 739 } | 743 } |
| 740 | 744 |
| 741 + (CGFloat)getContentAreaWidth:(NSRect)cellFrame { | 745 + (CGFloat)getContentAreaWidth:(NSRect)cellFrame { |
| 742 return NSWidth(cellFrame) - TextStartOffset(); | 746 return NSWidth(cellFrame) - TextStartOffset(); |
| 743 } | 747 } |
| 744 | 748 |
| 745 @end | 749 @end |
| OLD | NEW |