OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 "cc/layers/viewport.h" | 5 #include "cc/layers/viewport.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "cc/input/top_controls_manager.h" | 8 #include "cc/input/top_controls_manager.h" |
9 #include "cc/trees/layer_tree_host_impl.h" | 9 #include "cc/trees/layer_tree_host_impl.h" |
10 #include "cc/trees/layer_tree_impl.h" | 10 #include "cc/trees/layer_tree_impl.h" |
11 #include "ui/gfx/geometry/vector2d_conversions.h" | 11 #include "ui/gfx/geometry/vector2d_conversions.h" |
12 #include "ui/gfx/geometry/vector2d_f.h" | 12 #include "ui/gfx/geometry/vector2d_f.h" |
13 | 13 |
14 namespace cc { | 14 namespace cc { |
15 | 15 |
16 // static | 16 // static |
17 scoped_ptr<Viewport> Viewport::Create( | 17 scoped_ptr<Viewport> Viewport::Create( |
18 LayerTreeHostImpl* host_impl) { | 18 LayerTreeHostImpl* host_impl) { |
19 return make_scoped_ptr(new Viewport(host_impl)); | 19 return make_scoped_ptr(new Viewport(host_impl)); |
20 } | 20 } |
21 | 21 |
22 Viewport::Viewport(LayerTreeHostImpl* host_impl) | 22 Viewport::Viewport(LayerTreeHostImpl* host_impl) |
23 : host_impl_(host_impl) { | 23 : host_impl_(host_impl) { |
24 DCHECK(host_impl_); | 24 DCHECK(host_impl_); |
25 } | 25 } |
26 | 26 |
| 27 void Viewport::Pan(const gfx::Vector2dF& delta) { |
| 28 gfx::Vector2dF pending_delta = delta; |
| 29 |
| 30 pending_delta -= host_impl_->ScrollLayer(InnerScrollLayer(), |
| 31 pending_delta, |
| 32 gfx::Point(), |
| 33 false); |
| 34 } |
| 35 |
27 Viewport::ScrollResult Viewport::ScrollBy(const gfx::Vector2dF& delta, | 36 Viewport::ScrollResult Viewport::ScrollBy(const gfx::Vector2dF& delta, |
28 const gfx::Point& viewport_point, | 37 const gfx::Point& viewport_point, |
29 bool is_wheel_scroll) { | 38 bool is_wheel_scroll, |
| 39 bool affect_top_controls) { |
30 gfx::Vector2dF content_delta = delta; | 40 gfx::Vector2dF content_delta = delta; |
31 ScrollResult result; | 41 ScrollResult result; |
32 | 42 |
33 if (ShouldTopControlsConsumeScroll(delta)) { | 43 if (affect_top_controls && ShouldTopControlsConsumeScroll(delta)) { |
34 result.top_controls_applied_delta = ScrollTopControls(delta); | 44 result.top_controls_applied_delta = ScrollTopControls(delta); |
35 content_delta -= result.top_controls_applied_delta; | 45 content_delta -= result.top_controls_applied_delta; |
36 } | 46 } |
37 | 47 |
38 gfx::Vector2dF pending_content_delta = content_delta; | 48 gfx::Vector2dF pending_content_delta = content_delta; |
39 | 49 |
40 if (OuterScrollLayer()) { | 50 if (OuterScrollLayer()) { |
41 pending_content_delta -= host_impl_->ScrollLayer(OuterScrollLayer(), | 51 pending_content_delta -= host_impl_->ScrollLayer(OuterScrollLayer(), |
42 pending_content_delta, | 52 pending_content_delta, |
43 viewport_point, | 53 viewport_point, |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 | 134 |
125 LayerImpl* Viewport::InnerScrollLayer() const { | 135 LayerImpl* Viewport::InnerScrollLayer() const { |
126 return host_impl_->InnerViewportScrollLayer(); | 136 return host_impl_->InnerViewportScrollLayer(); |
127 } | 137 } |
128 | 138 |
129 LayerImpl* Viewport::OuterScrollLayer() const { | 139 LayerImpl* Viewport::OuterScrollLayer() const { |
130 return host_impl_->OuterViewportScrollLayer(); | 140 return host_impl_->OuterViewportScrollLayer(); |
131 } | 141 } |
132 | 142 |
133 } // namespace cc | 143 } // namespace cc |
OLD | NEW |