Commit 32de02b3 authored by stkhapugin@chromium.org's avatar stkhapugin@chromium.org Committed by Commit Bot

Use view controller containment for omnibox popup. Fix rotation bug.

Uses proper view controller containment APIs when displaying the popup.
Updates layout on screen rotation.

Bug: 837006
Cq-Include-Trybots: luci.chromium.try:ios-simulator-full-configs;master.tryserver.chromium.mac:ios-simulator-cronet
Change-Id: Ie7ff928d68b5cedc526cbe6057e1286cb54bd637
Reviewed-on: https://chromium-review.googlesource.com/1106175Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Commit-Queue: Stepan Khapugin <stkhapugin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#568793}
parent 3fb4f65b
...@@ -13,6 +13,9 @@ ...@@ -13,6 +13,9 @@
// View to which the popup view should be added as subview. // View to which the popup view should be added as subview.
- (UIView*)popupParentView; - (UIView*)popupParentView;
// The view controller that will parent the popup.
- (UIViewController*)popupParentViewController;
@end @end
#endif // IOS_CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_POPUP_POSITIONER_H_ #endif // IOS_CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_POPUP_POSITIONER_H_
...@@ -86,7 +86,11 @@ NS_INLINE CGFloat BottomPadding() { ...@@ -86,7 +86,11 @@ NS_INLINE CGFloat BottomPadding() {
- (void)updateHeightAndAnimateAppearanceIfNecessary { - (void)updateHeightAndAnimateAppearanceIfNecessary {
UIView* popup = self.popupContainerView; UIView* popup = self.popupContainerView;
if (!popup.superview) { if (!popup.superview) {
UIViewController* parentVC = [self.positioner popupParentViewController];
[parentVC addChildViewController:self.viewController];
[[self.positioner popupParentView] addSubview:popup]; [[self.positioner popupParentView] addSubview:popup];
[self.viewController didMoveToParentViewController:parentVC];
[self initialLayout]; [self initialLayout];
} }
...@@ -108,6 +112,7 @@ NS_INLINE CGFloat BottomPadding() { ...@@ -108,6 +112,7 @@ NS_INLINE CGFloat BottomPadding() {
- (void)animateCollapse { - (void)animateCollapse {
UIView* retainedPopupView = self.popupContainerView; UIView* retainedPopupView = self.popupContainerView;
UIViewController* retainedViewController = self.viewController;
if (!IsIPadIdiom()) { if (!IsIPadIdiom()) {
self.bottomConstraint.active = NO; self.bottomConstraint.active = NO;
} }
...@@ -119,7 +124,9 @@ NS_INLINE CGFloat BottomPadding() { ...@@ -119,7 +124,9 @@ NS_INLINE CGFloat BottomPadding() {
[[self.popupContainerView superview] layoutIfNeeded]; [[self.popupContainerView superview] layoutIfNeeded];
} }
completion:^(BOOL) { completion:^(BOOL) {
[retainedViewController willMoveToParentViewController:nil];
[retainedPopupView removeFromSuperview]; [retainedPopupView removeFromSuperview];
[retainedViewController removeFromParentViewController];
}]; }];
} }
......
...@@ -171,6 +171,17 @@ UIColor* BackgroundColorIncognito() { ...@@ -171,6 +171,17 @@ UIColor* BackgroundColorIncognito() {
[self layoutRows]; [self layoutRows];
} }
- (void)viewWillTransitionToSize:(CGSize)size
withTransitionCoordinator:
(id<UIViewControllerTransitionCoordinator>)coordinator {
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
[coordinator animateAlongsideTransition:^(
id<UIViewControllerTransitionCoordinatorContext> context) {
[self layoutRows];
}
completion:nil];
}
#pragma mark - Properties accessors #pragma mark - Properties accessors
- (void)setIncognito:(BOOL)incognito { - (void)setIncognito:(BOOL)incognito {
......
...@@ -165,6 +165,10 @@ ...@@ -165,6 +165,10 @@
return self.viewController.view.superview; return self.viewController.view.superview;
} }
- (UIViewController*)popupParentViewController {
return self.viewController.parentViewController;
}
#pragma mark - Protected override #pragma mark - Protected override
- (void)updateToolbarForSideSwipeSnapshot:(web::WebState*)webState { - (void)updateToolbarForSideSwipeSnapshot:(web::WebState*)webState {
......
...@@ -295,6 +295,10 @@ initWithToolsMenuConfigurationProvider: ...@@ -295,6 +295,10 @@ initWithToolsMenuConfigurationProvider:
return self.toolbarViewController.view.superview; return self.toolbarViewController.view.superview;
} }
- (UIViewController*)popupParentViewController {
return self.toolbarViewController.parentViewController;
}
#pragma mark - ToolsMenuPresentationStateProvider #pragma mark - ToolsMenuPresentationStateProvider
- (BOOL)isShowingToolsMenu { - (BOOL)isShowingToolsMenu {
......
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