| OLD | NEW |
| 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 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 return false; | 595 return false; |
| 596 } | 596 } |
| 597 | 597 |
| 598 EventListenerProperties LayerTreeHostImpl::GetEventListenerProperties( | 598 EventListenerProperties LayerTreeHostImpl::GetEventListenerProperties( |
| 599 EventListenerClass event_class) const { | 599 EventListenerClass event_class) const { |
| 600 return active_tree_->event_listener_properties(event_class); | 600 return active_tree_->event_listener_properties(event_class); |
| 601 } | 601 } |
| 602 | 602 |
| 603 // Return true if scrollable node for 'ancestor' is the same as 'child' or an | 603 // Return true if scrollable node for 'ancestor' is the same as 'child' or an |
| 604 // ancestor along the scroll tree. | 604 // ancestor along the scroll tree. |
| 605 bool IsScrolledBy(LayerImpl* child, ScrollNode* ancestor) { | 605 bool LayerTreeHostImpl::IsScrolledBy(LayerImpl* child, ScrollNode* ancestor) { |
| 606 DCHECK(ancestor && ancestor->scrollable); | 606 DCHECK(ancestor && ancestor->scrollable); |
| 607 if (!child) | 607 if (!child) |
| 608 return false; | 608 return false; |
| 609 | 609 DCHECK_EQ(child->layer_tree_impl(), active_tree_.get()); |
| 610 auto* property_trees = child->layer_tree_impl()->property_trees(); | 610 ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree; |
| 611 ScrollTree& scroll_tree = property_trees->scroll_tree; | |
| 612 for (ScrollNode* scroll_node = scroll_tree.Node(child->scroll_tree_index()); | 611 for (ScrollNode* scroll_node = scroll_tree.Node(child->scroll_tree_index()); |
| 613 scroll_node; scroll_node = scroll_tree.parent(scroll_node)) { | 612 scroll_node; scroll_node = scroll_tree.parent(scroll_node)) { |
| 614 if (scroll_node->id == ancestor->id) | 613 if (scroll_node->id == ancestor->id) |
| 615 return true; | 614 return true; |
| 616 } | 615 } |
| 617 return false; | 616 return false; |
| 618 } | 617 } |
| 619 | 618 |
| 620 InputHandler::TouchStartEventListenerType | 619 InputHandler::TouchStartEventListenerType |
| 621 LayerTreeHostImpl::EventListenerTypeForTouchStartAt( | 620 LayerTreeHostImpl::EventListenerTypeForTouchStartAt( |
| 622 const gfx::Point& viewport_point) { | 621 const gfx::Point& viewport_point) { |
| 623 gfx::PointF device_viewport_point = gfx::ScalePoint( | 622 gfx::PointF device_viewport_point = gfx::ScalePoint( |
| 624 gfx::PointF(viewport_point), active_tree_->device_scale_factor()); | 623 gfx::PointF(viewport_point), active_tree_->device_scale_factor()); |
| 625 | 624 |
| 626 // Now determine if there are actually any handlers at that point. | 625 // Now determine if there are actually any handlers at that point. |
| 627 // TODO(rbyers): Consider also honoring touch-action (crbug.com/347272). | 626 // TODO(rbyers): Consider also honoring touch-action (crbug.com/347272). |
| 628 LayerImpl* layer_impl = | 627 LayerImpl* layer_impl_with_touch_handler = |
| 629 active_tree_->FindLayerThatIsHitByPointInTouchHandlerRegion( | 628 active_tree_->FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 630 device_viewport_point); | 629 device_viewport_point); |
| 631 if (layer_impl == NULL) | 630 if (layer_impl_with_touch_handler == NULL) |
| 632 return InputHandler::TouchStartEventListenerType::NO_HANDLER; | 631 return InputHandler::TouchStartEventListenerType::NO_HANDLER; |
| 633 | 632 |
| 634 if (!CurrentlyScrollingNode()) | 633 if (!CurrentlyScrollingNode()) |
| 635 return InputHandler::TouchStartEventListenerType::HANDLER; | 634 return InputHandler::TouchStartEventListenerType::HANDLER; |
| 636 | 635 |
| 636 // Check if the touch start hits on the current scrolling layer or its |
| 637 // descendant. layer_impl_with_touch_handler is the layer hit by the pointer |
| 638 // and has an event handler, otherwise it is null. |
| 639 // We want to compare the most inner layer we are hitting on which may not |
| 640 // have an event listener with the actual scrolling layer. |
| 641 LayerImpl* layer_impl = |
| 642 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point); |
| 637 bool is_ancestor = IsScrolledBy(layer_impl, CurrentlyScrollingNode()); | 643 bool is_ancestor = IsScrolledBy(layer_impl, CurrentlyScrollingNode()); |
| 638 return is_ancestor ? InputHandler::TouchStartEventListenerType:: | 644 return is_ancestor ? InputHandler::TouchStartEventListenerType:: |
| 639 HANDLER_ON_SCROLLING_LAYER | 645 HANDLER_ON_SCROLLING_LAYER |
| 640 : InputHandler::TouchStartEventListenerType::HANDLER; | 646 : InputHandler::TouchStartEventListenerType::HANDLER; |
| 641 } | 647 } |
| 642 | 648 |
| 643 std::unique_ptr<SwapPromiseMonitor> | 649 std::unique_ptr<SwapPromiseMonitor> |
| 644 LayerTreeHostImpl::CreateLatencyInfoSwapPromiseMonitor( | 650 LayerTreeHostImpl::CreateLatencyInfoSwapPromiseMonitor( |
| 645 ui::LatencyInfo* latency) { | 651 ui::LatencyInfo* latency) { |
| 646 return base::WrapUnique( | 652 return base::WrapUnique( |
| (...skipping 3644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4291 } | 4297 } |
| 4292 | 4298 |
| 4293 void LayerTreeHostImpl::UpdateScrollSourceInfo(bool is_wheel_scroll) { | 4299 void LayerTreeHostImpl::UpdateScrollSourceInfo(bool is_wheel_scroll) { |
| 4294 if (is_wheel_scroll) | 4300 if (is_wheel_scroll) |
| 4295 has_scrolled_by_wheel_ = true; | 4301 has_scrolled_by_wheel_ = true; |
| 4296 else | 4302 else |
| 4297 has_scrolled_by_touch_ = true; | 4303 has_scrolled_by_touch_ = true; |
| 4298 } | 4304 } |
| 4299 | 4305 |
| 4300 } // namespace cc | 4306 } // namespace cc |
| OLD | NEW |