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

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: clean up code 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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 bool scroll_on_main_thread = (scroll_thread == MAIN_THREAD); 148 bool scroll_on_main_thread = (scroll_thread == MAIN_THREAD);
149 if (IsWheelBasedScroll(type)) { 149 if (IsWheelBasedScroll(type)) {
150 UMA_HISTOGRAM_BOOLEAN("Renderer4.CompositorWheelScrollUpdateThread", 150 UMA_HISTOGRAM_BOOLEAN("Renderer4.CompositorWheelScrollUpdateThread",
151 scroll_on_main_thread); 151 scroll_on_main_thread);
152 } else { 152 } else {
153 UMA_HISTOGRAM_BOOLEAN("Renderer4.CompositorTouchScrollUpdateThread", 153 UMA_HISTOGRAM_BOOLEAN("Renderer4.CompositorTouchScrollUpdateThread",
154 scroll_on_main_thread); 154 scroll_on_main_thread);
155 } 155 }
156 } 156 }
157 157
158 // Similar to LayerImpl::HasAncestor, but walks up the scroll parents.
159 static bool HasScrollAncestor(LayerImpl* child, LayerImpl* scroll_ancestor) {
160 DCHECK(scroll_ancestor);
161 if (!child)
162 return false;
163 ScrollTree& scroll_tree =
164 child->layer_tree_impl()->property_trees()->scroll_tree;
165 ScrollNode* scroll_node = scroll_tree.Node(child->scroll_tree_index());
166 for (; scroll_tree.parent(scroll_node);
bokan 2016/11/04 19:32:55 This will avoid comparing against the root layer.
167 scroll_node = scroll_tree.parent(scroll_node)) {
168 if (scroll_node->scrollable)
169 return scroll_node->owner_id == scroll_ancestor->id();
170 }
171 return false;
172 }
173
158 } // namespace 174 } // namespace
159 175
160 DEFINE_SCOPED_UMA_HISTOGRAM_TIMER(PendingTreeDurationHistogramTimer, 176 DEFINE_SCOPED_UMA_HISTOGRAM_TIMER(PendingTreeDurationHistogramTimer,
161 "Scheduling.%s.PendingTreeDuration"); 177 "Scheduling.%s.PendingTreeDuration");
162 178
163 LayerTreeHostImpl::FrameData::FrameData() 179 LayerTreeHostImpl::FrameData::FrameData()
164 : render_surface_layer_list(nullptr), 180 : render_surface_layer_list(nullptr),
165 has_no_damage(false), 181 has_no_damage(false),
166 may_contain_video(false) {} 182 may_contain_video(false) {}
167 183
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 } 600 }
585 601
586 return false; 602 return false;
587 } 603 }
588 604
589 EventListenerProperties LayerTreeHostImpl::GetEventListenerProperties( 605 EventListenerProperties LayerTreeHostImpl::GetEventListenerProperties(
590 EventListenerClass event_class) const { 606 EventListenerClass event_class) const {
591 return active_tree_->event_listener_properties(event_class); 607 return active_tree_->event_listener_properties(event_class);
592 } 608 }
593 609
594 bool LayerTreeHostImpl::DoTouchEventsBlockScrollAt( 610 InputHandler::TouchStartHitResult LayerTreeHostImpl::DoTouchEventsBlockScrollAt(
595 const gfx::Point& viewport_point) { 611 const gfx::Point& viewport_point) {
596 gfx::PointF device_viewport_point = gfx::ScalePoint( 612 gfx::PointF device_viewport_point = gfx::ScalePoint(
597 gfx::PointF(viewport_point), active_tree_->device_scale_factor()); 613 gfx::PointF(viewport_point), active_tree_->device_scale_factor());
598 614
599 // Now determine if there are actually any handlers at that point. 615 // Now determine if there are actually any handlers at that point.
600 // TODO(rbyers): Consider also honoring touch-action (crbug.com/347272). 616 // TODO(rbyers): Consider also honoring touch-action (crbug.com/347272).
601 LayerImpl* layer_impl = 617 LayerImpl* layer_impl =
602 active_tree_->FindLayerThatIsHitByPointInTouchHandlerRegion( 618 active_tree_->FindLayerThatIsHitByPointInTouchHandlerRegion(
603 device_viewport_point); 619 device_viewport_point);
604 return layer_impl != NULL; 620 if (layer_impl == NULL)
621 return TouchStartHitResult::HANDLER;
622
623 if (!CurrentlyScrollingLayer())
624 return TouchStartHitResult::SAME_LAYER;
tdresser 2016/11/04 17:15:20 I don't understand this, but I might just be confu
bokan 2016/11/04 19:32:55 +1, I don't know what these returns mean.
625
626 bool is_ancestor =
627 HasScrollAncestor(layer_impl, active_tree_->CurrentlyScrollingLayer());
bokan 2016/11/04 19:32:55 What should happen if layer_impl == CurrentlyScrol
628 return is_ancestor ? TouchStartHitResult::SAME_LAYER
629 : TouchStartHitResult::DIFFERENT_LAYER;
605 } 630 }
606 631
607 std::unique_ptr<SwapPromiseMonitor> 632 std::unique_ptr<SwapPromiseMonitor>
608 LayerTreeHostImpl::CreateLatencyInfoSwapPromiseMonitor( 633 LayerTreeHostImpl::CreateLatencyInfoSwapPromiseMonitor(
609 ui::LatencyInfo* latency) { 634 ui::LatencyInfo* latency) {
610 return base::WrapUnique( 635 return base::WrapUnique(
611 new LatencyInfoSwapPromiseMonitor(latency, NULL, this)); 636 new LatencyInfoSwapPromiseMonitor(latency, NULL, this));
612 } 637 }
613 638
614 ScrollElasticityHelper* LayerTreeHostImpl::CreateScrollElasticityHelper() { 639 ScrollElasticityHelper* LayerTreeHostImpl::CreateScrollElasticityHelper() {
(...skipping 1953 matching lines...) Expand 10 before | Expand all | Expand 10 after
2568 if (IsMainThreadScrolling(status, scroll_node)) { 2593 if (IsMainThreadScrolling(status, scroll_node)) {
2569 *scroll_on_main_thread = true; 2594 *scroll_on_main_thread = true;
2570 *main_thread_scrolling_reasons = status.main_thread_scrolling_reasons; 2595 *main_thread_scrolling_reasons = status.main_thread_scrolling_reasons;
2571 return NULL; 2596 return NULL;
2572 } 2597 }
2573 } 2598 }
2574 2599
2575 return potentially_scrolling_layer_impl; 2600 return potentially_scrolling_layer_impl;
2576 } 2601 }
2577 2602
2578 // Similar to LayerImpl::HasAncestor, but walks up the scroll parents.
2579 static bool HasScrollAncestor(LayerImpl* child, LayerImpl* scroll_ancestor) {
2580 DCHECK(scroll_ancestor);
2581 if (!child)
2582 return false;
2583 ScrollTree& scroll_tree =
2584 child->layer_tree_impl()->property_trees()->scroll_tree;
2585 ScrollNode* scroll_node = scroll_tree.Node(child->scroll_tree_index());
2586 for (; scroll_tree.parent(scroll_node);
2587 scroll_node = scroll_tree.parent(scroll_node)) {
2588 if (scroll_node->scrollable)
2589 return scroll_node->owner_id == scroll_ancestor->id();
2590 }
2591 return false;
2592 }
2593
2594 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollBeginImpl( 2603 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollBeginImpl(
2595 ScrollState* scroll_state, 2604 ScrollState* scroll_state,
2596 LayerImpl* scrolling_layer_impl, 2605 LayerImpl* scrolling_layer_impl,
2597 InputHandler::ScrollInputType type) { 2606 InputHandler::ScrollInputType type) {
2598 DCHECK(scroll_state); 2607 DCHECK(scroll_state);
2599 DCHECK(scroll_state->delta_x() == 0 && scroll_state->delta_y() == 0); 2608 DCHECK(scroll_state->delta_x() == 0 && scroll_state->delta_y() == 0);
2600 2609
2601 InputHandler::ScrollStatus scroll_status; 2610 InputHandler::ScrollStatus scroll_status;
2602 scroll_status.main_thread_scrolling_reasons = 2611 scroll_status.main_thread_scrolling_reasons =
2603 MainThreadScrollingReason::kNotScrollingOnMain; 2612 MainThreadScrollingReason::kNotScrollingOnMain;
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
2678 LayerImpl* scrolling_layer_impl = FindScrollLayerForDeviceViewportPoint( 2687 LayerImpl* scrolling_layer_impl = FindScrollLayerForDeviceViewportPoint(
2679 device_viewport_point, type, layer_impl, &scroll_on_main_thread, 2688 device_viewport_point, type, layer_impl, &scroll_on_main_thread,
2680 &scroll_status.main_thread_scrolling_reasons); 2689 &scroll_status.main_thread_scrolling_reasons);
2681 2690
2682 if (scrolling_layer_impl) 2691 if (scrolling_layer_impl)
2683 scroll_affects_scroll_handler_ = 2692 scroll_affects_scroll_handler_ =
2684 scrolling_layer_impl->layer_tree_impl()->have_scroll_event_handlers(); 2693 scrolling_layer_impl->layer_tree_impl()->have_scroll_event_handlers();
2685 2694
2686 if (scroll_on_main_thread) { 2695 if (scroll_on_main_thread) {
2687 RecordCompositorSlowScrollMetric(type, MAIN_THREAD); 2696 RecordCompositorSlowScrollMetric(type, MAIN_THREAD);
2688
2689 scroll_status.thread = SCROLL_ON_MAIN_THREAD; 2697 scroll_status.thread = SCROLL_ON_MAIN_THREAD;
2690 return scroll_status; 2698 return scroll_status;
2691 } 2699 }
2692 2700
2693 return ScrollBeginImpl(scroll_state, scrolling_layer_impl, type); 2701 return ScrollBeginImpl(scroll_state, scrolling_layer_impl, type);
2694 } 2702 }
2695 2703
2696 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollAnimatedBegin( 2704 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollAnimatedBegin(
2697 const gfx::Point& viewport_point) { 2705 const gfx::Point& viewport_point) {
2698 InputHandler::ScrollStatus scroll_status; 2706 InputHandler::ScrollStatus scroll_status;
(...skipping 1389 matching lines...) Expand 10 before | Expand all | Expand 10 after
4088 if (is_visible) { 4096 if (is_visible) {
4089 worker_context_visibility_ = 4097 worker_context_visibility_ =
4090 worker_context->CacheController()->ClientBecameVisible(); 4098 worker_context->CacheController()->ClientBecameVisible();
4091 } else { 4099 } else {
4092 worker_context->CacheController()->ClientBecameNotVisible( 4100 worker_context->CacheController()->ClientBecameNotVisible(
4093 std::move(worker_context_visibility_)); 4101 std::move(worker_context_visibility_));
4094 } 4102 }
4095 } 4103 }
4096 4104
4097 } // namespace cc 4105 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698