Commit f6f1f191 authored by Kurt Horimoto's avatar Kurt Horimoto Committed by Commit Bot

[iOS] Show toolbars after scrolling to the bottom of the page.

This CL updates the behavior of fullscreen such that the toolbars will
be re-shown when the user starts a scroll past the bottom of a page
when the toolbars are completely collapsed.

Bug: 841094
Cq-Include-Trybots: luci.chromium.try:ios-simulator-cronet;luci.chromium.try:ios-simulator-full-configs
Change-Id: I9e2cb3a59e931f83bb43e8a68df48a80bb6d0c3b
Reviewed-on: https://chromium-review.googlesource.com/1200563
Commit-Queue: Kurt Horimoto <kkhorimoto@chromium.org>
Reviewed-by: default avatarJustin Cohen <justincohen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#589357}
parent 329d8468
...@@ -4150,6 +4150,8 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint { ...@@ -4150,6 +4150,8 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint {
self.footerFullscreenProgress = progress; self.footerFullscreenProgress = progress;
if (IsUIRefreshPhase1Enabled()) { if (IsUIRefreshPhase1Enabled()) {
// TODO(crbug.com/880656): Update implementation to make the bottom toolbar
// animatable.
self.secondaryToolbarHeightConstraint.constant = self.secondaryToolbarHeightConstraint.constant =
[self secondaryToolbarHeightWithInset] * progress; [self secondaryToolbarHeightWithInset] * progress;
......
...@@ -120,6 +120,13 @@ void FullscreenMediator::FullscreenModelScrollEventStarted( ...@@ -120,6 +120,13 @@ void FullscreenMediator::FullscreenModelScrollEventStarted(
FullscreenModel* model) { FullscreenModel* model) {
DCHECK_EQ(model_, model); DCHECK_EQ(model_, model);
StopAnimating(true /* update_model */); StopAnimating(true /* update_model */);
// Show the toolbars if the user begins a scroll past the bottom edge of the
// screen and the toolbars have been fully collapsed.
if (model_->is_scrolled_to_bottom() &&
AreCGFloatsEqual(model_->progress(), 0.0) &&
model_->can_collapse_toolbar()) {
AnimateModelReset();
}
} }
void FullscreenMediator::FullscreenModelScrollEventEnded( void FullscreenMediator::FullscreenModelScrollEventEnded(
......
...@@ -47,6 +47,17 @@ class FullscreenModel : public ChromeBroadcastObserverInterface { ...@@ -47,6 +47,17 @@ class FullscreenModel : public ChromeBroadcastObserverInterface {
return expanded_toolbar_height_ - collapsed_toolbar_height_; return expanded_toolbar_height_ - collapsed_toolbar_height_;
} }
// Returns whether the page content is tall enough for the toolbar to be
// scrolled to an entirely collapsed position.
bool can_collapse_toolbar() const {
return content_height_ > scroll_view_height_ + toolbar_height_delta();
}
// Whether the view is scrolled all the way to the bottom.
bool is_scrolled_to_bottom() const {
return y_content_offset_ + scroll_view_height_ >= content_height_;
}
// Increments and decrements |disabled_counter_| for features that require the // Increments and decrements |disabled_counter_| for features that require the
// toolbar be completely visible. // toolbar be completely visible.
void IncrementDisabledCounter(); void IncrementDisabledCounter();
......
...@@ -224,17 +224,14 @@ FullscreenModel::ScrollAction FullscreenModel::ActionForScrollFromOffset( ...@@ -224,17 +224,14 @@ FullscreenModel::ScrollAction FullscreenModel::ActionForScrollFromOffset(
// Ignore if: // Ignore if:
// - explicitly requested via IgnoreRemainderOfCurrentScroll(), // - explicitly requested via IgnoreRemainderOfCurrentScroll(),
// - the scroll is a bounce-up animation at the top, // - the scroll is a bounce-up animation at the top,
// - the scroll is a bounce-down animation at the bottom, // - the scroll is attempting to scroll past the bottom of the page,
// - the scroll is attempting to scroll content up when it already fits. // - the scroll is attempting to scroll content up when it already fits.
bool scrolling_content_down = y_content_offset_ - from_offset < 0.0; bool scrolling_content_down = y_content_offset_ - from_offset < 0.0;
bool scrolling_past_top = y_content_offset_ <= -top_inset_; bool scrolling_past_top = y_content_offset_ <= -top_inset_;
bool scrolling_past_bottom =
y_content_offset_ + scroll_view_height_ >= content_height_;
bool content_fits = content_height_ <= scroll_view_height_ - top_inset_; bool content_fits = content_height_ <= scroll_view_height_ - top_inset_;
if (ignoring_current_scroll_ || if (ignoring_current_scroll_ ||
(scrolling_past_top && !scrolling_content_down) || (scrolling_past_top && !scrolling_content_down) ||
(scrolling_past_bottom && scrolling_content_down) || is_scrolled_to_bottom() || (content_fits && !scrolling_content_down)) {
(content_fits && !scrolling_content_down)) {
return ScrollAction::kIgnore; return ScrollAction::kIgnore;
} }
......
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