| 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 "content/browser/android/overscroll_refresh.h" | 5 #include "content/browser/android/overscroll_refresh.h" |
| 6 | 6 |
| 7 #include "cc/animation/timing_function.h" | 7 #include "cc/animation/timing_function.h" |
| 8 #include "cc/layers/ui_resource_layer.h" | 8 #include "cc/layers/ui_resource_layer.h" |
| 9 #include "cc/trees/layer_tree_host.h" | 9 #include "cc/trees/layer_tree_host.h" |
| 10 #include "content/browser/android/animation_utils.h" | 10 #include "content/browser/android/animation_utils.h" |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 | 405 |
| 406 DISALLOW_COPY_AND_ASSIGN(Effect); | 406 DISALLOW_COPY_AND_ASSIGN(Effect); |
| 407 }; | 407 }; |
| 408 | 408 |
| 409 OverscrollRefresh::OverscrollRefresh(ui::ResourceManager* resource_manager, | 409 OverscrollRefresh::OverscrollRefresh(ui::ResourceManager* resource_manager, |
| 410 OverscrollRefreshClient* client, | 410 OverscrollRefreshClient* client, |
| 411 float target_drag_offset_pixels, | 411 float target_drag_offset_pixels, |
| 412 bool mirror) | 412 bool mirror) |
| 413 : client_(client), | 413 : client_(client), |
| 414 scrolled_to_top_(true), | 414 scrolled_to_top_(true), |
| 415 overflow_y_hidden_(false), |
| 415 scroll_consumption_state_(DISABLED), | 416 scroll_consumption_state_(DISABLED), |
| 416 effect_(new Effect(resource_manager, target_drag_offset_pixels, mirror)) { | 417 effect_(new Effect(resource_manager, target_drag_offset_pixels, mirror)) { |
| 417 DCHECK(client); | 418 DCHECK(client); |
| 418 } | 419 } |
| 419 | 420 |
| 420 OverscrollRefresh::~OverscrollRefresh() { | 421 OverscrollRefresh::~OverscrollRefresh() { |
| 421 } | 422 } |
| 422 | 423 |
| 423 void OverscrollRefresh::Reset() { | 424 void OverscrollRefresh::Reset() { |
| 424 scroll_consumption_state_ = DISABLED; | 425 scroll_consumption_state_ = DISABLED; |
| 425 effect_->Finish(); | 426 effect_->Finish(); |
| 426 } | 427 } |
| 427 | 428 |
| 428 void OverscrollRefresh::OnScrollBegin() { | 429 void OverscrollRefresh::OnScrollBegin() { |
| 429 ReleaseWithoutActivation(); | 430 ReleaseWithoutActivation(); |
| 430 if (scrolled_to_top_) | 431 if (scrolled_to_top_ && !overflow_y_hidden_) |
| 431 scroll_consumption_state_ = AWAITING_SCROLL_UPDATE_ACK; | 432 scroll_consumption_state_ = AWAITING_SCROLL_UPDATE_ACK; |
| 432 } | 433 } |
| 433 | 434 |
| 434 void OverscrollRefresh::OnScrollEnd(const gfx::Vector2dF& scroll_velocity) { | 435 void OverscrollRefresh::OnScrollEnd(const gfx::Vector2dF& scroll_velocity) { |
| 435 bool allow_activation = scroll_velocity.y() > kMinFlingVelocityForActivation; | 436 bool allow_activation = scroll_velocity.y() > kMinFlingVelocityForActivation; |
| 436 Release(allow_activation); | 437 Release(allow_activation); |
| 437 } | 438 } |
| 438 | 439 |
| 439 void OverscrollRefresh::OnScrollUpdateAck(bool was_consumed) { | 440 void OverscrollRefresh::OnScrollUpdateAck(bool was_consumed) { |
| 440 if (scroll_consumption_state_ != AWAITING_SCROLL_UPDATE_ACK) | 441 if (scroll_consumption_state_ != AWAITING_SCROLL_UPDATE_ACK) |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 bool OverscrollRefresh::IsActive() const { | 489 bool OverscrollRefresh::IsActive() const { |
| 489 return scroll_consumption_state_ == ENABLED || !effect_->IsFinished(); | 490 return scroll_consumption_state_ == ENABLED || !effect_->IsFinished(); |
| 490 } | 491 } |
| 491 | 492 |
| 492 bool OverscrollRefresh::IsAwaitingScrollUpdateAck() const { | 493 bool OverscrollRefresh::IsAwaitingScrollUpdateAck() const { |
| 493 return scroll_consumption_state_ == AWAITING_SCROLL_UPDATE_ACK; | 494 return scroll_consumption_state_ == AWAITING_SCROLL_UPDATE_ACK; |
| 494 } | 495 } |
| 495 | 496 |
| 496 void OverscrollRefresh::UpdateDisplay( | 497 void OverscrollRefresh::UpdateDisplay( |
| 497 const gfx::SizeF& viewport_size, | 498 const gfx::SizeF& viewport_size, |
| 498 const gfx::Vector2dF& content_scroll_offset) { | 499 const gfx::Vector2dF& content_scroll_offset, |
| 500 bool root_overflow_y_hidden) { |
| 499 viewport_size_ = viewport_size; | 501 viewport_size_ = viewport_size; |
| 500 scrolled_to_top_ = content_scroll_offset.y() == 0; | 502 scrolled_to_top_ = content_scroll_offset.y() == 0; |
| 503 overflow_y_hidden_ = root_overflow_y_hidden; |
| 501 } | 504 } |
| 502 | 505 |
| 503 void OverscrollRefresh::Release(bool allow_activation) { | 506 void OverscrollRefresh::Release(bool allow_activation) { |
| 504 if (scroll_consumption_state_ == ENABLED) { | 507 if (scroll_consumption_state_ == ENABLED) { |
| 505 if (effect_->Release(base::TimeTicks::Now(), allow_activation)) | 508 if (effect_->Release(base::TimeTicks::Now(), allow_activation)) |
| 506 client_->TriggerRefresh(); | 509 client_->TriggerRefresh(); |
| 507 } | 510 } |
| 508 scroll_consumption_state_ = DISABLED; | 511 scroll_consumption_state_ = DISABLED; |
| 509 } | 512 } |
| 510 | 513 |
| 511 } // namespace content | 514 } // namespace content |
| OLD | NEW |