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

Side by Side Diff: content/browser/android/overscroll_refresh.cc

Issue 910373002: [Android] Disable pull-to-refresh with overflow:hidden (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Pass overflow:hidden via metadata Created 5 years, 10 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 unified diff | Download patch
OLDNEW
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 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 409
410 DISALLOW_COPY_AND_ASSIGN(Effect); 410 DISALLOW_COPY_AND_ASSIGN(Effect);
411 }; 411 };
412 412
413 OverscrollRefresh::OverscrollRefresh(ui::ResourceManager* resource_manager, 413 OverscrollRefresh::OverscrollRefresh(ui::ResourceManager* resource_manager,
414 OverscrollRefreshClient* client, 414 OverscrollRefreshClient* client,
415 float target_drag_offset_pixels, 415 float target_drag_offset_pixels,
416 bool mirror) 416 bool mirror)
417 : client_(client), 417 : client_(client),
418 scrolled_to_top_(true), 418 scrolled_to_top_(true),
419 overflow_y_hidden_(false),
419 scroll_consumption_state_(DISABLED), 420 scroll_consumption_state_(DISABLED),
420 effect_(new Effect(resource_manager, target_drag_offset_pixels, mirror)) { 421 effect_(new Effect(resource_manager, target_drag_offset_pixels, mirror)) {
421 DCHECK(client); 422 DCHECK(client);
422 } 423 }
423 424
424 OverscrollRefresh::~OverscrollRefresh() { 425 OverscrollRefresh::~OverscrollRefresh() {
425 } 426 }
426 427
427 void OverscrollRefresh::Reset() { 428 void OverscrollRefresh::Reset() {
428 scroll_consumption_state_ = DISABLED; 429 scroll_consumption_state_ = DISABLED;
429 effect_->Finish(); 430 effect_->Finish();
430 } 431 }
431 432
432 void OverscrollRefresh::OnScrollBegin() { 433 void OverscrollRefresh::OnScrollBegin() {
433 ReleaseWithoutActivation(); 434 ReleaseWithoutActivation();
434 if (scrolled_to_top_) 435 if (scrolled_to_top_ && !overflow_y_hidden_)
435 scroll_consumption_state_ = AWAITING_SCROLL_UPDATE_ACK; 436 scroll_consumption_state_ = AWAITING_SCROLL_UPDATE_ACK;
436 } 437 }
437 438
438 void OverscrollRefresh::OnScrollEnd(const gfx::Vector2dF& scroll_velocity) { 439 void OverscrollRefresh::OnScrollEnd(const gfx::Vector2dF& scroll_velocity) {
439 bool allow_activation = scroll_velocity.y() > kMinFlingVelocityForActivation; 440 bool allow_activation = scroll_velocity.y() > kMinFlingVelocityForActivation;
440 Release(allow_activation); 441 Release(allow_activation);
441 } 442 }
442 443
443 void OverscrollRefresh::OnScrollUpdateAck(bool was_consumed) { 444 void OverscrollRefresh::OnScrollUpdateAck(bool was_consumed) {
444 if (scroll_consumption_state_ != AWAITING_SCROLL_UPDATE_ACK) 445 if (scroll_consumption_state_ != AWAITING_SCROLL_UPDATE_ACK)
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 bool OverscrollRefresh::IsActive() const { 493 bool OverscrollRefresh::IsActive() const {
493 return scroll_consumption_state_ == ENABLED || !effect_->IsFinished(); 494 return scroll_consumption_state_ == ENABLED || !effect_->IsFinished();
494 } 495 }
495 496
496 bool OverscrollRefresh::IsAwaitingScrollUpdateAck() const { 497 bool OverscrollRefresh::IsAwaitingScrollUpdateAck() const {
497 return scroll_consumption_state_ == AWAITING_SCROLL_UPDATE_ACK; 498 return scroll_consumption_state_ == AWAITING_SCROLL_UPDATE_ACK;
498 } 499 }
499 500
500 void OverscrollRefresh::UpdateDisplay( 501 void OverscrollRefresh::UpdateDisplay(
501 const gfx::SizeF& viewport_size, 502 const gfx::SizeF& viewport_size,
502 const gfx::Vector2dF& content_scroll_offset) { 503 const gfx::Vector2dF& content_scroll_offset,
504 bool root_overflow_y_hidden) {
503 viewport_size_ = viewport_size; 505 viewport_size_ = viewport_size;
504 scrolled_to_top_ = content_scroll_offset.y() == 0; 506 scrolled_to_top_ = content_scroll_offset.y() == 0;
507 overflow_y_hidden_ = root_overflow_y_hidden;
505 } 508 }
506 509
507 void OverscrollRefresh::Release(bool allow_activation) { 510 void OverscrollRefresh::Release(bool allow_activation) {
508 if (scroll_consumption_state_ == ENABLED) { 511 if (scroll_consumption_state_ == ENABLED) {
509 if (effect_->Release(base::TimeTicks::Now(), allow_activation)) 512 if (effect_->Release(base::TimeTicks::Now(), allow_activation))
510 client_->TriggerRefresh(); 513 client_->TriggerRefresh();
511 } 514 }
512 scroll_consumption_state_ = DISABLED; 515 scroll_consumption_state_ = DISABLED;
513 } 516 }
514 517
515 } // namespace content 518 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698