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

Unified Diff: cc/input/top_controls_manager.cc

Issue 14139013: Hide location bar on Javascript-initiated scroll. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Upload again after sync. Created 7 years, 8 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
Index: cc/input/top_controls_manager.cc
diff --git a/cc/input/top_controls_manager.cc b/cc/input/top_controls_manager.cc
index 971ba0cbe5a1d0c56647622be75a7604295ad824..8ac642b2a0b3c732f2f2406f9eb775357e72ef1d 100644
--- a/cc/input/top_controls_manager.cc
+++ b/cc/input/top_controls_manager.cc
@@ -82,6 +82,16 @@ void TopControlsManager::UpdateTopControlsState(bool enable_hiding,
}
}
+void TopControlsManager::ShowTopControls(bool show) {
+ if (show) {
+ DCHECK(visibility_restriction_ != ALWAYS_HIDDEN);
+ SetupAnimation(SHOWING_CONTROLS);
+ } else {
+ DCHECK(visibility_restriction_ != ALWAYS_SHOWN);
+ SetupAnimation(HIDING_CONTROLS);
+ }
+}
+
void TopControlsManager::ScrollBegin() {
ResetAnimations();
current_scroll_delta_ = 0.f;
@@ -153,6 +163,19 @@ void TopControlsManager::ResetAnimations() {
}
void TopControlsManager::SetupAnimation(AnimationDirection direction) {
+ DCHECK(direction != NO_ANIMATION);
+
+ if (direction == SHOWING_CONTROLS && controls_top_offset_ == 0)
+ return;
+
+ if (direction == HIDING_CONTROLS &&
+ controls_top_offset_ == -top_controls_height_) {
+ return;
+ }
+
+ if (top_controls_animation_ && animation_direction_ == direction)
+ return;
+
top_controls_animation_ = KeyframedFloatAnimationCurve::Create();
double start_time =
(base::TimeTicks::Now() - base::TimeTicks()).InMillisecondsF();
@@ -166,6 +189,7 @@ void TopControlsManager::SetupAnimation(AnimationDirection direction) {
controls_top_offset_ + max_ending_offset,
EaseTimingFunction::Create()));
animation_direction_ = direction;
+ client_->DidChangeTopControlsPosition();
}
void TopControlsManager::StartAnimationIfNecessary() {
@@ -187,11 +211,8 @@ void TopControlsManager::StartAnimationIfNecessary() {
SHOWING_CONTROLS : HIDING_CONTROLS;
}
- if (show_controls != NO_ANIMATION &&
- (!top_controls_animation_ || animation_direction_ != show_controls)) {
+ if (show_controls != NO_ANIMATION)
SetupAnimation(show_controls);
- client_->DidChangeTopControlsPosition();
- }
}
}

Powered by Google App Engine
This is Rietveld 408576698