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

Side by Side Diff: cc/input/scroll_elasticity_helper.cc

Issue 1057283003: Remove parts of //cc we aren't using (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 8 months 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 unified diff | Download patch
« no previous file with comments | « cc/input/scroll_elasticity_helper.h ('k') | cc/input/scrollbar.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "cc/input/scroll_elasticity_helper.h"
6
7 #include "cc/layers/layer_impl.h"
8 #include "cc/trees/layer_tree_host_impl.h"
9 #include "cc/trees/layer_tree_impl.h"
10
11 namespace cc {
12
13 class ScrollElasticityHelperImpl : public ScrollElasticityHelper {
14 public:
15 explicit ScrollElasticityHelperImpl(LayerTreeHostImpl* layer_tree_host_impl);
16 ~ScrollElasticityHelperImpl() override;
17
18 bool IsUserScrollable() const override;
19 gfx::Vector2dF StretchAmount() const override;
20 void SetStretchAmount(const gfx::Vector2dF& stretch_amount) override;
21 gfx::ScrollOffset ScrollOffset() const override;
22 gfx::ScrollOffset MaxScrollOffset() const override;
23 void ScrollBy(const gfx::Vector2dF& delta) override;
24 void RequestAnimate() override;
25
26 private:
27 LayerTreeHostImpl* layer_tree_host_impl_;
28 };
29
30 ScrollElasticityHelperImpl::ScrollElasticityHelperImpl(
31 LayerTreeHostImpl* layer_tree)
32 : layer_tree_host_impl_(layer_tree) {
33 }
34
35 ScrollElasticityHelperImpl::~ScrollElasticityHelperImpl() {
36 }
37
38 bool ScrollElasticityHelperImpl::IsUserScrollable() const {
39 LayerImpl* layer = layer_tree_host_impl_->OuterViewportScrollLayer();
40 if (!layer)
41 return false;
42 return layer->user_scrollable_horizontal() ||
43 layer->user_scrollable_vertical();
44 }
45
46 gfx::Vector2dF ScrollElasticityHelperImpl::StretchAmount() const {
47 return layer_tree_host_impl_->active_tree()->elastic_overscroll()->Current(
48 true);
49 }
50
51 void ScrollElasticityHelperImpl::SetStretchAmount(
52 const gfx::Vector2dF& stretch_amount) {
53 if (stretch_amount == StretchAmount())
54 return;
55
56 layer_tree_host_impl_->active_tree()->elastic_overscroll()->SetCurrent(
57 stretch_amount);
58 layer_tree_host_impl_->active_tree()->set_needs_update_draw_properties();
59 layer_tree_host_impl_->SetNeedsCommit();
60 layer_tree_host_impl_->SetNeedsRedraw();
61 layer_tree_host_impl_->SetFullRootLayerDamage();
62 }
63
64 gfx::ScrollOffset ScrollElasticityHelperImpl::ScrollOffset() const {
65 return layer_tree_host_impl_->active_tree()->TotalScrollOffset();
66 }
67
68 gfx::ScrollOffset ScrollElasticityHelperImpl::MaxScrollOffset() const {
69 return layer_tree_host_impl_->active_tree()->TotalMaxScrollOffset();
70 }
71
72 void ScrollElasticityHelperImpl::ScrollBy(const gfx::Vector2dF& delta) {
73 LayerImpl* root_scroll_layer =
74 layer_tree_host_impl_->OuterViewportScrollLayer()
75 ? layer_tree_host_impl_->OuterViewportScrollLayer()
76 : layer_tree_host_impl_->InnerViewportScrollLayer();
77 if (root_scroll_layer)
78 root_scroll_layer->ScrollBy(delta);
79 }
80
81 void ScrollElasticityHelperImpl::RequestAnimate() {
82 layer_tree_host_impl_->SetNeedsAnimate();
83 }
84
85 // static
86 ScrollElasticityHelper* ScrollElasticityHelper::CreateForLayerTreeHostImpl(
87 LayerTreeHostImpl* layer_tree_host_impl) {
88 return new ScrollElasticityHelperImpl(layer_tree_host_impl);
89 }
90
91 } // namespace cc
OLDNEW
« no previous file with comments | « cc/input/scroll_elasticity_helper.h ('k') | cc/input/scrollbar.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698