| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/android/overscroll_refresh.h" | 5 #include "ui/android/overscroll_refresh.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "ui/android/overscroll_refresh_handler.h" | 8 #include "ui/android/overscroll_refresh_handler.h" |
| 9 | 9 |
| 10 namespace ui { | 10 namespace ui { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 ReleaseWithoutActivation(); | 36 ReleaseWithoutActivation(); |
| 37 if (scrolled_to_top_ && !overflow_y_hidden_) | 37 if (scrolled_to_top_ && !overflow_y_hidden_) |
| 38 scroll_consumption_state_ = AWAITING_SCROLL_UPDATE_ACK; | 38 scroll_consumption_state_ = AWAITING_SCROLL_UPDATE_ACK; |
| 39 } | 39 } |
| 40 | 40 |
| 41 void OverscrollRefresh::OnScrollEnd(const gfx::Vector2dF& scroll_velocity) { | 41 void OverscrollRefresh::OnScrollEnd(const gfx::Vector2dF& scroll_velocity) { |
| 42 bool allow_activation = scroll_velocity.y() > kMinFlingVelocityForActivation; | 42 bool allow_activation = scroll_velocity.y() > kMinFlingVelocityForActivation; |
| 43 Release(allow_activation); | 43 Release(allow_activation); |
| 44 } | 44 } |
| 45 | 45 |
| 46 void OverscrollRefresh::OnScrollUpdateAck(bool was_consumed) { | 46 void OverscrollRefresh::OnOverscrolled(bool can_navigate) { |
| 47 if (scroll_consumption_state_ != AWAITING_SCROLL_UPDATE_ACK) | 47 if (scroll_consumption_state_ != AWAITING_SCROLL_UPDATE_ACK) |
| 48 return; | 48 return; |
| 49 | 49 |
| 50 if (was_consumed) { | 50 if (!can_navigate) { |
| 51 scroll_consumption_state_ = DISABLED; | 51 scroll_consumption_state_ = DISABLED; |
| 52 return; | 52 return; |
| 53 } | 53 } |
| 54 | 54 |
| 55 scroll_consumption_state_ = handler_->PullStart() ? ENABLED : DISABLED; | 55 scroll_consumption_state_ = handler_->PullStart() ? ENABLED : DISABLED; |
| 56 } | 56 } |
| 57 | 57 |
| 58 bool OverscrollRefresh::WillHandleScrollUpdate( | 58 bool OverscrollRefresh::WillHandleScrollUpdate( |
| 59 const gfx::Vector2dF& scroll_delta) { | 59 const gfx::Vector2dF& scroll_delta) { |
| 60 switch (scroll_consumption_state_) { | 60 switch (scroll_consumption_state_) { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 overflow_y_hidden_ = root_overflow_y_hidden; | 96 overflow_y_hidden_ = root_overflow_y_hidden; |
| 97 } | 97 } |
| 98 | 98 |
| 99 void OverscrollRefresh::Release(bool allow_refresh) { | 99 void OverscrollRefresh::Release(bool allow_refresh) { |
| 100 if (scroll_consumption_state_ == ENABLED) | 100 if (scroll_consumption_state_ == ENABLED) |
| 101 handler_->PullRelease(allow_refresh); | 101 handler_->PullRelease(allow_refresh); |
| 102 scroll_consumption_state_ = DISABLED; | 102 scroll_consumption_state_ = DISABLED; |
| 103 } | 103 } |
| 104 | 104 |
| 105 } // namespace ui | 105 } // namespace ui |
| OLD | NEW |