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 #if !defined(__has_feature) || !__has_feature(objc_arc) |
7 #include "base/mac/scoped_nsobject.h" | 7 #error "This file requires ARC support." |
8 | 8 #endif |
9 @interface BookmarkTopBar () { | |
10 base::mac::ObjCPropertyReleaser _propertyReleaser_BookmarkBar; | |
11 } | |
12 @property(nonatomic, retain) UIView* contentView; | |
13 @end | |
14 | 9 |
15 @implementation BookmarkTopBar | 10 @implementation BookmarkTopBar |
16 | 11 |
17 @synthesize contentView = _contentView; | 12 @synthesize contentView = _contentView; |
18 | 13 |
19 + (CGFloat)expectedContentViewHeight { | 14 + (CGFloat)expectedContentViewHeight { |
20 return 56.0; | 15 return 56.0; |
21 } | 16 } |
22 | 17 |
23 - (instancetype)initWithFrame:(CGRect)frame { | 18 - (instancetype)initWithFrame:(CGRect)frame { |
24 self = [super initWithFrame:frame]; | 19 self = [super initWithFrame:frame]; |
25 if (self) { | 20 if (self) { |
26 _propertyReleaser_BookmarkBar.Init(self, [BookmarkTopBar class]); | |
27 | |
28 self.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin | | 21 self.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin | |
29 UIViewAutoresizingFlexibleWidth; | 22 UIViewAutoresizingFlexibleWidth; |
30 | 23 |
31 base::scoped_nsobject<UIView> contentView([[UIView alloc] init]); | 24 _contentView = [[UIView alloc] init]; |
32 self.contentView.backgroundColor = [UIColor clearColor]; | 25 [self addSubview:_contentView]; |
33 [self addSubview:contentView]; | |
34 self.contentView = contentView; | |
35 | 26 |
36 [self statelessLayoutContentView]; | 27 [self statelessLayoutContentView]; |
37 } | 28 } |
38 return self; | 29 return self; |
39 } | 30 } |
40 | 31 |
41 - (void)layoutSubviews { | 32 - (void)layoutSubviews { |
42 [super layoutSubviews]; | 33 [super layoutSubviews]; |
43 | 34 |
44 // The content view. | 35 // The content view. |
45 [self statelessLayoutContentView]; | 36 [self statelessLayoutContentView]; |
46 } | 37 } |
47 | 38 |
48 - (void)statelessLayoutContentView { | 39 - (void)statelessLayoutContentView { |
49 self.contentView.frame = CGRectMake( | 40 self.contentView.frame = CGRectMake( |
50 0, | 41 0, |
51 CGRectGetHeight(self.bounds) - [[self class] expectedContentViewHeight], | 42 CGRectGetHeight(self.bounds) - [[self class] expectedContentViewHeight], |
52 CGRectGetWidth(self.bounds), [[self class] expectedContentViewHeight]); | 43 CGRectGetWidth(self.bounds), [[self class] expectedContentViewHeight]); |
53 } | 44 } |
54 | 45 |
55 @end | 46 @end |
OLD | NEW |