OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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/trees/layer_tree_impl.h" | 5 #include "cc/trees/layer_tree_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 | 236 |
237 gfx::ScrollOffset current_offset = scroll_layer->CurrentScrollOffset(); | 237 gfx::ScrollOffset current_offset = scroll_layer->CurrentScrollOffset(); |
238 if (IsViewportLayerId(scroll_layer_id)) { | 238 if (IsViewportLayerId(scroll_layer_id)) { |
239 current_offset += InnerViewportScrollLayer()->CurrentScrollOffset(); | 239 current_offset += InnerViewportScrollLayer()->CurrentScrollOffset(); |
240 if (OuterViewportContainerLayer()) | 240 if (OuterViewportContainerLayer()) |
241 clip_size.SetToMin(OuterViewportContainerLayer()->BoundsForScrolling()); | 241 clip_size.SetToMin(OuterViewportContainerLayer()->BoundsForScrolling()); |
242 clip_size.Scale(1 / current_page_scale_factor()); | 242 clip_size.Scale(1 / current_page_scale_factor()); |
243 } | 243 } |
244 | 244 |
245 bool scrollbar_needs_animation = false; | 245 bool scrollbar_needs_animation = false; |
| 246 bool clip_layer_size_did_change = false; |
246 bool scroll_layer_size_did_change = false; | 247 bool scroll_layer_size_did_change = false; |
247 bool y_offset_did_change = false; | 248 bool y_offset_did_change = false; |
248 for (ScrollbarLayerImplBase* scrollbar : ScrollbarsFor(scroll_layer_id)) { | 249 for (ScrollbarLayerImplBase* scrollbar : ScrollbarsFor(scroll_layer_id)) { |
249 if (scrollbar->orientation() == HORIZONTAL) { | 250 if (scrollbar->orientation() == HORIZONTAL) { |
250 scrollbar_needs_animation |= scrollbar->SetCurrentPos(current_offset.x()); | 251 scrollbar_needs_animation |= scrollbar->SetCurrentPos(current_offset.x()); |
251 scrollbar_needs_animation |= | 252 clip_layer_size_did_change |= |
252 scrollbar->SetClipLayerLength(clip_size.width()); | 253 scrollbar->SetClipLayerLength(clip_size.width()); |
253 scrollbar_needs_animation |= scroll_layer_size_did_change |= | 254 scroll_layer_size_did_change |= |
254 scrollbar->SetScrollLayerLength(scroll_size.width()); | 255 scrollbar->SetScrollLayerLength(scroll_size.width()); |
255 } else { | 256 } else { |
256 scrollbar_needs_animation |= y_offset_did_change |= | 257 scrollbar_needs_animation |= y_offset_did_change |= |
257 scrollbar->SetCurrentPos(current_offset.y()); | 258 scrollbar->SetCurrentPos(current_offset.y()); |
258 scrollbar_needs_animation |= | 259 clip_layer_size_did_change |= |
259 scrollbar->SetClipLayerLength(clip_size.height()); | 260 scrollbar->SetClipLayerLength(clip_size.height()); |
260 scrollbar_needs_animation |= scroll_layer_size_did_change |= | 261 scroll_layer_size_did_change |= |
261 scrollbar->SetScrollLayerLength(scroll_size.height()); | 262 scrollbar->SetScrollLayerLength(scroll_size.height()); |
262 } | 263 } |
263 scrollbar_needs_animation |= | 264 scrollbar_needs_animation |= |
264 scrollbar->SetVerticalAdjust(clip_layer->bounds_delta().y()); | 265 scrollbar->SetVerticalAdjust(clip_layer->bounds_delta().y()); |
265 } | 266 } |
266 | 267 |
| 268 scrollbar_needs_animation |= |
| 269 (clip_layer_size_did_change || scroll_layer_size_did_change); |
| 270 |
267 if (y_offset_did_change && IsViewportLayerId(scroll_layer_id)) | 271 if (y_offset_did_change && IsViewportLayerId(scroll_layer_id)) |
268 TRACE_COUNTER_ID1("cc", "scroll_offset_y", scroll_layer->id(), | 272 TRACE_COUNTER_ID1("cc", "scroll_offset_y", scroll_layer->id(), |
269 current_offset.y()); | 273 current_offset.y()); |
270 | 274 |
271 if (scrollbar_needs_animation) { | 275 if (scrollbar_needs_animation) { |
272 ScrollbarAnimationController* controller = | 276 ScrollbarAnimationController* controller = |
273 layer_tree_host_impl_->ScrollbarAnimationControllerForId( | 277 layer_tree_host_impl_->ScrollbarAnimationControllerForId( |
274 scroll_layer_id); | 278 scroll_layer_id); |
275 if (controller) | 279 if (!controller) |
276 controller->DidScrollUpdate(scroll_layer_size_did_change); | 280 return; |
| 281 |
| 282 if (clip_layer_size_did_change || scroll_layer_size_did_change) { |
| 283 controller->DidResize(); |
| 284 } else { |
| 285 controller->DidScrollUpdate(); |
| 286 } |
277 } | 287 } |
278 } | 288 } |
279 | 289 |
280 RenderSurfaceImpl* LayerTreeImpl::RootRenderSurface() const { | 290 RenderSurfaceImpl* LayerTreeImpl::RootRenderSurface() const { |
281 return layer_list_.empty() ? nullptr : layer_list_[0]->GetRenderSurface(); | 291 return layer_list_.empty() ? nullptr : layer_list_[0]->GetRenderSurface(); |
282 } | 292 } |
283 | 293 |
284 bool LayerTreeImpl::LayerListIsEmpty() const { | 294 bool LayerTreeImpl::LayerListIsEmpty() const { |
285 return layer_list_.empty(); | 295 return layer_list_.empty(); |
286 } | 296 } |
(...skipping 1862 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2149 | 2159 |
2150 void LayerTreeImpl::ResetAllChangeTracking() { | 2160 void LayerTreeImpl::ResetAllChangeTracking() { |
2151 layers_that_should_push_properties_.clear(); | 2161 layers_that_should_push_properties_.clear(); |
2152 // Iterate over all layers, including masks. | 2162 // Iterate over all layers, including masks. |
2153 for (auto& layer : *layers_) | 2163 for (auto& layer : *layers_) |
2154 layer->ResetChangeTracking(); | 2164 layer->ResetChangeTracking(); |
2155 property_trees_.ResetAllChangeTracking(); | 2165 property_trees_.ResetAllChangeTracking(); |
2156 } | 2166 } |
2157 | 2167 |
2158 } // namespace cc | 2168 } // namespace cc |
OLD | NEW |