Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(375)

Unified Diff: cc/input/scroll_elasticity_helper.cc

Issue 817653003: Update from https://crrev.com/309717 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/input/scroll_elasticity_helper.h ('k') | cc/layers/delegated_renderer_layer_impl_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/input/scroll_elasticity_helper.cc
diff --git a/cc/input/scroll_elasticity_helper.cc b/cc/input/scroll_elasticity_helper.cc
index 7065e86a4911e236cecbf1912d9e87bd53cbc037..1e9fe7dff9f59fd482a286d89fc8dc5a613ac2aa 100644
--- a/cc/input/scroll_elasticity_helper.cc
+++ b/cc/input/scroll_elasticity_helper.cc
@@ -13,15 +13,13 @@ namespace cc {
class ScrollElasticityHelperImpl : public ScrollElasticityHelper {
public:
explicit ScrollElasticityHelperImpl(LayerTreeHostImpl* layer_tree_host_impl);
- virtual ~ScrollElasticityHelperImpl();
+ ~ScrollElasticityHelperImpl() override;
- // The amount that the view is stretched past the normal allowable bounds.
- // The "overhang" amount.
- gfx::Vector2dF StretchAmount() override;
+ gfx::Vector2dF StretchAmount() const override;
void SetStretchAmount(const gfx::Vector2dF& stretch_amount) override;
- bool PinnedInDirection(const gfx::Vector2dF& direction) override;
- bool CanScrollHorizontally() override;
- bool CanScrollVertically() override;
+ gfx::ScrollOffset ScrollOffset() const override;
+ gfx::ScrollOffset MaxScrollOffset() const override;
+ void ScrollBy(const gfx::Vector2dF& delta) override;
void RequestAnimate() override;
private:
@@ -36,8 +34,8 @@ ScrollElasticityHelperImpl::ScrollElasticityHelperImpl(
ScrollElasticityHelperImpl::~ScrollElasticityHelperImpl() {
}
-gfx::Vector2dF ScrollElasticityHelperImpl::StretchAmount() {
- return -layer_tree_host_impl_->active_tree()->elastic_overscroll()->Current(
+gfx::Vector2dF ScrollElasticityHelperImpl::StretchAmount() const {
+ return layer_tree_host_impl_->active_tree()->elastic_overscroll()->Current(
true);
}
@@ -47,37 +45,28 @@ void ScrollElasticityHelperImpl::SetStretchAmount(
return;
layer_tree_host_impl_->active_tree()->elastic_overscroll()->SetCurrent(
- -stretch_amount);
+ stretch_amount);
layer_tree_host_impl_->active_tree()->set_needs_update_draw_properties();
layer_tree_host_impl_->SetNeedsCommit();
layer_tree_host_impl_->SetNeedsRedraw();
layer_tree_host_impl_->SetFullRootLayerDamage();
}
-bool ScrollElasticityHelperImpl::PinnedInDirection(
- const gfx::Vector2dF& direction) {
- gfx::ScrollOffset scroll_offset =
- layer_tree_host_impl_->active_tree()->TotalScrollOffset();
- gfx::ScrollOffset max_scroll_offset =
- layer_tree_host_impl_->active_tree()->TotalMaxScrollOffset();
- bool result = false;
- if (direction.x() < 0)
- result |= scroll_offset.x() <= 0;
- if (direction.x() > 0)
- result |= scroll_offset.x() >= max_scroll_offset.x();
- if (direction.y() < 0)
- result |= scroll_offset.y() <= 0;
- if (direction.y() > 0)
- result |= scroll_offset.y() >= max_scroll_offset.y();
- return result;
+gfx::ScrollOffset ScrollElasticityHelperImpl::ScrollOffset() const {
+ return layer_tree_host_impl_->active_tree()->TotalScrollOffset();
}
-bool ScrollElasticityHelperImpl::CanScrollHorizontally() {
- return layer_tree_host_impl_->active_tree()->TotalMaxScrollOffset().x() > 0;
+gfx::ScrollOffset ScrollElasticityHelperImpl::MaxScrollOffset() const {
+ return layer_tree_host_impl_->active_tree()->TotalMaxScrollOffset();
}
-bool ScrollElasticityHelperImpl::CanScrollVertically() {
- return layer_tree_host_impl_->active_tree()->TotalMaxScrollOffset().y() > 0;
+void ScrollElasticityHelperImpl::ScrollBy(const gfx::Vector2dF& delta) {
+ LayerImpl* root_scroll_layer =
+ layer_tree_host_impl_->OuterViewportScrollLayer()
+ ? layer_tree_host_impl_->OuterViewportScrollLayer()
+ : layer_tree_host_impl_->InnerViewportScrollLayer();
+ if (root_scroll_layer)
+ root_scroll_layer->ScrollBy(delta);
}
void ScrollElasticityHelperImpl::RequestAnimate() {
« no previous file with comments | « cc/input/scroll_elasticity_helper.h ('k') | cc/layers/delegated_renderer_layer_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698