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

Side by Side Diff: ios/chrome/browser/ui/ntp/new_tab_page_bar.mm

Issue 2881183002: Revert of Replace ObjCPropertyReleaser with ReleaseProperties() project-wide. (Closed)
Patch Set: Created 3 years, 7 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/ntp/new_tab_page_bar.h" 5 #import "ios/chrome/browser/ui/ntp/new_tab_page_bar.h"
6 6
7 #import <QuartzCore/QuartzCore.h> 7 #import <QuartzCore/QuartzCore.h>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/mac/objc_release_properties.h" 11 #include "base/mac/objc_property_releaser.h"
12 #include "base/mac/scoped_nsobject.h" 12 #include "base/mac/scoped_nsobject.h"
13 #import "ios/chrome/browser/ui/bookmarks/bookmark_utils_ios.h" 13 #import "ios/chrome/browser/ui/bookmarks/bookmark_utils_ios.h"
14 #import "ios/chrome/browser/ui/ntp/new_tab_page_bar_button.h" 14 #import "ios/chrome/browser/ui/ntp/new_tab_page_bar_button.h"
15 #import "ios/chrome/browser/ui/ntp/new_tab_page_bar_item.h" 15 #import "ios/chrome/browser/ui/ntp/new_tab_page_bar_item.h"
16 #import "ios/chrome/browser/ui/rtl_geometry.h" 16 #import "ios/chrome/browser/ui/rtl_geometry.h"
17 #include "ios/chrome/browser/ui/ui_util.h" 17 #include "ios/chrome/browser/ui/ui_util.h"
18 #import "ios/chrome/browser/ui/uikit_ui_util.h" 18 #import "ios/chrome/browser/ui/uikit_ui_util.h"
19 #import "ui/gfx/ios/NSString+CrStringDrawing.h" 19 #import "ui/gfx/ios/NSString+CrStringDrawing.h"
20 #include "ui/gfx/scoped_ui_graphics_push_context_ios.h" 20 #include "ui/gfx/scoped_ui_graphics_push_context_ios.h"
21 21
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 // Logo view, used to center the tab buttons. 59 // Logo view, used to center the tab buttons.
60 base::scoped_nsobject<UIImageView> logoView_; 60 base::scoped_nsobject<UIImageView> logoView_;
61 // Overlay view, used to highlight the selected button. 61 // Overlay view, used to highlight the selected button.
62 base::scoped_nsobject<UIImageView> overlayView_; 62 base::scoped_nsobject<UIImageView> overlayView_;
63 // Overlay view, used to highlight the selected button. 63 // Overlay view, used to highlight the selected button.
64 base::scoped_nsobject<UIView> overlayColorView_; 64 base::scoped_nsobject<UIView> overlayColorView_;
65 // Width of a button. 65 // Width of a button.
66 CGFloat buttonWidth_; 66 CGFloat buttonWidth_;
67 // Percentage overlay sits over tab bar buttons. 67 // Percentage overlay sits over tab bar buttons.
68 CGFloat overlayPercentage_; 68 CGFloat overlayPercentage_;
69
70 base::mac::ObjCPropertyReleaser propertyReleaser_NewTabPageBar_;
69 } 71 }
70 72
71 @synthesize items = items_; 73 @synthesize items = items_;
72 @synthesize selectedIndex = selectedIndex_; 74 @synthesize selectedIndex = selectedIndex_;
73 @synthesize popupButton = popupButton_; 75 @synthesize popupButton = popupButton_;
74 @synthesize buttons = buttons_; 76 @synthesize buttons = buttons_;
75 @synthesize delegate = delegate_; 77 @synthesize delegate = delegate_;
76 @synthesize overlayPercentage = overlayPercentage_; 78 @synthesize overlayPercentage = overlayPercentage_;
77 79
78 - (id)initWithFrame:(CGRect)frame { 80 - (id)initWithFrame:(CGRect)frame {
79 self = [super initWithFrame:frame]; 81 self = [super initWithFrame:frame];
80 if (self) { 82 if (self) {
81 [self setup]; 83 [self setup];
82 } 84 }
83 return self; 85 return self;
84 } 86 }
85 87
86 - (id)initWithCoder:(NSCoder*)aDecoder { 88 - (id)initWithCoder:(NSCoder*)aDecoder {
87 self = [super initWithCoder:aDecoder]; 89 self = [super initWithCoder:aDecoder];
88 if (self) { 90 if (self) {
89 [self setup]; 91 [self setup];
90 } 92 }
91 return self; 93 return self;
92 } 94 }
93 95
94 - (void)setup { 96 - (void)setup {
97 propertyReleaser_NewTabPageBar_.Init(self, [NewTabPageBar class]);
95 self.selectedIndex = NSNotFound; 98 self.selectedIndex = NSNotFound;
96 canAnimate_ = NO; 99 canAnimate_ = NO;
97 self.autoresizingMask = 100 self.autoresizingMask =
98 UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleBottomMargin; 101 UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleBottomMargin;
99 self.autoresizesSubviews = YES; 102 self.autoresizesSubviews = YES;
100 self.backgroundColor = [UIColor clearColor]; 103 self.backgroundColor = [UIColor clearColor];
101 104
102 if ([self showOverlay]) { 105 if ([self showOverlay]) {
103 overlayView_.reset( 106 overlayView_.reset(
104 [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, buttonWidth_, 2)]); 107 [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, buttonWidth_, 2)]);
(...skipping 18 matching lines...) Expand all
123 // Shadow is positioned directly above the new tab page bar. 126 // Shadow is positioned directly above the new tab page bar.
124 [shadow_ 127 [shadow_
125 setFrame:CGRectMake(0, -shadowImage.size.height, self.bounds.size.width, 128 setFrame:CGRectMake(0, -shadowImage.size.height, self.bounds.size.width,
126 shadowImage.size.height)]; 129 shadowImage.size.height)];
127 [shadow_ setAutoresizingMask:UIViewAutoresizingFlexibleWidth]; 130 [shadow_ setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
128 [self addSubview:shadow_]; 131 [self addSubview:shadow_];
129 132
130 self.contentMode = UIViewContentModeRedraw; 133 self.contentMode = UIViewContentModeRedraw;
131 } 134 }
132 135
133 - (void)dealloc {
134 base::mac::ReleaseProperties(self);
135 [super dealloc];
136 }
137
138 - (void)layoutSubviews { 136 - (void)layoutSubviews {
139 [super layoutSubviews]; 137 [super layoutSubviews];
140 138
141 // |buttonWidth_| changes with the screen orientation when the NTP button bar 139 // |buttonWidth_| changes with the screen orientation when the NTP button bar
142 // is enabled. 140 // is enabled.
143 [self calculateButtonWidth]; 141 [self calculateButtonWidth];
144 142
145 CGFloat logoWidth = logoView_.get().image.size.width; 143 CGFloat logoWidth = logoView_.get().image.size.width;
146 CGFloat padding = [self useIconsInButtons] ? logoWidth : 0; 144 CGFloat padding = [self useIconsInButtons] ? logoWidth : 0;
147 CGFloat buttonPadding = floor((CGRectGetWidth(self.bounds) - padding - 145 CGFloat buttonPadding = floor((CGRectGetWidth(self.bounds) - padding -
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 return !IsIPadIdiom() || IsCompactTablet(); 322 return !IsIPadIdiom() || IsCompactTablet();
325 } 323 }
326 324
327 - (BOOL)showOverlay { 325 - (BOOL)showOverlay {
328 // The bar buttons launch modal dialogs on tap on iPhone. Don't show overlay 326 // The bar buttons launch modal dialogs on tap on iPhone. Don't show overlay
329 // in this case. 327 // in this case.
330 return IsIPadIdiom(); 328 return IsIPadIdiom();
331 } 329 }
332 330
333 @end 331 @end
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/main/browser_view_wrangler.mm ('k') | ios/chrome/browser/ui/ntp/new_tab_page_bar_button.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698