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

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

Issue 2759523002: Make sure all the touch events during an active fling are uncancelable (Closed)
Patch Set: fling layer Created 3 years, 9 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
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 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 return false; 591 return false;
592 } 592 }
593 593
594 EventListenerProperties LayerTreeHostImpl::GetEventListenerProperties( 594 EventListenerProperties LayerTreeHostImpl::GetEventListenerProperties(
595 EventListenerClass event_class) const { 595 EventListenerClass event_class) const {
596 return active_tree_->event_listener_properties(event_class); 596 return active_tree_->event_listener_properties(event_class);
597 } 597 }
598 598
599 // Return true if scrollable node for 'ancestor' is the same as 'child' or an 599 // Return true if scrollable node for 'ancestor' is the same as 'child' or an
600 // ancestor along the scroll tree. 600 // ancestor along the scroll tree.
601 bool IsScrolledBy(LayerImpl* child, ScrollNode* ancestor) { 601 bool LayerTreeHostImpl::IsScrolledBy(LayerImpl* child, ScrollNode* ancestor) {
602 DCHECK(ancestor && ancestor->scrollable); 602 DCHECK(ancestor && ancestor->scrollable);
603 if (!child) 603 if (!child)
604 return false; 604 return false;
605 605
606 auto* property_trees = child->layer_tree_impl()->property_trees(); 606 ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree;
weiliangc 2017/03/22 18:11:31 Could you DCHECK that child is on active tree? as
lanwei 2017/03/23 19:56:49 Done.
607 ScrollTree& scroll_tree = property_trees->scroll_tree;
608 for (ScrollNode* scroll_node = scroll_tree.Node(child->scroll_tree_index()); 607 for (ScrollNode* scroll_node = scroll_tree.Node(child->scroll_tree_index());
609 scroll_node; scroll_node = scroll_tree.parent(scroll_node)) { 608 scroll_node; scroll_node = scroll_tree.parent(scroll_node)) {
610 if (scroll_node->id == ancestor->id) 609 if (scroll_node->id == ancestor->id)
611 return true; 610 return true;
612 } 611 }
613 return false; 612 return false;
614 } 613 }
615 614
616 InputHandler::TouchStartEventListenerType 615 InputHandler::TouchStartEventListenerType
617 LayerTreeHostImpl::EventListenerTypeForTouchStartAt( 616 LayerTreeHostImpl::EventListenerTypeForTouchStartAt(
618 const gfx::Point& viewport_point) { 617 const gfx::Point& viewport_point) {
619 gfx::PointF device_viewport_point = gfx::ScalePoint( 618 gfx::PointF device_viewport_point = gfx::ScalePoint(
620 gfx::PointF(viewport_point), active_tree_->device_scale_factor()); 619 gfx::PointF(viewport_point), active_tree_->device_scale_factor());
621 620
622 // Now determine if there are actually any handlers at that point. 621 // Now determine if there are actually any handlers at that point.
623 // TODO(rbyers): Consider also honoring touch-action (crbug.com/347272). 622 // TODO(rbyers): Consider also honoring touch-action (crbug.com/347272).
624 LayerImpl* layer_impl = 623 LayerImpl* layer_impl_with_touch_handler =
625 active_tree_->FindLayerThatIsHitByPointInTouchHandlerRegion( 624 active_tree_->FindLayerThatIsHitByPointInTouchHandlerRegion(
626 device_viewport_point); 625 device_viewport_point);
627 if (layer_impl == NULL) 626 if (layer_impl_with_touch_handler == NULL)
628 return InputHandler::TouchStartEventListenerType::NO_HANDLER; 627 return InputHandler::TouchStartEventListenerType::NO_HANDLER;
629 628
630 if (!CurrentlyScrollingNode()) 629 if (!CurrentlyScrollingNode())
631 return InputHandler::TouchStartEventListenerType::HANDLER; 630 return InputHandler::TouchStartEventListenerType::HANDLER;
632 631
632 // Check if the touch start hits on the current scrolling layer or its
633 // descendant. When we scroll on layer_impl_with_touch_handler, a blank layer
634 // is created inside it, which is the actual scrolling layer, and it does not
pdr. 2017/03/22 20:30:11 If we have the following: <div style="border: 1px
lanwei 2017/03/23 19:56:49 I changed the comments, did not mention the blank
635 // have any event handler.
636 LayerImpl* layer_impl =
637 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point);
weiliangc 2017/03/22 18:11:31 Consider the case where there are two divs, where
pdr. 2017/03/22 20:30:11 +1 to Wei's question I am also curious: this logi
lanwei 2017/03/23 19:56:49 This change is part of our touch event interventio
lanwei 2017/03/23 19:56:49 Good question. No matter we scroll on the parent d
633 bool is_ancestor = IsScrolledBy(layer_impl, CurrentlyScrollingNode()); 638 bool is_ancestor = IsScrolledBy(layer_impl, CurrentlyScrollingNode());
634 return is_ancestor ? InputHandler::TouchStartEventListenerType:: 639 return is_ancestor ? InputHandler::TouchStartEventListenerType::
635 HANDLER_ON_SCROLLING_LAYER 640 HANDLER_ON_SCROLLING_LAYER
636 : InputHandler::TouchStartEventListenerType::HANDLER; 641 : InputHandler::TouchStartEventListenerType::HANDLER;
637 } 642 }
638 643
639 std::unique_ptr<SwapPromiseMonitor> 644 std::unique_ptr<SwapPromiseMonitor>
640 LayerTreeHostImpl::CreateLatencyInfoSwapPromiseMonitor( 645 LayerTreeHostImpl::CreateLatencyInfoSwapPromiseMonitor(
641 ui::LatencyInfo* latency) { 646 ui::LatencyInfo* latency) {
642 return base::WrapUnique( 647 return base::WrapUnique(
(...skipping 3543 matching lines...) Expand 10 before | Expand all | Expand 10 after
4186 worker_context_visibility_ = 4191 worker_context_visibility_ =
4187 worker_context->CacheController()->ClientBecameVisible(); 4192 worker_context->CacheController()->ClientBecameVisible();
4188 } else { 4193 } else {
4189 worker_context->CacheController()->ClientBecameNotVisible( 4194 worker_context->CacheController()->ClientBecameNotVisible(
4190 std::move(worker_context_visibility_)); 4195 std::move(worker_context_visibility_));
4191 } 4196 }
4192 } 4197 }
4193 } 4198 }
4194 4199
4195 } // namespace cc 4200 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698