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

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

Issue 2824693002: Refactor LayerTreeImpl's scrollbar map to be keyed on element ids (Closed)
Patch Set: rebase Created 3 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/input/single_scrollbar_animation_controller_thinning.h" 5 #include "cc/input/single_scrollbar_animation_controller_thinning.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
11 #include "cc/input/scrollbar_animation_controller.h" 11 #include "cc/input/scrollbar_animation_controller.h"
12 #include "cc/layers/layer_impl.h" 12 #include "cc/layers/layer_impl.h"
13 #include "cc/layers/scrollbar_layer_impl_base.h" 13 #include "cc/layers/scrollbar_layer_impl_base.h"
14 #include "cc/trees/layer_tree_impl.h" 14 #include "cc/trees/layer_tree_impl.h"
15 15
16 namespace cc { 16 namespace cc {
17 17
18 std::unique_ptr<SingleScrollbarAnimationControllerThinning> 18 std::unique_ptr<SingleScrollbarAnimationControllerThinning>
19 SingleScrollbarAnimationControllerThinning::Create( 19 SingleScrollbarAnimationControllerThinning::Create(
20 int scroll_layer_id, 20 ElementId scroll_element_id,
21 ScrollbarOrientation orientation, 21 ScrollbarOrientation orientation,
22 ScrollbarAnimationControllerClient* client, 22 ScrollbarAnimationControllerClient* client,
23 base::TimeDelta thinning_duration) { 23 base::TimeDelta thinning_duration) {
24 return base::WrapUnique(new SingleScrollbarAnimationControllerThinning( 24 return base::WrapUnique(new SingleScrollbarAnimationControllerThinning(
25 scroll_layer_id, orientation, client, thinning_duration)); 25 scroll_element_id, orientation, client, thinning_duration));
26 } 26 }
27 27
28 SingleScrollbarAnimationControllerThinning:: 28 SingleScrollbarAnimationControllerThinning::
29 SingleScrollbarAnimationControllerThinning( 29 SingleScrollbarAnimationControllerThinning(
30 int scroll_layer_id, 30 ElementId scroll_element_id,
31 ScrollbarOrientation orientation, 31 ScrollbarOrientation orientation,
32 ScrollbarAnimationControllerClient* client, 32 ScrollbarAnimationControllerClient* client,
33 base::TimeDelta thinning_duration) 33 base::TimeDelta thinning_duration)
34 : client_(client), 34 : client_(client),
35 is_animating_(false), 35 is_animating_(false),
36 scroll_layer_id_(scroll_layer_id), 36 scroll_element_id_(scroll_element_id),
37 orientation_(orientation), 37 orientation_(orientation),
38 captured_(false), 38 captured_(false),
39 mouse_is_over_scrollbar_(false), 39 mouse_is_over_scrollbar_(false),
40 mouse_is_near_scrollbar_(false), 40 mouse_is_near_scrollbar_(false),
41 thickness_change_(NONE), 41 thickness_change_(NONE),
42 thinning_duration_(thinning_duration) { 42 thinning_duration_(thinning_duration) {
43 ApplyThumbThicknessScale(kIdleThicknessScale); 43 ApplyThumbThicknessScale(kIdleThicknessScale);
44 } 44 }
45 45
46 bool SingleScrollbarAnimationControllerThinning::Animate(base::TimeTicks now) { 46 bool SingleScrollbarAnimationControllerThinning::Animate(base::TimeTicks now) {
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 } 172 }
173 173
174 void SingleScrollbarAnimationControllerThinning::UpdateThumbThicknessScale() { 174 void SingleScrollbarAnimationControllerThinning::UpdateThumbThicknessScale() {
175 StopAnimation(); 175 StopAnimation();
176 ApplyThumbThicknessScale(mouse_is_near_scrollbar_ ? 1.f 176 ApplyThumbThicknessScale(mouse_is_near_scrollbar_ ? 1.f
177 : kIdleThicknessScale); 177 : kIdleThicknessScale);
178 } 178 }
179 179
180 void SingleScrollbarAnimationControllerThinning::ApplyThumbThicknessScale( 180 void SingleScrollbarAnimationControllerThinning::ApplyThumbThicknessScale(
181 float thumb_thickness_scale) { 181 float thumb_thickness_scale) {
182 for (ScrollbarLayerImplBase* scrollbar : 182 for (auto* scrollbar : client_->ScrollbarsFor(scroll_element_id_)) {
183 client_->ScrollbarsFor(scroll_layer_id_)) {
184 if (scrollbar->orientation() != orientation_) 183 if (scrollbar->orientation() != orientation_)
185 continue; 184 continue;
186 if (!scrollbar->is_overlay_scrollbar()) 185 if (!scrollbar->is_overlay_scrollbar())
187 continue; 186 continue;
188 187
189 float scale = AdjustScale(thumb_thickness_scale, 188 float scale = AdjustScale(thumb_thickness_scale,
190 scrollbar->thumb_thickness_scale_factor(), 189 scrollbar->thumb_thickness_scale_factor(),
191 thickness_change_, kIdleThicknessScale, 1); 190 thickness_change_, kIdleThicknessScale, 1);
192 191
193 scrollbar->SetThumbThicknessScaleFactor(scale); 192 scrollbar->SetThumbThicknessScaleFactor(scale);
194 } 193 }
195 } 194 }
196 195
197 } // namespace cc 196 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698