Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(80)

Side by Side Diff: cc/trees/layer_tree_host_impl.cc

Issue 2388563002: Clean up viewport scrolling methods in CC (Closed)
Patch Set: Fix tests Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/trees/layer_tree_host_impl.h ('k') | ui/events/blink/input_handler_proxy.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 // mithro(TODO): Enable these checks. 445 // mithro(TODO): Enable these checks.
446 // DCHECK(!current_begin_frame_tracker_.HasFinished()); 446 // DCHECK(!current_begin_frame_tracker_.HasFinished());
447 // DCHECK(monotonic_time == current_begin_frame_tracker_.Current().frame_time) 447 // DCHECK(monotonic_time == current_begin_frame_tracker_.Current().frame_time)
448 // << "Called animate with unknown frame time!?"; 448 // << "Called animate with unknown frame time!?";
449 449
450 bool did_animate = false; 450 bool did_animate = false;
451 451
452 if (input_handler_client_) { 452 if (input_handler_client_) {
453 // This animates fling scrolls. But on Android WebView root flings are 453 // This animates fling scrolls. But on Android WebView root flings are
454 // controlled by the application, so the compositor does not animate them. 454 // controlled by the application, so the compositor does not animate them.
455 bool ignore_fling = settings_.ignore_root_layer_flings && 455 bool ignore_fling =
456 IsCurrentlyScrollingInnerViewport(); 456 settings_.ignore_root_layer_flings && IsCurrentlyScrollingViewport();
457 if (!ignore_fling) { 457 if (!ignore_fling) {
458 // This does not set did_animate, because if the InputHandlerClient 458 // This does not set did_animate, because if the InputHandlerClient
459 // changes anything it will be through the InputHandler interface which 459 // changes anything it will be through the InputHandler interface which
460 // does SetNeedsRedraw. 460 // does SetNeedsRedraw.
461 input_handler_client_->Animate(monotonic_time); 461 input_handler_client_->Animate(monotonic_time);
462 } 462 }
463 } 463 }
464 464
465 did_animate |= AnimatePageScale(monotonic_time); 465 did_animate |= AnimatePageScale(monotonic_time);
466 did_animate |= AnimateLayers(monotonic_time); 466 did_animate |= AnimateLayers(monotonic_time);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 page_scale_animation_->ZoomTo(scaled_target_offset, page_scale, 535 page_scale_animation_->ZoomTo(scaled_target_offset, page_scale,
536 duration.InSecondsF()); 536 duration.InSecondsF());
537 } 537 }
538 538
539 SetNeedsOneBeginImplFrame(); 539 SetNeedsOneBeginImplFrame();
540 client_->SetNeedsCommitOnImplThread(); 540 client_->SetNeedsCommitOnImplThread();
541 client_->RenewTreePriority(); 541 client_->RenewTreePriority();
542 } 542 }
543 543
544 void LayerTreeHostImpl::SetNeedsAnimateInput() { 544 void LayerTreeHostImpl::SetNeedsAnimateInput() {
545 DCHECK(!IsCurrentlyScrollingInnerViewport() || 545 DCHECK(!IsCurrentlyScrollingViewport() ||
546 !settings_.ignore_root_layer_flings); 546 !settings_.ignore_root_layer_flings);
547 SetNeedsOneBeginImplFrame(); 547 SetNeedsOneBeginImplFrame();
548 } 548 }
549 549
550 bool LayerTreeHostImpl::IsCurrentlyScrollingInnerViewport() const { 550 bool LayerTreeHostImpl::IsCurrentlyScrollingViewport() const {
551 LayerImpl* scrolling_layer = CurrentlyScrollingLayer(); 551 LayerImpl* scrolling_layer = CurrentlyScrollingLayer();
552 if (!scrolling_layer) 552 if (!scrolling_layer)
553 return false; 553 return false;
554 return scrolling_layer == InnerViewportScrollLayer(); 554 DCHECK(viewport());
555 return scrolling_layer == viewport()->MainScrollLayer();
555 } 556 }
556 557
557 bool LayerTreeHostImpl::IsCurrentlyScrollingLayerAt( 558 bool LayerTreeHostImpl::IsCurrentlyScrollingLayerAt(
558 const gfx::Point& viewport_point, 559 const gfx::Point& viewport_point,
559 InputHandler::ScrollInputType type) const { 560 InputHandler::ScrollInputType type) const {
560 LayerImpl* scrolling_layer_impl = CurrentlyScrollingLayer(); 561 LayerImpl* scrolling_layer_impl = CurrentlyScrollingLayer();
561 if (!scrolling_layer_impl) 562 if (!scrolling_layer_impl)
562 return false; 563 return false;
563 564
564 gfx::PointF device_viewport_point = gfx::ScalePoint( 565 gfx::PointF device_viewport_point = gfx::ScalePoint(
565 gfx::PointF(viewport_point), active_tree_->device_scale_factor()); 566 gfx::PointF(viewport_point), active_tree_->device_scale_factor());
566 567
567 LayerImpl* layer_impl = 568 LayerImpl* layer_impl =
568 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point); 569 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point);
569 570
570 bool scroll_on_main_thread = false; 571 bool scroll_on_main_thread = false;
571 uint32_t main_thread_scrolling_reasons; 572 uint32_t main_thread_scrolling_reasons;
572 LayerImpl* test_layer_impl = FindScrollLayerForDeviceViewportPoint( 573 LayerImpl* test_layer_impl = FindScrollLayerForDeviceViewportPoint(
573 device_viewport_point, type, layer_impl, &scroll_on_main_thread, 574 device_viewport_point, type, layer_impl, &scroll_on_main_thread,
574 &main_thread_scrolling_reasons); 575 &main_thread_scrolling_reasons);
575 576
576 if (!test_layer_impl) 577 if (!test_layer_impl)
577 return false; 578 return false;
578 579
579 if (scrolling_layer_impl == test_layer_impl) 580 if (scrolling_layer_impl == test_layer_impl)
580 return true; 581 return true;
581 582
582 // For active scrolling state treat the inner/outer viewports interchangeably. 583 // For active scrolling state treat the inner/outer viewports interchangeably.
583 if ((scrolling_layer_impl == InnerViewportScrollLayer() && 584 if (scrolling_layer_impl == InnerViewportScrollLayer() ||
584 test_layer_impl == OuterViewportScrollLayer()) || 585 scrolling_layer_impl == OuterViewportScrollLayer()) {
585 (scrolling_layer_impl == OuterViewportScrollLayer() && 586 return test_layer_impl == viewport()->MainScrollLayer();
586 test_layer_impl == InnerViewportScrollLayer())) {
587 return true;
588 } 587 }
589 588
590 return false; 589 return false;
591 } 590 }
592 591
593 EventListenerProperties LayerTreeHostImpl::GetEventListenerProperties( 592 EventListenerProperties LayerTreeHostImpl::GetEventListenerProperties(
594 EventListenerClass event_class) const { 593 EventListenerClass event_class) const {
595 return active_tree_->event_listener_properties(event_class); 594 return active_tree_->event_listener_properties(event_class);
596 } 595 }
597 596
(...skipping 1324 matching lines...) Expand 10 before | Expand all | Expand 10 after
1922 LayerImpl* LayerTreeHostImpl::CurrentlyScrollingLayer() const { 1921 LayerImpl* LayerTreeHostImpl::CurrentlyScrollingLayer() const {
1923 return active_tree_->CurrentlyScrollingLayer(); 1922 return active_tree_->CurrentlyScrollingLayer();
1924 } 1923 }
1925 1924
1926 bool LayerTreeHostImpl::IsActivelyScrolling() const { 1925 bool LayerTreeHostImpl::IsActivelyScrolling() const {
1927 if (!CurrentlyScrollingLayer()) 1926 if (!CurrentlyScrollingLayer())
1928 return false; 1927 return false;
1929 // On Android WebView root flings are controlled by the application, 1928 // On Android WebView root flings are controlled by the application,
1930 // so the compositor does not animate them and can't tell if they 1929 // so the compositor does not animate them and can't tell if they
1931 // are actually animating. So assume there are none. 1930 // are actually animating. So assume there are none.
1932 if (settings_.ignore_root_layer_flings && IsCurrentlyScrollingInnerViewport()) 1931 if (settings_.ignore_root_layer_flings && IsCurrentlyScrollingViewport())
1933 return false; 1932 return false;
1934 return did_lock_scrolling_layer_; 1933 return did_lock_scrolling_layer_;
1935 } 1934 }
1936 1935
1937 void LayerTreeHostImpl::CreatePendingTree() { 1936 void LayerTreeHostImpl::CreatePendingTree() {
1938 CHECK(!pending_tree_); 1937 CHECK(!pending_tree_);
1939 if (recycle_tree_) { 1938 if (recycle_tree_) {
1940 recycle_tree_.swap(pending_tree_); 1939 recycle_tree_.swap(pending_tree_);
1941 } else { 1940 } else {
1942 pending_tree_ = base::MakeUnique<LayerTreeImpl>( 1941 pending_tree_ = base::MakeUnique<LayerTreeImpl>(
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after
2544 } 2543 }
2545 2544
2546 if (status.thread == InputHandler::SCROLL_ON_IMPL_THREAD && 2545 if (status.thread == InputHandler::SCROLL_ON_IMPL_THREAD &&
2547 !potentially_scrolling_layer_impl) { 2546 !potentially_scrolling_layer_impl) {
2548 potentially_scrolling_layer_impl = 2547 potentially_scrolling_layer_impl =
2549 active_tree_->LayerById(scroll_node->owner_id); 2548 active_tree_->LayerById(scroll_node->owner_id);
2550 } 2549 }
2551 } 2550 }
2552 } 2551 }
2553 2552
2554 // Falling back to the root scroll layer ensures generation of root overscroll 2553 // Falling back to the viewport layer ensures generation of root overscroll
2555 // notifications. The inner viewport layer represents the viewport during 2554 // notifications. We use the viewport's main scroll layer to represent the
2556 // scrolling. 2555 // viewport in scrolling code.
2557 if (!potentially_scrolling_layer_impl) 2556 if (!potentially_scrolling_layer_impl ||
2558 potentially_scrolling_layer_impl = InnerViewportScrollLayer(); 2557 potentially_scrolling_layer_impl == OuterViewportScrollLayer() ||
2559 2558 potentially_scrolling_layer_impl == InnerViewportScrollLayer()) {
2560 // The inner viewport layer represents the viewport. 2559 potentially_scrolling_layer_impl = viewport()->MainScrollLayer();
2561 if (potentially_scrolling_layer_impl == OuterViewportScrollLayer()) 2560 }
2562 potentially_scrolling_layer_impl = InnerViewportScrollLayer();
2563 2561
2564 if (potentially_scrolling_layer_impl) { 2562 if (potentially_scrolling_layer_impl) {
2565 // Ensure that final layer scrolls on impl thread (crbug.com/625100) 2563 // Ensure that final layer scrolls on impl thread (crbug.com/625100)
2566 ScrollNode* scroll_node = 2564 ScrollNode* scroll_node =
2567 scroll_tree.Node(potentially_scrolling_layer_impl->scroll_tree_index()); 2565 scroll_tree.Node(potentially_scrolling_layer_impl->scroll_tree_index());
2568 ScrollStatus status = 2566 ScrollStatus status =
2569 TryScroll(device_viewport_point, type, scroll_tree, scroll_node); 2567 TryScroll(device_viewport_point, type, scroll_tree, scroll_node);
2570 if (IsMainThreadScrolling(status, scroll_node)) { 2568 if (IsMainThreadScrolling(status, scroll_node)) {
2571 *scroll_on_main_thread = true; 2569 *scroll_on_main_thread = true;
2572 *main_thread_scrolling_reasons = status.main_thread_scrolling_reasons; 2570 *main_thread_scrolling_reasons = status.main_thread_scrolling_reasons;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
2629 return scroll_status; 2627 return scroll_status;
2630 } 2628 }
2631 2629
2632 InputHandler::ScrollStatus LayerTreeHostImpl::RootScrollBegin( 2630 InputHandler::ScrollStatus LayerTreeHostImpl::RootScrollBegin(
2633 ScrollState* scroll_state, 2631 ScrollState* scroll_state,
2634 InputHandler::ScrollInputType type) { 2632 InputHandler::ScrollInputType type) {
2635 TRACE_EVENT0("cc", "LayerTreeHostImpl::RootScrollBegin"); 2633 TRACE_EVENT0("cc", "LayerTreeHostImpl::RootScrollBegin");
2636 2634
2637 ClearCurrentlyScrollingLayer(); 2635 ClearCurrentlyScrollingLayer();
2638 2636
2639 return ScrollBeginImpl(scroll_state, InnerViewportScrollLayer(), type); 2637 DCHECK(viewport());
2638 return ScrollBeginImpl(scroll_state, viewport()->MainScrollLayer(), type);
2640 } 2639 }
2641 2640
2642 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollBegin( 2641 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollBegin(
2643 ScrollState* scroll_state, 2642 ScrollState* scroll_state,
2644 InputHandler::ScrollInputType type) { 2643 InputHandler::ScrollInputType type) {
2645 ScrollStatus scroll_status; 2644 ScrollStatus scroll_status;
2646 scroll_status.main_thread_scrolling_reasons = 2645 scroll_status.main_thread_scrolling_reasons =
2647 MainThreadScrollingReason::kNotScrollingOnMain; 2646 MainThreadScrollingReason::kNotScrollingOnMain;
2648 TRACE_EVENT0("cc", "LayerTreeHostImpl::ScrollBegin"); 2647 TRACE_EVENT0("cc", "LayerTreeHostImpl::ScrollBegin");
2649 2648
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
2980 ScrollState* scroll_state) { 2979 ScrollState* scroll_state) {
2981 DCHECK(scroll_state); 2980 DCHECK(scroll_state);
2982 gfx::Point viewport_point(scroll_state->position_x(), 2981 gfx::Point viewport_point(scroll_state->position_x(),
2983 scroll_state->position_y()); 2982 scroll_state->position_y());
2984 const gfx::Vector2dF delta(scroll_state->delta_x(), scroll_state->delta_y()); 2983 const gfx::Vector2dF delta(scroll_state->delta_x(), scroll_state->delta_y());
2985 gfx::Vector2dF applied_delta; 2984 gfx::Vector2dF applied_delta;
2986 // TODO(tdresser): Use a more rational epsilon. See crbug.com/510550 for 2985 // TODO(tdresser): Use a more rational epsilon. See crbug.com/510550 for
2987 // details. 2986 // details.
2988 const float kEpsilon = 0.1f; 2987 const float kEpsilon = 0.1f;
2989 2988
2990 if (scroll_node->is_inner_viewport_scroll_layer) { 2989 bool is_viewport_scroll_layer =
2990 viewport()->MainScrollLayer() &&
2991 scroll_node->owner_id == viewport()->MainScrollLayer()->id();
2992
2993 if (is_viewport_scroll_layer) {
2991 bool affect_top_controls = !wheel_scrolling_; 2994 bool affect_top_controls = !wheel_scrolling_;
2992 Viewport::ScrollResult result = viewport()->ScrollBy( 2995 Viewport::ScrollResult result = viewport()->ScrollBy(
2993 delta, viewport_point, scroll_state->is_direct_manipulation(), 2996 delta, viewport_point, scroll_state->is_direct_manipulation(),
2994 affect_top_controls); 2997 affect_top_controls);
2995 applied_delta = result.consumed_delta; 2998 applied_delta = result.consumed_delta;
2996 scroll_state->set_caused_scroll( 2999 scroll_state->set_caused_scroll(
2997 std::abs(result.content_scrolled_delta.x()) > kEpsilon, 3000 std::abs(result.content_scrolled_delta.x()) > kEpsilon,
2998 std::abs(result.content_scrolled_delta.y()) > kEpsilon); 3001 std::abs(result.content_scrolled_delta.y()) > kEpsilon);
2999 scroll_state->ConsumeDelta(applied_delta.x(), applied_delta.y()); 3002 scroll_state->ConsumeDelta(applied_delta.x(), applied_delta.y());
3000 } else { 3003 } else {
3001 applied_delta = ScrollSingleNode( 3004 applied_delta = ScrollSingleNode(
3002 scroll_node, delta, viewport_point, 3005 scroll_node, delta, viewport_point,
3003 scroll_state->is_direct_manipulation(), 3006 scroll_state->is_direct_manipulation(),
3004 &scroll_state->layer_tree_impl()->property_trees()->scroll_tree); 3007 &scroll_state->layer_tree_impl()->property_trees()->scroll_tree);
3005 } 3008 }
3006 3009
3007 // If the layer wasn't able to move, try the next one in the hierarchy. 3010 // If the layer wasn't able to move, try the next one in the hierarchy.
3008 bool scrolled = std::abs(applied_delta.x()) > kEpsilon; 3011 bool scrolled = std::abs(applied_delta.x()) > kEpsilon;
3009 scrolled = scrolled || std::abs(applied_delta.y()) > kEpsilon; 3012 scrolled = scrolled || std::abs(applied_delta.y()) > kEpsilon;
3010 3013
3011 if (scrolled && !scroll_node->is_inner_viewport_scroll_layer) { 3014 if (scrolled && !is_viewport_scroll_layer) {
3012 // If the applied delta is within 45 degrees of the input 3015 // If the applied delta is within 45 degrees of the input
3013 // delta, bail out to make it easier to scroll just one layer 3016 // delta, bail out to make it easier to scroll just one layer
3014 // in one direction without affecting any of its parents. 3017 // in one direction without affecting any of its parents.
3015 float angle_threshold = 45; 3018 float angle_threshold = 45;
3016 if (MathUtil::SmallestAngleBetweenVectors(applied_delta, delta) < 3019 if (MathUtil::SmallestAngleBetweenVectors(applied_delta, delta) <
3017 angle_threshold) { 3020 angle_threshold) {
3018 applied_delta = delta; 3021 applied_delta = delta;
3019 } else { 3022 } else {
3020 // Allow further movement only on an axis perpendicular to the direction 3023 // Allow further movement only on an axis perpendicular to the direction
3021 // in which the layer moved. 3024 // in which the layer moved.
(...skipping 15 matching lines...) Expand all
3037 // is not the case here. We eventually want to have the same behaviour on both 3040 // is not the case here. We eventually want to have the same behaviour on both
3038 // sides but it may become a non issue if we get rid of scroll chaining (see 3041 // sides but it may become a non issue if we get rid of scroll chaining (see
3039 // crbug.com/526462) 3042 // crbug.com/526462)
3040 std::list<const ScrollNode*> current_scroll_chain; 3043 std::list<const ScrollNode*> current_scroll_chain;
3041 ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree; 3044 ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree;
3042 ScrollNode* scroll_node = scroll_tree.CurrentlyScrollingNode(); 3045 ScrollNode* scroll_node = scroll_tree.CurrentlyScrollingNode();
3043 if (scroll_node) { 3046 if (scroll_node) {
3044 for (; scroll_tree.parent(scroll_node); 3047 for (; scroll_tree.parent(scroll_node);
3045 scroll_node = scroll_tree.parent(scroll_node)) { 3048 scroll_node = scroll_tree.parent(scroll_node)) {
3046 if (scroll_node->is_outer_viewport_scroll_layer) { 3049 if (scroll_node->is_outer_viewport_scroll_layer) {
3050 // TODO(bokan): This should use Viewport::MainScrollLayer once that
3051 // returns the outer viewport scroll layer.
3047 // Don't chain scrolls past the outer viewport scroll layer. Once we 3052 // Don't chain scrolls past the outer viewport scroll layer. Once we
3048 // reach that, we should scroll the viewport, which is represented by 3053 // reach that, we should scroll the viewport which is represented by the
3049 // the inner viewport scroll layer. 3054 // main viewport scroll layer.
3050 ScrollNode* inner_viewport_scroll_node = 3055 DCHECK(viewport()->MainScrollLayer());
3051 scroll_tree.Node(InnerViewportScrollLayer()->scroll_tree_index()); 3056 ScrollNode* viewport_scroll_node = scroll_tree.Node(
3052 current_scroll_chain.push_front(inner_viewport_scroll_node); 3057 viewport()->MainScrollLayer()->scroll_tree_index());
3058 DCHECK(viewport_scroll_node);
3059 current_scroll_chain.push_front(viewport_scroll_node);
3053 break; 3060 break;
3054 } 3061 }
3055 3062
3056 if (!scroll_node->scrollable) 3063 if (!scroll_node->scrollable)
3057 continue; 3064 continue;
3058 3065
3059 current_scroll_chain.push_front(scroll_node); 3066 current_scroll_chain.push_front(scroll_node);
3060 } 3067 }
3061 } 3068 }
3062 scroll_state->set_scroll_chain_and_layer_tree(current_scroll_chain, 3069 scroll_state->set_scroll_chain_and_layer_tree(current_scroll_chain,
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
3238 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point); 3245 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point);
3239 HandleMouseOverScrollbar(layer_impl); 3246 HandleMouseOverScrollbar(layer_impl);
3240 if (scroll_layer_id_when_mouse_over_scrollbar_ != Layer::INVALID_ID) 3247 if (scroll_layer_id_when_mouse_over_scrollbar_ != Layer::INVALID_ID)
3241 return; 3248 return;
3242 3249
3243 bool scroll_on_main_thread = false; 3250 bool scroll_on_main_thread = false;
3244 uint32_t main_thread_scrolling_reasons; 3251 uint32_t main_thread_scrolling_reasons;
3245 LayerImpl* scroll_layer_impl = FindScrollLayerForDeviceViewportPoint( 3252 LayerImpl* scroll_layer_impl = FindScrollLayerForDeviceViewportPoint(
3246 device_viewport_point, InputHandler::TOUCHSCREEN, layer_impl, 3253 device_viewport_point, InputHandler::TOUCHSCREEN, layer_impl,
3247 &scroll_on_main_thread, &main_thread_scrolling_reasons); 3254 &scroll_on_main_thread, &main_thread_scrolling_reasons);
3255 // Scrollbars for the viewport are registered with the outer viewport layer.
3248 if (scroll_layer_impl == InnerViewportScrollLayer()) 3256 if (scroll_layer_impl == InnerViewportScrollLayer())
3249 scroll_layer_impl = OuterViewportScrollLayer(); 3257 scroll_layer_impl = OuterViewportScrollLayer();
3250 if (scroll_on_main_thread || !scroll_layer_impl) 3258 if (scroll_on_main_thread || !scroll_layer_impl)
3251 return; 3259 return;
3252 3260
3253 ScrollbarAnimationController* animation_controller = 3261 ScrollbarAnimationController* animation_controller =
3254 ScrollbarAnimationControllerForId(scroll_layer_impl->id()); 3262 ScrollbarAnimationControllerForId(scroll_layer_impl->id());
3255 if (!animation_controller) 3263 if (!animation_controller)
3256 return; 3264 return;
3257 3265
(...skipping 28 matching lines...) Expand all
3286 ScrollbarAnimationControllerForId( 3294 ScrollbarAnimationControllerForId(
3287 scroll_layer_id_when_mouse_over_scrollbar_); 3295 scroll_layer_id_when_mouse_over_scrollbar_);
3288 if (new_animation_controller) 3296 if (new_animation_controller)
3289 new_animation_controller->DidMouseMoveNear(0); 3297 new_animation_controller->DidMouseMoveNear(0);
3290 } 3298 }
3291 3299
3292 void LayerTreeHostImpl::PinchGestureBegin() { 3300 void LayerTreeHostImpl::PinchGestureBegin() {
3293 pinch_gesture_active_ = true; 3301 pinch_gesture_active_ = true;
3294 client_->RenewTreePriority(); 3302 client_->RenewTreePriority();
3295 pinch_gesture_end_should_clear_scrolling_layer_ = !CurrentlyScrollingLayer(); 3303 pinch_gesture_end_should_clear_scrolling_layer_ = !CurrentlyScrollingLayer();
3296 active_tree_->SetCurrentlyScrollingLayer( 3304 active_tree_->SetCurrentlyScrollingLayer(viewport()->MainScrollLayer());
3297 active_tree_->InnerViewportScrollLayer());
3298 top_controls_manager_->PinchBegin(); 3305 top_controls_manager_->PinchBegin();
3299 } 3306 }
3300 3307
3301 void LayerTreeHostImpl::PinchGestureUpdate(float magnify_delta, 3308 void LayerTreeHostImpl::PinchGestureUpdate(float magnify_delta,
3302 const gfx::Point& anchor) { 3309 const gfx::Point& anchor) {
3303 TRACE_EVENT0("cc", "LayerTreeHostImpl::PinchGestureUpdate"); 3310 TRACE_EVENT0("cc", "LayerTreeHostImpl::PinchGestureUpdate");
3304 if (!InnerViewportScrollLayer()) 3311 if (!InnerViewportScrollLayer())
3305 return; 3312 return;
3306 viewport()->PinchUpdate(magnify_delta, anchor); 3313 viewport()->PinchUpdate(magnify_delta, anchor);
3307 client_->SetNeedsCommitOnImplThread(); 3314 client_->SetNeedsCommitOnImplThread();
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
3365 active_tree_->elastic_overscroll()->PullDeltaForMainThread(); 3372 active_tree_->elastic_overscroll()->PullDeltaForMainThread();
3366 scroll_info->swap_promises.swap(swap_promises_for_main_thread_scroll_update_); 3373 scroll_info->swap_promises.swap(swap_promises_for_main_thread_scroll_update_);
3367 3374
3368 return scroll_info; 3375 return scroll_info;
3369 } 3376 }
3370 3377
3371 void LayerTreeHostImpl::SetFullViewportDamage() { 3378 void LayerTreeHostImpl::SetFullViewportDamage() {
3372 SetViewportDamage(gfx::Rect(DrawViewportSize())); 3379 SetViewportDamage(gfx::Rect(DrawViewportSize()));
3373 } 3380 }
3374 3381
3375 void LayerTreeHostImpl::ScrollViewportInnerFirst(gfx::Vector2dF scroll_delta) {
3376 DCHECK(InnerViewportScrollLayer());
3377 LayerImpl* scroll_layer = InnerViewportScrollLayer();
3378
3379 gfx::Vector2dF unused_delta = scroll_layer->ScrollBy(scroll_delta);
3380 if (!unused_delta.IsZero() && OuterViewportScrollLayer())
3381 OuterViewportScrollLayer()->ScrollBy(unused_delta);
3382 }
3383
3384 void LayerTreeHostImpl::ScrollViewportBy(gfx::Vector2dF scroll_delta) {
3385 DCHECK(InnerViewportScrollLayer());
3386 LayerImpl* scroll_layer = OuterViewportScrollLayer()
3387 ? OuterViewportScrollLayer()
3388 : InnerViewportScrollLayer();
3389
3390 gfx::Vector2dF unused_delta = scroll_layer->ScrollBy(scroll_delta);
3391
3392 if (!unused_delta.IsZero() && (scroll_layer == OuterViewportScrollLayer()))
3393 InnerViewportScrollLayer()->ScrollBy(unused_delta);
3394 }
3395
3396 bool LayerTreeHostImpl::AnimatePageScale(base::TimeTicks monotonic_time) { 3382 bool LayerTreeHostImpl::AnimatePageScale(base::TimeTicks monotonic_time) {
3397 if (!page_scale_animation_) 3383 if (!page_scale_animation_)
3398 return false; 3384 return false;
3399 3385
3400 gfx::ScrollOffset scroll_total = active_tree_->TotalScrollOffset(); 3386 gfx::ScrollOffset scroll_total = active_tree_->TotalScrollOffset();
3401 3387
3402 if (!page_scale_animation_->IsAnimationStarted()) 3388 if (!page_scale_animation_->IsAnimationStarted())
3403 page_scale_animation_->StartAnimation(monotonic_time); 3389 page_scale_animation_->StartAnimation(monotonic_time);
3404 3390
3405 active_tree_->SetPageScaleOnActiveTree( 3391 active_tree_->SetPageScaleOnActiveTree(
3406 page_scale_animation_->PageScaleFactorAtTime(monotonic_time)); 3392 page_scale_animation_->PageScaleFactorAtTime(monotonic_time));
3407 gfx::ScrollOffset next_scroll = gfx::ScrollOffset( 3393 gfx::ScrollOffset next_scroll = gfx::ScrollOffset(
3408 page_scale_animation_->ScrollOffsetAtTime(monotonic_time)); 3394 page_scale_animation_->ScrollOffsetAtTime(monotonic_time));
3409 3395
3410 ScrollViewportInnerFirst(next_scroll.DeltaFrom(scroll_total)); 3396 DCHECK(viewport());
3397 viewport()->ScrollByInnerFirst(next_scroll.DeltaFrom(scroll_total));
3411 3398
3412 if (page_scale_animation_->IsAnimationCompleteAtTime(monotonic_time)) { 3399 if (page_scale_animation_->IsAnimationCompleteAtTime(monotonic_time)) {
3413 page_scale_animation_ = nullptr; 3400 page_scale_animation_ = nullptr;
3414 client_->SetNeedsCommitOnImplThread(); 3401 client_->SetNeedsCommitOnImplThread();
3415 client_->RenewTreePriority(); 3402 client_->RenewTreePriority();
3416 client_->DidCompletePageScaleAnimationOnImplThread(); 3403 client_->DidCompletePageScaleAnimationOnImplThread();
3417 } else { 3404 } else {
3418 SetNeedsOneBeginImplFrame(); 3405 SetNeedsOneBeginImplFrame();
3419 } 3406 }
3420 return true; 3407 return true;
3421 } 3408 }
3422 3409
3423 bool LayerTreeHostImpl::AnimateTopControls(base::TimeTicks time) { 3410 bool LayerTreeHostImpl::AnimateTopControls(base::TimeTicks time) {
3424 if (!top_controls_manager_->has_animation()) 3411 if (!top_controls_manager_->has_animation())
3425 return false; 3412 return false;
3426 3413
3427 gfx::Vector2dF scroll = top_controls_manager_->Animate(time); 3414 gfx::Vector2dF scroll = top_controls_manager_->Animate(time);
3428 3415
3429 if (top_controls_manager_->has_animation()) 3416 if (top_controls_manager_->has_animation())
3430 SetNeedsOneBeginImplFrame(); 3417 SetNeedsOneBeginImplFrame();
3431 3418
3432 if (active_tree_->TotalScrollOffset().y() == 0.f) 3419 if (active_tree_->TotalScrollOffset().y() == 0.f)
3433 return false; 3420 return false;
3434 3421
3435 if (scroll.IsZero()) 3422 if (scroll.IsZero())
3436 return false; 3423 return false;
3437 3424
3438 ScrollViewportBy(gfx::ScaleVector2d( 3425 DCHECK(viewport());
3439 scroll, 1.f / active_tree_->current_page_scale_factor())); 3426 viewport()->ScrollBy(scroll, gfx::Point(), false, false);
3440 client_->SetNeedsCommitOnImplThread(); 3427 client_->SetNeedsCommitOnImplThread();
3441 client_->RenewTreePriority(); 3428 client_->RenewTreePriority();
3442 return true; 3429 return true;
3443 } 3430 }
3444 3431
3445 bool LayerTreeHostImpl::AnimateScrollbars(base::TimeTicks monotonic_time) { 3432 bool LayerTreeHostImpl::AnimateScrollbars(base::TimeTicks monotonic_time) {
3446 bool animated = false; 3433 bool animated = false;
3447 for (auto& pair : scrollbar_animation_controllers_) 3434 for (auto& pair : scrollbar_animation_controllers_)
3448 animated |= pair.second->Animate(monotonic_time); 3435 animated |= pair.second->Animate(monotonic_time);
3449 return animated; 3436 return animated;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
3513 } 3500 }
3514 3501
3515 void LayerTreeHostImpl::UnregisterScrollbarAnimationController( 3502 void LayerTreeHostImpl::UnregisterScrollbarAnimationController(
3516 int scroll_layer_id) { 3503 int scroll_layer_id) {
3517 scrollbar_animation_controllers_.erase(scroll_layer_id); 3504 scrollbar_animation_controllers_.erase(scroll_layer_id);
3518 } 3505 }
3519 3506
3520 ScrollbarAnimationController* 3507 ScrollbarAnimationController*
3521 LayerTreeHostImpl::ScrollbarAnimationControllerForId( 3508 LayerTreeHostImpl::ScrollbarAnimationControllerForId(
3522 int scroll_layer_id) const { 3509 int scroll_layer_id) const {
3510 // The viewport layers have only one set of scrollbars and their controller
3511 // is registered with the outer viewport.
3523 if (InnerViewportScrollLayer() && OuterViewportScrollLayer() && 3512 if (InnerViewportScrollLayer() && OuterViewportScrollLayer() &&
3524 scroll_layer_id == InnerViewportScrollLayer()->id()) 3513 scroll_layer_id == InnerViewportScrollLayer()->id())
3525 scroll_layer_id = OuterViewportScrollLayer()->id(); 3514 scroll_layer_id = OuterViewportScrollLayer()->id();
3526 auto i = scrollbar_animation_controllers_.find(scroll_layer_id); 3515 auto i = scrollbar_animation_controllers_.find(scroll_layer_id);
3527 if (i == scrollbar_animation_controllers_.end()) 3516 if (i == scrollbar_animation_controllers_.end())
3528 return nullptr; 3517 return nullptr;
3529 return i->second.get(); 3518 return i->second.get();
3530 } 3519 }
3531 3520
3532 void LayerTreeHostImpl::PostDelayedScrollbarAnimationTask( 3521 void LayerTreeHostImpl::PostDelayedScrollbarAnimationTask(
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after
4165 if (is_visible) { 4154 if (is_visible) {
4166 worker_context_visibility_ = 4155 worker_context_visibility_ =
4167 worker_context->CacheController()->ClientBecameVisible(); 4156 worker_context->CacheController()->ClientBecameVisible();
4168 } else { 4157 } else {
4169 worker_context->CacheController()->ClientBecameNotVisible( 4158 worker_context->CacheController()->ClientBecameNotVisible(
4170 std::move(worker_context_visibility_)); 4159 std::move(worker_context_visibility_));
4171 } 4160 }
4172 } 4161 }
4173 4162
4174 } // namespace cc 4163 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.h ('k') | ui/events/blink/input_handler_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698