scroll_elasticity_helper.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. #ifndef CC_INPUT_SCROLL_ELASTICITY_HELPER_H_
  5. #define CC_INPUT_SCROLL_ELASTICITY_HELPER_H_
  6. #include "cc/cc_export.h"
  7. #include "ui/gfx/geometry/point_f.h"
  8. #include "ui/gfx/geometry/size.h"
  9. #include "ui/gfx/geometry/vector2d_f.h"
  10. namespace cc {
  11. class LayerTreeHostImpl;
  12. // ScrollElasticityHelper is based on
  13. // WebKit/Source/platform/mac/ScrollElasticityController.h
  14. /*
  15. * Copyright (C) 2011 Apple Inc. All rights reserved.
  16. *
  17. * Redistribution and use in source and binary forms, with or without
  18. * modification, are permitted provided that the following conditions
  19. * are met:
  20. * 1. Redistributions of source code must retain the above copyright
  21. * notice, this list of conditions and the following disclaimer.
  22. * 2. Redistributions in binary form must reproduce the above copyright
  23. * notice, this list of conditions and the following disclaimer in the
  24. * documentation and/or other materials provided with the distribution.
  25. *
  26. * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
  27. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  28. * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  29. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
  30. * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  31. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  32. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  33. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  34. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  35. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  36. * THE POSSIBILITY OF SUCH DAMAGE.
  37. */
  38. // Interface between a LayerTreeHostImpl and the ScrollElasticityController. It
  39. // would be possible, in principle, for LayerTreeHostImpl to implement this
  40. // interface itself. This artificial boundary is introduced to reduce the amount
  41. // of logic and state held directly inside LayerTreeHostImpl.
  42. class CC_EXPORT ScrollElasticityHelper {
  43. public:
  44. static ScrollElasticityHelper* CreateForLayerTreeHostImpl(
  45. LayerTreeHostImpl* host_impl);
  46. virtual ~ScrollElasticityHelper() {}
  47. virtual bool IsUserScrollableHorizontal() const = 0;
  48. virtual bool IsUserScrollableVertical() const = 0;
  49. // The bounds of the root scroller.
  50. virtual gfx::Size ScrollBounds() const = 0;
  51. // The amount that the view is stretched past the normal allowable bounds.
  52. virtual gfx::Vector2dF StretchAmount() const = 0;
  53. virtual void SetStretchAmount(const gfx::Vector2dF& stretch_amount) = 0;
  54. // Functions for the scrolling of the root scroll layer.
  55. virtual gfx::PointF ScrollOffset() const = 0;
  56. virtual gfx::PointF MaxScrollOffset() const = 0;
  57. virtual void ScrollBy(const gfx::Vector2dF& delta) = 0;
  58. // Requests that another frame happens for the controller to continue ticking
  59. // animations.
  60. virtual void RequestOneBeginFrame() = 0;
  61. };
  62. } // namespace cc
  63. #endif // CC_INPUT_SCROLL_ELASTICITY_HELPER_H_