Chromium Code Reviews| 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 #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/ui_types.h" | 7 #import "ios/clean/chrome/browser/ui/ui_types.h" |
| 8 | 8 |
| 9 #if !defined(__has_feature) || !__has_feature(objc_arc) | 9 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 10 #error "This file requires ARC support." | 10 #error "This file requires ARC support." |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 173 - (void)detachChildViewController:(UIViewController*)viewController { | 173 - (void)detachChildViewController:(UIViewController*)viewController { |
| 174 if (viewController.parentViewController != self) | 174 if (viewController.parentViewController != self) |
| 175 return; | 175 return; |
| 176 [viewController willMoveToParentViewController:nil]; | 176 [viewController willMoveToParentViewController:nil]; |
| 177 [viewController.view removeFromSuperview]; | 177 [viewController.view removeFromSuperview]; |
| 178 [viewController removeFromParentViewController]; | 178 [viewController removeFromParentViewController]; |
| 179 } | 179 } |
| 180 | 180 |
| 181 #pragma mark - MenuPresentationDelegate | 181 #pragma mark - MenuPresentationDelegate |
| 182 | 182 |
| 183 - (CGRect)frameForMenuPresentation:(UIPresentationController*)presentation { | 183 - (CGRect)boundsForMenuPresentation { |
| 184 CGSize menuSize = presentation.presentedView.frame.size; | 184 return self.view.bounds; |
| 185 CGRect menuRect; | 185 } |
| 186 menuRect.size = menuSize; | 186 - (CGRect)originForMenuPresentation { |
| 187 | 187 return [self rectForZoomWithKey:@"" inView:self.view]; |
|
lpromero
2017/06/23 15:42:52
Why @"" here and nil above?
sczs
2017/06/23 15:52:35
The ZoomDelegate handles nil and empty as differen
| |
| 188 CGRect menuOriginRect = [self rectForZoomWithKey:@"" inView:self.view]; | |
| 189 if (CGRectIsNull(menuOriginRect)) { | |
| 190 menuRect.origin = CGPointMake(50, 50); | |
| 191 return menuRect; | |
| 192 } | |
| 193 // Calculate which corner of the menu the origin rect is in. This is | |
| 194 // determined by comparing frames, and thus is RTL-independent. | |
| 195 if (CGRectGetMinX(menuOriginRect) - CGRectGetMinX(self.view.bounds) < | |
| 196 CGRectGetMaxX(self.view.bounds) - CGRectGetMaxX(menuOriginRect)) { | |
| 197 // Origin rect is closer to the left edge of |self.view| than to the right. | |
| 198 menuRect.origin.x = CGRectGetMinX(menuOriginRect); | |
| 199 } else { | |
| 200 // Origin rect is closer to the right edge of |self.view| than to the left. | |
| 201 menuRect.origin.x = CGRectGetMaxX(menuOriginRect) - menuSize.width; | |
| 202 } | |
| 203 | |
| 204 if (CGRectGetMinY(menuOriginRect) - CGRectGetMinY(self.view.bounds) < | |
| 205 CGRectGetMaxY(self.view.bounds) - CGRectGetMaxY(menuOriginRect)) { | |
| 206 // Origin rect is closer to the top edge of |self.view| than to the bottom. | |
| 207 menuRect.origin.y = CGRectGetMinY(menuOriginRect); | |
| 208 } else { | |
| 209 // Origin rect is closer to the bottom edge of |self.view| than to the top. | |
| 210 menuRect.origin.y = CGRectGetMaxY(menuOriginRect) - menuSize.height; | |
| 211 } | |
| 212 | |
| 213 return menuRect; | |
| 214 } | 188 } |
| 215 | 189 |
| 216 #pragma mark - ZoomTransitionDelegate | 190 #pragma mark - ZoomTransitionDelegate |
| 217 | 191 |
| 218 - (CGRect)rectForZoomWithKey:(NSObject*)key inView:(UIView*)view { | 192 - (CGRect)rectForZoomWithKey:(NSObject*)key inView:(UIView*)view { |
| 219 if ([self.toolbarViewController | 193 if ([self.toolbarViewController |
| 220 conformsToProtocol:@protocol(ZoomTransitionDelegate)]) { | 194 conformsToProtocol:@protocol(ZoomTransitionDelegate)]) { |
| 221 return [reinterpret_cast<id<ZoomTransitionDelegate>>( | 195 return [reinterpret_cast<id<ZoomTransitionDelegate>>( |
| 222 self.toolbarViewController) rectForZoomWithKey:key | 196 self.toolbarViewController) rectForZoomWithKey:key |
| 223 inView:view]; | 197 inView:view]; |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 334 constraintEqualToAnchor:self.view.leadingAnchor], | 308 constraintEqualToAnchor:self.view.leadingAnchor], |
| 335 [self.toolbarView.trailingAnchor | 309 [self.toolbarView.trailingAnchor |
| 336 constraintEqualToAnchor:self.view.trailingAnchor], | 310 constraintEqualToAnchor:self.view.trailingAnchor], |
| 337 self.toolbarHeightConstraint, | 311 self.toolbarHeightConstraint, |
| 338 [self.toolbarView.bottomAnchor | 312 [self.toolbarView.bottomAnchor |
| 339 constraintEqualToAnchor:self.bottomLayoutGuide.topAnchor], | 313 constraintEqualToAnchor:self.bottomLayoutGuide.topAnchor], |
| 340 ]; | 314 ]; |
| 341 } | 315 } |
| 342 | 316 |
| 343 @end | 317 @end |
| OLD | NEW |