Chromium Code Reviews| Index: ios/clean/chrome/browser/ui/tab_grid/tab_grid_view_controller.mm |
| diff --git a/ios/clean/chrome/browser/ui/tab_grid/tab_grid_view_controller.mm b/ios/clean/chrome/browser/ui/tab_grid/tab_grid_view_controller.mm |
| index c2f7ec40497816ad920be0ddff5c7af98b4a536a..d1dda116645fa6d83f465ec620fd67f75dedd59f 100644 |
| --- a/ios/clean/chrome/browser/ui/tab_grid/tab_grid_view_controller.mm |
| +++ b/ios/clean/chrome/browser/ui/tab_grid/tab_grid_view_controller.mm |
| @@ -10,6 +10,7 @@ |
| #import "ios/clean/chrome/browser/ui/actions/tab_grid_actions.h" |
| #import "ios/clean/chrome/browser/ui/commands/settings_commands.h" |
| #import "ios/clean/chrome/browser/ui/commands/tab_grid_commands.h" |
| +#import "ios/clean/chrome/browser/ui/commands/tools_menu_commands.h" |
| #import "ios/clean/chrome/browser/ui/tab_collection/tab_collection_data_source.h" |
| #import "ios/clean/chrome/browser/ui/tab_collection/tab_collection_tab_cell.h" |
| #import "ios/clean/chrome/browser/ui/tab_grid/mdc_floating_button+cr_tab_grid.h" |
| @@ -90,6 +91,12 @@ |
| [self.dispatcher showSettings]; |
| } |
| +#pragma mark - ToolsMenuActions |
| + |
| +- (void)showToolsMenu:(id)sender { |
| + [self.dispatcher showToolsMenu]; |
| +} |
| + |
| #pragma mark - TabGridActions |
| - (void)showTabGrid:(id)sender { |
| @@ -103,13 +110,55 @@ |
| #pragma mark - ZoomTransitionDelegate methods |
| - (CGRect)rectForZoomWithKey:(NSObject*)key inView:(UIView*)view { |
| - NSIndexPath* cellPath = base::mac::ObjCCastStrict<NSIndexPath>(key); |
| - if (!key) |
| + if (!key) { |
|
edchin
2017/04/10 05:50:57
This logic requires some comments. It's not intuit
sczs
2017/04/11 18:47:59
Done.
|
| + if ([self.toolbar conformsToProtocol:@protocol(ZoomTransitionDelegate)]) { |
|
edchin
2017/04/10 05:50:57
Is it necessary to check conformance and reinterpr
marq (ping after 24h)
2017/04/10 11:36:39
It shouldn't be.
sczs
2017/04/11 18:47:59
Removed this check.
|
| + return [reinterpret_cast<id<ZoomTransitionDelegate>>(self.toolbar) |
| + rectForZoomWithKey:key |
| + inView:view]; |
| + } |
| return CGRectNull; |
| + } |
| + |
| + NSIndexPath* cellPath = base::mac::ObjCCastStrict<NSIndexPath>(key); |
| UICollectionViewCell* cell = [self.tabs cellForItemAtIndexPath:cellPath]; |
| return [view convertRect:cell.bounds fromView:cell]; |
| } |
| +#pragma mark - MenuPresentationDelegate |
| + |
| +- (CGRect)frameForMenuPresentation:(UIPresentationController*)presentation { |
|
edchin
2017/04/10 05:50:57
If this code exists in multiple places, maybe we s
sczs
2017/04/11 18:47:59
Definitely, I think thats out of the scope of this
|
| + CGSize menuSize = presentation.presentedView.frame.size; |
| + CGRect menuRect; |
| + menuRect.size = menuSize; |
| + |
| + CGRect menuOriginRect = [self rectForZoomWithKey:nil inView:self.view]; |
| + if (CGRectIsNull(menuOriginRect)) { |
| + menuRect.origin = CGPointMake(50, 50); |
|
edchin
2017/04/10 05:50:57
Magic numbers?
sczs
2017/04/11 18:47:59
Agree, this is Mark original code. Once we move to
|
| + return menuRect; |
| + } |
| + // Calculate which corner of the menu the origin rect is in. This is |
| + // determined by comparing frames, and thus is RTL-independent. |
| + if (CGRectGetMinX(menuOriginRect) - CGRectGetMinX(self.view.bounds) < |
| + CGRectGetMaxX(self.view.bounds) - CGRectGetMaxX(menuOriginRect)) { |
| + // Origin rect is closer to the left edge of |self.view| than to the right. |
| + menuRect.origin.x = CGRectGetMinX(menuOriginRect); |
| + } else { |
| + // Origin rect is closer to the right edge of |self.view| than to the left. |
| + menuRect.origin.x = CGRectGetMaxX(menuOriginRect) - menuSize.width; |
| + } |
| + |
| + if (CGRectGetMinY(menuOriginRect) - CGRectGetMinY(self.view.bounds) < |
| + CGRectGetMaxY(self.view.bounds) - CGRectGetMaxY(menuOriginRect)) { |
| + // Origin rect is closer to the top edge of |self.view| than to the bottom. |
| + menuRect.origin.y = CGRectGetMinY(menuOriginRect); |
| + } else { |
| + // Origin rect is closer to the bottom edge of |self.view| than to the top. |
| + menuRect.origin.y = CGRectGetMaxY(menuOriginRect) - menuSize.height; |
| + } |
| + |
| + return menuRect; |
| +} |
| + |
| #pragma mark - TabGridConsumer methods |
| - (void)addNoTabsOverlay { |