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 2604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2615 if (settings_.report_overscroll_only_for_scrollable_axes) { | 2615 if (settings_.report_overscroll_only_for_scrollable_axes) { |
2616 if (std::abs(active_tree_->TotalMaxScrollOffset().x()) <= kEpsilon || | 2616 if (std::abs(active_tree_->TotalMaxScrollOffset().x()) <= kEpsilon || |
2617 !layer_impl->user_scrollable_horizontal()) | 2617 !layer_impl->user_scrollable_horizontal()) |
2618 unused_root_delta.set_x(0.0f); | 2618 unused_root_delta.set_x(0.0f); |
2619 if (std::abs(active_tree_->TotalMaxScrollOffset().y()) <= kEpsilon || | 2619 if (std::abs(active_tree_->TotalMaxScrollOffset().y()) <= kEpsilon || |
2620 !layer_impl->user_scrollable_vertical()) | 2620 !layer_impl->user_scrollable_vertical()) |
2621 unused_root_delta.set_y(0.0f); | 2621 unused_root_delta.set_y(0.0f); |
2622 } | 2622 } |
2623 } | 2623 } |
2624 | 2624 |
2625 // Scrolls should bubble perfectly between the outer and inner viewports. | |
2626 bool allow_unrestricted_bubbling_for_current_layer = | |
2627 layer_impl == OuterViewportScrollLayer(); | |
2628 bool allow_bubbling_for_current_layer = | |
2629 allow_unrestricted_bubbling_for_current_layer || should_bubble_scrolls_; | |
2630 | |
2625 // If the layer wasn't able to move, try the next one in the hierarchy. | 2631 // If the layer wasn't able to move, try the next one in the hierarchy. |
2626 bool did_move_layer_x = std::abs(applied_delta.x()) > kEpsilon; | 2632 bool did_move_layer_x = std::abs(applied_delta.x()) > kEpsilon; |
2627 bool did_move_layer_y = std::abs(applied_delta.y()) > kEpsilon; | 2633 bool did_move_layer_y = std::abs(applied_delta.y()) > kEpsilon; |
2628 did_scroll_x |= did_move_layer_x; | 2634 did_scroll_x |= did_move_layer_x; |
2629 did_scroll_y |= did_move_layer_y; | 2635 did_scroll_y |= did_move_layer_y; |
2630 if (!did_move_layer_x && !did_move_layer_y) { | 2636 if (!did_move_layer_x && !did_move_layer_y) { |
2631 // Scrolls should always bubble between the outer and inner viewports | 2637 if (allow_bubbling_for_current_layer || !did_lock_scrolling_layer_) |
2632 if (should_bubble_scrolls_ || !did_lock_scrolling_layer_ || | |
2633 layer_impl == OuterViewportScrollLayer()) | |
2634 continue; | 2638 continue; |
2635 else | 2639 else |
2636 break; | 2640 break; |
2637 } | 2641 } |
2638 | 2642 |
2639 did_lock_scrolling_layer_ = true; | 2643 did_lock_scrolling_layer_ = true; |
2640 if (!should_bubble_scrolls_) { | 2644 if (!allow_bubbling_for_current_layer) { |
2641 active_tree_->SetCurrentlyScrollingLayer(layer_impl); | 2645 active_tree_->SetCurrentlyScrollingLayer(layer_impl); |
2642 break; | 2646 break; |
2643 } | 2647 } |
2644 | 2648 |
2645 // If the applied delta is within 45 degrees of the input delta, bail out to | 2649 if (allow_unrestricted_bubbling_for_current_layer) { |
2646 // make it easier to scroll just one layer in one direction without | 2650 pending_delta -= applied_delta; |
2647 // affecting any of its parents. | 2651 } else { |
2648 float angle_threshold = 45; | 2652 // If the applied delta is within 45 degrees of the input delta, bail out |
2649 if (MathUtil::SmallestAngleBetweenVectors( | 2653 // to make it easier to scroll just one layer in one direction without |
2650 applied_delta, pending_delta) < angle_threshold) { | 2654 // affecting any of its parents. |
2651 pending_delta = gfx::Vector2dF(); | 2655 float angle_threshold = 45; |
2652 break; | 2656 if (MathUtil::SmallestAngleBetweenVectors(applied_delta, pending_delta) < |
2657 angle_threshold) { | |
2658 pending_delta = gfx::Vector2dF(); | |
bokan
2014/11/19 00:58:33
I know you didn't write this, but do we need to cl
jdduke (slow)
2014/11/19 16:20:14
I'm guessing there was some trailing code that use
| |
2659 break; | |
2660 } | |
2661 | |
2662 // Allow further movement only on an axis perpendicular to the direction | |
2663 // in which the layer moved. | |
2664 gfx::Vector2dF perpendicular_axis(-applied_delta.y(), applied_delta.x()); | |
2665 pending_delta = | |
2666 MathUtil::ProjectVector(pending_delta, perpendicular_axis); | |
2653 } | 2667 } |
2654 | 2668 |
2655 // Allow further movement only on an axis perpendicular to the direction in | |
2656 // which the layer moved. | |
2657 gfx::Vector2dF perpendicular_axis(-applied_delta.y(), applied_delta.x()); | |
2658 pending_delta = MathUtil::ProjectVector(pending_delta, perpendicular_axis); | |
2659 | |
2660 if (gfx::ToRoundedVector2d(pending_delta).IsZero()) | 2669 if (gfx::ToRoundedVector2d(pending_delta).IsZero()) |
2661 break; | 2670 break; |
2662 } | 2671 } |
2663 | 2672 |
2664 bool did_scroll_content = did_scroll_x || did_scroll_y; | 2673 bool did_scroll_content = did_scroll_x || did_scroll_y; |
2665 if (did_scroll_content) { | 2674 if (did_scroll_content) { |
2666 // If we are scrolling with an active scroll handler, forward latency | 2675 // If we are scrolling with an active scroll handler, forward latency |
2667 // tracking information to the main thread so the delay introduced by the | 2676 // tracking information to the main thread so the delay introduced by the |
2668 // handler is accounted for. | 2677 // handler is accounted for. |
2669 if (scroll_affects_scroll_handler()) | 2678 if (scroll_affects_scroll_handler()) |
(...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3431 } | 3440 } |
3432 | 3441 |
3433 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { | 3442 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { |
3434 std::vector<PictureLayerImpl*>::iterator it = | 3443 std::vector<PictureLayerImpl*>::iterator it = |
3435 std::find(picture_layers_.begin(), picture_layers_.end(), layer); | 3444 std::find(picture_layers_.begin(), picture_layers_.end(), layer); |
3436 DCHECK(it != picture_layers_.end()); | 3445 DCHECK(it != picture_layers_.end()); |
3437 picture_layers_.erase(it); | 3446 picture_layers_.erase(it); |
3438 } | 3447 } |
3439 | 3448 |
3440 } // namespace cc | 3449 } // namespace cc |
OLD | NEW |