Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(193)

Unified Diff: cc/input/top_controls_manager.cc

Issue 960873002: Update from https://crrev.com/318214 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/input/top_controls_manager.h ('k') | cc/layers/draw_properties.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/input/top_controls_manager.cc
diff --git a/cc/input/top_controls_manager.cc b/cc/input/top_controls_manager.cc
index 615afb07056800b92d55ad38807fec7ce2212c65..7362805de99acba4c5caa3145f9f268df1778336 100644
--- a/cc/input/top_controls_manager.cc
+++ b/cc/input/top_controls_manager.cc
@@ -39,8 +39,8 @@ TopControlsManager::TopControlsManager(TopControlsManagerClient* client,
: client_(client),
animation_direction_(NO_ANIMATION),
permitted_state_(BOTH),
- current_scroll_delta_(0.f),
- controls_scroll_begin_offset_(0.f),
+ accumulated_scroll_delta_(0.f),
+ baseline_content_offset_(0.f),
top_controls_show_threshold_(top_controls_hide_threshold),
top_controls_hide_threshold_(top_controls_show_threshold),
pinch_gesture_active_(false) {
@@ -96,8 +96,7 @@ void TopControlsManager::UpdateTopControlsState(TopControlsState constraints,
void TopControlsManager::ScrollBegin() {
DCHECK(!pinch_gesture_active_);
ResetAnimations();
- current_scroll_delta_ = 0.f;
- controls_scroll_begin_offset_ = ContentTopOffset();
+ ResetBaseline();
}
gfx::Vector2dF TopControlsManager::ScrollBy(
@@ -110,19 +109,17 @@ gfx::Vector2dF TopControlsManager::ScrollBy(
else if (permitted_state_ == HIDDEN && pending_delta.y() < 0)
return pending_delta;
- current_scroll_delta_ += pending_delta.y();
+ accumulated_scroll_delta_ += pending_delta.y();
float old_offset = ContentTopOffset();
client_->SetCurrentTopControlsShownRatio(
- (controls_scroll_begin_offset_ - current_scroll_delta_) /
+ (baseline_content_offset_ - accumulated_scroll_delta_) /
TopControlsHeight());
// If the controls are fully visible, treat the current position as the
// new baseline even if the gesture didn't end.
- if (TopControlsShownRatio() == 1.f) {
- current_scroll_delta_ = 0.f;
- controls_scroll_begin_offset_ = ContentTopOffset();
- }
+ if (TopControlsShownRatio() == 1.f)
+ ResetBaseline();
ResetAnimations();
@@ -149,6 +146,10 @@ void TopControlsManager::PinchEnd() {
ScrollBegin();
}
+void TopControlsManager::MainThreadHasStoppedFlinging() {
+ StartAnimationIfNecessary();
+}
+
gfx::Vector2dF TopControlsManager::Animate(base::TimeTicks monotonic_time) {
if (!top_controls_animation_ || !client_->HaveRootScrollLayer())
return gfx::Vector2dF();
@@ -206,8 +207,8 @@ void TopControlsManager::StartAnimationIfNecessary() {
// If we could be either showing or hiding, we determine which one to
// do based on whether or not the total scroll delta was moving up or
// down.
- SetupAnimation(current_scroll_delta_ <= 0.f ? SHOWING_CONTROLS
- : HIDING_CONTROLS);
+ SetupAnimation(accumulated_scroll_delta_ <= 0.f ? SHOWING_CONTROLS
+ : HIDING_CONTROLS);
}
}
@@ -225,4 +226,9 @@ bool TopControlsManager::IsAnimationCompleteAtTime(base::TimeTicks time) {
return false;
}
+void TopControlsManager::ResetBaseline() {
+ accumulated_scroll_delta_ = 0.f;
+ baseline_content_offset_ = ContentTopOffset();
+}
+
} // namespace cc
« no previous file with comments | « cc/input/top_controls_manager.h ('k') | cc/layers/draw_properties.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698