Commit 9fe9ef67 authored by Justin Cohen's avatar Justin Cohen Committed by Commit Bot

[ios] Update toolbarViewController's topAnchor as well as frame.

Bug: 784510
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: I3ca7d45d6c5cf04aa97a787b106a2529daa8e421
Reviewed-on: https://chromium-review.googlesource.com/788450
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Reviewed-by: default avatarRohit Rao <rohitrao@chromium.org>
Reviewed-by: default avatarKurt Horimoto <kkhorimoto@chromium.org>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#521046}
parent 5f851e76
...@@ -652,6 +652,9 @@ NSString* const kBrowserViewControllerSnackbarCategory = ...@@ -652,6 +652,9 @@ NSString* const kBrowserViewControllerSnackbarCategory =
@property(nonatomic, strong) @property(nonatomic, strong)
BubbleViewControllerPresenter* incognitoTabTipBubblePresenter; BubbleViewControllerPresenter* incognitoTabTipBubblePresenter;
// Vertical offset for fullscreen toolbar.
@property(nonatomic, strong) NSLayoutConstraint* toolbarOffsetConstraint;
// BVC initialization: // BVC initialization:
// If the BVC is initialized with a valid browser state & tab model immediately, // If the BVC is initialized with a valid browser state & tab model immediately,
// the path is straightforward: functionality is enabled, and the UI is built // the path is straightforward: functionality is enabled, and the UI is built
...@@ -917,6 +920,7 @@ bubblePresenterForFeature:(const base::Feature&)feature ...@@ -917,6 +920,7 @@ bubblePresenterForFeature:(const base::Feature&)feature
@synthesize recentTabsCoordinator = _recentTabsCoordinator; @synthesize recentTabsCoordinator = _recentTabsCoordinator;
@synthesize tabStripCoordinator = _tabStripCoordinator; @synthesize tabStripCoordinator = _tabStripCoordinator;
@synthesize tabStripView = _tabStripView; @synthesize tabStripView = _tabStripView;
@synthesize toolbarOffsetConstraint = _toolbarOffsetConstraint;
#pragma mark - Object lifecycle #pragma mark - Object lifecycle
...@@ -1896,11 +1900,13 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint { ...@@ -1896,11 +1900,13 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint {
[_toolbarCoordinator adjustToolbarHeight]; [_toolbarCoordinator adjustToolbarHeight];
self.toolbarOffsetConstraint =
[_toolbarCoordinator.toolbarViewController.view.topAnchor
constraintEqualToAnchor:topAnchor];
[NSLayoutConstraint activateConstraints:@[ [NSLayoutConstraint activateConstraints:@[
self.toolbarOffsetConstraint,
[_toolbarCoordinator.toolbarViewController.view.leadingAnchor [_toolbarCoordinator.toolbarViewController.view.leadingAnchor
constraintEqualToAnchor:[self view].leadingAnchor], constraintEqualToAnchor:[self view].leadingAnchor],
[_toolbarCoordinator.toolbarViewController.view.topAnchor
constraintEqualToAnchor:topAnchor],
[_toolbarCoordinator.toolbarViewController.view.trailingAnchor [_toolbarCoordinator.toolbarViewController.view.trailingAnchor
constraintEqualToAnchor:[self view].trailingAnchor], constraintEqualToAnchor:[self view].trailingAnchor],
]]; ]];
...@@ -3186,8 +3192,18 @@ bubblePresenterForFeature:(const base::Feature&)feature ...@@ -3186,8 +3192,18 @@ bubblePresenterForFeature:(const base::Feature&)feature
atOffset:(CGFloat)headerOffset { atOffset:(CGFloat)headerOffset {
CGFloat height = [self headerOffset]; CGFloat height = [self headerOffset];
for (HeaderDefinition* header in headers) { for (HeaderDefinition* header in headers) {
CGFloat yOrigin = height - headerOffset - header.inset;
// Make sure the toolbarView's constraints are also updated. Leaving the
// -setFrame call to minimize changes in this CL -- otherwise the way
// toolbar_view manages it's alpha changes would also need to be updated.
// TODO(crbug.com/778822): This can be cleaned up when the new fullscreen
// is enabled.
if (IsSafeAreaCompatibleToolbarEnabled() &&
header.view == _toolbarCoordinator.toolbarViewController.view) {
self.toolbarOffsetConstraint.constant = yOrigin;
}
CGRect frame = [header.view frame]; CGRect frame = [header.view frame];
frame.origin.y = height - headerOffset - header.inset; frame.origin.y = yOrigin;
[header.view setFrame:frame]; [header.view setFrame:frame];
if (header.behaviour != Overlap) if (header.behaviour != Overlap)
height += CGRectGetHeight(frame); height += CGRectGetHeight(frame);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment