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

Side by Side Diff: cc/input/scrollbar_animation_controller.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 2014 The Chromium Authors. All rights reserved. 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 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/scrollbar_animation_controller.h" 5 #include "cc/input/scrollbar_animation_controller.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/time/time.h" 9 #include "base/time/time.h"
10 #include "cc/trees/layer_tree_impl.h" 10 #include "cc/trees/layer_tree_impl.h"
11 11
12 namespace cc { 12 namespace cc {
13 13
14 std::unique_ptr<ScrollbarAnimationController> 14 std::unique_ptr<ScrollbarAnimationController>
15 ScrollbarAnimationController::CreateScrollbarAnimationControllerAndroid( 15 ScrollbarAnimationController::CreateScrollbarAnimationControllerAndroid(
16 int scroll_layer_id, 16 ElementId scroll_element_id,
17 ScrollbarAnimationControllerClient* client, 17 ScrollbarAnimationControllerClient* client,
18 base::TimeDelta fade_out_delay, 18 base::TimeDelta fade_out_delay,
19 base::TimeDelta fade_out_resize_delay, 19 base::TimeDelta fade_out_resize_delay,
20 base::TimeDelta fade_out_duration) { 20 base::TimeDelta fade_out_duration) {
21 return base::WrapUnique(new ScrollbarAnimationController( 21 return base::WrapUnique(new ScrollbarAnimationController(
22 scroll_layer_id, client, fade_out_delay, fade_out_resize_delay, 22 scroll_element_id, client, fade_out_delay, fade_out_resize_delay,
23 fade_out_duration)); 23 fade_out_duration));
24 } 24 }
25 25
26 std::unique_ptr<ScrollbarAnimationController> 26 std::unique_ptr<ScrollbarAnimationController>
27 ScrollbarAnimationController::CreateScrollbarAnimationControllerAuraOverlay( 27 ScrollbarAnimationController::CreateScrollbarAnimationControllerAuraOverlay(
28 int scroll_layer_id, 28 ElementId scroll_element_id,
29 ScrollbarAnimationControllerClient* client, 29 ScrollbarAnimationControllerClient* client,
30 base::TimeDelta show_delay, 30 base::TimeDelta show_delay,
31 base::TimeDelta fade_out_delay, 31 base::TimeDelta fade_out_delay,
32 base::TimeDelta fade_out_resize_delay, 32 base::TimeDelta fade_out_resize_delay,
33 base::TimeDelta fade_out_duration, 33 base::TimeDelta fade_out_duration,
34 base::TimeDelta thinning_duration) { 34 base::TimeDelta thinning_duration) {
35 return base::WrapUnique(new ScrollbarAnimationController( 35 return base::WrapUnique(new ScrollbarAnimationController(
36 scroll_layer_id, client, show_delay, fade_out_delay, 36 scroll_element_id, client, show_delay, fade_out_delay,
37 fade_out_resize_delay, fade_out_duration, thinning_duration)); 37 fade_out_resize_delay, fade_out_duration, thinning_duration));
38 } 38 }
39 39
40 ScrollbarAnimationController::ScrollbarAnimationController( 40 ScrollbarAnimationController::ScrollbarAnimationController(
41 int scroll_layer_id, 41 ElementId scroll_element_id,
42 ScrollbarAnimationControllerClient* client, 42 ScrollbarAnimationControllerClient* client,
43 base::TimeDelta fade_out_delay, 43 base::TimeDelta fade_out_delay,
44 base::TimeDelta fade_out_resize_delay, 44 base::TimeDelta fade_out_resize_delay,
45 base::TimeDelta fade_out_duration) 45 base::TimeDelta fade_out_duration)
46 : client_(client), 46 : client_(client),
47 fade_out_delay_(fade_out_delay), 47 fade_out_delay_(fade_out_delay),
48 fade_out_resize_delay_(fade_out_resize_delay), 48 fade_out_resize_delay_(fade_out_resize_delay),
49 need_trigger_scrollbar_show_(false), 49 need_trigger_scrollbar_show_(false),
50 is_animating_(false), 50 is_animating_(false),
51 scroll_layer_id_(scroll_layer_id), 51 scroll_element_id_(scroll_element_id),
52 currently_scrolling_(false), 52 currently_scrolling_(false),
53 show_in_fast_scroll_(false), 53 show_in_fast_scroll_(false),
54 opacity_(0.0f), 54 opacity_(0.0f),
55 fade_out_duration_(fade_out_duration), 55 fade_out_duration_(fade_out_duration),
56 show_scrollbars_on_scroll_gesture_(false), 56 show_scrollbars_on_scroll_gesture_(false),
57 need_thinning_animation_(false), 57 need_thinning_animation_(false),
58 weak_factory_(this) { 58 weak_factory_(this) {
59 ApplyOpacityToScrollbars(0.0f); 59 ApplyOpacityToScrollbars(0.0f);
60 } 60 }
61 61
62 ScrollbarAnimationController::ScrollbarAnimationController( 62 ScrollbarAnimationController::ScrollbarAnimationController(
63 int scroll_layer_id, 63 ElementId scroll_element_id,
64 ScrollbarAnimationControllerClient* client, 64 ScrollbarAnimationControllerClient* client,
65 base::TimeDelta show_delay, 65 base::TimeDelta show_delay,
66 base::TimeDelta fade_out_delay, 66 base::TimeDelta fade_out_delay,
67 base::TimeDelta fade_out_resize_delay, 67 base::TimeDelta fade_out_resize_delay,
68 base::TimeDelta fade_out_duration, 68 base::TimeDelta fade_out_duration,
69 base::TimeDelta thinning_duration) 69 base::TimeDelta thinning_duration)
70 : client_(client), 70 : client_(client),
71 show_delay_(show_delay), 71 show_delay_(show_delay),
72 fade_out_delay_(fade_out_delay), 72 fade_out_delay_(fade_out_delay),
73 fade_out_resize_delay_(fade_out_resize_delay), 73 fade_out_resize_delay_(fade_out_resize_delay),
74 need_trigger_scrollbar_show_(false), 74 need_trigger_scrollbar_show_(false),
75 is_animating_(false), 75 is_animating_(false),
76 scroll_layer_id_(scroll_layer_id), 76 scroll_element_id_(scroll_element_id),
77 currently_scrolling_(false), 77 currently_scrolling_(false),
78 show_in_fast_scroll_(false), 78 show_in_fast_scroll_(false),
79 opacity_(0.0f), 79 opacity_(0.0f),
80 fade_out_duration_(fade_out_duration), 80 fade_out_duration_(fade_out_duration),
81 show_scrollbars_on_scroll_gesture_(true), 81 show_scrollbars_on_scroll_gesture_(true),
82 need_thinning_animation_(true), 82 need_thinning_animation_(true),
83 weak_factory_(this) { 83 weak_factory_(this) {
84 vertical_controller_ = SingleScrollbarAnimationControllerThinning::Create( 84 vertical_controller_ = SingleScrollbarAnimationControllerThinning::Create(
85 scroll_layer_id, ScrollbarOrientation::VERTICAL, client, 85 scroll_element_id, ScrollbarOrientation::VERTICAL, client,
86 thinning_duration); 86 thinning_duration);
87 horizontal_controller_ = SingleScrollbarAnimationControllerThinning::Create( 87 horizontal_controller_ = SingleScrollbarAnimationControllerThinning::Create(
88 scroll_layer_id, ScrollbarOrientation::HORIZONTAL, client, 88 scroll_element_id, ScrollbarOrientation::HORIZONTAL, client,
89 thinning_duration); 89 thinning_duration);
90 ApplyOpacityToScrollbars(0.0f); 90 ApplyOpacityToScrollbars(0.0f);
91 } 91 }
92 92
93 ScrollbarAnimationController::~ScrollbarAnimationController() {} 93 ScrollbarAnimationController::~ScrollbarAnimationController() {}
94 94
95 ScrollbarSet ScrollbarAnimationController::Scrollbars() const { 95 ScrollbarSet ScrollbarAnimationController::Scrollbars() const {
96 return client_->ScrollbarsFor(scroll_layer_id_); 96 return client_->ScrollbarsFor(scroll_element_id_);
97 } 97 }
98 98
99 SingleScrollbarAnimationControllerThinning& 99 SingleScrollbarAnimationControllerThinning&
100 ScrollbarAnimationController::GetScrollbarAnimationController( 100 ScrollbarAnimationController::GetScrollbarAnimationController(
101 ScrollbarOrientation orientation) const { 101 ScrollbarOrientation orientation) const {
102 DCHECK(need_thinning_animation_); 102 DCHECK(need_thinning_animation_);
103 if (orientation == ScrollbarOrientation::VERTICAL) 103 if (orientation == ScrollbarOrientation::VERTICAL)
104 return *(vertical_controller_.get()); 104 return *(vertical_controller_.get());
105 else 105 else
106 return *(horizontal_controller_.get()); 106 return *(horizontal_controller_.get());
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 if (opacity_ != opacity) 377 if (opacity_ != opacity)
378 client_->SetNeedsRedrawForScrollbarAnimation(); 378 client_->SetNeedsRedrawForScrollbarAnimation();
379 379
380 opacity_ = opacity; 380 opacity_ = opacity;
381 381
382 if (previouslyVisible != currentlyVisible) 382 if (previouslyVisible != currentlyVisible)
383 client_->DidChangeScrollbarVisibility(); 383 client_->DidChangeScrollbarVisibility();
384 } 384 }
385 385
386 } // namespace cc 386 } // namespace cc
OLDNEW
« no previous file with comments | « cc/input/scrollbar_animation_controller.h ('k') | cc/input/scrollbar_animation_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698