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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: cc/trees/layer_tree_host_impl.cc
diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc
index 0cf868ff75b5c5bb77f196d119ce0ac4063215da..c18b62c5f2caa5d2c72868176c07e361a62040b7 100644
--- a/cc/trees/layer_tree_host_impl.cc
+++ b/cc/trees/layer_tree_host_impl.cc
@@ -154,6 +154,23 @@ void RecordCompositorSlowScrollMetric(InputHandler::ScrollInputType type,
}
}
+// Return true if scrollable 'ancestor' is the same layer as 'child' or its
+// ancestor along the scroll tree.
+bool IsScrolledBy(LayerImpl* child, LayerImpl* ancestor) {
+ DCHECK(ancestor && ancestor->scrollable());
+ if (!child)
+ return false;
+
+ ScrollTree& scroll_tree =
+ child->layer_tree_impl()->property_trees()->scroll_tree;
+ for (ScrollNode* scroll_node = scroll_tree.Node(child->scroll_tree_index());
+ scroll_node; scroll_node = scroll_tree.parent(scroll_node)) {
+ if (scroll_node->owner_id == ancestor->id())
+ return true;
+ }
+ return false;
+}
+
} // namespace
DEFINE_SCOPED_UMA_HISTOGRAM_TIMER(PendingTreeDurationHistogramTimer,
@@ -581,7 +598,7 @@ EventListenerProperties LayerTreeHostImpl::GetEventListenerProperties(
return active_tree_->event_listener_properties(event_class);
}
-bool LayerTreeHostImpl::DoTouchEventsBlockScrollAt(
+EventListenerProperties LayerTreeHostImpl::DoTouchHandlersBlockScrollAt(
const gfx::Point& viewport_point) {
gfx::PointF device_viewport_point = gfx::ScalePoint(
gfx::PointF(viewport_point), active_tree_->device_scale_factor());
@@ -591,7 +608,16 @@ bool LayerTreeHostImpl::DoTouchEventsBlockScrollAt(
LayerImpl* layer_impl =
active_tree_->FindLayerThatIsHitByPointInTouchHandlerRegion(
device_viewport_point);
- return layer_impl != NULL;
+ if (layer_impl == NULL)
+ return EventListenerProperties::kNone;
+
+ if (!CurrentlyScrollingLayer())
+ return EventListenerProperties::kBlocking;
+
+ bool is_ancestor =
+ IsScrolledBy(layer_impl, active_tree_->CurrentlyScrollingLayer());
+ 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.
+ : EventListenerProperties::kBlocking;
}
std::unique_ptr<SwapPromiseMonitor>
@@ -2578,7 +2604,8 @@ LayerImpl* LayerTreeHostImpl::FindScrollLayerForDeviceViewportPoint(
}
// 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.
-static bool HasScrollAncestor(LayerImpl* child, LayerImpl* scroll_ancestor) {
+static bool IsClosestScrollAncestor(LayerImpl* child,
+ LayerImpl* scroll_ancestor) {
DCHECK(scroll_ancestor);
if (!child)
return false;
@@ -2663,7 +2690,7 @@ InputHandler::ScrollStatus LayerTreeHostImpl::ScrollBegin(
active_tree_->FindFirstScrollingLayerOrScrollbarLayerThatIsHitByPoint(
device_viewport_point);
if (scroll_layer_impl &&
- !HasScrollAncestor(layer_impl, scroll_layer_impl)) {
+ !IsClosestScrollAncestor(layer_impl, scroll_layer_impl)) {
scroll_status.thread = SCROLL_UNKNOWN;
scroll_status.main_thread_scrolling_reasons =
MainThreadScrollingReason::kFailedHitTest;

Powered by Google App Engine
This is Rietveld 408576698