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

Side by Side Diff: cc/layers/solid_color_scrollbar_layer.cc

Issue 2816063003: Replace layer id with Element id for tracking scrollbar animation controllers (Closed)
Patch Set: Address reviewer comments, pull element_id.h change to another patch 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/layers/solid_color_scrollbar_layer.h" 5 #include "cc/layers/solid_color_scrollbar_layer.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "cc/layers/layer_impl.h" 9 #include "cc/layers/layer_impl.h"
10 #include "cc/layers/solid_color_scrollbar_layer_impl.h" 10 #include "cc/layers/solid_color_scrollbar_layer_impl.h"
11 11
12 namespace cc { 12 namespace cc {
13 13
14 std::unique_ptr<LayerImpl> SolidColorScrollbarLayer::CreateLayerImpl( 14 std::unique_ptr<LayerImpl> SolidColorScrollbarLayer::CreateLayerImpl(
15 LayerTreeImpl* tree_impl) { 15 LayerTreeImpl* tree_impl) {
16 const bool kIsOverlayScrollbar = true; 16 const bool kIsOverlayScrollbar = true;
17 return SolidColorScrollbarLayerImpl::Create( 17 return SolidColorScrollbarLayerImpl::Create(
18 tree_impl, id(), orientation(), 18 tree_impl, id(), orientation(),
19 solid_color_scrollbar_layer_inputs_.thumb_thickness, 19 solid_color_scrollbar_layer_inputs_.thumb_thickness,
20 solid_color_scrollbar_layer_inputs_.track_start, 20 solid_color_scrollbar_layer_inputs_.track_start,
21 solid_color_scrollbar_layer_inputs_.is_left_side_vertical_scrollbar, 21 solid_color_scrollbar_layer_inputs_.is_left_side_vertical_scrollbar,
22 kIsOverlayScrollbar); 22 kIsOverlayScrollbar);
23 } 23 }
24 24
25 scoped_refptr<SolidColorScrollbarLayer> SolidColorScrollbarLayer::Create( 25 scoped_refptr<SolidColorScrollbarLayer> SolidColorScrollbarLayer::Create(
26 ScrollbarOrientation orientation, 26 ScrollbarOrientation orientation,
27 int thumb_thickness, 27 int thumb_thickness,
28 int track_start, 28 int track_start,
29 bool is_left_side_vertical_scrollbar, 29 bool is_left_side_vertical_scrollbar,
30 int scroll_layer_id) { 30 int scroll_layer_id,
31 ElementId scroll_element_id) {
31 return make_scoped_refptr(new SolidColorScrollbarLayer( 32 return make_scoped_refptr(new SolidColorScrollbarLayer(
32 orientation, thumb_thickness, track_start, 33 orientation, thumb_thickness, track_start,
33 is_left_side_vertical_scrollbar, scroll_layer_id)); 34 is_left_side_vertical_scrollbar, scroll_layer_id, scroll_element_id));
34 } 35 }
35 36
36 SolidColorScrollbarLayer::SolidColorScrollbarLayerInputs:: 37 SolidColorScrollbarLayer::SolidColorScrollbarLayerInputs::
37 SolidColorScrollbarLayerInputs(ScrollbarOrientation orientation, 38 SolidColorScrollbarLayerInputs(ScrollbarOrientation orientation,
38 int thumb_thickness, 39 int thumb_thickness,
39 int track_start, 40 int track_start,
40 bool is_left_side_vertical_scrollbar, 41 bool is_left_side_vertical_scrollbar,
41 int scroll_layer_id) 42 int scroll_layer_id,
43 ElementId scroll_element_id)
42 : scroll_layer_id(scroll_layer_id), 44 : scroll_layer_id(scroll_layer_id),
45 scroll_element_id(scroll_element_id),
43 orientation(orientation), 46 orientation(orientation),
44 thumb_thickness(thumb_thickness), 47 thumb_thickness(thumb_thickness),
45 track_start(track_start), 48 track_start(track_start),
46 is_left_side_vertical_scrollbar(is_left_side_vertical_scrollbar) {} 49 is_left_side_vertical_scrollbar(is_left_side_vertical_scrollbar) {}
47 50
48 SolidColorScrollbarLayer::SolidColorScrollbarLayerInputs:: 51 SolidColorScrollbarLayer::SolidColorScrollbarLayerInputs::
49 ~SolidColorScrollbarLayerInputs() = default; 52 ~SolidColorScrollbarLayerInputs() = default;
50 53
51 SolidColorScrollbarLayer::SolidColorScrollbarLayer( 54 SolidColorScrollbarLayer::SolidColorScrollbarLayer(
52 ScrollbarOrientation orientation, 55 ScrollbarOrientation orientation,
53 int thumb_thickness, 56 int thumb_thickness,
54 int track_start, 57 int track_start,
55 bool is_left_side_vertical_scrollbar, 58 bool is_left_side_vertical_scrollbar,
56 int scroll_layer_id) 59 int scroll_layer_id,
60 ElementId scroll_element_id)
57 : solid_color_scrollbar_layer_inputs_(orientation, 61 : solid_color_scrollbar_layer_inputs_(orientation,
58 thumb_thickness, 62 thumb_thickness,
59 track_start, 63 track_start,
60 is_left_side_vertical_scrollbar, 64 is_left_side_vertical_scrollbar,
61 scroll_layer_id) { 65 scroll_layer_id,
66 scroll_element_id) {
62 Layer::SetOpacity(0.f); 67 Layer::SetOpacity(0.f);
63 } 68 }
64 69
65 SolidColorScrollbarLayer::~SolidColorScrollbarLayer() {} 70 SolidColorScrollbarLayer::~SolidColorScrollbarLayer() {}
66 71
67 ScrollbarLayerInterface* SolidColorScrollbarLayer::ToScrollbarLayer() { 72 ScrollbarLayerInterface* SolidColorScrollbarLayer::ToScrollbarLayer() {
68 return this; 73 return this;
69 } 74 }
70 75
71 void SolidColorScrollbarLayer::SetOpacity(float opacity) { 76 void SolidColorScrollbarLayer::SetOpacity(float opacity) {
72 // The opacity of a solid color scrollbar layer is always 0 on main thread. 77 // The opacity of a solid color scrollbar layer is always 0 on main thread.
73 DCHECK_EQ(opacity, 0.f); 78 DCHECK_EQ(opacity, 0.f);
74 Layer::SetOpacity(opacity); 79 Layer::SetOpacity(opacity);
75 } 80 }
76 81
77 void SolidColorScrollbarLayer::PushPropertiesTo(LayerImpl* layer) { 82 void SolidColorScrollbarLayer::PushPropertiesTo(LayerImpl* layer) {
78 Layer::PushPropertiesTo(layer); 83 Layer::PushPropertiesTo(layer);
79 SolidColorScrollbarLayerImpl* scrollbar_layer = 84 SolidColorScrollbarLayerImpl* scrollbar_layer =
80 static_cast<SolidColorScrollbarLayerImpl*>(layer); 85 static_cast<SolidColorScrollbarLayerImpl*>(layer);
81 86
82 scrollbar_layer->SetScrollLayerId( 87 scrollbar_layer->SetScrollInfo(
83 solid_color_scrollbar_layer_inputs_.scroll_layer_id); 88 solid_color_scrollbar_layer_inputs_.scroll_layer_id,
89 solid_color_scrollbar_layer_inputs_.scroll_element_id);
84 } 90 }
85 91
86 void SolidColorScrollbarLayer::SetNeedsDisplayRect(const gfx::Rect& rect) { 92 void SolidColorScrollbarLayer::SetNeedsDisplayRect(const gfx::Rect& rect) {
87 // Never needs repaint. 93 // Never needs repaint.
88 } 94 }
89 95
90 bool SolidColorScrollbarLayer::OpacityCanAnimateOnImplThread() const { 96 bool SolidColorScrollbarLayer::OpacityCanAnimateOnImplThread() const {
91 return true; 97 return true;
92 } 98 }
93 99
94 bool SolidColorScrollbarLayer::AlwaysUseActiveTreeOpacity() const { 100 bool SolidColorScrollbarLayer::AlwaysUseActiveTreeOpacity() const {
95 return true; 101 return true;
96 } 102 }
97 103
98 int SolidColorScrollbarLayer::ScrollLayerId() const { 104 ElementId SolidColorScrollbarLayer::scroll_element_id() const {
99 return solid_color_scrollbar_layer_inputs_.scroll_layer_id; 105 return solid_color_scrollbar_layer_inputs_.scroll_element_id;
100 } 106 }
101 107
102 void SolidColorScrollbarLayer::SetScrollLayer(int layer_id) { 108 void SolidColorScrollbarLayer::SetScrollInfo(int layer_id,
103 if (layer_id == solid_color_scrollbar_layer_inputs_.scroll_layer_id) 109 ElementId element_id) {
110 if (layer_id == solid_color_scrollbar_layer_inputs_.scroll_layer_id &&
111 element_id == solid_color_scrollbar_layer_inputs_.scroll_element_id)
104 return; 112 return;
105 113
106 solid_color_scrollbar_layer_inputs_.scroll_layer_id = layer_id; 114 solid_color_scrollbar_layer_inputs_.scroll_layer_id = layer_id;
115 solid_color_scrollbar_layer_inputs_.scroll_element_id = element_id;
107 SetNeedsFullTreeSync(); 116 SetNeedsFullTreeSync();
108 } 117 }
109 118
110 ScrollbarOrientation SolidColorScrollbarLayer::orientation() const { 119 ScrollbarOrientation SolidColorScrollbarLayer::orientation() const {
111 return solid_color_scrollbar_layer_inputs_.orientation; 120 return solid_color_scrollbar_layer_inputs_.orientation;
112 } 121 }
113 122
114 } // namespace cc 123 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698