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

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

Issue 2621133002: Return main thread scroll layer in FindScrollLayerForDeviceViewportPoint (Closed)
Patch Set: test fix Created 3 years, 11 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 561 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 572
573 LayerImpl* layer_impl = 573 LayerImpl* layer_impl =
574 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point); 574 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point);
575 575
576 bool scroll_on_main_thread = false; 576 bool scroll_on_main_thread = false;
577 uint32_t main_thread_scrolling_reasons; 577 uint32_t main_thread_scrolling_reasons;
578 LayerImpl* test_layer_impl = FindScrollLayerForDeviceViewportPoint( 578 LayerImpl* test_layer_impl = FindScrollLayerForDeviceViewportPoint(
579 device_viewport_point, type, layer_impl, &scroll_on_main_thread, 579 device_viewport_point, type, layer_impl, &scroll_on_main_thread,
580 &main_thread_scrolling_reasons); 580 &main_thread_scrolling_reasons);
581 581
582 if (!test_layer_impl) 582 if (scroll_on_main_thread)
583 return false; 583 return false;
584 584
585 if (scrolling_layer_impl == test_layer_impl) 585 if (scrolling_layer_impl == test_layer_impl)
586 return true; 586 return true;
587 587
588 // For active scrolling state treat the inner/outer viewports interchangeably. 588 // For active scrolling state treat the inner/outer viewports interchangeably.
589 if (scrolling_layer_impl == InnerViewportScrollLayer() || 589 if (scrolling_layer_impl == InnerViewportScrollLayer() ||
590 scrolling_layer_impl == OuterViewportScrollLayer()) { 590 scrolling_layer_impl == OuterViewportScrollLayer()) {
591 return test_layer_impl == viewport()->MainScrollLayer(); 591 return test_layer_impl == viewport()->MainScrollLayer();
592 } 592 }
(...skipping 1058 matching lines...) Expand 10 before | Expand all | Expand 10 after
1651 1651
1652 // Collect all resource ids in the render passes into a single array. 1652 // Collect all resource ids in the render passes into a single array.
1653 ResourceProvider::ResourceIdArray resources; 1653 ResourceProvider::ResourceIdArray resources;
1654 for (const auto& render_pass : frame->render_passes) { 1654 for (const auto& render_pass : frame->render_passes) {
1655 for (auto* quad : render_pass->quad_list) { 1655 for (auto* quad : render_pass->quad_list) {
1656 for (ResourceId resource_id : quad->resources) 1656 for (ResourceId resource_id : quad->resources)
1657 resources.push_back(resource_id); 1657 resources.push_back(resource_id);
1658 } 1658 }
1659 } 1659 }
1660 1660
1661
1662 CompositorFrame compositor_frame; 1661 CompositorFrame compositor_frame;
1663 compositor_frame.metadata = std::move(metadata); 1662 compositor_frame.metadata = std::move(metadata);
1664 resource_provider_->PrepareSendToParent(resources, 1663 resource_provider_->PrepareSendToParent(resources,
1665 &compositor_frame.resource_list); 1664 &compositor_frame.resource_list);
1666 compositor_frame.render_pass_list = std::move(frame->render_passes); 1665 compositor_frame.render_pass_list = std::move(frame->render_passes);
1667 compositor_frame_sink_->SubmitCompositorFrame(std::move(compositor_frame)); 1666 compositor_frame_sink_->SubmitCompositorFrame(std::move(compositor_frame));
1668 1667
1669 // Clears the list of swap promises after calling DidSwap on each of them to 1668 // Clears the list of swap promises after calling DidSwap on each of them to
1670 // signal that the swap is over. 1669 // signal that the swap is over.
1671 active_tree()->ClearSwapPromises(); 1670 active_tree()->ClearSwapPromises();
(...skipping 848 matching lines...) Expand 10 before | Expand all | Expand 10 after
2520 LayerImpl* layer_impl, 2519 LayerImpl* layer_impl,
2521 bool* scroll_on_main_thread, 2520 bool* scroll_on_main_thread,
2522 uint32_t* main_thread_scrolling_reasons) const { 2521 uint32_t* main_thread_scrolling_reasons) const {
2523 DCHECK(scroll_on_main_thread); 2522 DCHECK(scroll_on_main_thread);
2524 DCHECK(main_thread_scrolling_reasons); 2523 DCHECK(main_thread_scrolling_reasons);
2525 *main_thread_scrolling_reasons = 2524 *main_thread_scrolling_reasons =
2526 MainThreadScrollingReason::kNotScrollingOnMain; 2525 MainThreadScrollingReason::kNotScrollingOnMain;
2527 2526
2528 // Walk up the hierarchy and look for a scrollable layer. 2527 // Walk up the hierarchy and look for a scrollable layer.
2529 ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree; 2528 ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree;
2530 LayerImpl* potentially_scrolling_layer_impl = NULL; 2529 LayerImpl* potentially_scrolling_layer_impl = nullptr;
2531 if (layer_impl) { 2530 if (layer_impl) {
2532 ScrollNode* scroll_node = scroll_tree.Node(layer_impl->scroll_tree_index()); 2531 ScrollNode* scroll_node = scroll_tree.Node(layer_impl->scroll_tree_index());
2533 for (; scroll_tree.parent(scroll_node); 2532 for (; scroll_tree.parent(scroll_node);
2534 scroll_node = scroll_tree.parent(scroll_node)) { 2533 scroll_node = scroll_tree.parent(scroll_node)) {
2535 // The content layer can also block attempts to scroll outside the main 2534 // The content layer can also block attempts to scroll outside the main
2536 // thread. 2535 // thread.
2537 ScrollStatus status = 2536 ScrollStatus status =
2538 TryScroll(device_viewport_point, type, scroll_tree, scroll_node); 2537 TryScroll(device_viewport_point, type, scroll_tree, scroll_node);
2539 if (IsMainThreadScrolling(status, scroll_node)) { 2538 if (IsMainThreadScrolling(status, scroll_node)) {
2540 *scroll_on_main_thread = true; 2539 *scroll_on_main_thread = true;
2541 *main_thread_scrolling_reasons = status.main_thread_scrolling_reasons; 2540 *main_thread_scrolling_reasons = status.main_thread_scrolling_reasons;
2542 return NULL; 2541 return active_tree_->LayerById(scroll_node->owning_layer_id);
2543 } 2542 }
2544 2543
2545 if (status.thread == InputHandler::SCROLL_ON_IMPL_THREAD && 2544 if (status.thread == InputHandler::SCROLL_ON_IMPL_THREAD &&
2546 !potentially_scrolling_layer_impl) { 2545 !potentially_scrolling_layer_impl) {
2547 potentially_scrolling_layer_impl = 2546 potentially_scrolling_layer_impl =
2548 active_tree_->LayerById(scroll_node->owning_layer_id); 2547 active_tree_->LayerById(scroll_node->owning_layer_id);
2549 } 2548 }
2550 } 2549 }
2551 } 2550 }
2552 2551
2553 // Falling back to the viewport layer ensures generation of root overscroll 2552 // Falling back to the viewport layer ensures generation of root overscroll
2554 // notifications. We use the viewport's main scroll layer to represent the 2553 // notifications. We use the viewport's main scroll layer to represent the
2555 // viewport in scrolling code. 2554 // viewport in scrolling code.
2556 if (!potentially_scrolling_layer_impl || 2555 if (!potentially_scrolling_layer_impl ||
2557 potentially_scrolling_layer_impl == OuterViewportScrollLayer() || 2556 potentially_scrolling_layer_impl == OuterViewportScrollLayer() ||
2558 potentially_scrolling_layer_impl == InnerViewportScrollLayer()) { 2557 potentially_scrolling_layer_impl == InnerViewportScrollLayer()) {
2559 potentially_scrolling_layer_impl = viewport()->MainScrollLayer(); 2558 potentially_scrolling_layer_impl = viewport()->MainScrollLayer();
2560 } 2559 }
2561 2560
2562 if (potentially_scrolling_layer_impl) { 2561 if (potentially_scrolling_layer_impl) {
2563 // Ensure that final layer scrolls on impl thread (crbug.com/625100) 2562 // Ensure that final layer scrolls on impl thread (crbug.com/625100)
2564 ScrollNode* scroll_node = 2563 ScrollNode* scroll_node =
2565 scroll_tree.Node(potentially_scrolling_layer_impl->scroll_tree_index()); 2564 scroll_tree.Node(potentially_scrolling_layer_impl->scroll_tree_index());
2566 ScrollStatus status = 2565 ScrollStatus status =
2567 TryScroll(device_viewport_point, type, scroll_tree, scroll_node); 2566 TryScroll(device_viewport_point, type, scroll_tree, scroll_node);
2568 if (IsMainThreadScrolling(status, scroll_node)) { 2567 if (IsMainThreadScrolling(status, scroll_node)) {
2569 *scroll_on_main_thread = true; 2568 *scroll_on_main_thread = true;
2570 *main_thread_scrolling_reasons = status.main_thread_scrolling_reasons; 2569 *main_thread_scrolling_reasons = status.main_thread_scrolling_reasons;
2571 return NULL;
2572 } 2570 }
2573 } 2571 }
2574 2572
2575 return potentially_scrolling_layer_impl; 2573 return potentially_scrolling_layer_impl;
2576 } 2574 }
2577 2575
2578 static bool IsClosestScrollAncestor(LayerImpl* child, 2576 static bool IsClosestScrollAncestor(LayerImpl* child,
2579 LayerImpl* scroll_ancestor) { 2577 LayerImpl* scroll_ancestor) {
2580 DCHECK(scroll_ancestor); 2578 DCHECK(scroll_ancestor);
2581 if (!child) 2579 if (!child)
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
2673 scroll_status.main_thread_scrolling_reasons = 2671 scroll_status.main_thread_scrolling_reasons =
2674 MainThreadScrollingReason::kFailedHitTest; 2672 MainThreadScrollingReason::kFailedHitTest;
2675 return scroll_status; 2673 return scroll_status;
2676 } 2674 }
2677 } 2675 }
2678 2676
2679 scrolling_layer_impl = FindScrollLayerForDeviceViewportPoint( 2677 scrolling_layer_impl = FindScrollLayerForDeviceViewportPoint(
2680 device_viewport_point, type, layer_impl, &scroll_on_main_thread, 2678 device_viewport_point, type, layer_impl, &scroll_on_main_thread,
2681 &scroll_status.main_thread_scrolling_reasons); 2679 &scroll_status.main_thread_scrolling_reasons);
2682 } 2680 }
2683 if (scrolling_layer_impl)
2684 scroll_affects_scroll_handler_ =
2685 scrolling_layer_impl->layer_tree_impl()->have_scroll_event_handlers();
2686 2681
2687 if (scroll_on_main_thread) { 2682 if (scroll_on_main_thread) {
2688 RecordCompositorSlowScrollMetric(type, MAIN_THREAD); 2683 RecordCompositorSlowScrollMetric(type, MAIN_THREAD);
2689 2684
2690 scroll_status.thread = SCROLL_ON_MAIN_THREAD; 2685 scroll_status.thread = SCROLL_ON_MAIN_THREAD;
2691 return scroll_status; 2686 return scroll_status;
2687 } else if (scrolling_layer_impl) {
2688 scroll_affects_scroll_handler_ =
2689 scrolling_layer_impl->layer_tree_impl()->have_scroll_event_handlers();
2692 } 2690 }
2693 2691
2694 return ScrollBeginImpl(scroll_state, scrolling_layer_impl, type); 2692 return ScrollBeginImpl(scroll_state, scrolling_layer_impl, type);
2695 } 2693 }
2696 2694
2697 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollAnimatedBegin( 2695 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollAnimatedBegin(
2698 const gfx::Point& viewport_point) { 2696 const gfx::Point& viewport_point) {
2699 InputHandler::ScrollStatus scroll_status; 2697 InputHandler::ScrollStatus scroll_status;
2700 scroll_status.main_thread_scrolling_reasons = 2698 scroll_status.main_thread_scrolling_reasons =
2701 MainThreadScrollingReason::kNotScrollingOnMain; 2699 MainThreadScrollingReason::kNotScrollingOnMain;
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after
3235 } 3233 }
3236 3234
3237 void LayerTreeHostImpl::MouseMoveAt(const gfx::Point& viewport_point) { 3235 void LayerTreeHostImpl::MouseMoveAt(const gfx::Point& viewport_point) {
3238 float distance_to_scrollbar = std::numeric_limits<float>::max(); 3236 float distance_to_scrollbar = std::numeric_limits<float>::max();
3239 gfx::PointF device_viewport_point = gfx::ScalePoint( 3237 gfx::PointF device_viewport_point = gfx::ScalePoint(
3240 gfx::PointF(viewport_point), active_tree_->device_scale_factor()); 3238 gfx::PointF(viewport_point), active_tree_->device_scale_factor());
3241 LayerImpl* layer_impl = 3239 LayerImpl* layer_impl =
3242 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point); 3240 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point);
3243 3241
3244 // Check if mouse is over a scrollbar or not. 3242 // Check if mouse is over a scrollbar or not.
3245 // TODO(sahel): get rid of this extera checking when
3246 // FindScrollLayerForDeviceViewportPoint finds the proper layer for
3247 // scrolling on main thread, as well.
bokan 2017/01/13 16:19:17 What extra checking is this TODO referring to?
3248 int new_id = Layer::INVALID_ID; 3243 int new_id = Layer::INVALID_ID;
3249 if (layer_impl && layer_impl->ToScrollbarLayer()) 3244 if (layer_impl && layer_impl->ToScrollbarLayer())
3250 new_id = layer_impl->ToScrollbarLayer()->ScrollLayerId(); 3245 new_id = layer_impl->ToScrollbarLayer()->ScrollLayerId();
3251 if (new_id != Layer::INVALID_ID) { 3246 if (new_id != Layer::INVALID_ID) {
3252 // Mouse over a scrollbar. 3247 // Mouse over a scrollbar.
3253 distance_to_scrollbar = 0; 3248 distance_to_scrollbar = 0;
3254 } else { 3249 } else {
3255 bool scroll_on_main_thread = false; 3250 bool scroll_on_main_thread = false;
3256 uint32_t main_thread_scrolling_reasons; 3251 uint32_t main_thread_scrolling_reasons;
3257 LayerImpl* scroll_layer_impl = FindScrollLayerForDeviceViewportPoint( 3252 LayerImpl* scroll_layer_impl = FindScrollLayerForDeviceViewportPoint(
(...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after
4089 worker_context_visibility_ = 4084 worker_context_visibility_ =
4090 worker_context->CacheController()->ClientBecameVisible(); 4085 worker_context->CacheController()->ClientBecameVisible();
4091 } else { 4086 } else {
4092 worker_context->CacheController()->ClientBecameNotVisible( 4087 worker_context->CacheController()->ClientBecameNotVisible(
4093 std::move(worker_context_visibility_)); 4088 std::move(worker_context_visibility_));
4094 } 4089 }
4095 } 4090 }
4096 } 4091 }
4097 4092
4098 } // namespace cc 4093 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698