OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 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_LAYERS_VIEWPORT_H_ |
| 6 #define CC_LAYERS_VIEWPORT_H_ |
| 7 |
| 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "cc/layers/layer_impl.h" |
| 10 #include "ui/gfx/geometry/vector2d_f.h" |
| 11 |
| 12 namespace cc { |
| 13 |
| 14 class LayerTreeHostImpl; |
| 15 |
| 16 // Encapsulates gesture handling logic on the viewport layers. The "viewport" |
| 17 // is made up of two scrolling layers, the inner viewport (visual) and the |
| 18 // outer viewport (layout) scroll layers. These layers have different scroll |
| 19 // bubbling behavior from the rest of the layer tree which is encoded in this |
| 20 // class. |
| 21 class CC_EXPORT Viewport { |
| 22 public: |
| 23 struct ScrollResult { |
| 24 gfx::Vector2dF applied_delta; |
| 25 gfx::Vector2dF unused_scroll_delta; |
| 26 gfx::Vector2dF top_controls_applied_delta; |
| 27 }; |
| 28 |
| 29 static scoped_ptr<Viewport> Create(LayerTreeHostImpl* host_impl); |
| 30 |
| 31 // Scrolls the viewport, applying the unique bubbling between the inner and |
| 32 // outer viewport. Scrolls can be consumed by top controls. |
| 33 ScrollResult ScrollBy(const gfx::Vector2dF& delta, |
| 34 const gfx::Point& viewport_point, |
| 35 bool is_wheel_scroll); |
| 36 |
| 37 private: |
| 38 explicit Viewport(LayerTreeHostImpl* host_impl); |
| 39 |
| 40 bool ShouldTopControlsConsumeScroll(const gfx::Vector2dF& scroll_delta) const; |
| 41 gfx::Vector2dF AdjustOverscroll(const gfx::Vector2dF& delta) const; |
| 42 |
| 43 // Sends the delta to the top controls, returns the amount applied. |
| 44 gfx::Vector2dF ScrollTopControls(const gfx::Vector2dF& delta); |
| 45 |
| 46 gfx::ScrollOffset MaxTotalScrollOffset() const; |
| 47 gfx::ScrollOffset TotalScrollOffset() const; |
| 48 |
| 49 LayerImpl* InnerScrollLayer() const; |
| 50 LayerImpl* OuterScrollLayer() const; |
| 51 |
| 52 LayerTreeHostImpl* host_impl_; |
| 53 |
| 54 DISALLOW_COPY_AND_ASSIGN(Viewport); |
| 55 }; |
| 56 |
| 57 } // namespace cc |
| 58 |
| 59 #endif // CC_LAYERS_VIEWPORT_H_ |
OLD | NEW |