Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/layer_impl.h" | 5 #include "cc/layers/layer_impl.h" |
| 6 | 6 |
| 7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
| 8 #include "base/debug/trace_event_argument.h" | 8 #include "base/debug/trace_event_argument.h" |
| 9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 1277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1288 scrollbar_layer->SetVisibleToTotalLengthRatio(visible_ratio); | 1288 scrollbar_layer->SetVisibleToTotalLengthRatio(visible_ratio); |
| 1289 } else { | 1289 } else { |
| 1290 float visible_ratio = clip_rect.height() / scroll_rect.height(); | 1290 float visible_ratio = clip_rect.height() / scroll_rect.height(); |
| 1291 scrollbar_needs_animation |= | 1291 scrollbar_needs_animation |= |
| 1292 scrollbar_layer->SetCurrentPos(current_offset.y()); | 1292 scrollbar_layer->SetCurrentPos(current_offset.y()); |
| 1293 scrollbar_needs_animation |= | 1293 scrollbar_needs_animation |= |
| 1294 scrollbar_layer->SetMaximum(scroll_rect.height() - clip_rect.height()); | 1294 scrollbar_layer->SetMaximum(scroll_rect.height() - clip_rect.height()); |
| 1295 scrollbar_needs_animation |= | 1295 scrollbar_needs_animation |= |
| 1296 scrollbar_layer->SetVisibleToTotalLengthRatio(visible_ratio); | 1296 scrollbar_layer->SetVisibleToTotalLengthRatio(visible_ratio); |
| 1297 } | 1297 } |
| 1298 | 1298 if (scrollbar_needs_animation) { |
| 1299 layer_tree_impl()->set_needs_update_draw_properties(); | 1299 layer_tree_impl()->set_needs_update_draw_properties(); |
| 1300 // TODO(wjmaclean) The scrollbar animator for the pinch-zoom scrollbars should | 1300 // TODO(wjmaclean) The scrollbar animator for the pinch-zoom scrollbars |
|
wjmaclean
2014/09/23 14:30:13
nit: please reformat this comment
MuVen
2014/09/23 14:44:08
Done.
| |
| 1301 // activate for every scroll on the main frame, not just the scrolls that move | 1301 // should |
| 1302 // the pinch virtual viewport (i.e. trigger from either inner or outer | 1302 // activate for every scroll on the main frame, not just the scrolls that |
| 1303 // viewport). | 1303 // move |
| 1304 if (scrollbar_animation_controller_ && scrollbar_needs_animation) { | 1304 // the pinch virtual viewport (i.e. trigger from either inner or outer |
| 1305 // When both non-overlay and overlay scrollbars are both present, don't | 1305 // viewport). |
| 1306 // animate the overlay scrollbars when page scale factor is at the min. | 1306 if (scrollbar_animation_controller_) { |
| 1307 // Non-overlay scrollbars also shouldn't trigger animations. | 1307 // When both non-overlay and overlay scrollbars are both present, don't |
| 1308 bool is_animatable_scrollbar = | 1308 // animate the overlay scrollbars when page scale factor is at the min. |
| 1309 scrollbar_layer->is_overlay_scrollbar() && | 1309 // Non-overlay scrollbars also shouldn't trigger animations. |
| 1310 ((layer_tree_impl()->total_page_scale_factor() > | 1310 bool is_animatable_scrollbar = |
| 1311 layer_tree_impl()->min_page_scale_factor()) || | 1311 scrollbar_layer->is_overlay_scrollbar() && |
| 1312 !layer_tree_impl()->settings().use_pinch_zoom_scrollbars); | 1312 ((layer_tree_impl()->total_page_scale_factor() > |
| 1313 if (is_animatable_scrollbar) | 1313 layer_tree_impl()->min_page_scale_factor()) || |
| 1314 scrollbar_animation_controller_->DidScrollUpdate(); | 1314 !layer_tree_impl()->settings().use_pinch_zoom_scrollbars); |
| 1315 if (is_animatable_scrollbar) | |
| 1316 scrollbar_animation_controller_->DidScrollUpdate(); | |
| 1317 } | |
| 1315 } | 1318 } |
| 1316 } | 1319 } |
| 1317 | 1320 |
| 1318 void LayerImpl::DidBecomeActive() { | 1321 void LayerImpl::DidBecomeActive() { |
| 1319 if (layer_tree_impl_->settings().scrollbar_animator == | 1322 if (layer_tree_impl_->settings().scrollbar_animator == |
| 1320 LayerTreeSettings::NoAnimator) { | 1323 LayerTreeSettings::NoAnimator) { |
| 1321 return; | 1324 return; |
| 1322 } | 1325 } |
| 1323 | 1326 |
| 1324 bool need_scrollbar_animation_controller = scrollable() && scrollbars_; | 1327 bool need_scrollbar_animation_controller = scrollable() && scrollbars_; |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1548 } | 1551 } |
| 1549 | 1552 |
| 1550 void LayerImpl::NotifyAnimationFinished( | 1553 void LayerImpl::NotifyAnimationFinished( |
| 1551 base::TimeTicks monotonic_time, | 1554 base::TimeTicks monotonic_time, |
| 1552 Animation::TargetProperty target_property) { | 1555 Animation::TargetProperty target_property) { |
| 1553 if (target_property == Animation::ScrollOffset) | 1556 if (target_property == Animation::ScrollOffset) |
| 1554 layer_tree_impl_->InputScrollAnimationFinished(); | 1557 layer_tree_impl_->InputScrollAnimationFinished(); |
| 1555 } | 1558 } |
| 1556 | 1559 |
| 1557 } // namespace cc | 1560 } // namespace cc |
| OLD | NEW |