Chromium Code Reviews| 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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 ancestor is same as child or its ancestor. | |
| 158 bool isScrollingAncestor(LayerImpl* child, LayerImpl* ancestor) { | |
| 159 DCHECK(ancestor); | |
| 160 if (!child) | |
| 161 return false; | |
| 162 | |
| 163 ScrollTree& scroll_tree = | |
| 164 child->layer_tree_impl()->property_trees()->scroll_tree; | |
| 165 for (ScrollNode* scroll_node = scroll_tree.Node(child->scroll_tree_index()); | |
| 166 scroll_node; scroll_node = scroll_tree.parent(scroll_node)) { | |
| 167 if (scroll_node->owner_id == ancestor->id()) | |
|
weiliangc
2016/11/15 18:50:38
Another difference between this function and HasSc
bokan
2016/11/15 19:02:29
We should get rid of one of the functions because
weiliangc
2016/11/15 19:13:46
We could break out of the loop and check if scroll
weiliangc
2016/11/15 19:43:47
Oops now paid more attention to the code, I think
| |
| 168 return true; | |
| 169 } | |
| 170 return false; | |
| 171 } | |
| 172 | |
| 157 } // namespace | 173 } // namespace |
| 158 | 174 |
| 159 DEFINE_SCOPED_UMA_HISTOGRAM_TIMER(PendingTreeDurationHistogramTimer, | 175 DEFINE_SCOPED_UMA_HISTOGRAM_TIMER(PendingTreeDurationHistogramTimer, |
| 160 "Scheduling.%s.PendingTreeDuration"); | 176 "Scheduling.%s.PendingTreeDuration"); |
| 161 | 177 |
| 162 LayerTreeHostImpl::FrameData::FrameData() | 178 LayerTreeHostImpl::FrameData::FrameData() |
| 163 : render_surface_layer_list(nullptr), | 179 : render_surface_layer_list(nullptr), |
| 164 has_no_damage(false), | 180 has_no_damage(false), |
| 165 may_contain_video(false) {} | 181 may_contain_video(false) {} |
| 166 | 182 |
| (...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 574 } | 590 } |
| 575 | 591 |
| 576 return false; | 592 return false; |
| 577 } | 593 } |
| 578 | 594 |
| 579 EventListenerProperties LayerTreeHostImpl::GetEventListenerProperties( | 595 EventListenerProperties LayerTreeHostImpl::GetEventListenerProperties( |
| 580 EventListenerClass event_class) const { | 596 EventListenerClass event_class) const { |
| 581 return active_tree_->event_listener_properties(event_class); | 597 return active_tree_->event_listener_properties(event_class); |
| 582 } | 598 } |
| 583 | 599 |
| 584 bool LayerTreeHostImpl::DoTouchEventsBlockScrollAt( | 600 EventListenerProperties LayerTreeHostImpl::DoTouchHandlersBlockScrollAt( |
| 585 const gfx::Point& viewport_point) { | 601 const gfx::Point& viewport_point) { |
| 586 gfx::PointF device_viewport_point = gfx::ScalePoint( | 602 gfx::PointF device_viewport_point = gfx::ScalePoint( |
| 587 gfx::PointF(viewport_point), active_tree_->device_scale_factor()); | 603 gfx::PointF(viewport_point), active_tree_->device_scale_factor()); |
| 588 | 604 |
| 589 // Now determine if there are actually any handlers at that point. | 605 // Now determine if there are actually any handlers at that point. |
| 590 // TODO(rbyers): Consider also honoring touch-action (crbug.com/347272). | 606 // TODO(rbyers): Consider also honoring touch-action (crbug.com/347272). |
| 591 LayerImpl* layer_impl = | 607 LayerImpl* layer_impl = |
| 592 active_tree_->FindLayerThatIsHitByPointInTouchHandlerRegion( | 608 active_tree_->FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 593 device_viewport_point); | 609 device_viewport_point); |
| 594 return layer_impl != NULL; | 610 if (layer_impl == NULL) |
| 611 return EventListenerProperties::kNone; | |
| 612 | |
| 613 if (!CurrentlyScrollingLayer()) | |
| 614 return EventListenerProperties::kBlocking; | |
| 615 | |
| 616 bool is_ancestor = | |
| 617 isScrollingAncestor(layer_impl, active_tree_->CurrentlyScrollingLayer()); | |
| 618 return is_ancestor ? EventListenerProperties::kBlockingAndPassiveDueToFling | |
| 619 : EventListenerProperties::kBlocking; | |
| 595 } | 620 } |
| 596 | 621 |
| 597 std::unique_ptr<SwapPromiseMonitor> | 622 std::unique_ptr<SwapPromiseMonitor> |
| 598 LayerTreeHostImpl::CreateLatencyInfoSwapPromiseMonitor( | 623 LayerTreeHostImpl::CreateLatencyInfoSwapPromiseMonitor( |
| 599 ui::LatencyInfo* latency) { | 624 ui::LatencyInfo* latency) { |
| 600 return base::WrapUnique( | 625 return base::WrapUnique( |
| 601 new LatencyInfoSwapPromiseMonitor(latency, NULL, this)); | 626 new LatencyInfoSwapPromiseMonitor(latency, NULL, this)); |
| 602 } | 627 } |
| 603 | 628 |
| 604 ScrollElasticityHelper* LayerTreeHostImpl::CreateScrollElasticityHelper() { | 629 ScrollElasticityHelper* LayerTreeHostImpl::CreateScrollElasticityHelper() { |
| (...skipping 1966 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2571 *scroll_on_main_thread = true; | 2596 *scroll_on_main_thread = true; |
| 2572 *main_thread_scrolling_reasons = status.main_thread_scrolling_reasons; | 2597 *main_thread_scrolling_reasons = status.main_thread_scrolling_reasons; |
| 2573 return NULL; | 2598 return NULL; |
| 2574 } | 2599 } |
| 2575 } | 2600 } |
| 2576 | 2601 |
| 2577 return potentially_scrolling_layer_impl; | 2602 return potentially_scrolling_layer_impl; |
| 2578 } | 2603 } |
| 2579 | 2604 |
| 2580 // Similar to LayerImpl::HasAncestor, but walks up the scroll parents. | 2605 // Similar to LayerImpl::HasAncestor, but walks up the scroll parents. |
| 2581 static bool HasScrollAncestor(LayerImpl* child, LayerImpl* scroll_ancestor) { | 2606 static bool isScrolledBy(LayerImpl* child, LayerImpl* scroll_ancestor) { |
| 2582 DCHECK(scroll_ancestor); | 2607 DCHECK(scroll_ancestor); |
| 2583 if (!child) | 2608 if (!child) |
| 2584 return false; | 2609 return false; |
| 2585 ScrollTree& scroll_tree = | 2610 ScrollTree& scroll_tree = |
| 2586 child->layer_tree_impl()->property_trees()->scroll_tree; | 2611 child->layer_tree_impl()->property_trees()->scroll_tree; |
| 2587 ScrollNode* scroll_node = scroll_tree.Node(child->scroll_tree_index()); | 2612 ScrollNode* scroll_node = scroll_tree.Node(child->scroll_tree_index()); |
| 2588 for (; scroll_tree.parent(scroll_node); | 2613 for (; scroll_tree.parent(scroll_node); |
| 2589 scroll_node = scroll_tree.parent(scroll_node)) { | 2614 scroll_node = scroll_tree.parent(scroll_node)) { |
| 2590 if (scroll_node->scrollable) | 2615 if (scroll_node->scrollable) |
| 2591 return scroll_node->owner_id == scroll_ancestor->id(); | 2616 return scroll_node->owner_id == scroll_ancestor->id(); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2655 | 2680 |
| 2656 gfx::PointF device_viewport_point = gfx::ScalePoint( | 2681 gfx::PointF device_viewport_point = gfx::ScalePoint( |
| 2657 gfx::PointF(viewport_point), active_tree_->device_scale_factor()); | 2682 gfx::PointF(viewport_point), active_tree_->device_scale_factor()); |
| 2658 LayerImpl* layer_impl = | 2683 LayerImpl* layer_impl = |
| 2659 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point); | 2684 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point); |
| 2660 | 2685 |
| 2661 if (layer_impl) { | 2686 if (layer_impl) { |
| 2662 LayerImpl* scroll_layer_impl = | 2687 LayerImpl* scroll_layer_impl = |
| 2663 active_tree_->FindFirstScrollingLayerOrScrollbarLayerThatIsHitByPoint( | 2688 active_tree_->FindFirstScrollingLayerOrScrollbarLayerThatIsHitByPoint( |
| 2664 device_viewport_point); | 2689 device_viewport_point); |
| 2665 if (scroll_layer_impl && | 2690 if (scroll_layer_impl && !isScrolledBy(layer_impl, scroll_layer_impl)) { |
| 2666 !HasScrollAncestor(layer_impl, scroll_layer_impl)) { | |
| 2667 scroll_status.thread = SCROLL_UNKNOWN; | 2691 scroll_status.thread = SCROLL_UNKNOWN; |
| 2668 scroll_status.main_thread_scrolling_reasons = | 2692 scroll_status.main_thread_scrolling_reasons = |
| 2669 MainThreadScrollingReason::kFailedHitTest; | 2693 MainThreadScrollingReason::kFailedHitTest; |
| 2670 return scroll_status; | 2694 return scroll_status; |
| 2671 } | 2695 } |
| 2672 } | 2696 } |
| 2673 | 2697 |
| 2674 bool scroll_on_main_thread = false; | 2698 bool scroll_on_main_thread = false; |
| 2675 LayerImpl* scrolling_layer_impl = FindScrollLayerForDeviceViewportPoint( | 2699 LayerImpl* scrolling_layer_impl = FindScrollLayerForDeviceViewportPoint( |
| 2676 device_viewport_point, type, layer_impl, &scroll_on_main_thread, | 2700 device_viewport_point, type, layer_impl, &scroll_on_main_thread, |
| (...skipping 1421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4098 if (is_visible) { | 4122 if (is_visible) { |
| 4099 worker_context_visibility_ = | 4123 worker_context_visibility_ = |
| 4100 worker_context->CacheController()->ClientBecameVisible(); | 4124 worker_context->CacheController()->ClientBecameVisible(); |
| 4101 } else { | 4125 } else { |
| 4102 worker_context->CacheController()->ClientBecameNotVisible( | 4126 worker_context->CacheController()->ClientBecameNotVisible( |
| 4103 std::move(worker_context_visibility_)); | 4127 std::move(worker_context_visibility_)); |
| 4104 } | 4128 } |
| 4105 } | 4129 } |
| 4106 | 4130 |
| 4107 } // namespace cc | 4131 } // namespace cc |
| OLD | NEW |