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

Side by Side Diff: ios/clean/chrome/browser/ui/tab/tab_container_view_controller.mm

Issue 2737563006: [ios] Adds support for Find in Page to the new architecture. (Closed)
Patch Set: Fix GN. Created 3 years, 8 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/clean/chrome/browser/ui/tab/tab_container_view_controller.h" 5 #import "ios/clean/chrome/browser/ui/tab/tab_container_view_controller.h"
6 6
7 #import "ios/clean/chrome/browser/ui/tab_strip/tab_strip_events.h" 7 #import "ios/clean/chrome/browser/ui/tab_strip/tab_strip_events.h"
8 #import "ios/clean/chrome/browser/ui/ui_types.h" 8 #import "ios/clean/chrome/browser/ui/ui_types.h"
9 9
10 #if !defined(__has_feature) || !__has_feature(objc_arc) 10 #if !defined(__has_feature) || !__has_feature(objc_arc)
11 #error "This file requires ARC support." 11 #error "This file requires ARC support."
12 #endif 12 #endif
13 13
14 namespace { 14 namespace {
15 CGFloat kToolbarHeight = 44.0f; 15 CGFloat kToolbarHeight = 44.0f;
16 CGFloat kTabStripHeight = 120.0f; 16 CGFloat kTabStripHeight = 120.0f;
17 } 17 }
18 18
19 @interface TabContainerViewController () 19 @interface TabContainerViewController ()
20 20
21 // Container views for child view controllers. The child view controller's 21 // Container views for child view controllers. The child view controller's
22 // view is added as a subview that fills it's container view via autoresizing. 22 // view is added as a subview that fills its container view via autoresizing.
23 @property(nonatomic, strong) UIView* findBarView;
23 @property(nonatomic, strong) UIView* tabStripView; 24 @property(nonatomic, strong) UIView* tabStripView;
24 @property(nonatomic, strong) UIView* toolbarView; 25 @property(nonatomic, strong) UIView* toolbarView;
25 @property(nonatomic, strong) UIView* contentView; 26 @property(nonatomic, strong) UIView* contentView;
26 27
27 // Height constraints for tabStripView and toolbarView. 28 // Height constraints for tabStripView and toolbarView.
28 @property(nonatomic, strong) NSLayoutConstraint* tabStripHeightConstraint; 29 @property(nonatomic, strong) NSLayoutConstraint* tabStripHeightConstraint;
29 @property(nonatomic, strong) NSLayoutConstraint* toolbarHeightConstraint; 30 @property(nonatomic, strong) NSLayoutConstraint* toolbarHeightConstraint;
30 31
31 // Cache for forwarding methods to child view controllers. 32 // Cache for forwarding methods to child view controllers.
32 @property(nonatomic, assign) SEL actionToForward; 33 @property(nonatomic, assign) SEL actionToForward;
33 @property(nonatomic, weak) UIResponder* forwardingTarget; 34 @property(nonatomic, weak) UIResponder* forwardingTarget;
34 35
35 // Abstract base method for subclasses to implement. 36 // Abstract base method for subclasses to implement.
36 // Returns constraints for tabStrip, toolbar, and content subviews. 37 // Returns constraints for tabStrip, toolbar, and content subviews.
37 - (Constraints*)subviewConstraints; 38 - (Constraints*)subviewConstraints;
38 39
39 @end 40 @end
40 41
41 @implementation TabContainerViewController 42 @implementation TabContainerViewController
42 43
43 @synthesize contentViewController = _contentViewController; 44 @synthesize contentViewController = _contentViewController;
45 @synthesize findBarView = _findBarView;
46 @synthesize findBarViewController = _findBarViewController;
44 @synthesize toolbarViewController = _toolbarViewController; 47 @synthesize toolbarViewController = _toolbarViewController;
45 @synthesize tabStripViewController = _tabStripViewController; 48 @synthesize tabStripViewController = _tabStripViewController;
46 @synthesize tabStripView = _tabStripView; 49 @synthesize tabStripView = _tabStripView;
47 @synthesize toolbarView = _toolbarView; 50 @synthesize toolbarView = _toolbarView;
48 @synthesize contentView = _contentView; 51 @synthesize contentView = _contentView;
49 @synthesize tabStripHeightConstraint = _tabStripHeightConstraint; 52 @synthesize tabStripHeightConstraint = _tabStripHeightConstraint;
50 @synthesize toolbarHeightConstraint = _toolbarHeightConstraint; 53 @synthesize toolbarHeightConstraint = _toolbarHeightConstraint;
51 @synthesize actionToForward = _actionToForward; 54 @synthesize actionToForward = _actionToForward;
52 @synthesize forwardingTarget = _forwardingTarget; 55 @synthesize forwardingTarget = _forwardingTarget;
53 56
54 #pragma mark - UIViewController 57 #pragma mark - UIViewController
55 58
56 - (void)viewDidLoad { 59 - (void)viewDidLoad {
57 [super viewDidLoad]; 60 [super viewDidLoad];
61 self.findBarView = [[UIView alloc] init];
58 self.tabStripView = [[UIView alloc] init]; 62 self.tabStripView = [[UIView alloc] init];
59 self.toolbarView = [[UIView alloc] init]; 63 self.toolbarView = [[UIView alloc] init];
60 self.contentView = [[UIView alloc] init]; 64 self.contentView = [[UIView alloc] init];
61 [self.view addSubview:self.tabStripView]; 65 self.findBarView.translatesAutoresizingMaskIntoConstraints = NO;
62 [self.view addSubview:self.toolbarView];
63 [self.view addSubview:self.contentView];
64 self.tabStripView.translatesAutoresizingMaskIntoConstraints = NO; 66 self.tabStripView.translatesAutoresizingMaskIntoConstraints = NO;
65 self.toolbarView.translatesAutoresizingMaskIntoConstraints = NO; 67 self.toolbarView.translatesAutoresizingMaskIntoConstraints = NO;
66 self.contentView.translatesAutoresizingMaskIntoConstraints = NO; 68 self.contentView.translatesAutoresizingMaskIntoConstraints = NO;
67 self.view.backgroundColor = [UIColor blackColor]; 69 self.view.backgroundColor = [UIColor blackColor];
70 self.findBarView.backgroundColor = [UIColor greenColor];
68 self.tabStripView.backgroundColor = [UIColor blackColor]; 71 self.tabStripView.backgroundColor = [UIColor blackColor];
69 self.toolbarView.backgroundColor = [UIColor blackColor]; 72 self.toolbarView.backgroundColor = [UIColor blackColor];
70 self.contentView.backgroundColor = [UIColor blackColor]; 73 self.contentView.backgroundColor = [UIColor blackColor];
71 74
75 // Views that are added last have the highest z-order.
76 [self.view addSubview:self.tabStripView];
77 [self.view addSubview:self.toolbarView];
78 [self.view addSubview:self.contentView];
79 [self.view addSubview:self.findBarView];
80 self.findBarView.hidden = YES;
81
72 [self addChildViewController:self.tabStripViewController 82 [self addChildViewController:self.tabStripViewController
73 toSubview:self.tabStripView]; 83 toSubview:self.tabStripView];
74 [self addChildViewController:self.toolbarViewController 84 [self addChildViewController:self.toolbarViewController
75 toSubview:self.toolbarView]; 85 toSubview:self.toolbarView];
76 [self addChildViewController:self.contentViewController 86 [self addChildViewController:self.contentViewController
77 toSubview:self.contentView]; 87 toSubview:self.contentView];
78 88
79 self.tabStripHeightConstraint = 89 self.tabStripHeightConstraint =
80 [self.tabStripView.heightAnchor constraintEqualToConstant:0.0f]; 90 [self.tabStripView.heightAnchor constraintEqualToConstant:0.0f];
81 self.toolbarHeightConstraint = 91 self.toolbarHeightConstraint =
(...skipping 11 matching lines...) Expand all
93 if (self.contentViewController == contentViewController) 103 if (self.contentViewController == contentViewController)
94 return; 104 return;
95 if ([self isViewLoaded]) { 105 if ([self isViewLoaded]) {
96 [self detachChildViewController:self.contentViewController]; 106 [self detachChildViewController:self.contentViewController];
97 [self addChildViewController:contentViewController 107 [self addChildViewController:contentViewController
98 toSubview:self.contentView]; 108 toSubview:self.contentView];
99 } 109 }
100 _contentViewController = contentViewController; 110 _contentViewController = contentViewController;
101 } 111 }
102 112
113 - (void)setFindBarViewController:(UIViewController*)findBarViewController {
114 if (self.findBarViewController == findBarViewController)
115 return;
116 if ([self isViewLoaded]) {
117 [self detachChildViewController:self.findBarViewController];
118 [self addChildViewController:findBarViewController
119 toSubview:self.findBarView];
120 }
121 _findBarViewController = findBarViewController;
122 self.findBarView.hidden = (_findBarViewController == nil);
123 }
124
103 - (void)setToolbarViewController:(UIViewController*)toolbarViewController { 125 - (void)setToolbarViewController:(UIViewController*)toolbarViewController {
104 if (self.toolbarViewController == toolbarViewController) 126 if (self.toolbarViewController == toolbarViewController)
105 return; 127 return;
106 if ([self isViewLoaded]) { 128 if ([self isViewLoaded]) {
107 [self detachChildViewController:self.toolbarViewController]; 129 [self detachChildViewController:self.toolbarViewController];
108 [self addChildViewController:toolbarViewController 130 [self addChildViewController:toolbarViewController
109 toSubview:self.toolbarView]; 131 toSubview:self.toolbarView];
110 } 132 }
111 _toolbarViewController = toolbarViewController; 133 _toolbarViewController = toolbarViewController;
112 } 134 }
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 235
214 #pragma mark - NSObject method forwarding 236 #pragma mark - NSObject method forwarding
215 237
216 - (id)forwardingTargetForSelector:(SEL)aSelector { 238 - (id)forwardingTargetForSelector:(SEL)aSelector {
217 if (aSelector == self.actionToForward) { 239 if (aSelector == self.actionToForward) {
218 return self.forwardingTarget; 240 return self.forwardingTarget;
219 } 241 }
220 return nil; 242 return nil;
221 } 243 }
222 244
223 #pragma mark - TabStripActions 245 #pragma mark - Action handling
246
224 - (void)showTabStrip:(id)sender { 247 - (void)showTabStrip:(id)sender {
225 self.tabStripHeightConstraint.constant = kTabStripHeight; 248 self.tabStripHeightConstraint.constant = kTabStripHeight;
226 // HACK: Remove fake action. 249 // HACK: Remove fake action.
227 [[UIApplication sharedApplication] sendAction:@selector(tabStripDidShow:) 250 [[UIApplication sharedApplication] sendAction:@selector(tabStripDidShow:)
228 to:nil 251 to:nil
229 from:sender 252 from:sender
230 forEvent:nil]; 253 forEvent:nil];
231 } 254 }
232 255
233 - (void)hideTabStrip:(id)sender { 256 - (void)hideTabStrip:(id)sender {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 constraintEqualToAnchor:self.view.trailingAnchor], 293 constraintEqualToAnchor:self.view.trailingAnchor],
271 self.toolbarHeightConstraint, 294 self.toolbarHeightConstraint,
272 [self.contentView.topAnchor 295 [self.contentView.topAnchor
273 constraintEqualToAnchor:self.toolbarView.bottomAnchor], 296 constraintEqualToAnchor:self.toolbarView.bottomAnchor],
274 [self.contentView.leadingAnchor 297 [self.contentView.leadingAnchor
275 constraintEqualToAnchor:self.view.leadingAnchor], 298 constraintEqualToAnchor:self.view.leadingAnchor],
276 [self.contentView.trailingAnchor 299 [self.contentView.trailingAnchor
277 constraintEqualToAnchor:self.view.trailingAnchor], 300 constraintEqualToAnchor:self.view.trailingAnchor],
278 [self.contentView.bottomAnchor 301 [self.contentView.bottomAnchor
279 constraintEqualToAnchor:self.bottomLayoutGuide.topAnchor], 302 constraintEqualToAnchor:self.bottomLayoutGuide.topAnchor],
303
304 [self.findBarView.topAnchor
305 constraintEqualToAnchor:self.toolbarView.topAnchor],
306 [self.findBarView.bottomAnchor
307 constraintEqualToAnchor:self.toolbarView.bottomAnchor],
308 [self.findBarView.leadingAnchor
309 constraintEqualToAnchor:self.toolbarView.leadingAnchor],
310 [self.findBarView.trailingAnchor
311 constraintEqualToAnchor:self.toolbarView.trailingAnchor],
280 ]; 312 ];
281 } 313 }
282 314
283 @end 315 @end
284 316
285 @implementation BottomToolbarTabViewController 317 @implementation BottomToolbarTabViewController
286 318
287 // Override with constraints that place the toolbar on bottom. 319 // Override with constraints that place the toolbar on bottom.
288 - (Constraints*)subviewConstraints { 320 - (Constraints*)subviewConstraints {
289 return @[ 321 return @[
(...skipping 16 matching lines...) Expand all
306 constraintEqualToAnchor:self.view.leadingAnchor], 338 constraintEqualToAnchor:self.view.leadingAnchor],
307 [self.toolbarView.trailingAnchor 339 [self.toolbarView.trailingAnchor
308 constraintEqualToAnchor:self.view.trailingAnchor], 340 constraintEqualToAnchor:self.view.trailingAnchor],
309 self.toolbarHeightConstraint, 341 self.toolbarHeightConstraint,
310 [self.toolbarView.bottomAnchor 342 [self.toolbarView.bottomAnchor
311 constraintEqualToAnchor:self.bottomLayoutGuide.topAnchor], 343 constraintEqualToAnchor:self.bottomLayoutGuide.topAnchor],
312 ]; 344 ];
313 } 345 }
314 346
315 @end 347 @end
OLDNEW
« no previous file with comments | « ios/clean/chrome/browser/ui/tab/tab_container_view_controller.h ('k') | ios/clean/chrome/browser/ui/tab/tab_coordinator.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698