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

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: 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..bc89cd550d5201bd526800eb8d55b2b9a3dff4bd 100644
--- a/cc/input/top_controls_manager.cc
+++ b/cc/input/top_controls_manager.cc
@@ -82,6 +82,17 @@ 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);
+ }
+}
+
Ted C 2013/04/16 02:05:58 remove extra line
Michael van Ouwerkerk 2013/04/16 15:02:47 Done.
+
void TopControlsManager::ScrollBegin() {
ResetAnimations();
current_scroll_delta_ = 0.f;
@@ -153,6 +164,18 @@ 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_)
Ted C 2013/04/16 02:05:58 if I recall, I think you need braces if the condit
Michael van Ouwerkerk 2013/04/16 15:02:47 Done.
+ 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,8 +211,7 @@ 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();
Ted C 2013/04/16 02:05:58 can remove this because it is called in Setup
Michael van Ouwerkerk 2013/04/16 15:02:47 Done.
}

Powered by Google App Engine
This is Rietveld 408576698