| 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 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 584 return layer_impl != NULL; | 584 return layer_impl != NULL; |
| 585 } | 585 } |
| 586 | 586 |
| 587 static LayerImpl* NextLayerInScrollOrder(LayerImpl* layer) { | 587 static LayerImpl* NextLayerInScrollOrder(LayerImpl* layer) { |
| 588 if (layer->scroll_parent()) | 588 if (layer->scroll_parent()) |
| 589 return layer->scroll_parent(); | 589 return layer->scroll_parent(); |
| 590 | 590 |
| 591 return layer->parent(); | 591 return layer->parent(); |
| 592 } | 592 } |
| 593 | 593 |
| 594 static ScrollBlocksOn EffectiveScrollBlocksOn(LayerImpl* layer) { | |
| 595 ScrollBlocksOn blocks = SCROLL_BLOCKS_ON_NONE; | |
| 596 for (; layer; layer = NextLayerInScrollOrder(layer)) { | |
| 597 blocks |= layer->scroll_blocks_on(); | |
| 598 } | |
| 599 return blocks; | |
| 600 } | |
| 601 | |
| 602 bool LayerTreeHostImpl::DoTouchEventsBlockScrollAt( | 594 bool LayerTreeHostImpl::DoTouchEventsBlockScrollAt( |
| 603 const gfx::Point& viewport_point) { | 595 const gfx::Point& viewport_point) { |
| 604 gfx::PointF device_viewport_point = gfx::ScalePoint( | 596 gfx::PointF device_viewport_point = gfx::ScalePoint( |
| 605 gfx::PointF(viewport_point), active_tree_->device_scale_factor()); | 597 gfx::PointF(viewport_point), active_tree_->device_scale_factor()); |
| 606 | 598 |
| 607 // First check if scrolling at this point is required to block on any | |
| 608 // touch event handlers. Note that we must start at the innermost layer | |
| 609 // (as opposed to only the layer found to contain a touch handler region | |
| 610 // below) to ensure all relevant scroll-blocks-on values are applied. | |
| 611 LayerImpl* layer_impl = | |
| 612 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point); | |
| 613 ScrollBlocksOn blocking = EffectiveScrollBlocksOn(layer_impl); | |
| 614 if (!(blocking & SCROLL_BLOCKS_ON_START_TOUCH)) | |
| 615 return false; | |
| 616 | |
| 617 // Now determine if there are actually any handlers at that point. | 599 // Now determine if there are actually any handlers at that point. |
| 618 // TODO(rbyers): Consider also honoring touch-action (crbug.com/347272). | 600 // TODO(rbyers): Consider also honoring touch-action (crbug.com/347272). |
| 619 layer_impl = active_tree_->FindLayerThatIsHitByPointInTouchHandlerRegion( | 601 LayerImpl* layer_impl = |
| 620 device_viewport_point); | 602 active_tree_->FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 603 device_viewport_point); |
| 621 return layer_impl != NULL; | 604 return layer_impl != NULL; |
| 622 } | 605 } |
| 623 | 606 |
| 624 scoped_ptr<SwapPromiseMonitor> | 607 scoped_ptr<SwapPromiseMonitor> |
| 625 LayerTreeHostImpl::CreateLatencyInfoSwapPromiseMonitor( | 608 LayerTreeHostImpl::CreateLatencyInfoSwapPromiseMonitor( |
| 626 ui::LatencyInfo* latency) { | 609 ui::LatencyInfo* latency) { |
| 627 return make_scoped_ptr( | 610 return make_scoped_ptr( |
| 628 new LatencyInfoSwapPromiseMonitor(latency, NULL, this)); | 611 new LatencyInfoSwapPromiseMonitor(latency, NULL, this)); |
| 629 } | 612 } |
| 630 | 613 |
| (...skipping 1852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2483 InputHandler::ScrollInputType type, | 2466 InputHandler::ScrollInputType type, |
| 2484 LayerImpl* layer_impl, | 2467 LayerImpl* layer_impl, |
| 2485 bool* scroll_on_main_thread, | 2468 bool* scroll_on_main_thread, |
| 2486 bool* optional_has_ancestor_scroll_handler, | 2469 bool* optional_has_ancestor_scroll_handler, |
| 2487 uint32_t* main_thread_scrolling_reasons) const { | 2470 uint32_t* main_thread_scrolling_reasons) const { |
| 2488 DCHECK(scroll_on_main_thread); | 2471 DCHECK(scroll_on_main_thread); |
| 2489 DCHECK(main_thread_scrolling_reasons); | 2472 DCHECK(main_thread_scrolling_reasons); |
| 2490 *main_thread_scrolling_reasons = | 2473 *main_thread_scrolling_reasons = |
| 2491 MainThreadScrollingReason::kNotScrollingOnMain; | 2474 MainThreadScrollingReason::kNotScrollingOnMain; |
| 2492 | 2475 |
| 2493 ScrollBlocksOn block_mode = EffectiveScrollBlocksOn(layer_impl); | |
| 2494 | |
| 2495 // Walk up the hierarchy and look for a scrollable layer. | 2476 // Walk up the hierarchy and look for a scrollable layer. |
| 2496 LayerImpl* potentially_scrolling_layer_impl = NULL; | 2477 LayerImpl* potentially_scrolling_layer_impl = NULL; |
| 2497 for (; layer_impl; layer_impl = NextLayerInScrollOrder(layer_impl)) { | 2478 for (; layer_impl; layer_impl = NextLayerInScrollOrder(layer_impl)) { |
| 2498 // The content layer can also block attempts to scroll outside the main | 2479 // The content layer can also block attempts to scroll outside the main |
| 2499 // thread. | 2480 // thread. |
| 2500 ScrollStatus status = | 2481 ScrollStatus status = layer_impl->TryScroll(device_viewport_point, type); |
| 2501 layer_impl->TryScroll(device_viewport_point, type, block_mode); | |
| 2502 if (status.thread == SCROLL_ON_MAIN_THREAD) { | 2482 if (status.thread == SCROLL_ON_MAIN_THREAD) { |
| 2503 if (layer_impl->should_scroll_on_main_thread()) { | 2483 if (layer_impl->should_scroll_on_main_thread()) { |
| 2504 DCHECK_LE(status.main_thread_scrolling_reasons, | 2484 DCHECK_LE(status.main_thread_scrolling_reasons, |
| 2505 MainThreadScrollingReason::kMaxNonTransientScrollingReasons); | 2485 MainThreadScrollingReason::kMaxNonTransientScrollingReasons); |
| 2506 } else { | 2486 } else { |
| 2507 DCHECK_GT(status.main_thread_scrolling_reasons, | 2487 DCHECK_GT(status.main_thread_scrolling_reasons, |
| 2508 MainThreadScrollingReason::kMaxNonTransientScrollingReasons); | 2488 MainThreadScrollingReason::kMaxNonTransientScrollingReasons); |
| 2509 } | 2489 } |
| 2510 | 2490 |
| 2511 *scroll_on_main_thread = true; | 2491 *scroll_on_main_thread = true; |
| 2512 *main_thread_scrolling_reasons = status.main_thread_scrolling_reasons; | 2492 *main_thread_scrolling_reasons = status.main_thread_scrolling_reasons; |
| 2513 return NULL; | 2493 return NULL; |
| 2514 } | 2494 } |
| 2515 | 2495 |
| 2516 LayerImpl* scroll_layer_impl = FindScrollLayerForContentLayer(layer_impl); | 2496 LayerImpl* scroll_layer_impl = FindScrollLayerForContentLayer(layer_impl); |
| 2517 if (!scroll_layer_impl) | 2497 if (!scroll_layer_impl) |
| 2518 continue; | 2498 continue; |
| 2519 | 2499 |
| 2520 status = | 2500 status = scroll_layer_impl->TryScroll(device_viewport_point, type); |
| 2521 scroll_layer_impl->TryScroll(device_viewport_point, type, block_mode); | |
| 2522 | 2501 |
| 2523 // If any layer wants to divert the scroll event to the main thread, abort. | 2502 // If any layer wants to divert the scroll event to the main thread, abort. |
| 2524 if (status.thread == SCROLL_ON_MAIN_THREAD) { | 2503 if (status.thread == SCROLL_ON_MAIN_THREAD) { |
| 2525 if (layer_impl->should_scroll_on_main_thread()) { | 2504 if (layer_impl->should_scroll_on_main_thread()) { |
| 2526 DCHECK_LE(status.main_thread_scrolling_reasons, | 2505 DCHECK_LE(status.main_thread_scrolling_reasons, |
| 2527 MainThreadScrollingReason::kMaxNonTransientScrollingReasons); | 2506 MainThreadScrollingReason::kMaxNonTransientScrollingReasons); |
| 2528 } else { | 2507 } else { |
| 2529 DCHECK_GT(status.main_thread_scrolling_reasons, | 2508 DCHECK_GT(status.main_thread_scrolling_reasons, |
| 2530 MainThreadScrollingReason::kMaxNonTransientScrollingReasons); | 2509 MainThreadScrollingReason::kMaxNonTransientScrollingReasons); |
| 2531 } | 2510 } |
| (...skipping 1388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3920 return task_runner_provider_->HasImplThread(); | 3899 return task_runner_provider_->HasImplThread(); |
| 3921 } | 3900 } |
| 3922 | 3901 |
| 3923 bool LayerTreeHostImpl::CommitToActiveTree() const { | 3902 bool LayerTreeHostImpl::CommitToActiveTree() const { |
| 3924 // In single threaded mode we skip the pending tree and commit directly to the | 3903 // In single threaded mode we skip the pending tree and commit directly to the |
| 3925 // active tree. | 3904 // active tree. |
| 3926 return !task_runner_provider_->HasImplThread(); | 3905 return !task_runner_provider_->HasImplThread(); |
| 3927 } | 3906 } |
| 3928 | 3907 |
| 3929 } // namespace cc | 3908 } // namespace cc |
| OLD | NEW |