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 <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
(...skipping 2378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2389 // notifications while preventing scroll updates from being unintentionally | 2389 // notifications while preventing scroll updates from being unintentionally |
2390 // forwarded to the main thread. The inner viewport layer represents the | 2390 // forwarded to the main thread. The inner viewport layer represents the |
2391 // viewport during scrolling. | 2391 // viewport during scrolling. |
2392 if (!potentially_scrolling_layer_impl) | 2392 if (!potentially_scrolling_layer_impl) |
2393 potentially_scrolling_layer_impl = InnerViewportScrollLayer(); | 2393 potentially_scrolling_layer_impl = InnerViewportScrollLayer(); |
2394 | 2394 |
2395 // The inner viewport layer represents the viewport. | 2395 // The inner viewport layer represents the viewport. |
2396 if (potentially_scrolling_layer_impl == OuterViewportScrollLayer()) | 2396 if (potentially_scrolling_layer_impl == OuterViewportScrollLayer()) |
2397 potentially_scrolling_layer_impl = InnerViewportScrollLayer(); | 2397 potentially_scrolling_layer_impl = InnerViewportScrollLayer(); |
2398 | 2398 |
2399 // Animated wheel scrolls need to scroll the outer viewport layer, and do not | |
2400 // go through Viewport::ScrollBy which would normally handle the distribution. | |
2401 // NOTE: This will need refactoring if we want smooth scrolling on Android. | |
2402 if (type == ANIMATED_WHEEL && | |
2403 potentially_scrolling_layer_impl == InnerViewportScrollLayer()) { | |
2404 potentially_scrolling_layer_impl = OuterViewportScrollLayer(); | |
ymalik
2015/10/19 22:36:54
Instead of adding a new ScrollInputType, I wonder
| |
2405 } | |
2406 | |
2399 return potentially_scrolling_layer_impl; | 2407 return potentially_scrolling_layer_impl; |
2400 } | 2408 } |
2401 | 2409 |
2402 // Similar to LayerImpl::HasAncestor, but walks up the scroll parents. | 2410 // Similar to LayerImpl::HasAncestor, but walks up the scroll parents. |
2403 static bool HasScrollAncestor(LayerImpl* child, LayerImpl* scroll_ancestor) { | 2411 static bool HasScrollAncestor(LayerImpl* child, LayerImpl* scroll_ancestor) { |
2404 DCHECK(scroll_ancestor); | 2412 DCHECK(scroll_ancestor); |
2405 for (LayerImpl* ancestor = child; ancestor; | 2413 for (LayerImpl* ancestor = child; ancestor; |
2406 ancestor = NextLayerInScrollOrder(ancestor)) { | 2414 ancestor = NextLayerInScrollOrder(ancestor)) { |
2407 if (ancestor->scrollable()) | 2415 if (ancestor->scrollable()) |
2408 return ancestor == scroll_ancestor; | 2416 return ancestor == scroll_ancestor; |
2409 } | 2417 } |
2410 return false; | 2418 return false; |
2411 } | 2419 } |
2412 | 2420 |
2413 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollBeginImpl( | 2421 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollBeginImpl( |
2414 LayerImpl* scrolling_layer_impl, | 2422 LayerImpl* scrolling_layer_impl, |
2415 InputHandler::ScrollInputType type) { | 2423 InputHandler::ScrollInputType type) { |
2416 if (!scrolling_layer_impl) | 2424 if (!scrolling_layer_impl) |
2417 return SCROLL_IGNORED; | 2425 return SCROLL_IGNORED; |
2418 | 2426 |
2419 top_controls_manager_->ScrollBegin(); | 2427 top_controls_manager_->ScrollBegin(); |
2420 | 2428 |
2421 active_tree_->SetCurrentlyScrollingLayer(scrolling_layer_impl); | 2429 active_tree_->SetCurrentlyScrollingLayer(scrolling_layer_impl); |
2422 wheel_scrolling_ = (type == WHEEL); | 2430 wheel_scrolling_ = (type == WHEEL || type == ANIMATED_WHEEL); |
2423 client_->RenewTreePriority(); | 2431 client_->RenewTreePriority(); |
2424 UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", false); | 2432 UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", false); |
2425 return SCROLL_STARTED; | 2433 return SCROLL_STARTED; |
2426 } | 2434 } |
2427 | 2435 |
2428 InputHandler::ScrollStatus LayerTreeHostImpl::RootScrollBegin( | 2436 InputHandler::ScrollStatus LayerTreeHostImpl::RootScrollBegin( |
2429 InputHandler::ScrollInputType type) { | 2437 InputHandler::ScrollInputType type) { |
2430 TRACE_EVENT0("cc", "LayerTreeHostImpl::RootScrollBegin"); | 2438 TRACE_EVENT0("cc", "LayerTreeHostImpl::RootScrollBegin"); |
2431 | 2439 |
2432 DCHECK(!CurrentlyScrollingLayer()); | 2440 DCHECK(!CurrentlyScrollingLayer()); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2473 const gfx::Point& viewport_point, | 2481 const gfx::Point& viewport_point, |
2474 const gfx::Vector2dF& scroll_delta) { | 2482 const gfx::Vector2dF& scroll_delta) { |
2475 if (LayerImpl* layer_impl = CurrentlyScrollingLayer()) { | 2483 if (LayerImpl* layer_impl = CurrentlyScrollingLayer()) { |
2476 return ScrollAnimationUpdateTarget(layer_impl, scroll_delta) | 2484 return ScrollAnimationUpdateTarget(layer_impl, scroll_delta) |
2477 ? SCROLL_STARTED | 2485 ? SCROLL_STARTED |
2478 : SCROLL_IGNORED; | 2486 : SCROLL_IGNORED; |
2479 } | 2487 } |
2480 // ScrollAnimated is only used for wheel scrolls. We use the same bubbling | 2488 // ScrollAnimated is only used for wheel scrolls. We use the same bubbling |
2481 // behavior as ScrollBy to determine which layer to animate, but we do not | 2489 // behavior as ScrollBy to determine which layer to animate, but we do not |
2482 // do the Android-specific things in ScrollBy like showing top controls. | 2490 // do the Android-specific things in ScrollBy like showing top controls. |
2483 InputHandler::ScrollStatus scroll_status = ScrollBegin(viewport_point, WHEEL); | 2491 InputHandler::ScrollStatus scroll_status = |
2492 ScrollBegin(viewport_point, ANIMATED_WHEEL); | |
2484 if (scroll_status == SCROLL_STARTED) { | 2493 if (scroll_status == SCROLL_STARTED) { |
2485 gfx::Vector2dF pending_delta = scroll_delta; | 2494 gfx::Vector2dF pending_delta = scroll_delta; |
2486 for (LayerImpl* layer_impl = CurrentlyScrollingLayer(); layer_impl; | 2495 for (LayerImpl* layer_impl = CurrentlyScrollingLayer(); layer_impl; |
2487 layer_impl = NextLayerInScrollOrder(layer_impl)) { | 2496 layer_impl = NextLayerInScrollOrder(layer_impl)) { |
2488 // The inner viewport layer represents the viewport. | 2497 if (!layer_impl->scrollable()) |
2489 if (!layer_impl->scrollable() || layer_impl == OuterViewportScrollLayer()) | |
2490 continue; | 2498 continue; |
2491 | 2499 |
2492 gfx::ScrollOffset current_offset = layer_impl->CurrentScrollOffset(); | 2500 gfx::ScrollOffset current_offset = layer_impl->CurrentScrollOffset(); |
2493 gfx::ScrollOffset target_offset = | 2501 gfx::ScrollOffset target_offset = |
2494 ScrollOffsetWithDelta(current_offset, pending_delta); | 2502 ScrollOffsetWithDelta(current_offset, pending_delta); |
2495 target_offset.SetToMax(gfx::ScrollOffset()); | 2503 target_offset.SetToMax(gfx::ScrollOffset()); |
2496 target_offset.SetToMin(layer_impl->MaxScrollOffset()); | 2504 target_offset.SetToMin(layer_impl->MaxScrollOffset()); |
2497 gfx::Vector2dF actual_delta = target_offset.DeltaFrom(current_offset); | 2505 gfx::Vector2dF actual_delta = target_offset.DeltaFrom(current_offset); |
2498 | 2506 |
2499 const float kEpsilon = 0.1f; | 2507 const float kEpsilon = 0.1f; |
(...skipping 1108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3608 if (active_tree()) { | 3616 if (active_tree()) { |
3609 LayerAnimationValueProvider* layer = active_tree()->LayerById(layer_id); | 3617 LayerAnimationValueProvider* layer = active_tree()->LayerById(layer_id); |
3610 if (layer) | 3618 if (layer) |
3611 return layer->ScrollOffsetForAnimation(); | 3619 return layer->ScrollOffsetForAnimation(); |
3612 } | 3620 } |
3613 | 3621 |
3614 return gfx::ScrollOffset(); | 3622 return gfx::ScrollOffset(); |
3615 } | 3623 } |
3616 | 3624 |
3617 } // namespace cc | 3625 } // namespace cc |
OLD | NEW |