| 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 // TODO(chaopeng) clip_layer_size_did_change should call DidResize after |
| 283 // crbug.com/701810 got fixed. |
| 284 if (scroll_layer_size_did_change) { |
| 285 controller->DidResize(); |
| 286 } else { |
| 287 controller->DidScrollUpdate(); |
| 288 } |
| 277 } | 289 } |
| 278 } | 290 } |
| 279 | 291 |
| 280 RenderSurfaceImpl* LayerTreeImpl::RootRenderSurface() const { | 292 RenderSurfaceImpl* LayerTreeImpl::RootRenderSurface() const { |
| 281 return layer_list_.empty() ? nullptr : layer_list_[0]->GetRenderSurface(); | 293 return layer_list_.empty() ? nullptr : layer_list_[0]->GetRenderSurface(); |
| 282 } | 294 } |
| 283 | 295 |
| 284 bool LayerTreeImpl::LayerListIsEmpty() const { | 296 bool LayerTreeImpl::LayerListIsEmpty() const { |
| 285 return layer_list_.empty(); | 297 return layer_list_.empty(); |
| 286 } | 298 } |
| (...skipping 1864 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2151 | 2163 |
| 2152 void LayerTreeImpl::ResetAllChangeTracking() { | 2164 void LayerTreeImpl::ResetAllChangeTracking() { |
| 2153 layers_that_should_push_properties_.clear(); | 2165 layers_that_should_push_properties_.clear(); |
| 2154 // Iterate over all layers, including masks. | 2166 // Iterate over all layers, including masks. |
| 2155 for (auto& layer : *layers_) | 2167 for (auto& layer : *layers_) |
| 2156 layer->ResetChangeTracking(); | 2168 layer->ResetChangeTracking(); |
| 2157 property_trees_.ResetAllChangeTracking(); | 2169 property_trees_.ResetAllChangeTracking(); |
| 2158 } | 2170 } |
| 2159 | 2171 |
| 2160 } // namespace cc | 2172 } // namespace cc |
| OLD | NEW |