Commit 7c051ee5 authored by Chris Lu's avatar Chris Lu Committed by Commit Bot

[ios] Don't resize overlay presentation container if insignificant

Upon layout, the container view of the Infobar banner view is resized
to match the size of the banner. But then a subsequently triggered
relayout may have a new banner frame size that is small enough to cause
an infinite loop. Thus, container resizing is only done if the height
and width of the new calculated banner frame are different by more
than 0.01.

Bug: 1129761
Change-Id: I0b397c63763c392e021bcf54fb7c7a2df8f872eb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2432661Reviewed-by: default avatarMike Dougherty <michaeldo@chromium.org>
Reviewed-by: default avatarRohit Rao <rohitrao@chromium.org>
Commit-Queue: Chris Lu <thegreenfrog@chromium.org>
Cr-Commit-Position: refs/heads/master@{#814502}
parent 139880d7
...@@ -19,6 +19,9 @@ const CGFloat kContainerHorizontalPadding = 8; ...@@ -19,6 +19,9 @@ const CGFloat kContainerHorizontalPadding = 8;
const CGFloat kContainerMaxWidth = 398; const CGFloat kContainerMaxWidth = 398;
// The presented view maximum height. // The presented view maximum height.
const CGFloat kContainerMaxHeight = 230; const CGFloat kContainerMaxHeight = 230;
// Minimum height or width frame change that should warrant a resizing of the
// container view in response to a relayout.
const CGFloat kMinimumSizeChange = 0.01;
} }
@interface InfobarBannerPresentationController () @interface InfobarBannerPresentationController ()
...@@ -104,8 +107,18 @@ const CGFloat kContainerMaxHeight = 230; ...@@ -104,8 +107,18 @@ const CGFloat kContainerMaxHeight = 230;
CGRect bannerFrame = self.bannerFrame; CGRect bannerFrame = self.bannerFrame;
UIView* containerView = self.containerView; UIView* containerView = self.containerView;
UIWindow* window = containerView.window; UIWindow* window = containerView.window;
containerView.frame = [containerView.superview convertRect:bannerFrame
fromView:window]; CGRect newFrame = [containerView.superview convertRect:bannerFrame
fromView:window];
// Make sure new calculate frame has changed enough to warrant a rerender.
// Otherwise, an infinite loop is possible.
if (std::fabs(newFrame.size.height - containerView.frame.size.height) >
kMinimumSizeChange ||
std::fabs(newFrame.size.width - containerView.frame.size.width) >
kMinimumSizeChange) {
containerView.frame = newFrame;
}
UIView* bannerView = self.presentedView; UIView* bannerView = self.presentedView;
bannerView.frame = [bannerView.superview convertRect:bannerFrame bannerView.frame = [bannerView.superview convertRect:bannerFrame
fromView:window]; fromView:window];
......
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