Index: cc/input/browser_controls_offset_manager.cc |
diff --git a/cc/input/browser_controls_offset_manager.cc b/cc/input/browser_controls_offset_manager.cc |
index 841aad39bb628d02192e735106c7a863c87c5424..5a970627bc302658ec7bb9a2a115c4f60916f48f 100644 |
--- a/cc/input/browser_controls_offset_manager.cc |
+++ b/cc/input/browser_controls_offset_manager.cc |
@@ -43,7 +43,8 @@ BrowserControlsOffsetManager::BrowserControlsOffsetManager( |
animation_direction_(NO_ANIMATION), |
permitted_state_(BOTH), |
accumulated_scroll_delta_(0.f), |
- baseline_content_offset_(0.f), |
+ baseline_top_content_offset_(0.f), |
+ baseline_bottom_content_offset_(0.f), |
controls_show_threshold_(controls_hide_threshold), |
controls_hide_threshold_(controls_show_threshold), |
pinch_gesture_active_(false) { |
@@ -60,12 +61,6 @@ float BrowserControlsOffsetManager::ContentTopOffset() const { |
return TopControlsShownRatio() * TopControlsHeight(); |
} |
-float BrowserControlsOffsetManager::ContentOffsetInternal() const { |
- if (!TopControlsHeight()) |
- return BottomControlsShownRatio() * BottomControlsHeight(); |
- return ContentTopOffset(); |
-} |
- |
float BrowserControlsOffsetManager::TopControlsShownRatio() const { |
return client_->CurrentBrowserControlsShownRatio(); |
} |
@@ -144,9 +139,11 @@ gfx::Vector2dF BrowserControlsOffsetManager::ScrollBy( |
accumulated_scroll_delta_ += pending_delta.y(); |
- float old_offset = ContentOffsetInternal(); |
+ float old_top_offset = ContentTopOffset(); |
+ float baseline_content_offset = TopControlsHeight() |
aelias_OOO_until_Jul13
2016/11/01 21:15:46
I think this should be structured more symmetrical
|
+ ? baseline_top_content_offset_ : baseline_bottom_content_offset_; |
client_->SetCurrentBrowserControlsShownRatio( |
- (baseline_content_offset_ - accumulated_scroll_delta_) / controls_height); |
+ (baseline_content_offset - accumulated_scroll_delta_) / controls_height); |
// If the controls are fully visible, treat the current position as the |
// new baseline even if the gesture didn't end. |
@@ -155,7 +152,12 @@ gfx::Vector2dF BrowserControlsOffsetManager::ScrollBy( |
ResetAnimations(); |
- gfx::Vector2dF applied_delta(0.f, old_offset - ContentOffsetInternal()); |
+ // applied_delta will negate any scroll on the content if the top browser |
+ // controls are showing in favor of hiding the controls and resizing the |
+ // content. If the top controls have no height, the content should scroll |
+ // immediately. |
+ gfx::Vector2dF applied_delta(0.f, |
+ TopControlsHeight() ? old_top_offset - ContentTopOffset() : 0.0f); |
return pending_delta - applied_delta; |
} |
@@ -189,7 +191,7 @@ gfx::Vector2dF BrowserControlsOffsetManager::Animate( |
if (!has_animation() || !client_->HaveRootScrollLayer()) |
return gfx::Vector2dF(); |
- float old_offset = ContentOffsetInternal(); |
+ float old_offset = ContentTopOffset(); |
float new_ratio = gfx::Tween::ClampedFloatValueBetween( |
monotonic_time, animation_start_time_, animation_start_value_, |
animation_stop_time_, animation_stop_value_); |
@@ -198,7 +200,9 @@ gfx::Vector2dF BrowserControlsOffsetManager::Animate( |
if (IsAnimationComplete(new_ratio)) |
ResetAnimations(); |
- gfx::Vector2dF scroll_delta(0.f, ContentOffsetInternal() - old_offset); |
+ // Don't move the content if the top controls aren't used. |
+ gfx::Vector2dF scroll_delta(0.f, |
+ TopControlsHeight() ? (ContentTopOffset() - old_offset) : 0.0f); |
return scroll_delta; |
} |
@@ -265,7 +269,8 @@ bool BrowserControlsOffsetManager::IsAnimationComplete(float new_ratio) { |
void BrowserControlsOffsetManager::ResetBaseline() { |
accumulated_scroll_delta_ = 0.f; |
- baseline_content_offset_ = ContentOffsetInternal(); |
+ baseline_top_content_offset_ = ContentTopOffset(); |
+ baseline_bottom_content_offset_ = ContentBottomOffset(); |
} |
} // namespace cc |