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

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

Issue 2827163005: Remove scroll layer ids from scrollbar layers (Closed)
Patch Set: 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,
31 ElementId scroll_element_id) { 30 ElementId scroll_element_id) {
32 return make_scoped_refptr(new SolidColorScrollbarLayer( 31 return make_scoped_refptr(new SolidColorScrollbarLayer(
33 orientation, thumb_thickness, track_start, 32 orientation, thumb_thickness, track_start,
34 is_left_side_vertical_scrollbar, scroll_layer_id, scroll_element_id)); 33 is_left_side_vertical_scrollbar, scroll_element_id));
35 } 34 }
36 35
37 SolidColorScrollbarLayer::SolidColorScrollbarLayerInputs:: 36 SolidColorScrollbarLayer::SolidColorScrollbarLayerInputs::
38 SolidColorScrollbarLayerInputs(ScrollbarOrientation orientation, 37 SolidColorScrollbarLayerInputs(ScrollbarOrientation orientation,
39 int thumb_thickness, 38 int thumb_thickness,
40 int track_start, 39 int track_start,
41 bool is_left_side_vertical_scrollbar, 40 bool is_left_side_vertical_scrollbar,
42 int scroll_layer_id,
43 ElementId scroll_element_id) 41 ElementId scroll_element_id)
44 : scroll_layer_id(scroll_layer_id), 42 : scroll_element_id(scroll_element_id),
45 scroll_element_id(scroll_element_id),
46 orientation(orientation), 43 orientation(orientation),
47 thumb_thickness(thumb_thickness), 44 thumb_thickness(thumb_thickness),
48 track_start(track_start), 45 track_start(track_start),
49 is_left_side_vertical_scrollbar(is_left_side_vertical_scrollbar) {} 46 is_left_side_vertical_scrollbar(is_left_side_vertical_scrollbar) {}
50 47
51 SolidColorScrollbarLayer::SolidColorScrollbarLayerInputs:: 48 SolidColorScrollbarLayer::SolidColorScrollbarLayerInputs::
52 ~SolidColorScrollbarLayerInputs() = default; 49 ~SolidColorScrollbarLayerInputs() = default;
53 50
54 SolidColorScrollbarLayer::SolidColorScrollbarLayer( 51 SolidColorScrollbarLayer::SolidColorScrollbarLayer(
55 ScrollbarOrientation orientation, 52 ScrollbarOrientation orientation,
56 int thumb_thickness, 53 int thumb_thickness,
57 int track_start, 54 int track_start,
58 bool is_left_side_vertical_scrollbar, 55 bool is_left_side_vertical_scrollbar,
59 int scroll_layer_id,
60 ElementId scroll_element_id) 56 ElementId scroll_element_id)
61 : solid_color_scrollbar_layer_inputs_(orientation, 57 : solid_color_scrollbar_layer_inputs_(orientation,
62 thumb_thickness, 58 thumb_thickness,
63 track_start, 59 track_start,
64 is_left_side_vertical_scrollbar, 60 is_left_side_vertical_scrollbar,
65 scroll_layer_id,
66 scroll_element_id) { 61 scroll_element_id) {
67 Layer::SetOpacity(0.f); 62 Layer::SetOpacity(0.f);
68 } 63 }
69 64
70 SolidColorScrollbarLayer::~SolidColorScrollbarLayer() {} 65 SolidColorScrollbarLayer::~SolidColorScrollbarLayer() {}
71 66
72 ScrollbarLayerInterface* SolidColorScrollbarLayer::ToScrollbarLayer() { 67 ScrollbarLayerInterface* SolidColorScrollbarLayer::ToScrollbarLayer() {
73 return this; 68 return this;
74 } 69 }
75 70
76 void SolidColorScrollbarLayer::SetOpacity(float opacity) { 71 void SolidColorScrollbarLayer::SetOpacity(float opacity) {
77 // The opacity of a solid color scrollbar layer is always 0 on main thread. 72 // The opacity of a solid color scrollbar layer is always 0 on main thread.
78 DCHECK_EQ(opacity, 0.f); 73 DCHECK_EQ(opacity, 0.f);
79 Layer::SetOpacity(opacity); 74 Layer::SetOpacity(opacity);
80 } 75 }
81 76
82 void SolidColorScrollbarLayer::PushPropertiesTo(LayerImpl* layer) { 77 void SolidColorScrollbarLayer::PushPropertiesTo(LayerImpl* layer) {
83 Layer::PushPropertiesTo(layer); 78 Layer::PushPropertiesTo(layer);
84 SolidColorScrollbarLayerImpl* scrollbar_layer = 79 SolidColorScrollbarLayerImpl* scrollbar_layer =
85 static_cast<SolidColorScrollbarLayerImpl*>(layer); 80 static_cast<SolidColorScrollbarLayerImpl*>(layer);
86 81
87 scrollbar_layer->SetScrollInfo( 82 scrollbar_layer->SetScrollElementId(
88 solid_color_scrollbar_layer_inputs_.scroll_layer_id,
89 solid_color_scrollbar_layer_inputs_.scroll_element_id); 83 solid_color_scrollbar_layer_inputs_.scroll_element_id);
90 } 84 }
91 85
92 void SolidColorScrollbarLayer::SetNeedsDisplayRect(const gfx::Rect& rect) { 86 void SolidColorScrollbarLayer::SetNeedsDisplayRect(const gfx::Rect& rect) {
93 // Never needs repaint. 87 // Never needs repaint.
94 } 88 }
95 89
96 bool SolidColorScrollbarLayer::OpacityCanAnimateOnImplThread() const { 90 bool SolidColorScrollbarLayer::OpacityCanAnimateOnImplThread() const {
97 return true; 91 return true;
98 } 92 }
99 93
100 bool SolidColorScrollbarLayer::AlwaysUseActiveTreeOpacity() const { 94 bool SolidColorScrollbarLayer::AlwaysUseActiveTreeOpacity() const {
101 return true; 95 return true;
102 } 96 }
103 97
104 ElementId SolidColorScrollbarLayer::scroll_element_id() const { 98 ElementId SolidColorScrollbarLayer::scroll_element_id() const {
105 return solid_color_scrollbar_layer_inputs_.scroll_element_id; 99 return solid_color_scrollbar_layer_inputs_.scroll_element_id;
106 } 100 }
107 101
108 void SolidColorScrollbarLayer::SetScrollInfo(int layer_id, 102 void SolidColorScrollbarLayer::SetScrollElementId(ElementId element_id) {
109 ElementId element_id) { 103 if (element_id == solid_color_scrollbar_layer_inputs_.scroll_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)
112 return; 104 return;
113 105
114 solid_color_scrollbar_layer_inputs_.scroll_layer_id = layer_id;
115 solid_color_scrollbar_layer_inputs_.scroll_element_id = element_id; 106 solid_color_scrollbar_layer_inputs_.scroll_element_id = element_id;
116 SetNeedsFullTreeSync(); 107 SetNeedsFullTreeSync();
117 } 108 }
118 109
119 ScrollbarOrientation SolidColorScrollbarLayer::orientation() const { 110 ScrollbarOrientation SolidColorScrollbarLayer::orientation() const {
120 return solid_color_scrollbar_layer_inputs_.orientation; 111 return solid_color_scrollbar_layer_inputs_.orientation;
121 } 112 }
122 113
123 } // namespace cc 114 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698