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 1257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1268 } | 1268 } |
| 1269 // TODO(wjmaclean) Once we move to a model where the two-viewport model is | 1269 // TODO(wjmaclean) Once we move to a model where the two-viewport model is |
| 1270 // turned on in all builds, remove the next two lines. For now however, the | 1270 // turned on in all builds, remove the next two lines. For now however, the |
| 1271 // page scale layer may coincide with the clip layer, and so this is | 1271 // page scale layer may coincide with the clip layer, and so this is |
| 1272 // necessary. | 1272 // necessary. |
| 1273 if (page_scale_layer == scrollbar_clip_layer) { | 1273 if (page_scale_layer == scrollbar_clip_layer) { |
| 1274 scroll_rect.Scale(layer_tree_impl()->total_page_scale_factor()); | 1274 scroll_rect.Scale(layer_tree_impl()->total_page_scale_factor()); |
| 1275 current_offset.Scale(layer_tree_impl()->total_page_scale_factor()); | 1275 current_offset.Scale(layer_tree_impl()->total_page_scale_factor()); |
| 1276 } | 1276 } |
| 1277 | 1277 |
| 1278 scrollbar_layer->SetVerticalAdjust(scrollbar_clip_layer->bounds_delta().y()); | 1278 bool scrollbar_needs_animation = false; |
| 1279 scrollbar_needs_animation = scrollbar_layer->SetVerticalAdjust( | |
| 1280 scrollbar_clip_layer->bounds_delta().y()); | |
| 1279 if (scrollbar_layer->orientation() == HORIZONTAL) { | 1281 if (scrollbar_layer->orientation() == HORIZONTAL) { |
| 1280 float visible_ratio = clip_rect.width() / scroll_rect.width(); | 1282 float visible_ratio = clip_rect.width() / scroll_rect.width(); |
| 1281 scrollbar_layer->SetCurrentPos(current_offset.x()); | 1283 scrollbar_needs_animation = |
|
aelias_OOO_until_Jul13
2014/09/22 06:53:01
This will reset to false if any later line is fals
MuVen
2014/09/22 14:02:27
True, MissRead the logic :( Done.
| |
| 1282 scrollbar_layer->SetMaximum(scroll_rect.width() - clip_rect.width()); | 1284 scrollbar_layer->SetCurrentPos(current_offset.x()); |
| 1283 scrollbar_layer->SetVisibleToTotalLengthRatio(visible_ratio); | 1285 scrollbar_needs_animation = |
| 1286 scrollbar_layer->SetMaximum(scroll_rect.width() - clip_rect.width()); | |
| 1287 scrollbar_needs_animation = | |
| 1288 scrollbar_layer->SetVisibleToTotalLengthRatio(visible_ratio); | |
| 1284 } else { | 1289 } else { |
| 1285 float visible_ratio = clip_rect.height() / scroll_rect.height(); | 1290 float visible_ratio = clip_rect.height() / scroll_rect.height(); |
| 1286 scrollbar_layer->SetCurrentPos(current_offset.y()); | 1291 scrollbar_needs_animation = |
| 1287 scrollbar_layer->SetMaximum(scroll_rect.height() - clip_rect.height()); | 1292 scrollbar_layer->SetCurrentPos(current_offset.y()); |
| 1288 scrollbar_layer->SetVisibleToTotalLengthRatio(visible_ratio); | 1293 scrollbar_needs_animation = |
| 1294 scrollbar_layer->SetMaximum(scroll_rect.height() - clip_rect.height()); | |
| 1295 scrollbar_needs_animation = | |
| 1296 scrollbar_layer->SetVisibleToTotalLengthRatio(visible_ratio); | |
| 1289 } | 1297 } |
| 1290 | 1298 |
| 1291 layer_tree_impl()->set_needs_update_draw_properties(); | 1299 layer_tree_impl()->set_needs_update_draw_properties(); |
| 1292 // TODO(wjmaclean) The scrollbar animator for the pinch-zoom scrollbars should | 1300 // TODO(wjmaclean) The scrollbar animator for the pinch-zoom scrollbars should |
| 1293 // activate for every scroll on the main frame, not just the scrolls that move | 1301 // activate for every scroll on the main frame, not just the scrolls that move |
| 1294 // the pinch virtual viewport (i.e. trigger from either inner or outer | 1302 // the pinch virtual viewport (i.e. trigger from either inner or outer |
| 1295 // viewport). | 1303 // viewport). |
| 1296 if (scrollbar_animation_controller_) { | 1304 if (scrollbar_animation_controller_ && scrollbar_needs_animation) { |
| 1297 // When both non-overlay and overlay scrollbars are both present, don't | 1305 // When both non-overlay and overlay scrollbars are both present, don't |
| 1298 // animate the overlay scrollbars when page scale factor is at the min. | 1306 // animate the overlay scrollbars when page scale factor is at the min. |
| 1299 // Non-overlay scrollbars also shouldn't trigger animations. | 1307 // Non-overlay scrollbars also shouldn't trigger animations. |
| 1300 bool is_animatable_scrollbar = | 1308 bool is_animatable_scrollbar = |
| 1301 scrollbar_layer->is_overlay_scrollbar() && | 1309 scrollbar_layer->is_overlay_scrollbar() && |
| 1302 ((layer_tree_impl()->total_page_scale_factor() > | 1310 ((layer_tree_impl()->total_page_scale_factor() > |
| 1303 layer_tree_impl()->min_page_scale_factor()) || | 1311 layer_tree_impl()->min_page_scale_factor()) || |
| 1304 !layer_tree_impl()->settings().use_pinch_zoom_scrollbars); | 1312 !layer_tree_impl()->settings().use_pinch_zoom_scrollbars); |
| 1305 if (is_animatable_scrollbar) | 1313 if (is_animatable_scrollbar) |
| 1306 scrollbar_animation_controller_->DidScrollUpdate(); | 1314 scrollbar_animation_controller_->DidScrollUpdate(); |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1538 } | 1546 } |
| 1539 | 1547 |
| 1540 void LayerImpl::NotifyAnimationFinished( | 1548 void LayerImpl::NotifyAnimationFinished( |
| 1541 base::TimeTicks monotonic_time, | 1549 base::TimeTicks monotonic_time, |
| 1542 Animation::TargetProperty target_property) { | 1550 Animation::TargetProperty target_property) { |
| 1543 if (target_property == Animation::ScrollOffset) | 1551 if (target_property == Animation::ScrollOffset) |
| 1544 layer_tree_impl_->InputScrollAnimationFinished(); | 1552 layer_tree_impl_->InputScrollAnimationFinished(); |
| 1545 } | 1553 } |
| 1546 | 1554 |
| 1547 } // namespace cc | 1555 } // namespace cc |
| OLD | NEW |