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

Side by Side Diff: ios/clean/chrome/browser/ui/tab_strip/tab_strip_container_view_controller.mm

Issue 2709013002: [ios clean] Rename removeChildViewController -> detachChildViewController (Closed)
Patch Set: Created 3 years, 10 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 // ====== New Architecture ===== 5 // ====== New Architecture =====
6 // = This code is only used in the new iOS Chrome architecture. = 6 // = This code is only used in the new iOS Chrome architecture. =
7 // ============================================================================ 7 // ============================================================================
8 8
9 #import "ios/clean/chrome/browser/ui/tab_strip/tab_strip_container_view_controll er.h" 9 #import "ios/clean/chrome/browser/ui/tab_strip/tab_strip_container_view_controll er.h"
10 10
(...skipping 19 matching lines...) Expand all
30 @property(nonatomic, strong) Constraints* contentConstraintsWithoutStrip; 30 @property(nonatomic, strong) Constraints* contentConstraintsWithoutStrip;
31 @property(nonatomic, strong) Constraints* stripConstraints; 31 @property(nonatomic, strong) Constraints* stripConstraints;
32 32
33 // Cache for forwarding methods to child view controllers. 33 // Cache for forwarding methods to child view controllers.
34 @property(nonatomic, assign) SEL actionToForward; 34 @property(nonatomic, assign) SEL actionToForward;
35 @property(nonatomic, weak) UIResponder* forwardingTarget; 35 @property(nonatomic, weak) UIResponder* forwardingTarget;
36 36
37 @property(nonatomic, strong) NSLayoutConstraint* stripHeightConstraint; 37 @property(nonatomic, strong) NSLayoutConstraint* stripHeightConstraint;
38 38
39 // Contained view controller utility methods. 39 // Contained view controller utility methods.
40 - (void)removeChildViewController:(UIViewController*)viewController; 40 - (void)removeChildViewControllerFromParent:(UIViewController*)viewController;
41 41
42 // Called after a new content view controller is set, but before 42 // Called after a new content view controller is set, but before
43 // |-didMoveToParentViewController:| is called on that view controller. 43 // |-didMoveToParentViewController:| is called on that view controller.
44 - (void)didAddContentViewController; 44 - (void)didAddContentViewController;
45 45
46 // Called after a new strip view controller is set, but before 46 // Called after a new strip view controller is set, but before
47 // |-didMoveToParentViewController:| is called on that view controller. 47 // |-didMoveToParentViewController:| is called on that view controller.
48 - (void)didAddTabStripViewController; 48 - (void)didAddTabStripViewController;
49 49
50 // Methods to populate the constraint properties. 50 // Methods to populate the constraint properties.
(...skipping 18 matching lines...) Expand all
69 #pragma mark - Public properties 69 #pragma mark - Public properties
70 70
71 - (void)setContentViewController:(UIViewController*)contentViewController { 71 - (void)setContentViewController:(UIViewController*)contentViewController {
72 if (self.contentViewController == contentViewController) 72 if (self.contentViewController == contentViewController)
73 return; 73 return;
74 74
75 // Remove the current content view controller, if any. 75 // Remove the current content view controller, if any.
76 [NSLayoutConstraint 76 [NSLayoutConstraint
77 deactivateConstraints:self.contentConstraintsWithoutStrip]; 77 deactivateConstraints:self.contentConstraintsWithoutStrip];
78 [NSLayoutConstraint deactivateConstraints:self.contentConstraintsWithStrip]; 78 [NSLayoutConstraint deactivateConstraints:self.contentConstraintsWithStrip];
79 [self removeChildViewController:self.contentViewController]; 79 [self removeChildViewControllerFromParent:self.contentViewController];
80 80
81 // Add the new content view controller. 81 // Add the new content view controller.
82 [self addChildViewController:contentViewController]; 82 [self addChildViewController:contentViewController];
83 contentViewController.view.translatesAutoresizingMaskIntoConstraints = NO; 83 contentViewController.view.translatesAutoresizingMaskIntoConstraints = NO;
84 [self.view addSubview:contentViewController.view]; 84 [self.view addSubview:contentViewController.view];
85 _contentViewController = contentViewController; 85 _contentViewController = contentViewController;
86 [self didAddContentViewController]; 86 [self didAddContentViewController];
87 [self.view setNeedsUpdateConstraints]; 87 [self.view setNeedsUpdateConstraints];
88 [self.contentViewController didMoveToParentViewController:self]; 88 [self.contentViewController didMoveToParentViewController:self];
89 } 89 }
90 90
91 - (void)setTabStripViewController:(UIViewController*)tabStripViewController { 91 - (void)setTabStripViewController:(UIViewController*)tabStripViewController {
92 if (self.tabStripViewController == tabStripViewController) 92 if (self.tabStripViewController == tabStripViewController)
93 return; 93 return;
94 94
95 // Remove the current strip view controller, if any. 95 // Remove the current strip view controller, if any.
96 [NSLayoutConstraint deactivateConstraints:self.stripConstraints]; 96 [NSLayoutConstraint deactivateConstraints:self.stripConstraints];
97 [NSLayoutConstraint deactivateConstraints:self.contentConstraintsWithStrip]; 97 [NSLayoutConstraint deactivateConstraints:self.contentConstraintsWithStrip];
98 [self removeChildViewController:self.tabStripViewController]; 98 [self removeChildViewControllerFromParent:self.tabStripViewController];
99 99
100 // Add the new strip view controller. 100 // Add the new strip view controller.
101 [self addChildViewController:tabStripViewController]; 101 [self addChildViewController:tabStripViewController];
102 tabStripViewController.view.translatesAutoresizingMaskIntoConstraints = NO; 102 tabStripViewController.view.translatesAutoresizingMaskIntoConstraints = NO;
103 [self.view addSubview:tabStripViewController.view]; 103 [self.view addSubview:tabStripViewController.view];
104 _tabStripViewController = tabStripViewController; 104 _tabStripViewController = tabStripViewController;
105 [self didAddTabStripViewController]; 105 [self didAddTabStripViewController];
106 [self.view setNeedsUpdateConstraints]; 106 [self.view setNeedsUpdateConstraints];
107 [self.tabStripViewController didMoveToParentViewController:self]; 107 [self.tabStripViewController didMoveToParentViewController:self];
108 } 108 }
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 conformsToProtocol:@protocol(ZoomTransitionDelegate)]) { 205 conformsToProtocol:@protocol(ZoomTransitionDelegate)]) {
206 return [reinterpret_cast<id<ZoomTransitionDelegate>>( 206 return [reinterpret_cast<id<ZoomTransitionDelegate>>(
207 self.contentViewController) rectForZoomWithKey:key 207 self.contentViewController) rectForZoomWithKey:key
208 inView:view]; 208 inView:view];
209 } 209 }
210 return CGRectNull; 210 return CGRectNull;
211 } 211 }
212 212
213 #pragma mark - Private methods 213 #pragma mark - Private methods
214 214
215 - (void)removeChildViewController:(UIViewController*)viewController { 215 - (void)removeChildViewControllerFromParent:(UIViewController*)viewController {
216 if (viewController.parentViewController != self) 216 if (viewController.parentViewController != self)
217 return; 217 return;
218 [viewController willMoveToParentViewController:nil]; 218 [viewController willMoveToParentViewController:nil];
219 [viewController.view removeFromSuperview]; 219 [viewController.view removeFromSuperview];
220 [viewController removeFromParentViewController]; 220 [viewController removeFromParentViewController];
221 } 221 }
222 222
223 - (void)didAddContentViewController { 223 - (void)didAddContentViewController {
224 if (self.tabStripViewController) { 224 if (self.tabStripViewController) {
225 [self updateContentConstraintsWithStrip]; 225 [self updateContentConstraintsWithStrip];
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 [stripView.heightAnchor constraintEqualToConstant:0.0]; 268 [stripView.heightAnchor constraintEqualToConstant:0.0];
269 self.stripConstraints = @[ 269 self.stripConstraints = @[
270 [stripView.topAnchor constraintEqualToAnchor:self.view.topAnchor], 270 [stripView.topAnchor constraintEqualToAnchor:self.view.topAnchor],
271 [stripView.leadingAnchor constraintEqualToAnchor:self.view.leadingAnchor], 271 [stripView.leadingAnchor constraintEqualToAnchor:self.view.leadingAnchor],
272 [stripView.trailingAnchor constraintEqualToAnchor:self.view.trailingAnchor], 272 [stripView.trailingAnchor constraintEqualToAnchor:self.view.trailingAnchor],
273 self.stripHeightConstraint, 273 self.stripHeightConstraint,
274 ]; 274 ];
275 } 275 }
276 276
277 @end 277 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698