| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #import "ios/chrome/browser/ui/bookmarks/bars/bookmark_top_bar.h" | 4 #import "ios/chrome/browser/ui/bookmarks/bars/bookmark_top_bar.h" |
| 5 | 5 |
| 6 #include "base/mac/objc_property_releaser.h" | 6 #include "base/mac/objc_release_properties.h" |
| 7 #include "base/mac/scoped_nsobject.h" | 7 #include "base/mac/scoped_nsobject.h" |
| 8 | 8 |
| 9 @interface BookmarkTopBar () { | 9 @interface BookmarkTopBar () |
| 10 base::mac::ObjCPropertyReleaser _propertyReleaser_BookmarkBar; | |
| 11 } | |
| 12 @property(nonatomic, retain) UIView* contentView; | 10 @property(nonatomic, retain) UIView* contentView; |
| 13 @end | 11 @end |
| 14 | 12 |
| 15 @implementation BookmarkTopBar | 13 @implementation BookmarkTopBar |
| 16 | 14 |
| 17 @synthesize contentView = _contentView; | 15 @synthesize contentView = _contentView; |
| 18 | 16 |
| 19 + (CGFloat)expectedContentViewHeight { | 17 + (CGFloat)expectedContentViewHeight { |
| 20 return 56.0; | 18 return 56.0; |
| 21 } | 19 } |
| 22 | 20 |
| 23 - (instancetype)initWithFrame:(CGRect)frame { | 21 - (instancetype)initWithFrame:(CGRect)frame { |
| 24 self = [super initWithFrame:frame]; | 22 self = [super initWithFrame:frame]; |
| 25 if (self) { | 23 if (self) { |
| 26 _propertyReleaser_BookmarkBar.Init(self, [BookmarkTopBar class]); | |
| 27 | |
| 28 self.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin | | 24 self.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin | |
| 29 UIViewAutoresizingFlexibleWidth; | 25 UIViewAutoresizingFlexibleWidth; |
| 30 | 26 |
| 31 base::scoped_nsobject<UIView> contentView([[UIView alloc] init]); | 27 base::scoped_nsobject<UIView> contentView([[UIView alloc] init]); |
| 32 self.contentView.backgroundColor = [UIColor clearColor]; | 28 self.contentView.backgroundColor = [UIColor clearColor]; |
| 33 [self addSubview:contentView]; | 29 [self addSubview:contentView]; |
| 34 self.contentView = contentView; | 30 self.contentView = contentView; |
| 35 | 31 |
| 36 [self statelessLayoutContentView]; | 32 [self statelessLayoutContentView]; |
| 37 } | 33 } |
| 38 return self; | 34 return self; |
| 39 } | 35 } |
| 40 | 36 |
| 37 - (void)dealloc { |
| 38 base::mac::ReleaseProperties(self); |
| 39 [super dealloc]; |
| 40 } |
| 41 |
| 41 - (void)layoutSubviews { | 42 - (void)layoutSubviews { |
| 42 [super layoutSubviews]; | 43 [super layoutSubviews]; |
| 43 | 44 |
| 44 // The content view. | 45 // The content view. |
| 45 [self statelessLayoutContentView]; | 46 [self statelessLayoutContentView]; |
| 46 } | 47 } |
| 47 | 48 |
| 48 - (void)statelessLayoutContentView { | 49 - (void)statelessLayoutContentView { |
| 49 self.contentView.frame = CGRectMake( | 50 self.contentView.frame = CGRectMake( |
| 50 0, | 51 0, |
| 51 CGRectGetHeight(self.bounds) - [[self class] expectedContentViewHeight], | 52 CGRectGetHeight(self.bounds) - [[self class] expectedContentViewHeight], |
| 52 CGRectGetWidth(self.bounds), [[self class] expectedContentViewHeight]); | 53 CGRectGetWidth(self.bounds), [[self class] expectedContentViewHeight]); |
| 53 } | 54 } |
| 54 | 55 |
| 55 @end | 56 @end |
| OLD | NEW |