Index: content/browser/android/overscroll_controller_android.cc |
diff --git a/content/browser/android/overscroll_controller_android.cc b/content/browser/android/overscroll_controller_android.cc |
index 3be50dac488ac9fdad7f86d83d778b8ef26cd3fd..60f6455790ccb96e8ad1db54cd91ad448c853789 100644 |
--- a/content/browser/android/overscroll_controller_android.cc |
+++ b/content/browser/android/overscroll_controller_android.cc |
@@ -95,6 +95,20 @@ std::unique_ptr<OverscrollRefresh> CreateRefreshEffect( |
} // namespace |
+OverscrollControllerAndroid::OverscrollControllerAndroid( |
+ ui::OverscrollGlow* glow_effect, |
+ ui::OverscrollRefresh* refresh_effect, |
+ ui::WindowAndroidCompositor* compositor, |
+ float dpi_scale) |
+ : compositor_(compositor), |
+ dpi_scale_(dpi_scale), |
+ enabled_(true), |
+ scroll_update_consumed_(false), |
+ glow_effect_(glow_effect), |
+ refresh_effect_(refresh_effect) { |
+ DCHECK(compositor_); |
+} |
+ |
OverscrollControllerAndroid::OverscrollControllerAndroid( |
ui::OverscrollRefreshHandler* overscroll_refresh_handler, |
ui::WindowAndroidCompositor* compositor, |
@@ -102,6 +116,7 @@ OverscrollControllerAndroid::OverscrollControllerAndroid( |
: compositor_(compositor), |
dpi_scale_(dpi_scale), |
enabled_(true), |
+ scroll_update_consumed_(false), |
glow_effect_(CreateGlowEffect(this, dpi_scale_)), |
refresh_effect_(CreateRefreshEffect(overscroll_refresh_handler)) { |
majidvp
2017/07/12 21:04:20
This constructor should delegate to the one above
sunyunjia
2017/07/19 20:44:11
Done. I'm not sure if the delegate is worth it. I
|
DCHECK(compositor_); |
@@ -128,6 +143,7 @@ bool OverscrollControllerAndroid::WillHandleGestureEvent( |
switch (event.GetType()) { |
case blink::WebInputEvent::kGestureScrollBegin: |
refresh_effect_->OnScrollBegin(); |
+ scroll_update_consumed_ = false; |
break; |
case blink::WebInputEvent::kGestureScrollUpdate: { |
@@ -189,23 +205,49 @@ void OverscrollControllerAndroid::OnGestureEventAck( |
refresh_effect_) { |
// The effect should only be allowed if both the causal touch events go |
// unconsumed and the generated scroll events go unconsumed. |
- bool consumed = |
+ scroll_update_consumed_ = |
ack_result == INPUT_EVENT_ACK_STATE_CONSUMED || |
event.data.scroll_update.previous_update_in_sequence_prevented; |
- refresh_effect_->OnScrollUpdateAck(consumed); |
} |
} |
void OverscrollControllerAndroid::OnOverscrolled( |
- const DidOverscrollParams& params) { |
+ const DidOverscrollParams& overscroll_params) { |
if (!enabled_) |
return; |
- if (refresh_effect_ && (refresh_effect_->IsActive() || |
- refresh_effect_->IsAwaitingScrollUpdateAck())) { |
- // An active (or potentially active) refresh effect should always pre-empt |
- // the passive glow effect. |
- return; |
+ DidOverscrollParams params = overscroll_params; |
majidvp
2017/07/12 21:04:20
Seems a bit inefficient and unnecessary to create
sunyunjia
2017/07/19 20:44:11
Done.
|
+ |
+ if (refresh_effect_) { |
+ bool can_navigate = |
+ (!scroll_update_consumed_) && |
+ (params.scroll_boundary_behavior.y == |
+ cc::ScrollBoundaryBehavior::ScrollBoundaryBehaviorType:: |
+ kScrollBoundaryBehaviorTypeAuto); |
+ refresh_effect_->OnOverscrolled(can_navigate); |
+ |
+ if (refresh_effect_->IsActive() || |
+ refresh_effect_->IsAwaitingScrollUpdateAck()) { |
+ // An active (or potentially active) refresh effect should always pre-empt |
+ // the passive glow effect. |
+ return; |
+ } |
+ } |
+ |
+ if (params.scroll_boundary_behavior.x == |
+ cc::ScrollBoundaryBehavior::ScrollBoundaryBehaviorType:: |
+ kScrollBoundaryBehaviorTypeNone) { |
+ params.accumulated_overscroll.set_x(0); |
+ params.latest_overscroll_delta.set_x(0); |
+ params.current_fling_velocity.set_x(0); |
+ } |
+ |
+ if (params.scroll_boundary_behavior.y == |
+ cc::ScrollBoundaryBehavior::ScrollBoundaryBehaviorType:: |
+ kScrollBoundaryBehaviorTypeNone) { |
+ params.accumulated_overscroll.set_y(0); |
+ params.latest_overscroll_delta.set_y(0); |
+ params.current_fling_velocity.set_y(0); |
} |
if (glow_effect_ && |