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

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

Issue 2471523002: Make touch events uncancelable during fling when they are on the current active scroll layer (Closed)
Patch Set: fling layer Created 4 years, 1 month 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 'ancestor' is the same layer as 'child' or its
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 ScrollTree& scroll_tree =
165 child->layer_tree_impl()->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->owner_id == ancestor->id())
169 return true;
170 }
171 return false;
172 }
173
157 } // namespace 174 } // namespace
158 175
159 DEFINE_SCOPED_UMA_HISTOGRAM_TIMER(PendingTreeDurationHistogramTimer, 176 DEFINE_SCOPED_UMA_HISTOGRAM_TIMER(PendingTreeDurationHistogramTimer,
160 "Scheduling.%s.PendingTreeDuration"); 177 "Scheduling.%s.PendingTreeDuration");
161 178
162 LayerTreeHostImpl::FrameData::FrameData() 179 LayerTreeHostImpl::FrameData::FrameData()
163 : render_surface_layer_list(nullptr), 180 : render_surface_layer_list(nullptr),
164 has_no_damage(false), 181 has_no_damage(false),
165 may_contain_video(false) {} 182 may_contain_video(false) {}
166 183
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 } 591 }
575 592
576 return false; 593 return false;
577 } 594 }
578 595
579 EventListenerProperties LayerTreeHostImpl::GetEventListenerProperties( 596 EventListenerProperties LayerTreeHostImpl::GetEventListenerProperties(
580 EventListenerClass event_class) const { 597 EventListenerClass event_class) const {
581 return active_tree_->event_listener_properties(event_class); 598 return active_tree_->event_listener_properties(event_class);
582 } 599 }
583 600
584 bool LayerTreeHostImpl::DoTouchEventsBlockScrollAt( 601 EventListenerProperties LayerTreeHostImpl::EventListenerTypeForTouchStartAt(
585 const gfx::Point& viewport_point) { 602 const gfx::Point& viewport_point) {
586 gfx::PointF device_viewport_point = gfx::ScalePoint( 603 gfx::PointF device_viewport_point = gfx::ScalePoint(
587 gfx::PointF(viewport_point), active_tree_->device_scale_factor()); 604 gfx::PointF(viewport_point), active_tree_->device_scale_factor());
588 605
589 // Now determine if there are actually any handlers at that point. 606 // Now determine if there are actually any handlers at that point.
590 // TODO(rbyers): Consider also honoring touch-action (crbug.com/347272). 607 // TODO(rbyers): Consider also honoring touch-action (crbug.com/347272).
591 LayerImpl* layer_impl = 608 LayerImpl* layer_impl =
592 active_tree_->FindLayerThatIsHitByPointInTouchHandlerRegion( 609 active_tree_->FindLayerThatIsHitByPointInTouchHandlerRegion(
593 device_viewport_point); 610 device_viewport_point);
594 return layer_impl != NULL; 611 if (layer_impl == NULL)
612 return EventListenerProperties::kNone;
613
614 if (!CurrentlyScrollingLayer())
615 return EventListenerProperties::kBlocking;
616
617 bool is_ancestor =
618 IsScrolledBy(layer_impl, active_tree_->CurrentlyScrollingLayer());
619 return is_ancestor
620 ? EventListenerProperties::kBlockingAndMaybePassiveDueToFling
621 : EventListenerProperties::kBlocking;
595 } 622 }
596 623
597 std::unique_ptr<SwapPromiseMonitor> 624 std::unique_ptr<SwapPromiseMonitor>
598 LayerTreeHostImpl::CreateLatencyInfoSwapPromiseMonitor( 625 LayerTreeHostImpl::CreateLatencyInfoSwapPromiseMonitor(
599 ui::LatencyInfo* latency) { 626 ui::LatencyInfo* latency) {
600 return base::WrapUnique( 627 return base::WrapUnique(
601 new LatencyInfoSwapPromiseMonitor(latency, NULL, this)); 628 new LatencyInfoSwapPromiseMonitor(latency, NULL, this));
602 } 629 }
603 630
604 ScrollElasticityHelper* LayerTreeHostImpl::CreateScrollElasticityHelper() { 631 ScrollElasticityHelper* LayerTreeHostImpl::CreateScrollElasticityHelper() {
(...skipping 1951 matching lines...) Expand 10 before | Expand all | Expand 10 after
2556 if (IsMainThreadScrolling(status, scroll_node)) { 2583 if (IsMainThreadScrolling(status, scroll_node)) {
2557 *scroll_on_main_thread = true; 2584 *scroll_on_main_thread = true;
2558 *main_thread_scrolling_reasons = status.main_thread_scrolling_reasons; 2585 *main_thread_scrolling_reasons = status.main_thread_scrolling_reasons;
2559 return NULL; 2586 return NULL;
2560 } 2587 }
2561 } 2588 }
2562 2589
2563 return potentially_scrolling_layer_impl; 2590 return potentially_scrolling_layer_impl;
2564 } 2591 }
2565 2592
2566 // Similar to LayerImpl::HasAncestor, but walks up the scroll parents. 2593 static bool IsClosestScrollAncestor(LayerImpl* child,
2567 static bool HasScrollAncestor(LayerImpl* child, LayerImpl* scroll_ancestor) { 2594 LayerImpl* scroll_ancestor) {
2568 DCHECK(scroll_ancestor); 2595 DCHECK(scroll_ancestor);
2569 if (!child) 2596 if (!child)
2570 return false; 2597 return false;
2571 ScrollTree& scroll_tree = 2598 ScrollTree& scroll_tree =
2572 child->layer_tree_impl()->property_trees()->scroll_tree; 2599 child->layer_tree_impl()->property_trees()->scroll_tree;
2573 ScrollNode* scroll_node = scroll_tree.Node(child->scroll_tree_index()); 2600 ScrollNode* scroll_node = scroll_tree.Node(child->scroll_tree_index());
2574 for (; scroll_tree.parent(scroll_node); 2601 for (; scroll_tree.parent(scroll_node);
2575 scroll_node = scroll_tree.parent(scroll_node)) { 2602 scroll_node = scroll_tree.parent(scroll_node)) {
2576 if (scroll_node->scrollable) 2603 if (scroll_node->scrollable)
2577 return scroll_node->owner_id == scroll_ancestor->id(); 2604 return scroll_node->owner_id == scroll_ancestor->id();
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
2642 gfx::PointF device_viewport_point = gfx::ScalePoint( 2669 gfx::PointF device_viewport_point = gfx::ScalePoint(
2643 gfx::PointF(viewport_point), active_tree_->device_scale_factor()); 2670 gfx::PointF(viewport_point), active_tree_->device_scale_factor());
2644 LayerImpl* layer_impl = 2671 LayerImpl* layer_impl =
2645 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point); 2672 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point);
2646 2673
2647 if (layer_impl) { 2674 if (layer_impl) {
2648 LayerImpl* scroll_layer_impl = 2675 LayerImpl* scroll_layer_impl =
2649 active_tree_->FindFirstScrollingLayerOrScrollbarLayerThatIsHitByPoint( 2676 active_tree_->FindFirstScrollingLayerOrScrollbarLayerThatIsHitByPoint(
2650 device_viewport_point); 2677 device_viewport_point);
2651 if (scroll_layer_impl && 2678 if (scroll_layer_impl &&
2652 !HasScrollAncestor(layer_impl, scroll_layer_impl)) { 2679 !IsClosestScrollAncestor(layer_impl, scroll_layer_impl)) {
2653 scroll_status.thread = SCROLL_UNKNOWN; 2680 scroll_status.thread = SCROLL_UNKNOWN;
2654 scroll_status.main_thread_scrolling_reasons = 2681 scroll_status.main_thread_scrolling_reasons =
2655 MainThreadScrollingReason::kFailedHitTest; 2682 MainThreadScrollingReason::kFailedHitTest;
2656 return scroll_status; 2683 return scroll_status;
2657 } 2684 }
2658 } 2685 }
2659 2686
2660 bool scroll_on_main_thread = false; 2687 bool scroll_on_main_thread = false;
2661 LayerImpl* scrolling_layer_impl = FindScrollLayerForDeviceViewportPoint( 2688 LayerImpl* scrolling_layer_impl = FindScrollLayerForDeviceViewportPoint(
2662 device_viewport_point, type, layer_impl, &scroll_on_main_thread, 2689 device_viewport_point, type, layer_impl, &scroll_on_main_thread,
(...skipping 1412 matching lines...) Expand 10 before | Expand all | Expand 10 after
4075 worker_context_visibility_ = 4102 worker_context_visibility_ =
4076 worker_context->CacheController()->ClientBecameVisible(); 4103 worker_context->CacheController()->ClientBecameVisible();
4077 } else { 4104 } else {
4078 worker_context->CacheController()->ClientBecameNotVisible( 4105 worker_context->CacheController()->ClientBecameNotVisible(
4079 std::move(worker_context_visibility_)); 4106 std::move(worker_context_visibility_));
4080 } 4107 }
4081 } 4108 }
4082 } 4109 }
4083 4110
4084 } // namespace cc 4111 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698