| 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" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 pinch_zoom_active_ = true; | 92 pinch_zoom_active_ = true; |
| 93 } | 93 } |
| 94 | 94 |
| 95 LayerTreeImpl* active_tree = host_impl_->active_tree(); | 95 LayerTreeImpl* active_tree = host_impl_->active_tree(); |
| 96 | 96 |
| 97 // Keep the center-of-pinch anchor specified by (x, y) in a stable | 97 // Keep the center-of-pinch anchor specified by (x, y) in a stable |
| 98 // position over the course of the magnify. | 98 // position over the course of the magnify. |
| 99 gfx::Point adjusted_anchor = anchor + pinch_anchor_adjustment_; | 99 gfx::Point adjusted_anchor = anchor + pinch_anchor_adjustment_; |
| 100 float page_scale = active_tree->current_page_scale_factor(); | 100 float page_scale = active_tree->current_page_scale_factor(); |
| 101 gfx::PointF previous_scale_anchor = | 101 gfx::PointF previous_scale_anchor = |
| 102 gfx::ScalePoint(adjusted_anchor, 1.f / page_scale); | 102 gfx::ScalePoint(gfx::PointF(adjusted_anchor), 1.f / page_scale); |
| 103 active_tree->SetPageScaleOnActiveTree(page_scale * magnify_delta); | 103 active_tree->SetPageScaleOnActiveTree(page_scale * magnify_delta); |
| 104 page_scale = active_tree->current_page_scale_factor(); | 104 page_scale = active_tree->current_page_scale_factor(); |
| 105 gfx::PointF new_scale_anchor = | 105 gfx::PointF new_scale_anchor = |
| 106 gfx::ScalePoint(adjusted_anchor, 1.f / page_scale); | 106 gfx::ScalePoint(gfx::PointF(adjusted_anchor), 1.f / page_scale); |
| 107 gfx::Vector2dF move = previous_scale_anchor - new_scale_anchor; | 107 gfx::Vector2dF move = previous_scale_anchor - new_scale_anchor; |
| 108 | 108 |
| 109 // Scale back to viewport space since that's the coordinate space ScrollBy | 109 // Scale back to viewport space since that's the coordinate space ScrollBy |
| 110 // uses. | 110 // uses. |
| 111 move.Scale(page_scale); | 111 move.Scale(page_scale); |
| 112 | 112 |
| 113 // If clamping the inner viewport scroll offset causes a change, it should | 113 // If clamping the inner viewport scroll offset causes a change, it should |
| 114 // be accounted for from the intended move. | 114 // be accounted for from the intended move. |
| 115 move -= InnerScrollLayer()->ClampScrollToMaxScrollOffset(); | 115 move -= InnerScrollLayer()->ClampScrollToMaxScrollOffset(); |
| 116 | 116 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 | 179 |
| 180 LayerImpl* Viewport::InnerScrollLayer() const { | 180 LayerImpl* Viewport::InnerScrollLayer() const { |
| 181 return host_impl_->InnerViewportScrollLayer(); | 181 return host_impl_->InnerViewportScrollLayer(); |
| 182 } | 182 } |
| 183 | 183 |
| 184 LayerImpl* Viewport::OuterScrollLayer() const { | 184 LayerImpl* Viewport::OuterScrollLayer() const { |
| 185 return host_impl_->OuterViewportScrollLayer(); | 185 return host_impl_->OuterViewportScrollLayer(); |
| 186 } | 186 } |
| 187 | 187 |
| 188 } // namespace cc | 188 } // namespace cc |
| OLD | NEW |