Commit 87899a86 authored by Gauthier Ambard's avatar Gauthier Ambard Committed by Commit Bot

[iOS] Adjust pinnedYOffset value to neareset pixel

This CL makes sure that the value returned by -pinnedYOffset is adjusted
to the nearest pixel. This is because when the content size isn't the
default one, the value isn't adjusted on a pixel. When it is used to
compare to the scroll value of the collection view, this gap prevents
the collection view from being considered as completely scrolled.

Bug: 905276
Change-Id: Ia44de6063b039a022fcde95e015c3e7df4259308
Reviewed-on: https://chromium-review.googlesource.com/c/1337490
Commit-Queue: Gauthier Ambard <gambard@chromium.org>
Reviewed-by: default avatarJustin Cohen <justincohen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#608748}
parent ee1eb7d3
...@@ -113,7 +113,8 @@ CGFloat doodleTopMargin(BOOL toolbarPresent, CGFloat topInset) { ...@@ -113,7 +113,8 @@ CGFloat doodleTopMargin(BOOL toolbarPresent, CGFloat topInset) {
if (!IsCompactWidth() && !IsCompactHeight()) if (!IsCompactWidth() && !IsCompactHeight())
return kDoodleTopMarginRegularXRegular; return kDoodleTopMarginRegularXRegular;
return topInset + kDoodleTopMarginOther + return topInset + kDoodleTopMarginOther +
kDoodleScaledTopMarginOther * SystemSuggestedFontSizeMultiplier(); AlignValueToPixel(kDoodleScaledTopMarginOther *
SystemSuggestedFontSizeMultiplier());
} }
CGFloat searchFieldTopMargin() { CGFloat searchFieldTopMargin() {
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#import "ios/chrome/browser/ui/toolbar/toolbar_utils.h" #import "ios/chrome/browser/ui/toolbar/toolbar_utils.h"
#import "ios/chrome/browser/ui/url_loader.h" #import "ios/chrome/browser/ui/url_loader.h"
#import "ios/chrome/browser/ui/util/named_guide.h" #import "ios/chrome/browser/ui/util/named_guide.h"
#include "ios/chrome/browser/ui/util/ui_util.h"
#import "ios/chrome/browser/ui/util/uikit_ui_util.h" #import "ios/chrome/browser/ui/util/uikit_ui_util.h"
#import "ios/chrome/common/ui_util/constraints_ui_util.h" #import "ios/chrome/common/ui_util/constraints_ui_util.h"
#include "ios/chrome/grit/ios_strings.h" #include "ios/chrome/grit/ios_strings.h"
...@@ -197,7 +198,7 @@ using base::UserMetricsAction; ...@@ -197,7 +198,7 @@ using base::UserMetricsAction;
[self topInset]; [self topInset];
} }
return offsetY; return AlignValueToPixel(offsetY);
} }
- (CGFloat)headerHeight { - (CGFloat)headerHeight {
......
...@@ -12,14 +12,15 @@ ...@@ -12,14 +12,15 @@
CGFloat ToolbarClampedFontSizeMultiplier(UIContentSizeCategory category); CGFloat ToolbarClampedFontSizeMultiplier(UIContentSizeCategory category);
// Returns the height of the toolbar when it is collapsed, based on the current // Returns the height of the toolbar when it is collapsed, based on the current
// |category|. // |category|, rounded to the nearest lower pixel.
CGFloat ToolbarCollapsedHeight(UIContentSizeCategory category); CGFloat ToolbarCollapsedHeight(UIContentSizeCategory category);
// Returns the height of the toolbar when it is expanded, based on the current // Returns the height of the toolbar when it is expanded, based on the current
// |category|. // |category|, rounded to the nearest lower pixel.
CGFloat ToolbarExpandedHeight(UIContentSizeCategory category); CGFloat ToolbarExpandedHeight(UIContentSizeCategory category);
// Returns the height of the location bar, based on the |category|. // Returns the height of the location bar, based on the |category|, rounded to
// the nearest lower pixel.
CGFloat LocationBarHeight(UIContentSizeCategory category); CGFloat LocationBarHeight(UIContentSizeCategory category);
#endif // IOS_CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_UTILS_H_ #endif // IOS_CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_UTILS_H_
...@@ -62,5 +62,5 @@ CGFloat LocationBarHeight(UIContentSizeCategory category) { ...@@ -62,5 +62,5 @@ CGFloat LocationBarHeight(UIContentSizeCategory category) {
(kLocationBarVerticalMarginDynamicType + (kLocationBarVerticalMarginDynamicType +
kAdaptiveLocationBarVerticalMargin); kAdaptiveLocationBarVerticalMargin);
verticalMargin = verticalMargin + dynamicTypeVerticalAdjustment; verticalMargin = verticalMargin + dynamicTypeVerticalAdjustment;
return ToolbarExpandedHeight(category) - verticalMargin; return AlignValueToPixel(ToolbarExpandedHeight(category) - verticalMargin);
} }
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