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

Side by Side Diff: ios/clean/chrome/browser/ui/root/root_container_view_controller.mm

Issue 2952213003: [ios clean] Refactors ToolsMenu and Tabs presentation (Closed)
Patch Set: Created 3 years, 6 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/root/root_container_view_controller.h" 5 #import "ios/clean/chrome/browser/ui/root/root_container_view_controller.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 conformsToProtocol:@protocol(ZoomTransitionDelegate)]) { 64 conformsToProtocol:@protocol(ZoomTransitionDelegate)]) {
65 return [static_cast<id<ZoomTransitionDelegate>>(self.contentViewController) 65 return [static_cast<id<ZoomTransitionDelegate>>(self.contentViewController)
66 rectForZoomWithKey:key 66 rectForZoomWithKey:key
67 inView:view]; 67 inView:view];
68 } 68 }
69 return CGRectNull; 69 return CGRectNull;
70 } 70 }
71 71
72 #pragma mark - MenuPresentationDelegate 72 #pragma mark - MenuPresentationDelegate
73 73
74 - (CGRect)frameForMenuPresentation:(UIPresentationController*)presentation { 74 - (CGRect)boundsForMenuPresentation {
75 CGSize menuSize = presentation.presentedView.frame.size; 75 return self.view.bounds;
76 CGRect menuRect; 76 }
77 menuRect.size = menuSize; 77 - (CGRect)originForMenuPresentation {
78 78 return [self rectForZoomWithKey:nil inView:self.view];
79 CGRect menuOriginRect = [self rectForZoomWithKey:nil inView:self.view];
80 if (CGRectIsNull(menuOriginRect)) {
81 menuRect.origin = CGPointMake(50, 50);
82 return menuRect;
83 }
84 // Calculate which corner of the menu the origin rect is in. This is
85 // determined by comparing frames, and thus is RTL-independent.
86 if (CGRectGetMinX(menuOriginRect) - CGRectGetMinX(self.view.bounds) <
87 CGRectGetMaxX(self.view.bounds) - CGRectGetMaxX(menuOriginRect)) {
88 // Origin rect is closer to the left edge of |self.view| than to the right.
89 menuRect.origin.x = CGRectGetMinX(menuOriginRect);
90 } else {
91 // Origin rect is closer to the right edge of |self.view| than to the left.
92 menuRect.origin.x = CGRectGetMaxX(menuOriginRect) - menuSize.width;
93 }
94
95 if (CGRectGetMinY(menuOriginRect) - CGRectGetMinY(self.view.bounds) <
96 CGRectGetMaxY(self.view.bounds) - CGRectGetMaxY(menuOriginRect)) {
97 // Origin rect is closer to the top edge of |self.view| than to the bottom.
98 menuRect.origin.y = CGRectGetMinY(menuOriginRect);
99 } else {
100 // Origin rect is closer to the bottom edge of |self.view| than to the top.
101 menuRect.origin.y = CGRectGetMaxY(menuOriginRect) - menuSize.height;
102 }
103
104 return menuRect;
105 } 79 }
106 80
107 @end 81 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698