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

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

Issue 1419123002: android: move overscroll effects to ui/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix exports for component build Created 5 years, 2 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_refresh.cc
diff --git a/content/browser/android/overscroll_refresh.cc b/content/browser/android/overscroll_refresh.cc
deleted file mode 100644
index c2a1453bc1750eea5e49f337c65f9601f7fe1667..0000000000000000000000000000000000000000
--- a/content/browser/android/overscroll_refresh.cc
+++ /dev/null
@@ -1,104 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "content/browser/android/overscroll_refresh.h"
-
-#include "base/logging.h"
-
-namespace content {
-namespace {
-
-// Experimentally determined constant used to allow activation even if touch
-// release results in a small upward fling (quite common during a slow scroll).
-const float kMinFlingVelocityForActivation = -500.f;
-
-} // namespace
-
-OverscrollRefresh::OverscrollRefresh(OverscrollRefreshHandler* handler)
- : scrolled_to_top_(true),
- overflow_y_hidden_(false),
- scroll_consumption_state_(DISABLED),
- handler_(handler) {
- DCHECK(handler);
-}
-
-OverscrollRefresh::~OverscrollRefresh() {
-}
-
-void OverscrollRefresh::Reset() {
- scroll_consumption_state_ = DISABLED;
- handler_->PullReset();
-}
-
-void OverscrollRefresh::OnScrollBegin() {
- ReleaseWithoutActivation();
- if (scrolled_to_top_ && !overflow_y_hidden_)
- scroll_consumption_state_ = AWAITING_SCROLL_UPDATE_ACK;
-}
-
-void OverscrollRefresh::OnScrollEnd(const gfx::Vector2dF& scroll_velocity) {
- bool allow_activation = scroll_velocity.y() > kMinFlingVelocityForActivation;
- Release(allow_activation);
-}
-
-void OverscrollRefresh::OnScrollUpdateAck(bool was_consumed) {
- if (scroll_consumption_state_ != AWAITING_SCROLL_UPDATE_ACK)
- return;
-
- if (was_consumed) {
- scroll_consumption_state_ = DISABLED;
- return;
- }
-
- scroll_consumption_state_ = handler_->PullStart() ? ENABLED : DISABLED;
-}
-
-bool OverscrollRefresh::WillHandleScrollUpdate(
- const gfx::Vector2dF& scroll_delta) {
- switch (scroll_consumption_state_) {
- case DISABLED:
- return false;
-
- case AWAITING_SCROLL_UPDATE_ACK:
- // If the initial scroll motion is downward, never allow activation.
- if (scroll_delta.y() <= 0)
- scroll_consumption_state_ = DISABLED;
- return false;
-
- case ENABLED:
- handler_->PullUpdate(scroll_delta.y());
- return true;
- }
-
- NOTREACHED() << "Invalid overscroll state: " << scroll_consumption_state_;
- return false;
-}
-
-void OverscrollRefresh::ReleaseWithoutActivation() {
- bool allow_activation = false;
- Release(allow_activation);
-}
-
-bool OverscrollRefresh::IsActive() const {
- return scroll_consumption_state_ == ENABLED;
-}
-
-bool OverscrollRefresh::IsAwaitingScrollUpdateAck() const {
- return scroll_consumption_state_ == AWAITING_SCROLL_UPDATE_ACK;
-}
-
-void OverscrollRefresh::OnFrameUpdated(
- const gfx::Vector2dF& content_scroll_offset,
- bool root_overflow_y_hidden) {
- scrolled_to_top_ = content_scroll_offset.y() == 0;
- overflow_y_hidden_ = root_overflow_y_hidden;
-}
-
-void OverscrollRefresh::Release(bool allow_refresh) {
- if (scroll_consumption_state_ == ENABLED)
- handler_->PullRelease(allow_refresh);
- scroll_consumption_state_ = DISABLED;
-}
-
-} // namespace content
« no previous file with comments | « content/browser/android/overscroll_refresh.h ('k') | content/browser/android/overscroll_refresh_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698