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 #ifndef CC_INPUT_SCROLL_ELASTICITY_HELPER_H_ |
| 6 #define CC_INPUT_SCROLL_ELASTICITY_HELPER_H_ |
| 7 |
| 8 #include "base/time/time.h" |
| 9 #include "cc/base/cc_export.h" |
| 10 #include "ui/gfx/geometry/vector2d_f.h" |
| 11 |
| 12 namespace cc { |
| 13 |
| 14 class LayerTreeHostImpl; |
| 15 |
| 16 // ScrollElasticityHelper is based on |
| 17 // WebKit/Source/platform/mac/ScrollElasticityController.h |
| 18 /* |
| 19 * Copyright (C) 2011 Apple Inc. All rights reserved. |
| 20 * |
| 21 * Redistribution and use in source and binary forms, with or without |
| 22 * modification, are permitted provided that the following conditions |
| 23 * are met: |
| 24 * 1. Redistributions of source code must retain the above copyright |
| 25 * notice, this list of conditions and the following disclaimer. |
| 26 * 2. Redistributions in binary form must reproduce the above copyright |
| 27 * notice, this list of conditions and the following disclaimer in the |
| 28 * documentation and/or other materials provided with the distribution. |
| 29 * |
| 30 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' |
| 31 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
| 32 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 33 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS |
| 34 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 35 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 36 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 37 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 38 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 39 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
| 40 * THE POSSIBILITY OF SUCH DAMAGE. |
| 41 */ |
| 42 |
| 43 // Interface between a LayerTreeHostImpl and the ScrollElasticityController. It |
| 44 // would be possible, in principle, for LayerTreeHostImpl to implement this |
| 45 // interface itself. This artificial boundary is introduced to reduce the amount |
| 46 // of logic and state held directly inside LayerTreeHostImpl. |
| 47 class CC_EXPORT ScrollElasticityHelper { |
| 48 public: |
| 49 explicit ScrollElasticityHelper(LayerTreeHostImpl* layer_tree); |
| 50 ~ScrollElasticityHelper(); |
| 51 |
| 52 bool AllowsHorizontalStretching(); |
| 53 bool AllowsVerticalStretching(); |
| 54 // The amount that the view is stretched past the normal allowable bounds. |
| 55 // The "overhang" amount. |
| 56 gfx::Vector2dF StretchAmount(); |
| 57 bool PinnedInDirection(const gfx::Vector2dF& direction); |
| 58 bool CanScrollHorizontally(); |
| 59 bool CanScrollVertically(); |
| 60 |
| 61 // Return the absolute scroll position, not relative to the scroll origin. |
| 62 gfx::Vector2dF AbsoluteScrollPosition(); |
| 63 |
| 64 void ImmediateScrollBy(const gfx::Vector2dF& scroll); |
| 65 void ImmediateScrollByWithoutContentEdgeConstraints( |
| 66 const gfx::Vector2dF& scroll); |
| 67 void StartSnapRubberbandTimer(); |
| 68 void StopSnapRubberbandTimer(); |
| 69 void SnapRubberbandTimerFired(); |
| 70 |
| 71 // If the current scroll position is within the overhang area, this function |
| 72 // will cause |
| 73 // the page to scroll to the nearest boundary point. |
| 74 void AdjustScrollPositionToBoundsIfNecessary(); |
| 75 |
| 76 private: |
| 77 LayerTreeHostImpl* layer_tree_host_impl_; |
| 78 gfx::Vector2dF stretch_offset_; |
| 79 bool timer_active_; |
| 80 }; |
| 81 |
| 82 } // namespace cc |
| 83 |
| 84 #endif // CC_INPUT_SCROLL_ELASTICITY_HELPER_H_ |
OLD | NEW |