Index: ios/clean/chrome/browser/ui/root/root_container_view_controller.mm |
diff --git a/ios/clean/chrome/browser/ui/root/root_container_view_controller.mm b/ios/clean/chrome/browser/ui/root/root_container_view_controller.mm |
new file mode 100644 |
index 0000000000000000000000000000000000000000..e45e88fb74699c5b1cac846724361f23ab78107e |
--- /dev/null |
+++ b/ios/clean/chrome/browser/ui/root/root_container_view_controller.mm |
@@ -0,0 +1,69 @@ |
+// Copyright 2017 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#import "ios/clean/chrome/browser/ui/root/root_container_view_controller.h" |
+ |
+#if !defined(__has_feature) || !__has_feature(objc_arc) |
+#error "This file requires ARC support." |
+#endif |
+ |
+@implementation RootContainerViewController |
+@synthesize contentViewController = _contentViewController; |
+ |
+#pragma mark - UIViewController |
+ |
+- (void)viewDidLoad { |
+ [super viewDidLoad]; |
+ self.view.backgroundColor = [UIColor blackColor]; |
+ [self attachChildViewController:self.contentViewController]; |
+} |
+ |
+#pragma mark - Public properties |
+ |
+- (void)setContentViewController:(UIViewController*)contentViewController { |
+ if (self.contentViewController == contentViewController) |
+ return; |
+ if ([self isViewLoaded]) { |
+ [self detachChildViewController:self.contentViewController]; |
+ [self attachChildViewController:contentViewController]; |
+ } |
+ _contentViewController = contentViewController; |
+} |
+ |
+#pragma mark - ChildViewController helper methods |
+ |
+- (void)attachChildViewController:(UIViewController*)viewController { |
+ if (!viewController) { |
+ return; |
+ } |
+ [self addChildViewController:viewController]; |
+ viewController.view.translatesAutoresizingMaskIntoConstraints = YES; |
marq (ping after 24h)
2017/04/10 11:04:25
This is the default, no need to set it.
edchin
2017/04/10 16:41:28
Done.
|
+ viewController.view.autoresizingMask = |
+ UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; |
+ viewController.view.frame = self.view.bounds; |
+ [self.view addSubview:viewController.view]; |
+ [viewController didMoveToParentViewController:self]; |
+} |
+ |
+- (void)detachChildViewController:(UIViewController*)viewController { |
+ if (viewController.parentViewController != self) |
+ return; |
+ [viewController willMoveToParentViewController:nil]; |
+ [viewController.view removeFromSuperview]; |
+ [viewController removeFromParentViewController]; |
+} |
+ |
+#pragma mark - ZoomTransitionDelegate |
+ |
+- (CGRect)rectForZoomWithKey:(NSObject*)key inView:(UIView*)view { |
marq (ping after 24h)
2017/04/10 11:04:25
No change for now, but I'd like to figure out a wa
edchin
2017/04/10 16:41:28
Could not agree more.
|
+ if ([self.contentViewController |
+ conformsToProtocol:@protocol(ZoomTransitionDelegate)]) { |
+ return [reinterpret_cast<id<ZoomTransitionDelegate>>( |
marq (ping after 24h)
2017/04/10 11:04:25
Despite what I might have said in the past, this s
edchin
2017/04/10 16:41:28
Done.
|
+ self.contentViewController) rectForZoomWithKey:key |
+ inView:view]; |
+ } |
+ return CGRectNull; |
+} |
+ |
+@end |