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 UIView* contentView = [[UIView alloc] init]; |
lpromero
2017/03/10 15:45:14
Use _contentView here. See below.
stkhapugin
2017/04/10 13:51:06
Done.
| |
32 self.contentView.backgroundColor = [UIColor clearColor]; | 25 self.contentView.backgroundColor = [UIColor clearColor]; |
lpromero
2017/03/10 15:45:15
This is a bug, as self.contentView is nil here. Yo
stkhapugin
2017/04/10 13:51:06
Done.
| |
33 [self addSubview:contentView]; | 26 [self addSubview:contentView]; |
34 self.contentView = contentView; | 27 _contentView = contentView; |
35 | 28 |
36 [self statelessLayoutContentView]; | 29 [self statelessLayoutContentView]; |
37 } | 30 } |
38 return self; | 31 return self; |
39 } | 32 } |
40 | 33 |
41 - (void)layoutSubviews { | 34 - (void)layoutSubviews { |
42 [super layoutSubviews]; | 35 [super layoutSubviews]; |
43 | 36 |
44 // The content view. | 37 // The content view. |
45 [self statelessLayoutContentView]; | 38 [self statelessLayoutContentView]; |
46 } | 39 } |
47 | 40 |
48 - (void)statelessLayoutContentView { | 41 - (void)statelessLayoutContentView { |
49 self.contentView.frame = CGRectMake( | 42 self.contentView.frame = CGRectMake( |
50 0, | 43 0, |
51 CGRectGetHeight(self.bounds) - [[self class] expectedContentViewHeight], | 44 CGRectGetHeight(self.bounds) - [[self class] expectedContentViewHeight], |
52 CGRectGetWidth(self.bounds), [[self class] expectedContentViewHeight]); | 45 CGRectGetWidth(self.bounds), [[self class] expectedContentViewHeight]); |
53 } | 46 } |
54 | 47 |
55 @end | 48 @end |
OLD | NEW |