Commit 1aa843ab authored by Gauthier Ambard's avatar Gauthier Ambard Committed by Commit Bot

Fix overscroll for BCVC fullscreen

This CL fixes the overscroll actions, mainly for the NTP when the BCVC
is in fullscreen.

Bug: 836730
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: Ib4475e32bb45d05682e9fd663de4e1dee193e812
Reviewed-on: https://chromium-review.googlesource.com/1059149Reviewed-by: default avatarKurt Horimoto <kkhorimoto@chromium.org>
Commit-Queue: Gauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#558996}
parent 3828edc3
......@@ -3833,6 +3833,8 @@ bubblePresenterForFeature:(const base::Feature&)feature
}
- (CGFloat)overscrollHeaderHeight {
if (base::FeatureList::IsEnabled(kBrowserContainerFullscreen))
return self.headerHeight;
return self.headerHeight + StatusBarHeight();
}
......
......@@ -24,6 +24,7 @@ source_set("overscroll_actions") {
"//ios/chrome/app/strings:ios_strings_grit",
"//ios/chrome/app/theme",
"//ios/chrome/browser/ui",
"//ios/chrome/browser/ui:feature_flags",
"//ios/chrome/browser/ui:notifications",
"//ios/chrome/browser/ui/content_suggestions:content_suggestions_constant",
"//ios/chrome/browser/ui/fullscreen",
......
......@@ -23,6 +23,7 @@
#include "ios/chrome/browser/ui/rtl_geometry.h"
#import "ios/chrome/browser/ui/toolbar/legacy/toolbar_controller_constants.h"
#import "ios/chrome/browser/ui/tools_menu/public/tools_menu_constants.h"
#include "ios/chrome/browser/ui/ui_feature_flags.h"
#include "ios/chrome/browser/ui/uikit_ui_util.h"
#import "ios/chrome/browser/ui/voice/voice_search_notification_names.h"
#import "ios/web/public/web_state/ui/crw_web_view_proxy.h"
......@@ -368,7 +369,14 @@ NSString* const kOverscrollActionsDidEnd = @"OverscrollActionsDidStop";
}
CGFloat contentOffsetFromExpandedHeader =
contentOffsetFromTheTop + self.initialHeaderInset;
if (contentOffsetFromExpandedHeader >= 0) {
CGFloat limit = 0;
CGFloat topMargin = 0;
if (!_webViewProxy &&
base::FeatureList::IsEnabled(kBrowserContainerFullscreen)) {
limit = -StatusBarHeight();
topMargin = StatusBarHeight();
}
if (contentOffsetFromExpandedHeader >= limit) {
// Record initial content offset and dispatch delegate on state change.
self.overscrollState = OverscrollState::NO_PULL_STARTED;
} else {
......@@ -382,7 +390,8 @@ NSString* const kOverscrollActionsDidEnd = @"OverscrollActionsDidStop";
_initialHeaderHeight = [[self delegate] overscrollHeaderHeight];
self.overscrollState = OverscrollState::STARTED_PULLING;
}
[self updateWithVerticalOffset:-contentOffsetFromExpandedHeader];
[self updateWithVerticalOffset:-contentOffsetFromExpandedHeader
topMargin:topMargin];
}
}
......@@ -814,13 +823,16 @@ NSString* const kOverscrollActionsDidEnd = @"OverscrollActionsDidStop";
}
}
- (void)updateWithVerticalOffset:(CGFloat)verticalOffset {
- (void)updateWithVerticalOffset:(CGFloat)verticalOffset
topMargin:(CGFloat)topMargin {
self.overscrollActionView.backgroundView.alpha =
1.0 -
Clamp(verticalOffset / (kHeaderMaxExpansionThreshold / 2.0), 0.0, 1.0);
Clamp((verticalOffset - topMargin) / (kHeaderMaxExpansionThreshold / 2.0),
0.0, 1.0);
SetViewFrameHeight(self.overscrollActionView,
self.initialHeaderHeight + verticalOffset);
[self.overscrollActionView updateWithVerticalOffset:verticalOffset];
[self.overscrollActionView
updateWithVerticalOffset:verticalOffset - topMargin];
}
- (CGFloat)initialContentInset {
......@@ -893,8 +905,9 @@ NSString* const kOverscrollActionsDidEnd = @"OverscrollActionsDidStop";
if (_bounceState.yInset - _bounceState.headerInset < 0.5)
_bounceState.yInset = _bounceState.headerInset;
if (_performingScrollViewIndependentAnimation) {
[self updateWithVerticalOffset:_bounceState.yInset -
_bounceState.headerInset];
[self
updateWithVerticalOffset:_bounceState.yInset - _bounceState.headerInset
topMargin:0];
} else {
const UIEdgeInsets insets = UIEdgeInsetsMake(_bounceState.yInset, 0, 0, 0);
_forceStateUpdate = YES;
......
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