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_host_impl.h" | 5 #include "cc/trees/layer_tree_host_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 2663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2674 did_scroll_x |= did_move_layer_x; | 2674 did_scroll_x |= did_move_layer_x; |
2675 did_scroll_y |= did_move_layer_y; | 2675 did_scroll_y |= did_move_layer_y; |
2676 if (!did_move_layer_x && !did_move_layer_y) { | 2676 if (!did_move_layer_x && !did_move_layer_y) { |
2677 if (allow_bubbling_for_current_layer || !did_lock_scrolling_layer_) | 2677 if (allow_bubbling_for_current_layer || !did_lock_scrolling_layer_) |
2678 continue; | 2678 continue; |
2679 else | 2679 else |
2680 break; | 2680 break; |
2681 } | 2681 } |
2682 | 2682 |
2683 did_lock_scrolling_layer_ = true; | 2683 did_lock_scrolling_layer_ = true; |
2684 if (!allow_bubbling_for_current_layer) { | 2684 |
| 2685 // When scrolls are allowed to bubble, it's important that the original |
| 2686 // scrolling layer be preserved. This ensures that, after a scroll bubbles, |
| 2687 // the user can reverse scroll directions and immediately resume scrolling |
| 2688 // the original layer that scrolled. |
| 2689 if (!should_bubble_scrolls_) |
2685 active_tree_->SetCurrentlyScrollingLayer(layer_impl); | 2690 active_tree_->SetCurrentlyScrollingLayer(layer_impl); |
| 2691 |
| 2692 if (!allow_bubbling_for_current_layer) |
2686 break; | 2693 break; |
2687 } | |
2688 | 2694 |
2689 if (allow_unrestricted_bubbling_for_current_layer) { | 2695 if (allow_unrestricted_bubbling_for_current_layer) { |
2690 pending_delta -= applied_delta; | 2696 pending_delta -= applied_delta; |
2691 } else { | 2697 } else { |
2692 // If the applied delta is within 45 degrees of the input delta, bail out | 2698 // If the applied delta is within 45 degrees of the input delta, bail out |
2693 // to make it easier to scroll just one layer in one direction without | 2699 // to make it easier to scroll just one layer in one direction without |
2694 // affecting any of its parents. | 2700 // affecting any of its parents. |
2695 float angle_threshold = 45; | 2701 float angle_threshold = 45; |
2696 if (MathUtil::SmallestAngleBetweenVectors(applied_delta, pending_delta) < | 2702 if (MathUtil::SmallestAngleBetweenVectors(applied_delta, pending_delta) < |
2697 angle_threshold) { | 2703 angle_threshold) { |
(...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3477 } | 3483 } |
3478 | 3484 |
3479 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { | 3485 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { |
3480 std::vector<PictureLayerImpl*>::iterator it = | 3486 std::vector<PictureLayerImpl*>::iterator it = |
3481 std::find(picture_layers_.begin(), picture_layers_.end(), layer); | 3487 std::find(picture_layers_.begin(), picture_layers_.end(), layer); |
3482 DCHECK(it != picture_layers_.end()); | 3488 DCHECK(it != picture_layers_.end()); |
3483 picture_layers_.erase(it); | 3489 picture_layers_.erase(it); |
3484 } | 3490 } |
3485 | 3491 |
3486 } // namespace cc | 3492 } // namespace cc |
OLD | NEW |