| 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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 | 151 |
| 152 gfx::Vector2dF Viewport::AdjustOverscroll(const gfx::Vector2dF& delta) const { | 152 gfx::Vector2dF Viewport::AdjustOverscroll(const gfx::Vector2dF& delta) const { |
| 153 const float kEpsilon = 0.1f; | 153 const float kEpsilon = 0.1f; |
| 154 gfx::Vector2dF adjusted = delta; | 154 gfx::Vector2dF adjusted = delta; |
| 155 | 155 |
| 156 if (std::abs(adjusted.x()) < kEpsilon) | 156 if (std::abs(adjusted.x()) < kEpsilon) |
| 157 adjusted.set_x(0.0f); | 157 adjusted.set_x(0.0f); |
| 158 if (std::abs(adjusted.y()) < kEpsilon) | 158 if (std::abs(adjusted.y()) < kEpsilon) |
| 159 adjusted.set_y(0.0f); | 159 adjusted.set_y(0.0f); |
| 160 | 160 |
| 161 // Disable overscroll on axes which are impossible to scroll. | |
| 162 if (host_impl_->settings().report_overscroll_only_for_scrollable_axes) { | |
| 163 if (std::abs(MaxTotalScrollOffset().x()) <= kEpsilon || | |
| 164 !InnerScrollLayer()->user_scrollable_horizontal()) | |
| 165 adjusted.set_x(0.0f); | |
| 166 if (std::abs(MaxTotalScrollOffset().y()) <= kEpsilon || | |
| 167 !InnerScrollLayer()->user_scrollable_vertical()) | |
| 168 adjusted.set_y(0.0f); | |
| 169 } | |
| 170 | |
| 171 return adjusted; | 161 return adjusted; |
| 172 } | 162 } |
| 173 | 163 |
| 174 gfx::ScrollOffset Viewport::MaxTotalScrollOffset() const { | 164 gfx::ScrollOffset Viewport::MaxTotalScrollOffset() const { |
| 175 gfx::ScrollOffset offset; | 165 gfx::ScrollOffset offset; |
| 176 | 166 |
| 177 offset += InnerScrollLayer()->MaxScrollOffset(); | 167 offset += InnerScrollLayer()->MaxScrollOffset(); |
| 178 | 168 |
| 179 if (OuterScrollLayer()) | 169 if (OuterScrollLayer()) |
| 180 offset += OuterScrollLayer()->MaxScrollOffset(); | 170 offset += OuterScrollLayer()->MaxScrollOffset(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 195 | 185 |
| 196 LayerImpl* Viewport::InnerScrollLayer() const { | 186 LayerImpl* Viewport::InnerScrollLayer() const { |
| 197 return host_impl_->InnerViewportScrollLayer(); | 187 return host_impl_->InnerViewportScrollLayer(); |
| 198 } | 188 } |
| 199 | 189 |
| 200 LayerImpl* Viewport::OuterScrollLayer() const { | 190 LayerImpl* Viewport::OuterScrollLayer() const { |
| 201 return host_impl_->OuterViewportScrollLayer(); | 191 return host_impl_->OuterViewportScrollLayer(); |
| 202 } | 192 } |
| 203 | 193 |
| 204 } // namespace cc | 194 } // namespace cc |
| OLD | NEW |