OLD | NEW |
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/scrollbar_layer_impl_base.h" | 5 #include "cc/layers/scrollbar_layer_impl_base.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include "cc/trees/layer_tree_impl.h" | 8 #include "cc/trees/layer_tree_impl.h" |
9 #include "ui/gfx/rect_conversions.h" | 9 #include "ui/gfx/rect_conversions.h" |
10 | 10 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 gfx::Rect ScrollbarLayerImplBase::ScrollbarLayerRectToContentRect( | 98 gfx::Rect ScrollbarLayerImplBase::ScrollbarLayerRectToContentRect( |
99 const gfx::RectF& layer_rect) const { | 99 const gfx::RectF& layer_rect) const { |
100 // Don't intersect with the bounds as in LayerRectToContentRect() because | 100 // Don't intersect with the bounds as in LayerRectToContentRect() because |
101 // layer_rect here might be in coordinates of the containing layer. | 101 // layer_rect here might be in coordinates of the containing layer. |
102 gfx::RectF content_rect = gfx::ScaleRect(layer_rect, | 102 gfx::RectF content_rect = gfx::ScaleRect(layer_rect, |
103 contents_scale_x(), | 103 contents_scale_x(), |
104 contents_scale_y()); | 104 contents_scale_y()); |
105 return gfx::ToEnclosingRect(content_rect); | 105 return gfx::ToEnclosingRect(content_rect); |
106 } | 106 } |
107 | 107 |
108 void ScrollbarLayerImplBase::SetCurrentPos(float current_pos) { | 108 bool ScrollbarLayerImplBase::SetCurrentPos(float current_pos) { |
109 if (current_pos_ == current_pos) | 109 if (current_pos_ == current_pos) |
110 return; | 110 return false; |
111 current_pos_ = current_pos; | 111 current_pos_ = current_pos; |
112 NoteLayerPropertyChanged(); | 112 NoteLayerPropertyChanged(); |
| 113 return true; |
113 } | 114 } |
114 | 115 |
115 void ScrollbarLayerImplBase::SetMaximum(int maximum) { | 116 bool ScrollbarLayerImplBase::SetMaximum(int maximum) { |
116 if (maximum_ == maximum) | 117 if (maximum_ == maximum) |
117 return; | 118 return false; |
118 maximum_ = maximum; | 119 maximum_ = maximum; |
119 NoteLayerPropertyChanged(); | 120 NoteLayerPropertyChanged(); |
| 121 return true; |
120 } | 122 } |
121 | 123 |
122 void ScrollbarLayerImplBase::SetVerticalAdjust(float vertical_adjust) { | 124 bool ScrollbarLayerImplBase::SetVerticalAdjust(float vertical_adjust) { |
123 if (vertical_adjust_ == vertical_adjust) | 125 if (vertical_adjust_ == vertical_adjust) |
124 return; | 126 return false; |
125 vertical_adjust_ = vertical_adjust; | 127 vertical_adjust_ = vertical_adjust; |
126 NoteLayerPropertyChanged(); | 128 NoteLayerPropertyChanged(); |
| 129 return true; |
127 } | 130 } |
128 | 131 |
129 void ScrollbarLayerImplBase::SetVisibleToTotalLengthRatio(float ratio) { | 132 bool ScrollbarLayerImplBase::SetVisibleToTotalLengthRatio(float ratio) { |
130 if (!IsThumbResizable()) | 133 if (!IsThumbResizable()) |
131 return; | 134 return false; |
132 | 135 |
133 if (visible_to_total_length_ratio_ == ratio) | 136 if (visible_to_total_length_ratio_ == ratio) |
134 return; | 137 return false; |
135 visible_to_total_length_ratio_ = ratio; | 138 visible_to_total_length_ratio_ = ratio; |
136 NoteLayerPropertyChanged(); | 139 NoteLayerPropertyChanged(); |
| 140 return true; |
137 } | 141 } |
138 | 142 |
139 void ScrollbarLayerImplBase::SetThumbThicknessScaleFactor(float factor) { | 143 bool ScrollbarLayerImplBase::SetThumbThicknessScaleFactor(float factor) { |
140 if (thumb_thickness_scale_factor_ == factor) | 144 if (thumb_thickness_scale_factor_ == factor) |
141 return; | 145 return false; |
142 thumb_thickness_scale_factor_ = factor; | 146 thumb_thickness_scale_factor_ = factor; |
143 NoteLayerPropertyChanged(); | 147 NoteLayerPropertyChanged(); |
| 148 return true; |
144 } | 149 } |
145 | 150 |
146 gfx::Rect ScrollbarLayerImplBase::ComputeThumbQuadRect() const { | 151 gfx::Rect ScrollbarLayerImplBase::ComputeThumbQuadRect() const { |
147 // Thumb extent is the length of the thumb in the scrolling direction, thumb | 152 // Thumb extent is the length of the thumb in the scrolling direction, thumb |
148 // thickness is in the perpendicular direction. Here's an example of a | 153 // thickness is in the perpendicular direction. Here's an example of a |
149 // horizontal scrollbar - inputs are above the scrollbar, computed values | 154 // horizontal scrollbar - inputs are above the scrollbar, computed values |
150 // below: | 155 // below: |
151 // | 156 // |
152 // |<------------------- track_length_ ------------------->| | 157 // |<------------------- track_length_ ------------------->| |
153 // | 158 // |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 } | 248 } |
244 | 249 |
245 void ScrollbarLayerImplBase::ScrollbarParametersDidChange() { | 250 void ScrollbarLayerImplBase::ScrollbarParametersDidChange() { |
246 if (!clip_layer_ || !scroll_layer_) | 251 if (!clip_layer_ || !scroll_layer_) |
247 return; | 252 return; |
248 | 253 |
249 scroll_layer_->SetScrollbarPosition(this, clip_layer_); | 254 scroll_layer_->SetScrollbarPosition(this, clip_layer_); |
250 } | 255 } |
251 | 256 |
252 } // namespace cc | 257 } // namespace cc |
OLD | NEW |