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

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: rename both functions 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::DoTouchHandlersBlockScrollAt(
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 ? EventListenerProperties::kBlockingAndPassiveDueToFling
bokan 2016/11/15 22:42:40 It's only a fling if we're currently in a touch st
lanwei 2016/11/16 21:13:28 Done.
620 : EventListenerProperties::kBlocking;
595 } 621 }
596 622
597 std::unique_ptr<SwapPromiseMonitor> 623 std::unique_ptr<SwapPromiseMonitor>
598 LayerTreeHostImpl::CreateLatencyInfoSwapPromiseMonitor( 624 LayerTreeHostImpl::CreateLatencyInfoSwapPromiseMonitor(
599 ui::LatencyInfo* latency) { 625 ui::LatencyInfo* latency) {
600 return base::WrapUnique( 626 return base::WrapUnique(
601 new LatencyInfoSwapPromiseMonitor(latency, NULL, this)); 627 new LatencyInfoSwapPromiseMonitor(latency, NULL, this));
602 } 628 }
603 629
604 ScrollElasticityHelper* LayerTreeHostImpl::CreateScrollElasticityHelper() { 630 ScrollElasticityHelper* LayerTreeHostImpl::CreateScrollElasticityHelper() {
(...skipping 1965 matching lines...) Expand 10 before | Expand all | Expand 10 after
2570 if (IsMainThreadScrolling(status, scroll_node)) { 2596 if (IsMainThreadScrolling(status, scroll_node)) {
2571 *scroll_on_main_thread = true; 2597 *scroll_on_main_thread = true;
2572 *main_thread_scrolling_reasons = status.main_thread_scrolling_reasons; 2598 *main_thread_scrolling_reasons = status.main_thread_scrolling_reasons;
2573 return NULL; 2599 return NULL;
2574 } 2600 }
2575 } 2601 }
2576 2602
2577 return potentially_scrolling_layer_impl; 2603 return potentially_scrolling_layer_impl;
2578 } 2604 }
2579 2605
2580 // Similar to LayerImpl::HasAncestor, but walks up the scroll parents. 2606 // Similar to LayerImpl::HasAncestor, but walks up the scroll parents.
bokan 2016/11/15 22:42:40 It's Layer::HasAncestor and the difference is sign
lanwei 2016/11/16 21:13:28 Done.
2581 static bool HasScrollAncestor(LayerImpl* child, LayerImpl* scroll_ancestor) { 2607 static bool IsClosestScrollAncestor(LayerImpl* child,
2608 LayerImpl* scroll_ancestor) {
2582 DCHECK(scroll_ancestor); 2609 DCHECK(scroll_ancestor);
2583 if (!child) 2610 if (!child)
2584 return false; 2611 return false;
2585 ScrollTree& scroll_tree = 2612 ScrollTree& scroll_tree =
2586 child->layer_tree_impl()->property_trees()->scroll_tree; 2613 child->layer_tree_impl()->property_trees()->scroll_tree;
2587 ScrollNode* scroll_node = scroll_tree.Node(child->scroll_tree_index()); 2614 ScrollNode* scroll_node = scroll_tree.Node(child->scroll_tree_index());
2588 for (; scroll_tree.parent(scroll_node); 2615 for (; scroll_tree.parent(scroll_node);
2589 scroll_node = scroll_tree.parent(scroll_node)) { 2616 scroll_node = scroll_tree.parent(scroll_node)) {
2590 if (scroll_node->scrollable) 2617 if (scroll_node->scrollable)
2591 return scroll_node->owner_id == scroll_ancestor->id(); 2618 return scroll_node->owner_id == scroll_ancestor->id();
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
2656 gfx::PointF device_viewport_point = gfx::ScalePoint( 2683 gfx::PointF device_viewport_point = gfx::ScalePoint(
2657 gfx::PointF(viewport_point), active_tree_->device_scale_factor()); 2684 gfx::PointF(viewport_point), active_tree_->device_scale_factor());
2658 LayerImpl* layer_impl = 2685 LayerImpl* layer_impl =
2659 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point); 2686 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point);
2660 2687
2661 if (layer_impl) { 2688 if (layer_impl) {
2662 LayerImpl* scroll_layer_impl = 2689 LayerImpl* scroll_layer_impl =
2663 active_tree_->FindFirstScrollingLayerOrScrollbarLayerThatIsHitByPoint( 2690 active_tree_->FindFirstScrollingLayerOrScrollbarLayerThatIsHitByPoint(
2664 device_viewport_point); 2691 device_viewport_point);
2665 if (scroll_layer_impl && 2692 if (scroll_layer_impl &&
2666 !HasScrollAncestor(layer_impl, scroll_layer_impl)) { 2693 !IsClosestScrollAncestor(layer_impl, scroll_layer_impl)) {
2667 scroll_status.thread = SCROLL_UNKNOWN; 2694 scroll_status.thread = SCROLL_UNKNOWN;
2668 scroll_status.main_thread_scrolling_reasons = 2695 scroll_status.main_thread_scrolling_reasons =
2669 MainThreadScrollingReason::kFailedHitTest; 2696 MainThreadScrollingReason::kFailedHitTest;
2670 return scroll_status; 2697 return scroll_status;
2671 } 2698 }
2672 } 2699 }
2673 2700
2674 bool scroll_on_main_thread = false; 2701 bool scroll_on_main_thread = false;
2675 LayerImpl* scrolling_layer_impl = FindScrollLayerForDeviceViewportPoint( 2702 LayerImpl* scrolling_layer_impl = FindScrollLayerForDeviceViewportPoint(
2676 device_viewport_point, type, layer_impl, &scroll_on_main_thread, 2703 device_viewport_point, type, layer_impl, &scroll_on_main_thread,
(...skipping 1421 matching lines...) Expand 10 before | Expand all | Expand 10 after
4098 if (is_visible) { 4125 if (is_visible) {
4099 worker_context_visibility_ = 4126 worker_context_visibility_ =
4100 worker_context->CacheController()->ClientBecameVisible(); 4127 worker_context->CacheController()->ClientBecameVisible();
4101 } else { 4128 } else {
4102 worker_context->CacheController()->ClientBecameNotVisible( 4129 worker_context->CacheController()->ClientBecameNotVisible(
4103 std::move(worker_context_visibility_)); 4130 std::move(worker_context_visibility_));
4104 } 4131 }
4105 } 4132 }
4106 4133
4107 } // namespace cc 4134 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698