| 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 2482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2493 // Walk up the hierarchy and look for a scrollable layer. | 2493 // Walk up the hierarchy and look for a scrollable layer. |
| 2494 LayerImpl* potentially_scrolling_layer_impl = NULL; | 2494 LayerImpl* potentially_scrolling_layer_impl = NULL; |
| 2495 for (; layer_impl; layer_impl = NextLayerInScrollOrder(layer_impl)) { | 2495 for (; layer_impl; layer_impl = NextLayerInScrollOrder(layer_impl)) { |
| 2496 // The content layer can also block attempts to scroll outside the main | 2496 // The content layer can also block attempts to scroll outside the main |
| 2497 // thread. | 2497 // thread. |
| 2498 ScrollStatus status = | 2498 ScrollStatus status = |
| 2499 layer_impl->TryScroll(device_viewport_point, type, block_mode); | 2499 layer_impl->TryScroll(device_viewport_point, type, block_mode); |
| 2500 if (status.thread == SCROLL_ON_MAIN_THREAD) { | 2500 if (status.thread == SCROLL_ON_MAIN_THREAD) { |
| 2501 if (layer_impl->should_scroll_on_main_thread()) { | 2501 if (layer_impl->should_scroll_on_main_thread()) { |
| 2502 DCHECK_LE(status.main_thread_scrolling_reasons, | 2502 DCHECK_LE(status.main_thread_scrolling_reasons, |
| 2503 MainThreadScrollingReason::kMaxNonTransientScrollingReason); | 2503 MainThreadScrollingReason::kMaxNonTransientScrollingReasons); |
| 2504 } else { | 2504 } else { |
| 2505 DCHECK_GT(status.main_thread_scrolling_reasons, | 2505 DCHECK_GT(status.main_thread_scrolling_reasons, |
| 2506 MainThreadScrollingReason::kMaxNonTransientScrollingReason); | 2506 MainThreadScrollingReason::kMaxNonTransientScrollingReasons); |
| 2507 } | 2507 } |
| 2508 | 2508 |
| 2509 *scroll_on_main_thread = true; | 2509 *scroll_on_main_thread = true; |
| 2510 *main_thread_scrolling_reasons = status.main_thread_scrolling_reasons; | 2510 *main_thread_scrolling_reasons = status.main_thread_scrolling_reasons; |
| 2511 return NULL; | 2511 return NULL; |
| 2512 } | 2512 } |
| 2513 | 2513 |
| 2514 LayerImpl* scroll_layer_impl = FindScrollLayerForContentLayer(layer_impl); | 2514 LayerImpl* scroll_layer_impl = FindScrollLayerForContentLayer(layer_impl); |
| 2515 if (!scroll_layer_impl) | 2515 if (!scroll_layer_impl) |
| 2516 continue; | 2516 continue; |
| 2517 | 2517 |
| 2518 status = | 2518 status = |
| 2519 scroll_layer_impl->TryScroll(device_viewport_point, type, block_mode); | 2519 scroll_layer_impl->TryScroll(device_viewport_point, type, block_mode); |
| 2520 | 2520 |
| 2521 // If any layer wants to divert the scroll event to the main thread, abort. | 2521 // If any layer wants to divert the scroll event to the main thread, abort. |
| 2522 if (status.thread == SCROLL_ON_MAIN_THREAD) { | 2522 if (status.thread == SCROLL_ON_MAIN_THREAD) { |
| 2523 if (layer_impl->should_scroll_on_main_thread()) { | 2523 if (layer_impl->should_scroll_on_main_thread()) { |
| 2524 DCHECK_LE(status.main_thread_scrolling_reasons, | 2524 DCHECK_LE(status.main_thread_scrolling_reasons, |
| 2525 MainThreadScrollingReason::kMaxNonTransientScrollingReason); | 2525 MainThreadScrollingReason::kMaxNonTransientScrollingReasons); |
| 2526 } else { | 2526 } else { |
| 2527 DCHECK_GT(status.main_thread_scrolling_reasons, | 2527 DCHECK_GT(status.main_thread_scrolling_reasons, |
| 2528 MainThreadScrollingReason::kMaxNonTransientScrollingReason); | 2528 MainThreadScrollingReason::kMaxNonTransientScrollingReasons); |
| 2529 } | 2529 } |
| 2530 | 2530 |
| 2531 *scroll_on_main_thread = true; | 2531 *scroll_on_main_thread = true; |
| 2532 *main_thread_scrolling_reasons = status.main_thread_scrolling_reasons; | 2532 *main_thread_scrolling_reasons = status.main_thread_scrolling_reasons; |
| 2533 return NULL; | 2533 return NULL; |
| 2534 } | 2534 } |
| 2535 | 2535 |
| 2536 if (optional_has_ancestor_scroll_handler && | 2536 if (optional_has_ancestor_scroll_handler && |
| 2537 scroll_layer_impl->have_scroll_event_handlers()) | 2537 scroll_layer_impl->have_scroll_event_handlers()) |
| 2538 *optional_has_ancestor_scroll_handler = true; | 2538 *optional_has_ancestor_scroll_handler = true; |
| (...skipping 1380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3919 return task_runner_provider_->HasImplThread(); | 3919 return task_runner_provider_->HasImplThread(); |
| 3920 } | 3920 } |
| 3921 | 3921 |
| 3922 bool LayerTreeHostImpl::CommitToActiveTree() const { | 3922 bool LayerTreeHostImpl::CommitToActiveTree() const { |
| 3923 // In single threaded mode we skip the pending tree and commit directly to the | 3923 // In single threaded mode we skip the pending tree and commit directly to the |
| 3924 // active tree. | 3924 // active tree. |
| 3925 return !task_runner_provider_->HasImplThread(); | 3925 return !task_runner_provider_->HasImplThread(); |
| 3926 } | 3926 } |
| 3927 | 3927 |
| 3928 } // namespace cc | 3928 } // namespace cc |
| OLD | NEW |