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

Unified Diff: ui/android/overscroll_refresh.cc

Issue 2884423003: Use scroll-boundary-behavior to control overscroll-refresh/glow on android. (Closed)
Patch Set: Fix nits and rebase Created 3 years, 4 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: ui/android/overscroll_refresh.cc
diff --git a/ui/android/overscroll_refresh.cc b/ui/android/overscroll_refresh.cc
index 2f2af62d8cd56abe468ecb688e0675fa140b8ccc..546d19d41ba19cb4c0f4a19364b45bdebeb3c330 100644
--- a/ui/android/overscroll_refresh.cc
+++ b/ui/android/overscroll_refresh.cc
@@ -20,16 +20,15 @@ OverscrollRefresh::OverscrollRefresh(OverscrollRefreshHandler* handler)
: scrolled_to_top_(true),
overflow_y_hidden_(false),
scroll_consumption_state_(DISABLED),
- handler_(handler) {
- DCHECK(handler);
-}
+ handler_(handler) {}
OverscrollRefresh::~OverscrollRefresh() {
}
void OverscrollRefresh::Reset() {
scroll_consumption_state_ = DISABLED;
- handler_->PullReset();
+ if (handler_)
boliu 2017/08/23 19:17:02 hmm, handler is constant, so if this one needs a n
sunyunjia 2017/08/23 23:47:06 Feels like it's a bit complicated to mock an Overs
+ handler_->PullReset();
}
void OverscrollRefresh::OnScrollBegin() {
@@ -43,15 +42,11 @@ void OverscrollRefresh::OnScrollEnd(const gfx::Vector2dF& scroll_velocity) {
Release(allow_activation);
}
-void OverscrollRefresh::OnScrollUpdateAck(bool was_consumed) {
+void OverscrollRefresh::OnOverscrolled() {
if (scroll_consumption_state_ != AWAITING_SCROLL_UPDATE_ACK)
return;
- if (was_consumed) {
- scroll_consumption_state_ = DISABLED;
- return;
- }
-
+ DCHECK(handler_);
scroll_consumption_state_ = handler_->PullStart() ? ENABLED : DISABLED;
}
@@ -68,6 +63,7 @@ bool OverscrollRefresh::WillHandleScrollUpdate(
return false;
case ENABLED:
+ DCHECK(handler_);
handler_->PullUpdate(scroll_delta.y());
return true;
}
@@ -97,8 +93,10 @@ void OverscrollRefresh::OnFrameUpdated(
}
void OverscrollRefresh::Release(bool allow_refresh) {
- if (scroll_consumption_state_ == ENABLED)
+ if (scroll_consumption_state_ == ENABLED) {
+ DCHECK(handler_);
handler_->PullRelease(allow_refresh);
+ }
scroll_consumption_state_ = DISABLED;
}

Powered by Google App Engine
This is Rietveld 408576698