Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(837)

Side by Side Diff: cc/trees/layer_tree_host_impl.cc

Issue 2720183003: Track the currently scrolling ScrollNode instead of the scrolling layer (Closed)
Patch Set: Rebase Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 bool scroll_on_main_thread = (scroll_thread == MAIN_THREAD); 147 bool scroll_on_main_thread = (scroll_thread == MAIN_THREAD);
148 if (IsWheelBasedScroll(type)) { 148 if (IsWheelBasedScroll(type)) {
149 UMA_HISTOGRAM_BOOLEAN("Renderer4.CompositorWheelScrollUpdateThread", 149 UMA_HISTOGRAM_BOOLEAN("Renderer4.CompositorWheelScrollUpdateThread",
150 scroll_on_main_thread); 150 scroll_on_main_thread);
151 } else { 151 } else {
152 UMA_HISTOGRAM_BOOLEAN("Renderer4.CompositorTouchScrollUpdateThread", 152 UMA_HISTOGRAM_BOOLEAN("Renderer4.CompositorTouchScrollUpdateThread",
153 scroll_on_main_thread); 153 scroll_on_main_thread);
154 } 154 }
155 } 155 }
156 156
157 // Return true if scrollable node for 'ancestor' is the same as 'child' or an
158 // ancestor along the scroll tree.
159 bool IsScrolledBy(LayerImpl* child, LayerImpl* ancestor) {
160 DCHECK(ancestor && ancestor->scrollable());
161 if (!child)
162 return false;
163
164 auto* property_trees = child->layer_tree_impl()->property_trees();
165 ScrollTree& scroll_tree = property_trees->scroll_tree;
166 for (ScrollNode* scroll_node = scroll_tree.Node(child->scroll_tree_index());
167 scroll_node; scroll_node = scroll_tree.parent(scroll_node)) {
168 if (scroll_node->id == ancestor->scroll_tree_index())
169 return true;
170 }
171 return false;
172 }
173
174 } // namespace 157 } // namespace
175 158
176 DEFINE_SCOPED_UMA_HISTOGRAM_TIMER(PendingTreeDurationHistogramTimer, 159 DEFINE_SCOPED_UMA_HISTOGRAM_TIMER(PendingTreeDurationHistogramTimer,
177 "Scheduling.%s.PendingTreeDuration"); 160 "Scheduling.%s.PendingTreeDuration");
178 161
179 LayerTreeHostImpl::FrameData::FrameData() 162 LayerTreeHostImpl::FrameData::FrameData()
180 : render_surface_layer_list(nullptr), 163 : render_surface_layer_list(nullptr),
181 has_no_damage(false), 164 has_no_damage(false),
182 may_contain_video(false) {} 165 may_contain_video(false) {}
183 166
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 // Must be initialized after is_synchronous_single_threaded_ and 215 // Must be initialized after is_synchronous_single_threaded_ and
233 // task_runner_provider_. 216 // task_runner_provider_.
234 tile_manager_(this, 217 tile_manager_(this,
235 GetTaskRunner(), 218 GetTaskRunner(),
236 std::move(image_worker_task_runner), 219 std::move(image_worker_task_runner),
237 is_synchronous_single_threaded_ 220 is_synchronous_single_threaded_
238 ? std::numeric_limits<size_t>::max() 221 ? std::numeric_limits<size_t>::max()
239 : settings.scheduled_raster_task_limit, 222 : settings.scheduled_raster_task_limit,
240 settings.ToTileManagerSettings()), 223 settings.ToTileManagerSettings()),
241 pinch_gesture_active_(false), 224 pinch_gesture_active_(false),
242 pinch_gesture_end_should_clear_scrolling_layer_(false), 225 pinch_gesture_end_should_clear_scrolling_node_(false),
243 fps_counter_( 226 fps_counter_(
244 FrameRateCounter::Create(task_runner_provider_->HasImplThread())), 227 FrameRateCounter::Create(task_runner_provider_->HasImplThread())),
245 memory_history_(MemoryHistory::Create()), 228 memory_history_(MemoryHistory::Create()),
246 debug_rect_history_(DebugRectHistory::Create()), 229 debug_rect_history_(DebugRectHistory::Create()),
247 max_memory_needed_bytes_(0), 230 max_memory_needed_bytes_(0),
248 resourceless_software_draw_(false), 231 resourceless_software_draw_(false),
249 mutator_host_(std::move(mutator_host)), 232 mutator_host_(std::move(mutator_host)),
250 rendering_stats_instrumentation_(rendering_stats_instrumentation), 233 rendering_stats_instrumentation_(rendering_stats_instrumentation),
251 micro_benchmark_controller_(this), 234 micro_benchmark_controller_(this),
252 task_graph_runner_(task_graph_runner), 235 task_graph_runner_(task_graph_runner),
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 client_->RenewTreePriority(); 541 client_->RenewTreePriority();
559 } 542 }
560 543
561 void LayerTreeHostImpl::SetNeedsAnimateInput() { 544 void LayerTreeHostImpl::SetNeedsAnimateInput() {
562 DCHECK(!IsCurrentlyScrollingViewport() || 545 DCHECK(!IsCurrentlyScrollingViewport() ||
563 !settings_.ignore_root_layer_flings); 546 !settings_.ignore_root_layer_flings);
564 SetNeedsOneBeginImplFrame(); 547 SetNeedsOneBeginImplFrame();
565 } 548 }
566 549
567 bool LayerTreeHostImpl::IsCurrentlyScrollingViewport() const { 550 bool LayerTreeHostImpl::IsCurrentlyScrollingViewport() const {
568 LayerImpl* scrolling_layer = CurrentlyScrollingLayer(); 551 auto* node = CurrentlyScrollingNode();
569 if (!scrolling_layer) 552 if (!node)
570 return false; 553 return false;
571 DCHECK(viewport()); 554 DCHECK(viewport());
572 return scrolling_layer == viewport()->MainScrollLayer(); 555 return node->id == viewport()->MainScrollLayer()->scroll_tree_index();
573 } 556 }
574 557
575 bool LayerTreeHostImpl::IsCurrentlyScrollingLayerAt( 558 bool LayerTreeHostImpl::IsCurrentlyScrollingLayerAt(
576 const gfx::Point& viewport_point, 559 const gfx::Point& viewport_point,
577 InputHandler::ScrollInputType type) const { 560 InputHandler::ScrollInputType type) const {
578 LayerImpl* scrolling_layer_impl = CurrentlyScrollingLayer(); 561 auto* scrolling_node = CurrentlyScrollingNode();
579 if (!scrolling_layer_impl) 562 if (!scrolling_node)
580 return false; 563 return false;
581 564
582 gfx::PointF device_viewport_point = gfx::ScalePoint( 565 gfx::PointF device_viewport_point = gfx::ScalePoint(
583 gfx::PointF(viewport_point), active_tree_->device_scale_factor()); 566 gfx::PointF(viewport_point), active_tree_->device_scale_factor());
584 567
585 LayerImpl* layer_impl = 568 LayerImpl* layer_impl =
586 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point); 569 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point);
587 570
588 bool scroll_on_main_thread = false; 571 bool scroll_on_main_thread = false;
589 uint32_t main_thread_scrolling_reasons; 572 uint32_t main_thread_scrolling_reasons;
590 LayerImpl* test_layer_impl = FindScrollLayerForDeviceViewportPoint( 573 LayerImpl* test_layer_impl = FindScrollLayerForDeviceViewportPoint(
591 device_viewport_point, type, layer_impl, &scroll_on_main_thread, 574 device_viewport_point, type, layer_impl, &scroll_on_main_thread,
592 &main_thread_scrolling_reasons); 575 &main_thread_scrolling_reasons);
593 576
594 if (scroll_on_main_thread) 577 if (scroll_on_main_thread)
595 return false; 578 return false;
596 579
597 if (scrolling_layer_impl == test_layer_impl) 580 int test_scroll_tree_index = test_layer_impl->scroll_tree_index();
581 if (scrolling_node->id == test_scroll_tree_index)
598 return true; 582 return true;
599 583
600 // For active scrolling state treat the inner/outer viewports interchangeably. 584 // For active scrolling state treat the inner/outer viewports interchangeably.
601 if (scrolling_layer_impl == InnerViewportScrollLayer() || 585 if (scrolling_node->scrolls_inner_viewport ||
602 scrolling_layer_impl == OuterViewportScrollLayer()) { 586 scrolling_node->scrolls_outer_viewport) {
603 return test_layer_impl == viewport()->MainScrollLayer(); 587 return test_layer_impl == viewport()->MainScrollLayer();
604 } 588 }
605 589
606 return false; 590 return false;
607 } 591 }
608 592
609 EventListenerProperties LayerTreeHostImpl::GetEventListenerProperties( 593 EventListenerProperties LayerTreeHostImpl::GetEventListenerProperties(
610 EventListenerClass event_class) const { 594 EventListenerClass event_class) const {
611 return active_tree_->event_listener_properties(event_class); 595 return active_tree_->event_listener_properties(event_class);
612 } 596 }
613 597
598 // Return true if scrollable node for 'ancestor' is the same as 'child' or an
599 // ancestor along the scroll tree.
600 bool IsScrolledBy(LayerImpl* child, ScrollNode* ancestor) {
601 DCHECK(ancestor && ancestor->scrollable);
602 if (!child)
603 return false;
604
605 auto* property_trees = child->layer_tree_impl()->property_trees();
606 ScrollTree& scroll_tree = property_trees->scroll_tree;
607 for (ScrollNode* scroll_node = scroll_tree.Node(child->scroll_tree_index());
608 scroll_node; scroll_node = scroll_tree.parent(scroll_node)) {
609 if (scroll_node->id == ancestor->id)
610 return true;
611 }
612 return false;
613 }
614
614 InputHandler::TouchStartEventListenerType 615 InputHandler::TouchStartEventListenerType
615 LayerTreeHostImpl::EventListenerTypeForTouchStartAt( 616 LayerTreeHostImpl::EventListenerTypeForTouchStartAt(
616 const gfx::Point& viewport_point) { 617 const gfx::Point& viewport_point) {
617 gfx::PointF device_viewport_point = gfx::ScalePoint( 618 gfx::PointF device_viewport_point = gfx::ScalePoint(
618 gfx::PointF(viewport_point), active_tree_->device_scale_factor()); 619 gfx::PointF(viewport_point), active_tree_->device_scale_factor());
619 620
620 // Now determine if there are actually any handlers at that point. 621 // Now determine if there are actually any handlers at that point.
621 // TODO(rbyers): Consider also honoring touch-action (crbug.com/347272). 622 // TODO(rbyers): Consider also honoring touch-action (crbug.com/347272).
622 LayerImpl* layer_impl = 623 LayerImpl* layer_impl =
623 active_tree_->FindLayerThatIsHitByPointInTouchHandlerRegion( 624 active_tree_->FindLayerThatIsHitByPointInTouchHandlerRegion(
624 device_viewport_point); 625 device_viewport_point);
625 if (layer_impl == NULL) 626 if (layer_impl == NULL)
626 return InputHandler::TouchStartEventListenerType::NO_HANDLER; 627 return InputHandler::TouchStartEventListenerType::NO_HANDLER;
627 628
628 if (!CurrentlyScrollingLayer()) 629 if (!CurrentlyScrollingNode())
629 return InputHandler::TouchStartEventListenerType::HANDLER; 630 return InputHandler::TouchStartEventListenerType::HANDLER;
630 631
631 bool is_ancestor = 632 bool is_ancestor = IsScrolledBy(layer_impl, CurrentlyScrollingNode());
632 IsScrolledBy(layer_impl, active_tree_->CurrentlyScrollingLayer());
633 return is_ancestor ? InputHandler::TouchStartEventListenerType:: 633 return is_ancestor ? InputHandler::TouchStartEventListenerType::
634 HANDLER_ON_SCROLLING_LAYER 634 HANDLER_ON_SCROLLING_LAYER
635 : InputHandler::TouchStartEventListenerType::HANDLER; 635 : InputHandler::TouchStartEventListenerType::HANDLER;
636 } 636 }
637 637
638 std::unique_ptr<SwapPromiseMonitor> 638 std::unique_ptr<SwapPromiseMonitor>
639 LayerTreeHostImpl::CreateLatencyInfoSwapPromiseMonitor( 639 LayerTreeHostImpl::CreateLatencyInfoSwapPromiseMonitor(
640 ui::LatencyInfo* latency) { 640 ui::LatencyInfo* latency) {
641 return base::WrapUnique( 641 return base::WrapUnique(
642 new LatencyInfoSwapPromiseMonitor(latency, NULL, this)); 642 new LatencyInfoSwapPromiseMonitor(latency, NULL, this));
(...skipping 1311 matching lines...) Expand 10 before | Expand all | Expand 10 after
1954 } 1954 }
1955 1955
1956 LayerImpl* LayerTreeHostImpl::InnerViewportScrollLayer() const { 1956 LayerImpl* LayerTreeHostImpl::InnerViewportScrollLayer() const {
1957 return active_tree_->InnerViewportScrollLayer(); 1957 return active_tree_->InnerViewportScrollLayer();
1958 } 1958 }
1959 1959
1960 LayerImpl* LayerTreeHostImpl::OuterViewportScrollLayer() const { 1960 LayerImpl* LayerTreeHostImpl::OuterViewportScrollLayer() const {
1961 return active_tree_->OuterViewportScrollLayer(); 1961 return active_tree_->OuterViewportScrollLayer();
1962 } 1962 }
1963 1963
1964 LayerImpl* LayerTreeHostImpl::CurrentlyScrollingLayer() const { 1964 ScrollNode* LayerTreeHostImpl::CurrentlyScrollingNode() {
1965 return active_tree_->CurrentlyScrollingLayer(); 1965 return active_tree()->CurrentlyScrollingNode();
1966 }
1967
1968 const ScrollNode* LayerTreeHostImpl::CurrentlyScrollingNode() const {
1969 return active_tree()->CurrentlyScrollingNode();
1966 } 1970 }
1967 1971
1968 bool LayerTreeHostImpl::IsActivelyScrolling() const { 1972 bool LayerTreeHostImpl::IsActivelyScrolling() const {
1969 if (!CurrentlyScrollingLayer()) 1973 if (!CurrentlyScrollingNode())
1970 return false; 1974 return false;
1971 // On Android WebView root flings are controlled by the application, 1975 // On Android WebView root flings are controlled by the application,
1972 // so the compositor does not animate them and can't tell if they 1976 // so the compositor does not animate them and can't tell if they
1973 // are actually animating. So assume there are none. 1977 // are actually animating. So assume there are none.
1974 if (settings_.ignore_root_layer_flings && IsCurrentlyScrollingViewport()) 1978 if (settings_.ignore_root_layer_flings && IsCurrentlyScrollingViewport())
1975 return false; 1979 return false;
1976 return did_lock_scrolling_layer_; 1980 return did_lock_scrolling_layer_;
1977 } 1981 }
1978 1982
1979 void LayerTreeHostImpl::CreatePendingTree() { 1983 void LayerTreeHostImpl::CreatePendingTree() {
(...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after
2619 2623
2620 // TODO(pdr): Refactor this function to directly return |impl_scroll_node| 2624 // TODO(pdr): Refactor this function to directly return |impl_scroll_node|
2621 // instead of using ScrollNode's owning_layer_id to return a LayerImpl. 2625 // instead of using ScrollNode's owning_layer_id to return a LayerImpl.
2622 if (!impl_scroll_node) 2626 if (!impl_scroll_node)
2623 return nullptr; 2627 return nullptr;
2624 return active_tree_->LayerById(impl_scroll_node->owning_layer_id); 2628 return active_tree_->LayerById(impl_scroll_node->owning_layer_id);
2625 } 2629 }
2626 2630
2627 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollBeginImpl( 2631 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollBeginImpl(
2628 ScrollState* scroll_state, 2632 ScrollState* scroll_state,
2629 LayerImpl* scrolling_layer_impl, 2633 ScrollNode* scrolling_node,
2630 InputHandler::ScrollInputType type) { 2634 InputHandler::ScrollInputType type) {
2631 DCHECK(scroll_state); 2635 DCHECK(scroll_state);
2632 DCHECK(scroll_state->delta_x() == 0 && scroll_state->delta_y() == 0); 2636 DCHECK(scroll_state->delta_x() == 0 && scroll_state->delta_y() == 0);
2633 2637
2634 InputHandler::ScrollStatus scroll_status; 2638 InputHandler::ScrollStatus scroll_status;
2635 scroll_status.main_thread_scrolling_reasons = 2639 scroll_status.main_thread_scrolling_reasons =
2636 MainThreadScrollingReason::kNotScrollingOnMain; 2640 MainThreadScrollingReason::kNotScrollingOnMain;
2637 if (!scrolling_layer_impl) { 2641 if (!scrolling_node) {
2638 scroll_status.thread = SCROLL_IGNORED; 2642 scroll_status.thread = SCROLL_IGNORED;
2639 scroll_status.main_thread_scrolling_reasons = 2643 scroll_status.main_thread_scrolling_reasons =
2640 MainThreadScrollingReason::kNoScrollingLayer; 2644 MainThreadScrollingReason::kNoScrollingLayer;
2641 return scroll_status; 2645 return scroll_status;
2642 } 2646 }
2643 scroll_status.thread = SCROLL_ON_IMPL_THREAD; 2647 scroll_status.thread = SCROLL_ON_IMPL_THREAD;
2644 mutator_host_->ScrollAnimationAbort(); 2648 mutator_host_->ScrollAnimationAbort();
2645 2649
2646 browser_controls_offset_manager_->ScrollBegin(); 2650 browser_controls_offset_manager_->ScrollBegin();
2647 2651
2648 active_tree_->SetCurrentlyScrollingLayer(scrolling_layer_impl); 2652 active_tree_->SetCurrentlyScrollingNode(scrolling_node);
2649 // TODO(majidvp): get rid of wheel_scrolling_ and set is_direct_manipulation 2653 // TODO(majidvp): get rid of wheel_scrolling_ and set is_direct_manipulation
2650 // in input_handler_proxy instead. 2654 // in input_handler_proxy instead.
2651 wheel_scrolling_ = IsWheelBasedScroll(type); 2655 wheel_scrolling_ = IsWheelBasedScroll(type);
2652 scroll_state->set_is_direct_manipulation(!wheel_scrolling_); 2656 scroll_state->set_is_direct_manipulation(!wheel_scrolling_);
2653 // Invoke |DistributeScrollDelta| even with zero delta and velocity to ensure 2657 // Invoke |DistributeScrollDelta| even with zero delta and velocity to ensure
2654 // scroll customization callbacks are invoked. 2658 // scroll customization callbacks are invoked.
2655 DistributeScrollDelta(scroll_state); 2659 DistributeScrollDelta(scroll_state);
2656 2660
2657 client_->RenewTreePriority(); 2661 client_->RenewTreePriority();
2658 RecordCompositorSlowScrollMetric(type, CC_THREAD); 2662 RecordCompositorSlowScrollMetric(type, CC_THREAD);
2659 2663
2660 return scroll_status; 2664 return scroll_status;
2661 } 2665 }
2662 2666
2663 InputHandler::ScrollStatus LayerTreeHostImpl::RootScrollBegin( 2667 InputHandler::ScrollStatus LayerTreeHostImpl::RootScrollBegin(
2664 ScrollState* scroll_state, 2668 ScrollState* scroll_state,
2665 InputHandler::ScrollInputType type) { 2669 InputHandler::ScrollInputType type) {
2666 TRACE_EVENT0("cc", "LayerTreeHostImpl::RootScrollBegin"); 2670 TRACE_EVENT0("cc", "LayerTreeHostImpl::RootScrollBegin");
2667 2671
2668 ClearCurrentlyScrollingLayer(); 2672 ClearCurrentlyScrollingNode();
2669 2673
2670 DCHECK(viewport()); 2674 DCHECK(viewport());
2671 return ScrollBeginImpl(scroll_state, viewport()->MainScrollLayer(), type); 2675 ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree;
2676 ScrollNode* viewport_scroll_node =
2677 viewport()->MainScrollLayer()
ajuma 2017/02/28 22:59:37 Can MainScrollLayer() be null here? The code added
pdr. 2017/03/01 07:21:03 I confirmed that MainScrollLayer can be null in te
2678 ? scroll_tree.Node(viewport()->MainScrollLayer()->scroll_tree_index())
2679 : nullptr;
2680 return ScrollBeginImpl(scroll_state, viewport_scroll_node, type);
2672 } 2681 }
2673 2682
2674 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollBegin( 2683 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollBegin(
2675 ScrollState* scroll_state, 2684 ScrollState* scroll_state,
2676 InputHandler::ScrollInputType type) { 2685 InputHandler::ScrollInputType type) {
2677 ScrollStatus scroll_status; 2686 ScrollStatus scroll_status;
2678 scroll_status.main_thread_scrolling_reasons = 2687 scroll_status.main_thread_scrolling_reasons =
2679 MainThreadScrollingReason::kNotScrollingOnMain; 2688 MainThreadScrollingReason::kNotScrollingOnMain;
2680 TRACE_EVENT0("cc", "LayerTreeHostImpl::ScrollBegin"); 2689 TRACE_EVENT0("cc", "LayerTreeHostImpl::ScrollBegin");
2681 2690
2682 LayerImpl* scrolling_layer_impl = nullptr; 2691 ScrollNode* scrolling_node = nullptr;
2683 bool scroll_on_main_thread = false; 2692 bool scroll_on_main_thread = false;
2684 2693
2685 if (scroll_state->is_in_inertial_phase()) 2694 if (scroll_state->is_in_inertial_phase())
2686 scrolling_layer_impl = CurrentlyScrollingLayer(); 2695 scrolling_node = CurrentlyScrollingNode();
2687 2696
2688 if (!scrolling_layer_impl) { 2697 if (!scrolling_node) {
2689 ClearCurrentlyScrollingLayer(); 2698 ClearCurrentlyScrollingNode();
2690 2699
2691 gfx::Point viewport_point(scroll_state->position_x(), 2700 gfx::Point viewport_point(scroll_state->position_x(),
2692 scroll_state->position_y()); 2701 scroll_state->position_y());
2693 2702
2694 gfx::PointF device_viewport_point = gfx::ScalePoint( 2703 gfx::PointF device_viewport_point = gfx::ScalePoint(
2695 gfx::PointF(viewport_point), active_tree_->device_scale_factor()); 2704 gfx::PointF(viewport_point), active_tree_->device_scale_factor());
2696 LayerImpl* layer_impl = 2705 LayerImpl* layer_impl =
2697 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point); 2706 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point);
2698 2707
2699 if (layer_impl) { 2708 if (layer_impl) {
2700 if (!IsInitialScrollHitTestReliable(layer_impl, device_viewport_point)) { 2709 if (!IsInitialScrollHitTestReliable(layer_impl, device_viewport_point)) {
2701 scroll_status.thread = SCROLL_UNKNOWN; 2710 scroll_status.thread = SCROLL_UNKNOWN;
2702 scroll_status.main_thread_scrolling_reasons = 2711 scroll_status.main_thread_scrolling_reasons =
2703 MainThreadScrollingReason::kFailedHitTest; 2712 MainThreadScrollingReason::kFailedHitTest;
2704 return scroll_status; 2713 return scroll_status;
2705 } 2714 }
2706 } 2715 }
2707 2716
2708 scrolling_layer_impl = FindScrollLayerForDeviceViewportPoint( 2717 auto* scrolling_layer = FindScrollLayerForDeviceViewportPoint(
2709 device_viewport_point, type, layer_impl, &scroll_on_main_thread, 2718 device_viewport_point, type, layer_impl, &scroll_on_main_thread,
2710 &scroll_status.main_thread_scrolling_reasons); 2719 &scroll_status.main_thread_scrolling_reasons);
2720 ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree;
2721 scrolling_node =
2722 scrolling_layer ? scroll_tree.Node(scrolling_layer->scroll_tree_index())
2723 : nullptr;
2711 } 2724 }
2712 2725
2713 if (scroll_on_main_thread) { 2726 if (scroll_on_main_thread) {
2714 RecordCompositorSlowScrollMetric(type, MAIN_THREAD); 2727 RecordCompositorSlowScrollMetric(type, MAIN_THREAD);
2715 2728
2716 scroll_status.thread = SCROLL_ON_MAIN_THREAD; 2729 scroll_status.thread = SCROLL_ON_MAIN_THREAD;
2717 return scroll_status; 2730 return scroll_status;
2718 } else if (scrolling_layer_impl) { 2731 } else if (scrolling_node) {
2719 scroll_affects_scroll_handler_ = 2732 scroll_affects_scroll_handler_ = active_tree_->have_scroll_event_handlers();
2720 scrolling_layer_impl->layer_tree_impl()->have_scroll_event_handlers();
2721 } 2733 }
2722 2734
2723 return ScrollBeginImpl(scroll_state, scrolling_layer_impl, type); 2735 return ScrollBeginImpl(scroll_state, scrolling_node, type);
2724 } 2736 }
2725 2737
2726 // Some initial scroll tests are known to be unreliable and require falling 2738 // Some initial scroll tests are known to be unreliable and require falling
2727 // back to main thread scrolling. 2739 // back to main thread scrolling.
2728 bool LayerTreeHostImpl::IsInitialScrollHitTestReliable( 2740 bool LayerTreeHostImpl::IsInitialScrollHitTestReliable(
2729 LayerImpl* layer_impl, 2741 LayerImpl* layer_impl,
2730 const gfx::PointF& device_viewport_point) { 2742 const gfx::PointF& device_viewport_point) {
2731 LayerImpl* first_scrolling_layer_or_drawn_scrollbar = 2743 LayerImpl* first_scrolling_layer_or_drawn_scrollbar =
2732 active_tree_->FindFirstScrollingLayerOrDrawnScrollbarThatIsHitByPoint( 2744 active_tree_->FindFirstScrollingLayerOrDrawnScrollbarThatIsHitByPoint(
2733 device_viewport_point); 2745 device_viewport_point);
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
3144 scroll_state->set_scroll_chain_and_layer_tree(current_scroll_chain, 3156 scroll_state->set_scroll_chain_and_layer_tree(current_scroll_chain,
3145 active_tree()); 3157 active_tree());
3146 scroll_state->DistributeToScrollChainDescendant(); 3158 scroll_state->DistributeToScrollChainDescendant();
3147 } 3159 }
3148 3160
3149 InputHandlerScrollResult LayerTreeHostImpl::ScrollBy( 3161 InputHandlerScrollResult LayerTreeHostImpl::ScrollBy(
3150 ScrollState* scroll_state) { 3162 ScrollState* scroll_state) {
3151 DCHECK(scroll_state); 3163 DCHECK(scroll_state);
3152 3164
3153 TRACE_EVENT0("cc", "LayerTreeHostImpl::ScrollBy"); 3165 TRACE_EVENT0("cc", "LayerTreeHostImpl::ScrollBy");
3154 if (!CurrentlyScrollingLayer()) 3166 if (!CurrentlyScrollingNode())
3155 return InputHandlerScrollResult(); 3167 return InputHandlerScrollResult();
3156 3168
3157 float initial_top_controls_offset = 3169 float initial_top_controls_offset =
3158 browser_controls_offset_manager_->ControlsTopOffset(); 3170 browser_controls_offset_manager_->ControlsTopOffset();
3159 3171
3160 scroll_state->set_delta_consumed_for_scroll_sequence( 3172 scroll_state->set_delta_consumed_for_scroll_sequence(
3161 did_lock_scrolling_layer_); 3173 did_lock_scrolling_layer_);
3162 scroll_state->set_is_direct_manipulation(!wheel_scrolling_); 3174 scroll_state->set_is_direct_manipulation(!wheel_scrolling_);
3163 scroll_state->set_current_native_scrolling_node( 3175 scroll_state->set_current_native_scrolling_node(
3164 active_tree()->property_trees()->scroll_tree.CurrentlyScrollingNode()); 3176 active_tree()->property_trees()->scroll_tree.CurrentlyScrollingNode());
3165 3177
3166 DistributeScrollDelta(scroll_state); 3178 DistributeScrollDelta(scroll_state);
3167 3179
3168 active_tree_->SetCurrentlyScrollingLayer(active_tree_->LayerById( 3180 active_tree_->SetCurrentlyScrollingNode(
3169 scroll_state->current_native_scrolling_node()->owning_layer_id)); 3181 scroll_state->current_native_scrolling_node());
3170 did_lock_scrolling_layer_ = 3182 did_lock_scrolling_layer_ =
3171 scroll_state->delta_consumed_for_scroll_sequence(); 3183 scroll_state->delta_consumed_for_scroll_sequence();
3172 3184
3173 bool did_scroll_x = scroll_state->caused_scroll_x(); 3185 bool did_scroll_x = scroll_state->caused_scroll_x();
3174 bool did_scroll_y = scroll_state->caused_scroll_y(); 3186 bool did_scroll_y = scroll_state->caused_scroll_y();
3175 bool did_scroll_content = did_scroll_x || did_scroll_y; 3187 bool did_scroll_content = did_scroll_x || did_scroll_y;
3176 if (did_scroll_content) { 3188 if (did_scroll_content) {
3177 // If we are scrolling with an active scroll handler, forward latency 3189 // If we are scrolling with an active scroll handler, forward latency
3178 // tracking information to the main thread so the delay introduced by the 3190 // tracking information to the main thread so the delay introduced by the
3179 // handler is accounted for. 3191 // handler is accounted for.
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
3235 return; 3247 return;
3236 3248
3237 client_->SetNeedsCommitOnImplThread(); 3249 client_->SetNeedsCommitOnImplThread();
3238 // After applying the synchronous input handler's scroll offset, tell it what 3250 // After applying the synchronous input handler's scroll offset, tell it what
3239 // we ended up with. 3251 // we ended up with.
3240 UpdateRootLayerStateForSynchronousInputHandler(); 3252 UpdateRootLayerStateForSynchronousInputHandler();
3241 SetFullViewportDamage(); 3253 SetFullViewportDamage();
3242 SetNeedsRedraw(); 3254 SetNeedsRedraw();
3243 } 3255 }
3244 3256
3245 void LayerTreeHostImpl::ClearCurrentlyScrollingLayer() { 3257 void LayerTreeHostImpl::ClearCurrentlyScrollingNode() {
3246 active_tree_->ClearCurrentlyScrollingLayer(); 3258 active_tree_->ClearCurrentlyScrollingNode();
3247 did_lock_scrolling_layer_ = false; 3259 did_lock_scrolling_layer_ = false;
3248 scroll_affects_scroll_handler_ = false; 3260 scroll_affects_scroll_handler_ = false;
3249 accumulated_root_overscroll_ = gfx::Vector2dF(); 3261 accumulated_root_overscroll_ = gfx::Vector2dF();
3250 } 3262 }
3251 3263
3252 void LayerTreeHostImpl::ScrollEnd(ScrollState* scroll_state) { 3264 void LayerTreeHostImpl::ScrollEnd(ScrollState* scroll_state) {
3253 DCHECK(scroll_state); 3265 DCHECK(scroll_state);
3254 DCHECK(scroll_state->delta_x() == 0 && scroll_state->delta_y() == 0); 3266 DCHECK(scroll_state->delta_x() == 0 && scroll_state->delta_y() == 0);
3255 3267
3256 DistributeScrollDelta(scroll_state); 3268 DistributeScrollDelta(scroll_state);
3257 browser_controls_offset_manager_->ScrollEnd(); 3269 browser_controls_offset_manager_->ScrollEnd();
3258 ClearCurrentlyScrollingLayer(); 3270 ClearCurrentlyScrollingNode();
3259 } 3271 }
3260 3272
3261 InputHandler::ScrollStatus LayerTreeHostImpl::FlingScrollBegin() { 3273 InputHandler::ScrollStatus LayerTreeHostImpl::FlingScrollBegin() {
3262 InputHandler::ScrollStatus scroll_status; 3274 InputHandler::ScrollStatus scroll_status;
3263 scroll_status.main_thread_scrolling_reasons = 3275 scroll_status.main_thread_scrolling_reasons =
3264 MainThreadScrollingReason::kNotScrollingOnMain; 3276 MainThreadScrollingReason::kNotScrollingOnMain;
3265 if (!CurrentlyScrollingLayer()) { 3277 if (!CurrentlyScrollingNode()) {
3266 scroll_status.thread = SCROLL_IGNORED; 3278 scroll_status.thread = SCROLL_IGNORED;
3267 scroll_status.main_thread_scrolling_reasons = 3279 scroll_status.main_thread_scrolling_reasons =
3268 MainThreadScrollingReason::kNoScrollingLayer; 3280 MainThreadScrollingReason::kNoScrollingLayer;
3269 } else { 3281 } else {
3270 scroll_status.thread = SCROLL_ON_IMPL_THREAD; 3282 scroll_status.thread = SCROLL_ON_IMPL_THREAD;
3271 } 3283 }
3272 return scroll_status; 3284 return scroll_status;
3273 } 3285 }
3274 3286
3275 float LayerTreeHostImpl::DeviceSpaceDistanceToLayer( 3287 float LayerTreeHostImpl::DeviceSpaceDistanceToLayer(
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
3362 3374
3363 void LayerTreeHostImpl::MouseLeave() { 3375 void LayerTreeHostImpl::MouseLeave() {
3364 for (auto& pair : scrollbar_animation_controllers_) 3376 for (auto& pair : scrollbar_animation_controllers_)
3365 pair.second->DidMouseLeave(); 3377 pair.second->DidMouseLeave();
3366 scroll_layer_id_mouse_currently_over_ = Layer::INVALID_ID; 3378 scroll_layer_id_mouse_currently_over_ = Layer::INVALID_ID;
3367 } 3379 }
3368 3380
3369 void LayerTreeHostImpl::PinchGestureBegin() { 3381 void LayerTreeHostImpl::PinchGestureBegin() {
3370 pinch_gesture_active_ = true; 3382 pinch_gesture_active_ = true;
3371 client_->RenewTreePriority(); 3383 client_->RenewTreePriority();
3372 pinch_gesture_end_should_clear_scrolling_layer_ = !CurrentlyScrollingLayer(); 3384 pinch_gesture_end_should_clear_scrolling_node_ = !CurrentlyScrollingNode();
3373 active_tree_->SetCurrentlyScrollingLayer(viewport()->MainScrollLayer()); 3385
3386 DCHECK(viewport());
3387 ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree;
3388 ScrollNode* viewport_scroll_node =
3389 viewport()->MainScrollLayer()
3390 ? scroll_tree.Node(viewport()->MainScrollLayer()->scroll_tree_index())
3391 : nullptr;
3392 active_tree_->SetCurrentlyScrollingNode(viewport_scroll_node);
3374 browser_controls_offset_manager_->PinchBegin(); 3393 browser_controls_offset_manager_->PinchBegin();
3375 } 3394 }
3376 3395
3377 void LayerTreeHostImpl::PinchGestureUpdate(float magnify_delta, 3396 void LayerTreeHostImpl::PinchGestureUpdate(float magnify_delta,
3378 const gfx::Point& anchor) { 3397 const gfx::Point& anchor) {
3379 TRACE_EVENT0("cc", "LayerTreeHostImpl::PinchGestureUpdate"); 3398 TRACE_EVENT0("cc", "LayerTreeHostImpl::PinchGestureUpdate");
3380 if (!InnerViewportScrollLayer()) 3399 if (!InnerViewportScrollLayer())
3381 return; 3400 return;
3382 viewport()->PinchUpdate(magnify_delta, anchor); 3401 viewport()->PinchUpdate(magnify_delta, anchor);
3383 client_->SetNeedsCommitOnImplThread(); 3402 client_->SetNeedsCommitOnImplThread();
3384 SetNeedsRedraw(); 3403 SetNeedsRedraw();
3385 client_->RenewTreePriority(); 3404 client_->RenewTreePriority();
3386 // Pinching can change the root scroll offset, so inform the synchronous input 3405 // Pinching can change the root scroll offset, so inform the synchronous input
3387 // handler. 3406 // handler.
3388 UpdateRootLayerStateForSynchronousInputHandler(); 3407 UpdateRootLayerStateForSynchronousInputHandler();
3389 } 3408 }
3390 3409
3391 void LayerTreeHostImpl::PinchGestureEnd() { 3410 void LayerTreeHostImpl::PinchGestureEnd() {
3392 pinch_gesture_active_ = false; 3411 pinch_gesture_active_ = false;
3393 if (pinch_gesture_end_should_clear_scrolling_layer_) { 3412 if (pinch_gesture_end_should_clear_scrolling_node_) {
3394 pinch_gesture_end_should_clear_scrolling_layer_ = false; 3413 pinch_gesture_end_should_clear_scrolling_node_ = false;
3395 ClearCurrentlyScrollingLayer(); 3414 ClearCurrentlyScrollingNode();
3396 } 3415 }
3397 viewport()->PinchEnd(); 3416 viewport()->PinchEnd();
3398 browser_controls_offset_manager_->PinchEnd(); 3417 browser_controls_offset_manager_->PinchEnd();
3399 client_->SetNeedsCommitOnImplThread(); 3418 client_->SetNeedsCommitOnImplThread();
3400 // When a pinch ends, we may be displaying content cached at incorrect scales, 3419 // When a pinch ends, we may be displaying content cached at incorrect scales,
3401 // so updating draw properties and drawing will ensure we are using the right 3420 // so updating draw properties and drawing will ensure we are using the right
3402 // scales that we want when we're not inside a pinch. 3421 // scales that we want when we're not inside a pinch.
3403 active_tree_->set_needs_update_draw_properties(); 3422 active_tree_->set_needs_update_draw_properties();
3404 SetNeedsRedraw(); 3423 SetNeedsRedraw();
3405 } 3424 }
(...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after
4149 worker_context_visibility_ = 4168 worker_context_visibility_ =
4150 worker_context->CacheController()->ClientBecameVisible(); 4169 worker_context->CacheController()->ClientBecameVisible();
4151 } else { 4170 } else {
4152 worker_context->CacheController()->ClientBecameNotVisible( 4171 worker_context->CacheController()->ClientBecameNotVisible(
4153 std::move(worker_context_visibility_)); 4172 std::move(worker_context_visibility_));
4154 } 4173 }
4155 } 4174 }
4156 } 4175 }
4157 4176
4158 } // namespace cc 4177 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698