Chromium Code Reviews| 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 if (!did_lock_scrolling_layer_) { |
| 2640 if (!should_bubble_scrolls_) { | 2644 did_lock_scrolling_layer_ = true; |
|
jdduke (slow)
2014/11/18 21:29:55
Hmm, this is wrong and needs some work.
jdduke (slow)
2014/11/18 21:34:15
Restored the old logic here, not really related to
| |
| 2641 active_tree_->SetCurrentlyScrollingLayer(layer_impl); | 2645 active_tree_->SetCurrentlyScrollingLayer(layer_impl); |
| 2642 break; | |
| 2643 } | 2646 } |
| 2644 | 2647 |
| 2645 // If the applied delta is within 45 degrees of the input delta, bail out to | 2648 if (!allow_bubbling_for_current_layer) |
| 2646 // make it easier to scroll just one layer in one direction without | |
| 2647 // affecting any of its parents. | |
| 2648 float angle_threshold = 45; | |
| 2649 if (MathUtil::SmallestAngleBetweenVectors( | |
| 2650 applied_delta, pending_delta) < angle_threshold) { | |
| 2651 pending_delta = gfx::Vector2dF(); | |
| 2652 break; | 2649 break; |
| 2650 | |
| 2651 if (allow_unrestricted_bubbling_for_current_layer) { | |
| 2652 pending_delta -= applied_delta; | |
| 2653 } else { | |
| 2654 // If the applied delta is within 45 degrees of the input delta, bail out | |
| 2655 // to make it easier to scroll just one layer in one direction without | |
| 2656 // affecting any of its parents. | |
| 2657 float angle_threshold = 45; | |
| 2658 if (MathUtil::SmallestAngleBetweenVectors(applied_delta, pending_delta) < | |
| 2659 angle_threshold) { | |
| 2660 pending_delta = gfx::Vector2dF(); | |
| 2661 break; | |
| 2662 } | |
| 2663 | |
| 2664 // Allow further movement only on an axis perpendicular to the direction | |
| 2665 // in which the layer moved. | |
| 2666 gfx::Vector2dF perpendicular_axis(-applied_delta.y(), applied_delta.x()); | |
| 2667 pending_delta = | |
| 2668 MathUtil::ProjectVector(pending_delta, perpendicular_axis); | |
| 2653 } | 2669 } |
| 2654 | 2670 |
| 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()) | 2671 if (gfx::ToRoundedVector2d(pending_delta).IsZero()) |
| 2661 break; | 2672 break; |
| 2662 } | 2673 } |
| 2663 | 2674 |
| 2664 bool did_scroll_content = did_scroll_x || did_scroll_y; | 2675 bool did_scroll_content = did_scroll_x || did_scroll_y; |
| 2665 if (did_scroll_content) { | 2676 if (did_scroll_content) { |
| 2666 // If we are scrolling with an active scroll handler, forward latency | 2677 // If we are scrolling with an active scroll handler, forward latency |
| 2667 // tracking information to the main thread so the delay introduced by the | 2678 // tracking information to the main thread so the delay introduced by the |
| 2668 // handler is accounted for. | 2679 // handler is accounted for. |
| 2669 if (scroll_affects_scroll_handler()) | 2680 if (scroll_affects_scroll_handler()) |
| (...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3431 } | 3442 } |
| 3432 | 3443 |
| 3433 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { | 3444 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { |
| 3434 std::vector<PictureLayerImpl*>::iterator it = | 3445 std::vector<PictureLayerImpl*>::iterator it = |
| 3435 std::find(picture_layers_.begin(), picture_layers_.end(), layer); | 3446 std::find(picture_layers_.begin(), picture_layers_.end(), layer); |
| 3436 DCHECK(it != picture_layers_.end()); | 3447 DCHECK(it != picture_layers_.end()); |
| 3437 picture_layers_.erase(it); | 3448 picture_layers_.erase(it); |
| 3438 } | 3449 } |
| 3439 | 3450 |
| 3440 } // namespace cc | 3451 } // namespace cc |
| OLD | NEW |