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

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

Issue 2252523002: [Merge to 2785] Fix many memory leaks in chrome/browser/ui/cocoa/omnibox. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2785
Patch Set: Created 4 years, 4 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_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
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 base::mac::ObjCPropertyReleaser propertyReleaser_OmniboxPopupCellData_;
401 }
402 @end
403
398 @interface OmniboxPopupCell () 404 @interface OmniboxPopupCell ()
399 - (CGFloat)drawMatchPart:(NSAttributedString*)attributedString 405 - (CGFloat)drawMatchPart:(NSAttributedString*)attributedString
400 withFrame:(NSRect)cellFrame 406 withFrame:(NSRect)cellFrame
401 origin:(NSPoint)origin 407 origin:(NSPoint)origin
402 withMaxWidth:(int)maxWidth 408 withMaxWidth:(int)maxWidth
403 forDarkTheme:(BOOL)isDarkTheme; 409 forDarkTheme:(BOOL)isDarkTheme;
404 - (CGFloat)drawMatchPrefixWithFrame:(NSRect)cellFrame 410 - (CGFloat)drawMatchPrefixWithFrame:(NSRect)cellFrame
405 tableView:(OmniboxPopupMatrix*)tableView 411 tableView:(OmniboxPopupMatrix*)tableView
406 withContentsMaxWidth:(int*)contentsMaxWidth 412 withContentsMaxWidth:(int*)contentsMaxWidth
407 forDarkTheme:(BOOL)isDarkTheme; 413 forDarkTheme:(BOOL)isDarkTheme;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 contents_ = [CreateClassifiedAttributedString( 464 contents_ = [CreateClassifiedAttributedString(
459 match.contents, ContentTextColor(isDarkTheme), match.contents_class, 465 match.contents, ContentTextColor(isDarkTheme), match.contents_class,
460 isDarkTheme) retain]; 466 isDarkTheme) retain];
461 if (!match.description.empty()) { 467 if (!match.description.empty()) {
462 description_ = [CreateClassifiedAttributedString( 468 description_ = [CreateClassifiedAttributedString(
463 match.description, DimTextColor(isDarkTheme), 469 match.description, DimTextColor(isDarkTheme),
464 match.description_class, isDarkTheme) retain]; 470 match.description_class, isDarkTheme) retain];
465 } 471 }
466 max_lines_ = 1; 472 max_lines_ = 1;
467 } 473 }
474 propertyReleaser_OmniboxPopupCellData_.Init(self,
475 [OmniboxPopupCellData class]);
468 } 476 }
469 return self; 477 return self;
470 } 478 }
471 479
472 - (void)dealloc {
473 [incognitoImage_ release];
474 [super dealloc];
475 }
476
477 - (instancetype)copyWithZone:(NSZone*)zone { 480 - (instancetype)copyWithZone:(NSZone*)zone {
478 return [self retain]; 481 return [self retain];
479 } 482 }
480 483
481 - (CGFloat)getMatchContentsWidth { 484 - (CGFloat)getMatchContentsWidth {
482 return [contents_ size].width; 485 return [contents_ size].width;
483 } 486 }
484 487
485 @end 488 @end
486 489
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 base::string16 raw_separator = 739 base::string16 raw_separator =
737 l10n_util::GetStringUTF16(IDS_AUTOCOMPLETE_MATCH_DESCRIPTION_SEPARATOR); 740 l10n_util::GetStringUTF16(IDS_AUTOCOMPLETE_MATCH_DESCRIPTION_SEPARATOR);
738 return CreateAttributedString(raw_separator, DimTextColor(isDarkTheme)); 741 return CreateAttributedString(raw_separator, DimTextColor(isDarkTheme));
739 } 742 }
740 743
741 + (CGFloat)getContentAreaWidth:(NSRect)cellFrame { 744 + (CGFloat)getContentAreaWidth:(NSRect)cellFrame {
742 return NSWidth(cellFrame) - TextStartOffset(); 745 return NSWidth(cellFrame) - TextStartOffset();
743 } 746 }
744 747
745 @end 748 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/omnibox/omnibox_popup_cell.h ('k') | chrome/browser/ui/cocoa/omnibox/omnibox_popup_matrix.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698