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

[ios] Correctly set frame of NTP.

This only affects the kBrowserContainerContainsNTP feature.

Bug: 826369
Cq-Include-Trybots: luci.chromium.try:ios-simulator-cronet;luci.chromium.try:ios-simulator-full-configs
Change-Id: I93b1c0844a5071756ff4d2a23f07afb8ac2e4572
Reviewed-on: https://chromium-review.googlesource.com/c/1283840
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Reviewed-by: default avatarKurt Horimoto <kkhorimoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#600281}
parent 01493038
......@@ -764,6 +764,10 @@ NSString* const kBrowserViewControllerSnackbarCategory =
- (void)dismissPopups;
// Returns the footer view if one exists (e.g. the voice search bar).
- (UIView*)footerView;
// Returns the appropriate frame for the NTP.
// TODO(crbug.com/826369): Most of this method's implementation details can be
// unwound when BVC fullscreen and NTP experiments are enabled by default.
- (CGRect)ntpFrameForWebState:(web::WebState*)webState;
// Returns web contents frame without including primary toolbar.
- (CGRect)visibleFrameForTab:(Tab*)tab;
// Returns the header height needed for |tab|.
......@@ -1705,6 +1709,16 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint {
// Update the toolbar height to account for |topLayoutGuide| changes.
self.primaryToolbarHeightConstraint.constant =
[self primaryToolbarHeightWithInset];
if (self.currentWebState) {
NewTabPageTabHelper* NTPHelper =
NewTabPageTabHelper::FromWebState(self.currentWebState);
if (NTPHelper && NTPHelper->IsActive()) {
UIViewController* viewController = NTPHelper->GetViewController();
viewController.view.frame =
[self ntpFrameForWebState:self.currentWebState];
}
}
}
- (void)viewDidAppear:(BOOL)animated {
......@@ -2561,6 +2575,7 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint {
NewTabPageTabHelper::FromWebState(tab.webState);
if (NTPHelper && NTPHelper->IsActive()) {
UIViewController* viewController = NTPHelper->GetViewController();
viewController.view.frame = [self ntpFrameForWebState:tab.webState];
_browserContainerCoordinator.viewController.contentViewController =
viewController;
} else {
......@@ -2659,6 +2674,12 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint {
return self.secondaryToolbarCoordinator.viewController.view;
}
- (CGRect)ntpFrameForWebState:(web::WebState*)webState {
UIEdgeInsets headerInset = UIEdgeInsetsMake(
[self nativeContentHeaderHeightForWebState:webState], 0, 0, 0);
return UIEdgeInsetsInsetRect(self.contentArea.bounds, headerInset);
}
- (CGRect)visibleFrameForTab:(Tab*)tab {
UIEdgeInsets headerInset = UIEdgeInsetsMake(
[self nativeContentHeaderHeightForWebState:tab.webState], 0, 0, 0);
......
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