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 float vertical_adjust = scrollbar_clip_layer->bounds_delta().y(); | |
bokan
2014/09/15 17:29:55
I think this should only affect the vertical scrol
| |
1279 float current_pos = (scrollbar_layer->orientation() == HORIZONTAL) | |
weiliangc
2014/09/15 17:14:37
nit: Prefer one if statement than three ternary op
bokan
2014/09/15 17:29:55
Agreed.
MuVen
2014/09/15 17:48:42
Done.
| |
1280 ? current_offset.x() | |
1281 : current_offset.y(); | |
1282 int maximum = (scrollbar_layer->orientation() == HORIZONTAL) | |
1283 ? (scroll_rect.width() - clip_rect.width()) | |
1284 : (scroll_rect.height() - clip_rect.height()); | |
1285 float visible_ratio = (scrollbar_layer->orientation() == HORIZONTAL) | |
bokan
2014/09/15 17:29:55
Do we need this? I think if the maximum changes th
MuVen
2014/09/15 17:48:42
if maximum changes, visible ration also changes as
| |
1286 ? (clip_rect.width() / scroll_rect.width()) | |
1287 : (clip_rect.height() / scroll_rect.height()); | |
1288 | |
1289 if (!scrollbar_layer->ScrollbarNeedsUpdate( | |
weiliangc
2014/09/15 17:14:37
As per comment in scrollbar_layer_impl_base file,
MuVen
2014/09/15 17:48:41
Yes i agree weiliangc, Setter functions are alread
| |
1290 vertical_adjust, current_pos, maximum, visible_ratio)) | |
1291 return; | |
1292 | |
1278 scrollbar_layer->SetVerticalAdjust(scrollbar_clip_layer->bounds_delta().y()); | 1293 scrollbar_layer->SetVerticalAdjust(scrollbar_clip_layer->bounds_delta().y()); |
1279 if (scrollbar_layer->orientation() == HORIZONTAL) { | 1294 scrollbar_layer->SetCurrentPos(current_pos); |
1280 float visible_ratio = clip_rect.width() / scroll_rect.width(); | 1295 scrollbar_layer->SetMaximum(maximum); |
1281 scrollbar_layer->SetCurrentPos(current_offset.x()); | 1296 scrollbar_layer->SetVisibleToTotalLengthRatio(visible_ratio); |
1282 scrollbar_layer->SetMaximum(scroll_rect.width() - clip_rect.width()); | |
1283 scrollbar_layer->SetVisibleToTotalLengthRatio(visible_ratio); | |
1284 } else { | |
1285 float visible_ratio = clip_rect.height() / scroll_rect.height(); | |
1286 scrollbar_layer->SetCurrentPos(current_offset.y()); | |
1287 scrollbar_layer->SetMaximum(scroll_rect.height() - clip_rect.height()); | |
1288 scrollbar_layer->SetVisibleToTotalLengthRatio(visible_ratio); | |
1289 } | |
1290 | 1297 |
1291 layer_tree_impl()->set_needs_update_draw_properties(); | 1298 layer_tree_impl()->set_needs_update_draw_properties(); |
weiliangc
2014/09/15 17:14:37
The four Setter function seems to call this line w
bokan
2014/09/15 17:29:55
I think his idea is that we need to skip the DidSc
MuVen
2014/09/15 17:48:42
Yes bokan, Main idea is to skip DidScrollUpdate ca
MuVen
2014/09/15 17:48:42
Done.
MuVen
2014/09/15 17:57:07
or may be can i use LayerPropertyChanged() ??
danakj
2014/09/15 18:04:56
That's not the same thing. When something changes
| |
1292 // TODO(wjmaclean) The scrollbar animator for the pinch-zoom scrollbars should | 1299 // 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 | 1300 // 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 | 1301 // the pinch virtual viewport (i.e. trigger from either inner or outer |
1295 // viewport). | 1302 // viewport). |
1296 if (scrollbar_animation_controller_) { | 1303 if (scrollbar_animation_controller_) { |
weiliangc
2014/09/15 17:14:37
I am not too familiar with pinch-zoom scrollbar be
| |
1297 // When both non-overlay and overlay scrollbars are both present, don't | 1304 // 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. | 1305 // animate the overlay scrollbars when page scale factor is at the min. |
1299 // Non-overlay scrollbars also shouldn't trigger animations. | 1306 // Non-overlay scrollbars also shouldn't trigger animations. |
1300 bool is_animatable_scrollbar = | 1307 bool is_animatable_scrollbar = |
1301 scrollbar_layer->is_overlay_scrollbar() && | 1308 scrollbar_layer->is_overlay_scrollbar() && |
1302 ((layer_tree_impl()->total_page_scale_factor() > | 1309 ((layer_tree_impl()->total_page_scale_factor() > |
1303 layer_tree_impl()->min_page_scale_factor()) || | 1310 layer_tree_impl()->min_page_scale_factor()) || |
1304 !layer_tree_impl()->settings().use_pinch_zoom_scrollbars); | 1311 !layer_tree_impl()->settings().use_pinch_zoom_scrollbars); |
1305 if (is_animatable_scrollbar) | 1312 if (is_animatable_scrollbar) |
1306 scrollbar_animation_controller_->DidScrollUpdate(); | 1313 scrollbar_animation_controller_->DidScrollUpdate(); |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1540 } | 1547 } |
1541 | 1548 |
1542 void LayerImpl::NotifyAnimationFinished( | 1549 void LayerImpl::NotifyAnimationFinished( |
1543 base::TimeTicks monotonic_time, | 1550 base::TimeTicks monotonic_time, |
1544 Animation::TargetProperty target_property) { | 1551 Animation::TargetProperty target_property) { |
1545 if (target_property == Animation::ScrollOffset) | 1552 if (target_property == Animation::ScrollOffset) |
1546 layer_tree_impl_->InputScrollAnimationFinished(); | 1553 layer_tree_impl_->InputScrollAnimationFinished(); |
1547 } | 1554 } |
1548 | 1555 |
1549 } // namespace cc | 1556 } // namespace cc |
OLD | NEW |