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

Unified Diff: content/browser/android/overscroll_controller_android.cc

Issue 2884423003: Use scroll-boundary-behavior to control overscroll-refresh/glow on android. (Closed)
Patch Set: Fixed the comments Created 3 years, 7 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: 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..d57f465ed81d45d58c28742e5d484a88b0d814cd 100644
--- a/content/browser/android/overscroll_controller_android.cc
+++ b/content/browser/android/overscroll_controller_android.cc
@@ -128,6 +128,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 +190,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;
+
+ 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_ &&

Powered by Google App Engine
This is Rietveld 408576698