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 "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #include "cc/input/top_controls_manager.h" | 9 #include "cc/input/top_controls_manager.h" |
10 #include "cc/trees/layer_tree_host_impl.h" | 10 #include "cc/trees/layer_tree_host_impl.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 scroll_tree.Node(OuterScrollLayer()->scroll_tree_index()); | 61 scroll_tree.Node(OuterScrollLayer()->scroll_tree_index()); |
62 pending_content_delta -= host_impl_->ScrollSingleNode( | 62 pending_content_delta -= host_impl_->ScrollSingleNode( |
63 outer_node, pending_content_delta, viewport_point, is_direct_manipulation, | 63 outer_node, pending_content_delta, viewport_point, is_direct_manipulation, |
64 &scroll_tree); | 64 &scroll_tree); |
65 result.consumed_delta = delta - AdjustOverscroll(pending_content_delta); | 65 result.consumed_delta = delta - AdjustOverscroll(pending_content_delta); |
66 | 66 |
67 result.content_scrolled_delta = content_delta - pending_content_delta; | 67 result.content_scrolled_delta = content_delta - pending_content_delta; |
68 return result; | 68 return result; |
69 } | 69 } |
70 | 70 |
| 71 void Viewport::ScrollByInnerFirst(const gfx::Vector2dF& delta) { |
| 72 LayerImpl* scroll_layer = InnerScrollLayer(); |
| 73 |
| 74 gfx::Vector2dF unused_delta = scroll_layer->ScrollBy(delta); |
| 75 if (!unused_delta.IsZero() && OuterScrollLayer()) |
| 76 OuterScrollLayer()->ScrollBy(unused_delta); |
| 77 } |
| 78 |
71 bool Viewport::ShouldAnimateViewport(const gfx::Vector2dF& viewport_delta, | 79 bool Viewport::ShouldAnimateViewport(const gfx::Vector2dF& viewport_delta, |
72 const gfx::Vector2dF& pending_delta) { | 80 const gfx::Vector2dF& pending_delta) { |
73 float max_dim_viewport_delta = | 81 float max_dim_viewport_delta = |
74 std::max(std::abs(viewport_delta.x()), std::abs(viewport_delta.y())); | 82 std::max(std::abs(viewport_delta.x()), std::abs(viewport_delta.y())); |
75 float max_dim_pending_delta = | 83 float max_dim_pending_delta = |
76 std::max(std::abs(pending_delta.x()), std::abs(pending_delta.y())); | 84 std::max(std::abs(pending_delta.x()), std::abs(pending_delta.y())); |
77 return max_dim_viewport_delta > max_dim_pending_delta; | 85 return max_dim_viewport_delta > max_dim_pending_delta; |
78 } | 86 } |
79 | 87 |
80 gfx::Vector2dF Viewport::ScrollAnimated(const gfx::Vector2dF& delta, | 88 gfx::Vector2dF Viewport::ScrollAnimated(const gfx::Vector2dF& delta, |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 move -= InnerScrollLayer()->ClampScrollToMaxScrollOffset(); | 187 move -= InnerScrollLayer()->ClampScrollToMaxScrollOffset(); |
180 | 188 |
181 Pan(move); | 189 Pan(move); |
182 } | 190 } |
183 | 191 |
184 void Viewport::PinchEnd() { | 192 void Viewport::PinchEnd() { |
185 pinch_anchor_adjustment_ = gfx::Vector2d(); | 193 pinch_anchor_adjustment_ = gfx::Vector2d(); |
186 pinch_zoom_active_ = false; | 194 pinch_zoom_active_ = false; |
187 } | 195 } |
188 | 196 |
| 197 LayerImpl* Viewport::MainScrollLayer() const { |
| 198 return InnerScrollLayer(); |
| 199 } |
| 200 |
189 gfx::Vector2dF Viewport::ScrollTopControls(const gfx::Vector2dF& delta) { | 201 gfx::Vector2dF Viewport::ScrollTopControls(const gfx::Vector2dF& delta) { |
190 gfx::Vector2dF excess_delta = | 202 gfx::Vector2dF excess_delta = |
191 host_impl_->top_controls_manager()->ScrollBy(delta); | 203 host_impl_->top_controls_manager()->ScrollBy(delta); |
192 | 204 |
193 return delta - excess_delta; | 205 return delta - excess_delta; |
194 } | 206 } |
195 | 207 |
196 bool Viewport::ShouldTopControlsConsumeScroll( | 208 bool Viewport::ShouldTopControlsConsumeScroll( |
197 const gfx::Vector2dF& scroll_delta) const { | 209 const gfx::Vector2dF& scroll_delta) const { |
198 // Always consume if it's in the direction to show the top controls. | 210 // Always consume if it's in the direction to show the top controls. |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 | 255 |
244 LayerImpl* Viewport::InnerScrollLayer() const { | 256 LayerImpl* Viewport::InnerScrollLayer() const { |
245 return host_impl_->InnerViewportScrollLayer(); | 257 return host_impl_->InnerViewportScrollLayer(); |
246 } | 258 } |
247 | 259 |
248 LayerImpl* Viewport::OuterScrollLayer() const { | 260 LayerImpl* Viewport::OuterScrollLayer() const { |
249 return host_impl_->OuterViewportScrollLayer(); | 261 return host_impl_->OuterViewportScrollLayer(); |
250 } | 262 } |
251 | 263 |
252 } // namespace cc | 264 } // namespace cc |
OLD | NEW |