OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "cc/trees/tree_scroll_elasticity_client.h" |
| 6 |
| 7 #include "cc/layers/layer_impl.h" |
| 8 #include "cc/trees/layer_tree_host_impl.h" |
| 9 |
| 10 namespace cc { |
| 11 |
| 12 TreeScrollElasticityClient::TreeScrollElasticityClient(LayerTreeHostImpl* tree) |
| 13 : tree_(tree), timer_active_(false), controller_(NULL) {} |
| 14 |
| 15 TreeScrollElasticityClient::~TreeScrollElasticityClient() {} |
| 16 |
| 17 void TreeScrollElasticityClient::BindToController( |
| 18 ScrollElasticityController* controller) { |
| 19 controller_ = controller; |
| 20 } |
| 21 |
| 22 bool TreeScrollElasticityClient::allowsHorizontalStretching() const { |
| 23 return true; |
| 24 } |
| 25 |
| 26 bool TreeScrollElasticityClient::allowsVerticalStretching() const { |
| 27 return true; |
| 28 } |
| 29 |
| 30 // The amount that the view is stretched past the normal allowable bounds. |
| 31 // The "overhang" amount. |
| 32 gfx::Vector2dF TreeScrollElasticityClient::stretchAmount() const { |
| 33 return stretch_offset_; |
| 34 } |
| 35 |
| 36 bool TreeScrollElasticityClient::pinnedInDirection(const gfx::Vector2dF& delta)
const { |
| 37 LayerImpl* layer = tree_->InnerViewportScrollLayer(); |
| 38 bool result = false; |
| 39 if (delta.x() < 0) |
| 40 result |= layer->TotalScrollOffset().x() <= 0; |
| 41 if (delta.x() > 0) |
| 42 result |= layer->TotalScrollOffset().x() >= layer->MaxScrollOffset().x(); |
| 43 if (delta.y() < 0) |
| 44 result |= layer->TotalScrollOffset().y() <= 0; |
| 45 if (delta.y() > 0) |
| 46 result |= layer->TotalScrollOffset().y() >= layer->MaxScrollOffset().y(); |
| 47 printf("pinned delta=%s offset=%s max=%s : %d\n", |
| 48 delta.ToString().c_str(), |
| 49 layer->TotalScrollOffset().ToString().c_str(), |
| 50 layer->MaxScrollOffset().ToString().c_str(), |
| 51 result); |
| 52 return result; |
| 53 } |
| 54 |
| 55 bool TreeScrollElasticityClient::canScrollHorizontally() const { |
| 56 return true; |
| 57 } |
| 58 |
| 59 bool TreeScrollElasticityClient::canScrollVertically() const { |
| 60 return true; |
| 61 } |
| 62 |
| 63 // Return the absolute scroll position, not relative to the scroll origin. |
| 64 gfx::Vector2dF TreeScrollElasticityClient::absoluteScrollPosition() const { |
| 65 return stretchAmount(); |
| 66 } |
| 67 |
| 68 void TreeScrollElasticityClient::immediateScrollBy(const gfx::Vector2dF& delta)
{ |
| 69 } |
| 70 |
| 71 void TreeScrollElasticityClient::immediateScrollByWithoutContentEdgeConstraints(
const gfx::Vector2dF& delta) { |
| 72 stretch_offset_ += delta; |
| 73 // tree_->UpdateRubberband(-stretch_offset_); |
| 74 } |
| 75 |
| 76 void TreeScrollElasticityClient::startSnapRubberbandTimer() { |
| 77 timer_active_ = true; |
| 78 tree_->SetNeedsAnimate(); |
| 79 } |
| 80 |
| 81 void TreeScrollElasticityClient::stopSnapRubberbandTimer() { |
| 82 timer_active_ = false; |
| 83 } |
| 84 |
| 85 void TreeScrollElasticityClient::adjustScrollPositionToBoundsIfNecessary() { |
| 86 } |
| 87 |
| 88 } // namespace cc |
OLD | NEW |