| 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_release_properties.h" | 14 #include "base/mac/objc_property_releaser.h" |
| 15 #include "base/mac/scoped_nsobject.h" | 15 #include "base/mac/scoped_nsobject.h" |
| 16 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
| 17 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
| 18 #include "base/strings/sys_string_conversions.h" | 18 #include "base/strings/sys_string_conversions.h" |
| 19 #include "base/strings/utf_string_conversions.h" | 19 #include "base/strings/utf_string_conversions.h" |
| 20 #include "chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.h" | 20 #include "chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.h" |
| 21 #include "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h" | 21 #include "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h" |
| 22 #import "chrome/browser/ui/cocoa/themed_window.h" | 22 #import "chrome/browser/ui/cocoa/themed_window.h" |
| 23 #include "chrome/grit/generated_resources.h" | 23 #include "chrome/grit/generated_resources.h" |
| 24 #include "components/omnibox/browser/omnibox_popup_model.h" | 24 #include "components/omnibox/browser/omnibox_popup_model.h" |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 value:DimTextColor(is_dark_theme) | 336 value:DimTextColor(is_dark_theme) |
| 337 range:range]; | 337 range:range]; |
| 338 } | 338 } |
| 339 } | 339 } |
| 340 | 340 |
| 341 return attributedString; | 341 return attributedString; |
| 342 } | 342 } |
| 343 | 343 |
| 344 } // namespace | 344 } // namespace |
| 345 | 345 |
| 346 @interface OmniboxPopupCellData () { |
| 347 base::mac::ObjCPropertyReleaser propertyReleaser_OmniboxPopupCellData_; |
| 348 } |
| 349 @end |
| 350 |
| 346 @interface OmniboxPopupCell () | 351 @interface OmniboxPopupCell () |
| 347 - (CGFloat)drawMatchPart:(NSAttributedString*)attributedString | 352 - (CGFloat)drawMatchPart:(NSAttributedString*)attributedString |
| 348 withFrame:(NSRect)cellFrame | 353 withFrame:(NSRect)cellFrame |
| 349 origin:(NSPoint)origin | 354 origin:(NSPoint)origin |
| 350 withMaxWidth:(int)maxWidth | 355 withMaxWidth:(int)maxWidth |
| 351 forDarkTheme:(BOOL)isDarkTheme; | 356 forDarkTheme:(BOOL)isDarkTheme; |
| 352 - (CGFloat)drawMatchPrefixWithFrame:(NSRect)cellFrame | 357 - (CGFloat)drawMatchPrefixWithFrame:(NSRect)cellFrame |
| 353 tableView:(OmniboxPopupMatrix*)tableView | 358 tableView:(OmniboxPopupMatrix*)tableView |
| 354 withContentsMaxWidth:(int*)contentsMaxWidth | 359 withContentsMaxWidth:(int*)contentsMaxWidth |
| 355 forDarkTheme:(BOOL)isDarkTheme; | 360 forDarkTheme:(BOOL)isDarkTheme; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 contents_ = [CreateClassifiedAttributedString( | 411 contents_ = [CreateClassifiedAttributedString( |
| 407 match.contents, ContentTextColor(isDarkTheme), match.contents_class, | 412 match.contents, ContentTextColor(isDarkTheme), match.contents_class, |
| 408 isDarkTheme) retain]; | 413 isDarkTheme) retain]; |
| 409 if (!match.description.empty()) { | 414 if (!match.description.empty()) { |
| 410 description_ = [CreateClassifiedAttributedString( | 415 description_ = [CreateClassifiedAttributedString( |
| 411 match.description, DimTextColor(isDarkTheme), | 416 match.description, DimTextColor(isDarkTheme), |
| 412 match.description_class, isDarkTheme) retain]; | 417 match.description_class, isDarkTheme) retain]; |
| 413 } | 418 } |
| 414 maxLines_ = 1; | 419 maxLines_ = 1; |
| 415 } | 420 } |
| 421 propertyReleaser_OmniboxPopupCellData_.Init(self, |
| 422 [OmniboxPopupCellData class]); |
| 416 } | 423 } |
| 417 return self; | 424 return self; |
| 418 } | 425 } |
| 419 | 426 |
| 420 - (void)dealloc { | |
| 421 base::mac::ReleaseProperties(self); | |
| 422 [super dealloc]; | |
| 423 } | |
| 424 | |
| 425 - (instancetype)copyWithZone:(NSZone*)zone { | 427 - (instancetype)copyWithZone:(NSZone*)zone { |
| 426 return [self retain]; | 428 return [self retain]; |
| 427 } | 429 } |
| 428 | 430 |
| 429 - (CGFloat)getMatchContentsWidth { | 431 - (CGFloat)getMatchContentsWidth { |
| 430 return [contents_ size].width; | 432 return [contents_ size].width; |
| 431 } | 433 } |
| 432 | 434 |
| 433 @end | 435 @end |
| 434 | 436 |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 677 base::string16 raw_separator = | 679 base::string16 raw_separator = |
| 678 l10n_util::GetStringUTF16(IDS_AUTOCOMPLETE_MATCH_DESCRIPTION_SEPARATOR); | 680 l10n_util::GetStringUTF16(IDS_AUTOCOMPLETE_MATCH_DESCRIPTION_SEPARATOR); |
| 679 return CreateAttributedString(raw_separator, DimTextColor(isDarkTheme)); | 681 return CreateAttributedString(raw_separator, DimTextColor(isDarkTheme)); |
| 680 } | 682 } |
| 681 | 683 |
| 682 + (CGFloat)getContentAreaWidth:(NSRect)cellFrame { | 684 + (CGFloat)getContentAreaWidth:(NSRect)cellFrame { |
| 683 return NSWidth(cellFrame) - kMaterialTextStartOffset; | 685 return NSWidth(cellFrame) - kMaterialTextStartOffset; |
| 684 } | 686 } |
| 685 | 687 |
| 686 @end | 688 @end |
| OLD | NEW |