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 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
235 | 235 |
236 gfx::ScrollOffset current_offset = scroll_layer->CurrentScrollOffset(); | 236 gfx::ScrollOffset current_offset = scroll_layer->CurrentScrollOffset(); |
237 if (IsViewportLayerId(scroll_layer_id)) { | 237 if (IsViewportLayerId(scroll_layer_id)) { |
238 current_offset += InnerViewportScrollLayer()->CurrentScrollOffset(); | 238 current_offset += InnerViewportScrollLayer()->CurrentScrollOffset(); |
239 if (OuterViewportContainerLayer()) | 239 if (OuterViewportContainerLayer()) |
240 clip_size.SetToMin(OuterViewportContainerLayer()->BoundsForScrolling()); | 240 clip_size.SetToMin(OuterViewportContainerLayer()->BoundsForScrolling()); |
241 clip_size.Scale(1 / current_page_scale_factor()); | 241 clip_size.Scale(1 / current_page_scale_factor()); |
242 } | 242 } |
243 | 243 |
244 bool scrollbar_needs_animation = false; | 244 bool scrollbar_needs_animation = false; |
245 bool clip_layer_size_did_change = false; | |
245 bool scroll_layer_size_did_change = false; | 246 bool scroll_layer_size_did_change = false; |
246 bool y_offset_did_change = false; | 247 bool y_offset_did_change = false; |
247 for (ScrollbarLayerImplBase* scrollbar : ScrollbarsFor(scroll_layer_id)) { | 248 for (ScrollbarLayerImplBase* scrollbar : ScrollbarsFor(scroll_layer_id)) { |
248 if (scrollbar->orientation() == HORIZONTAL) { | 249 if (scrollbar->orientation() == HORIZONTAL) { |
249 scrollbar_needs_animation |= scrollbar->SetCurrentPos(current_offset.x()); | 250 scrollbar_needs_animation |= scrollbar->SetCurrentPos(current_offset.x()); |
250 scrollbar_needs_animation |= | 251 scrollbar_needs_animation |= clip_layer_size_did_change |= |
bokan
2017/02/27 23:34:17
Nit: separate this into separate lines.
chaopeng
2017/02/28 01:51:12
This is formatted by clang-format.
bokan
2017/02/28 14:16:07
I mean separate statements. Turn it in to this:
c
| |
251 scrollbar->SetClipLayerLength(clip_size.width()); | 252 scrollbar->SetClipLayerLength(clip_size.width()); |
252 scrollbar_needs_animation |= scroll_layer_size_did_change |= | 253 scrollbar_needs_animation |= scroll_layer_size_did_change |= |
253 scrollbar->SetScrollLayerLength(scroll_size.width()); | 254 scrollbar->SetScrollLayerLength(scroll_size.width()); |
254 } else { | 255 } else { |
255 scrollbar_needs_animation |= y_offset_did_change |= | 256 scrollbar_needs_animation |= y_offset_did_change |= |
256 scrollbar->SetCurrentPos(current_offset.y()); | 257 scrollbar->SetCurrentPos(current_offset.y()); |
257 scrollbar_needs_animation |= | 258 scrollbar_needs_animation |= clip_layer_size_did_change |= |
258 scrollbar->SetClipLayerLength(clip_size.height()); | 259 scrollbar->SetClipLayerLength(clip_size.height()); |
259 scrollbar_needs_animation |= scroll_layer_size_did_change |= | 260 scrollbar_needs_animation |= scroll_layer_size_did_change |= |
260 scrollbar->SetScrollLayerLength(scroll_size.height()); | 261 scrollbar->SetScrollLayerLength(scroll_size.height()); |
261 } | 262 } |
262 scrollbar_needs_animation |= | 263 scrollbar_needs_animation |= |
263 scrollbar->SetVerticalAdjust(clip_layer->bounds_delta().y()); | 264 scrollbar->SetVerticalAdjust(clip_layer->bounds_delta().y()); |
264 } | 265 } |
265 | 266 |
266 if (y_offset_did_change && IsViewportLayerId(scroll_layer_id)) | 267 if (y_offset_did_change && IsViewportLayerId(scroll_layer_id)) |
267 TRACE_COUNTER_ID1("cc", "scroll_offset_y", scroll_layer->id(), | 268 TRACE_COUNTER_ID1("cc", "scroll_offset_y", scroll_layer->id(), |
268 current_offset.y()); | 269 current_offset.y()); |
269 | 270 |
270 if (scrollbar_needs_animation) { | 271 if (scrollbar_needs_animation) { |
271 ScrollbarAnimationController* controller = | 272 ScrollbarAnimationController* controller = |
272 layer_tree_host_impl_->ScrollbarAnimationControllerForId( | 273 layer_tree_host_impl_->ScrollbarAnimationControllerForId( |
273 scroll_layer_id); | 274 scroll_layer_id); |
274 if (controller) | 275 if (!controller) |
275 controller->DidScrollUpdate(scroll_layer_size_did_change); | 276 return; |
277 | |
278 if (clip_layer_size_did_change || scroll_layer_size_did_change) { | |
279 controller->DidResize(); | |
280 } else { | |
281 controller->WillUpdateScroll(); | |
282 } | |
276 } | 283 } |
277 } | 284 } |
278 | 285 |
279 RenderSurfaceImpl* LayerTreeImpl::RootRenderSurface() const { | 286 RenderSurfaceImpl* LayerTreeImpl::RootRenderSurface() const { |
280 return layer_list_.empty() ? nullptr : layer_list_[0]->GetRenderSurface(); | 287 return layer_list_.empty() ? nullptr : layer_list_[0]->GetRenderSurface(); |
281 } | 288 } |
282 | 289 |
283 bool LayerTreeImpl::LayerListIsEmpty() const { | 290 bool LayerTreeImpl::LayerListIsEmpty() const { |
284 return layer_list_.empty(); | 291 return layer_list_.empty(); |
285 } | 292 } |
(...skipping 1836 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2122 | 2129 |
2123 void LayerTreeImpl::ResetAllChangeTracking() { | 2130 void LayerTreeImpl::ResetAllChangeTracking() { |
2124 layers_that_should_push_properties_.clear(); | 2131 layers_that_should_push_properties_.clear(); |
2125 // Iterate over all layers, including masks. | 2132 // Iterate over all layers, including masks. |
2126 for (auto& layer : *layers_) | 2133 for (auto& layer : *layers_) |
2127 layer->ResetChangeTracking(); | 2134 layer->ResetChangeTracking(); |
2128 property_trees_.ResetAllChangeTracking(); | 2135 property_trees_.ResetAllChangeTracking(); |
2129 } | 2136 } |
2130 | 2137 |
2131 } // namespace cc | 2138 } // namespace cc |
OLD | NEW |