| OLD | NEW |
| 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 18 matching lines...) Expand all Loading... |
| 29 @property(nonatomic, strong) Constraints* contentConstraintsWithStrip; | 29 @property(nonatomic, strong) Constraints* contentConstraintsWithStrip; |
| 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. This method cannot be named |
| 40 - (void)removeChildViewController:(UIViewController*)viewController; | 40 //-removeChildViewController:, as that is a private superclass method. |
| 41 - (void)detachChildViewController:(UIViewController*)viewController; |
| 41 | 42 |
| 42 // Called after a new content view controller is set, but before | 43 // Called after a new content view controller is set, but before |
| 43 // |-didMoveToParentViewController:| is called on that view controller. | 44 // |-didMoveToParentViewController:| is called on that view controller. |
| 44 - (void)didAddContentViewController; | 45 - (void)didAddContentViewController; |
| 45 | 46 |
| 46 // Called after a new strip view controller is set, but before | 47 // Called after a new strip view controller is set, but before |
| 47 // |-didMoveToParentViewController:| is called on that view controller. | 48 // |-didMoveToParentViewController:| is called on that view controller. |
| 48 - (void)didAddTabStripViewController; | 49 - (void)didAddTabStripViewController; |
| 49 | 50 |
| 50 // Methods to populate the constraint properties. | 51 // Methods to populate the constraint properties. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 69 #pragma mark - Public properties | 70 #pragma mark - Public properties |
| 70 | 71 |
| 71 - (void)setContentViewController:(UIViewController*)contentViewController { | 72 - (void)setContentViewController:(UIViewController*)contentViewController { |
| 72 if (self.contentViewController == contentViewController) | 73 if (self.contentViewController == contentViewController) |
| 73 return; | 74 return; |
| 74 | 75 |
| 75 // Remove the current content view controller, if any. | 76 // Remove the current content view controller, if any. |
| 76 [NSLayoutConstraint | 77 [NSLayoutConstraint |
| 77 deactivateConstraints:self.contentConstraintsWithoutStrip]; | 78 deactivateConstraints:self.contentConstraintsWithoutStrip]; |
| 78 [NSLayoutConstraint deactivateConstraints:self.contentConstraintsWithStrip]; | 79 [NSLayoutConstraint deactivateConstraints:self.contentConstraintsWithStrip]; |
| 79 [self removeChildViewController:self.contentViewController]; | 80 [self detachChildViewController:self.contentViewController]; |
| 80 | 81 |
| 81 // Add the new content view controller. | 82 // Add the new content view controller. |
| 82 [self addChildViewController:contentViewController]; | 83 [self addChildViewController:contentViewController]; |
| 83 contentViewController.view.translatesAutoresizingMaskIntoConstraints = NO; | 84 contentViewController.view.translatesAutoresizingMaskIntoConstraints = NO; |
| 84 [self.view addSubview:contentViewController.view]; | 85 [self.view addSubview:contentViewController.view]; |
| 85 _contentViewController = contentViewController; | 86 _contentViewController = contentViewController; |
| 86 [self didAddContentViewController]; | 87 [self didAddContentViewController]; |
| 87 [self.view setNeedsUpdateConstraints]; | 88 [self.view setNeedsUpdateConstraints]; |
| 88 [self.contentViewController didMoveToParentViewController:self]; | 89 [self.contentViewController didMoveToParentViewController:self]; |
| 89 } | 90 } |
| 90 | 91 |
| 91 - (void)setTabStripViewController:(UIViewController*)tabStripViewController { | 92 - (void)setTabStripViewController:(UIViewController*)tabStripViewController { |
| 92 if (self.tabStripViewController == tabStripViewController) | 93 if (self.tabStripViewController == tabStripViewController) |
| 93 return; | 94 return; |
| 94 | 95 |
| 95 // Remove the current strip view controller, if any. | 96 // Remove the current strip view controller, if any. |
| 96 [NSLayoutConstraint deactivateConstraints:self.stripConstraints]; | 97 [NSLayoutConstraint deactivateConstraints:self.stripConstraints]; |
| 97 [NSLayoutConstraint deactivateConstraints:self.contentConstraintsWithStrip]; | 98 [NSLayoutConstraint deactivateConstraints:self.contentConstraintsWithStrip]; |
| 98 [self removeChildViewController:self.tabStripViewController]; | 99 [self detachChildViewController:self.tabStripViewController]; |
| 99 | 100 |
| 100 // Add the new strip view controller. | 101 // Add the new strip view controller. |
| 101 [self addChildViewController:tabStripViewController]; | 102 [self addChildViewController:tabStripViewController]; |
| 102 tabStripViewController.view.translatesAutoresizingMaskIntoConstraints = NO; | 103 tabStripViewController.view.translatesAutoresizingMaskIntoConstraints = NO; |
| 103 [self.view addSubview:tabStripViewController.view]; | 104 [self.view addSubview:tabStripViewController.view]; |
| 104 _tabStripViewController = tabStripViewController; | 105 _tabStripViewController = tabStripViewController; |
| 105 [self didAddTabStripViewController]; | 106 [self didAddTabStripViewController]; |
| 106 [self.view setNeedsUpdateConstraints]; | 107 [self.view setNeedsUpdateConstraints]; |
| 107 [self.tabStripViewController didMoveToParentViewController:self]; | 108 [self.tabStripViewController didMoveToParentViewController:self]; |
| 108 } | 109 } |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 conformsToProtocol:@protocol(ZoomTransitionDelegate)]) { | 206 conformsToProtocol:@protocol(ZoomTransitionDelegate)]) { |
| 206 return [reinterpret_cast<id<ZoomTransitionDelegate>>( | 207 return [reinterpret_cast<id<ZoomTransitionDelegate>>( |
| 207 self.contentViewController) rectForZoomWithKey:key | 208 self.contentViewController) rectForZoomWithKey:key |
| 208 inView:view]; | 209 inView:view]; |
| 209 } | 210 } |
| 210 return CGRectNull; | 211 return CGRectNull; |
| 211 } | 212 } |
| 212 | 213 |
| 213 #pragma mark - Private methods | 214 #pragma mark - Private methods |
| 214 | 215 |
| 215 - (void)removeChildViewController:(UIViewController*)viewController { | 216 - (void)detachChildViewController:(UIViewController*)viewController { |
| 216 if (viewController.parentViewController != self) | 217 if (viewController.parentViewController != self) |
| 217 return; | 218 return; |
| 218 [viewController willMoveToParentViewController:nil]; | 219 [viewController willMoveToParentViewController:nil]; |
| 219 [viewController.view removeFromSuperview]; | 220 [viewController.view removeFromSuperview]; |
| 220 [viewController removeFromParentViewController]; | 221 [viewController removeFromParentViewController]; |
| 221 } | 222 } |
| 222 | 223 |
| 223 - (void)didAddContentViewController { | 224 - (void)didAddContentViewController { |
| 224 if (self.tabStripViewController) { | 225 if (self.tabStripViewController) { |
| 225 [self updateContentConstraintsWithStrip]; | 226 [self updateContentConstraintsWithStrip]; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 [stripView.heightAnchor constraintEqualToConstant:0.0]; | 269 [stripView.heightAnchor constraintEqualToConstant:0.0]; |
| 269 self.stripConstraints = @[ | 270 self.stripConstraints = @[ |
| 270 [stripView.topAnchor constraintEqualToAnchor:self.view.topAnchor], | 271 [stripView.topAnchor constraintEqualToAnchor:self.view.topAnchor], |
| 271 [stripView.leadingAnchor constraintEqualToAnchor:self.view.leadingAnchor], | 272 [stripView.leadingAnchor constraintEqualToAnchor:self.view.leadingAnchor], |
| 272 [stripView.trailingAnchor constraintEqualToAnchor:self.view.trailingAnchor], | 273 [stripView.trailingAnchor constraintEqualToAnchor:self.view.trailingAnchor], |
| 273 self.stripHeightConstraint, | 274 self.stripHeightConstraint, |
| 274 ]; | 275 ]; |
| 275 } | 276 } |
| 276 | 277 |
| 277 @end | 278 @end |
| OLD | NEW |