| 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 17 matching lines...) Expand all Loading... |
| 28 #include "cc/animation/animation_host.h" | 28 #include "cc/animation/animation_host.h" |
| 29 #include "cc/base/histograms.h" | 29 #include "cc/base/histograms.h" |
| 30 #include "cc/base/math_util.h" | 30 #include "cc/base/math_util.h" |
| 31 #include "cc/debug/benchmark_instrumentation.h" | 31 #include "cc/debug/benchmark_instrumentation.h" |
| 32 #include "cc/debug/debug_rect_history.h" | 32 #include "cc/debug/debug_rect_history.h" |
| 33 #include "cc/debug/devtools_instrumentation.h" | 33 #include "cc/debug/devtools_instrumentation.h" |
| 34 #include "cc/debug/frame_rate_counter.h" | 34 #include "cc/debug/frame_rate_counter.h" |
| 35 #include "cc/debug/frame_viewer_instrumentation.h" | 35 #include "cc/debug/frame_viewer_instrumentation.h" |
| 36 #include "cc/debug/rendering_stats_instrumentation.h" | 36 #include "cc/debug/rendering_stats_instrumentation.h" |
| 37 #include "cc/debug/traced_value.h" | 37 #include "cc/debug/traced_value.h" |
| 38 #include "cc/input/browser_controls_offset_manager.h" |
| 38 #include "cc/input/main_thread_scrolling_reason.h" | 39 #include "cc/input/main_thread_scrolling_reason.h" |
| 39 #include "cc/input/page_scale_animation.h" | 40 #include "cc/input/page_scale_animation.h" |
| 40 #include "cc/input/scroll_elasticity_helper.h" | 41 #include "cc/input/scroll_elasticity_helper.h" |
| 41 #include "cc/input/scroll_state.h" | 42 #include "cc/input/scroll_state.h" |
| 42 #include "cc/input/scrollbar_animation_controller.h" | 43 #include "cc/input/scrollbar_animation_controller.h" |
| 43 #include "cc/input/top_controls_manager.h" | |
| 44 #include "cc/layers/append_quads_data.h" | 44 #include "cc/layers/append_quads_data.h" |
| 45 #include "cc/layers/heads_up_display_layer_impl.h" | 45 #include "cc/layers/heads_up_display_layer_impl.h" |
| 46 #include "cc/layers/layer_impl.h" | 46 #include "cc/layers/layer_impl.h" |
| 47 #include "cc/layers/layer_iterator.h" | 47 #include "cc/layers/layer_iterator.h" |
| 48 #include "cc/layers/painted_scrollbar_layer_impl.h" | 48 #include "cc/layers/painted_scrollbar_layer_impl.h" |
| 49 #include "cc/layers/render_surface_impl.h" | 49 #include "cc/layers/render_surface_impl.h" |
| 50 #include "cc/layers/scrollbar_layer_impl_base.h" | 50 #include "cc/layers/scrollbar_layer_impl_base.h" |
| 51 #include "cc/layers/surface_layer_impl.h" | 51 #include "cc/layers/surface_layer_impl.h" |
| 52 #include "cc/layers/viewport.h" | 52 #include "cc/layers/viewport.h" |
| 53 #include "cc/output/compositor_frame.h" | 53 #include "cc/output/compositor_frame.h" |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 DCHECK(animation_host_); | 245 DCHECK(animation_host_); |
| 246 animation_host_->SetMutatorHostClient(this); | 246 animation_host_->SetMutatorHostClient(this); |
| 247 | 247 |
| 248 DCHECK(task_runner_provider_->IsImplThread()); | 248 DCHECK(task_runner_provider_->IsImplThread()); |
| 249 DidVisibilityChange(this, visible_); | 249 DidVisibilityChange(this, visible_); |
| 250 | 250 |
| 251 SetDebugState(settings.initial_debug_state); | 251 SetDebugState(settings.initial_debug_state); |
| 252 | 252 |
| 253 // LTHI always has an active tree. | 253 // LTHI always has an active tree. |
| 254 active_tree_ = base::MakeUnique<LayerTreeImpl>( | 254 active_tree_ = base::MakeUnique<LayerTreeImpl>( |
| 255 this, new SyncedProperty<ScaleGroup>, new SyncedTopControls, | 255 this, new SyncedProperty<ScaleGroup>, new SyncedBrowserControls, |
| 256 new SyncedElasticOverscroll); | 256 new SyncedElasticOverscroll); |
| 257 active_tree_->property_trees()->is_active = true; | 257 active_tree_->property_trees()->is_active = true; |
| 258 | 258 |
| 259 viewport_ = Viewport::Create(this); | 259 viewport_ = Viewport::Create(this); |
| 260 | 260 |
| 261 TRACE_EVENT_OBJECT_CREATED_WITH_ID(TRACE_DISABLED_BY_DEFAULT("cc.debug"), | 261 TRACE_EVENT_OBJECT_CREATED_WITH_ID(TRACE_DISABLED_BY_DEFAULT("cc.debug"), |
| 262 "cc::LayerTreeHostImpl", id_); | 262 "cc::LayerTreeHostImpl", id_); |
| 263 | 263 |
| 264 top_controls_manager_ = | 264 browser_controls_offset_manager_ = BrowserControlsOffsetManager::Create( |
| 265 TopControlsManager::Create(this, settings.top_controls_show_threshold, | 265 this, settings.top_controls_show_threshold, |
| 266 settings.top_controls_hide_threshold); | 266 settings.top_controls_hide_threshold); |
| 267 } | 267 } |
| 268 | 268 |
| 269 LayerTreeHostImpl::~LayerTreeHostImpl() { | 269 LayerTreeHostImpl::~LayerTreeHostImpl() { |
| 270 DCHECK(task_runner_provider_->IsImplThread()); | 270 DCHECK(task_runner_provider_->IsImplThread()); |
| 271 TRACE_EVENT0("cc", "LayerTreeHostImpl::~LayerTreeHostImpl()"); | 271 TRACE_EVENT0("cc", "LayerTreeHostImpl::~LayerTreeHostImpl()"); |
| 272 TRACE_EVENT_OBJECT_DELETED_WITH_ID(TRACE_DISABLED_BY_DEFAULT("cc.debug"), | 272 TRACE_EVENT_OBJECT_DELETED_WITH_ID(TRACE_DISABLED_BY_DEFAULT("cc.debug"), |
| 273 "cc::LayerTreeHostImpl", id_); | 273 "cc::LayerTreeHostImpl", id_); |
| 274 | 274 |
| 275 // It is released before shutdown. | 275 // It is released before shutdown. |
| 276 DCHECK(!compositor_frame_sink_); | 276 DCHECK(!compositor_frame_sink_); |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 // This does not set did_animate, because if the InputHandlerClient | 456 // This does not set did_animate, because if the InputHandlerClient |
| 457 // changes anything it will be through the InputHandler interface which | 457 // changes anything it will be through the InputHandler interface which |
| 458 // does SetNeedsRedraw. | 458 // does SetNeedsRedraw. |
| 459 input_handler_client_->Animate(monotonic_time); | 459 input_handler_client_->Animate(monotonic_time); |
| 460 } | 460 } |
| 461 } | 461 } |
| 462 | 462 |
| 463 did_animate |= AnimatePageScale(monotonic_time); | 463 did_animate |= AnimatePageScale(monotonic_time); |
| 464 did_animate |= AnimateLayers(monotonic_time); | 464 did_animate |= AnimateLayers(monotonic_time); |
| 465 did_animate |= AnimateScrollbars(monotonic_time); | 465 did_animate |= AnimateScrollbars(monotonic_time); |
| 466 did_animate |= AnimateTopControls(monotonic_time); | 466 did_animate |= AnimateBrowserControls(monotonic_time); |
| 467 | 467 |
| 468 if (active_tree) { | 468 if (active_tree) { |
| 469 did_animate |= Mutate(monotonic_time); | 469 did_animate |= Mutate(monotonic_time); |
| 470 | 470 |
| 471 // Animating stuff can change the root scroll offset, so inform the | 471 // Animating stuff can change the root scroll offset, so inform the |
| 472 // synchronous input handler. | 472 // synchronous input handler. |
| 473 UpdateRootLayerStateForSynchronousInputHandler(); | 473 UpdateRootLayerStateForSynchronousInputHandler(); |
| 474 if (did_animate) { | 474 if (did_animate) { |
| 475 // If the tree changed, then we want to draw at the end of the current | 475 // If the tree changed, then we want to draw at the end of the current |
| 476 // frame. | 476 // frame. |
| (...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1026 // separate render pass for the layer, which will persist until a new commit | 1026 // separate render pass for the layer, which will persist until a new commit |
| 1027 // removes it. Force a commit after copy requests, to remove extra render | 1027 // removes it. Force a commit after copy requests, to remove extra render |
| 1028 // passes. | 1028 // passes. |
| 1029 if (have_copy_request) | 1029 if (have_copy_request) |
| 1030 client_->SetNeedsCommitOnImplThread(); | 1030 client_->SetNeedsCommitOnImplThread(); |
| 1031 | 1031 |
| 1032 return draw_result; | 1032 return draw_result; |
| 1033 } | 1033 } |
| 1034 | 1034 |
| 1035 void LayerTreeHostImpl::MainThreadHasStoppedFlinging() { | 1035 void LayerTreeHostImpl::MainThreadHasStoppedFlinging() { |
| 1036 top_controls_manager_->MainThreadHasStoppedFlinging(); | 1036 browser_controls_offset_manager_->MainThreadHasStoppedFlinging(); |
| 1037 if (input_handler_client_) | 1037 if (input_handler_client_) |
| 1038 input_handler_client_->MainThreadHasStoppedFlinging(); | 1038 input_handler_client_->MainThreadHasStoppedFlinging(); |
| 1039 } | 1039 } |
| 1040 | 1040 |
| 1041 void LayerTreeHostImpl::DidAnimateScrollOffset() { | 1041 void LayerTreeHostImpl::DidAnimateScrollOffset() { |
| 1042 client_->SetNeedsCommitOnImplThread(); | 1042 client_->SetNeedsCommitOnImplThread(); |
| 1043 client_->RenewTreePriority(); | 1043 client_->RenewTreePriority(); |
| 1044 } | 1044 } |
| 1045 | 1045 |
| 1046 void LayerTreeHostImpl::SetViewportDamage(const gfx::Rect& damage_rect) { | 1046 void LayerTreeHostImpl::SetViewportDamage(const gfx::Rect& damage_rect) { |
| (...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1533 CompositorFrameMetadata LayerTreeHostImpl::MakeCompositorFrameMetadata() const { | 1533 CompositorFrameMetadata LayerTreeHostImpl::MakeCompositorFrameMetadata() const { |
| 1534 CompositorFrameMetadata metadata; | 1534 CompositorFrameMetadata metadata; |
| 1535 metadata.device_scale_factor = active_tree_->painted_device_scale_factor() * | 1535 metadata.device_scale_factor = active_tree_->painted_device_scale_factor() * |
| 1536 active_tree_->device_scale_factor(); | 1536 active_tree_->device_scale_factor(); |
| 1537 | 1537 |
| 1538 metadata.page_scale_factor = active_tree_->current_page_scale_factor(); | 1538 metadata.page_scale_factor = active_tree_->current_page_scale_factor(); |
| 1539 metadata.scrollable_viewport_size = active_tree_->ScrollableViewportSize(); | 1539 metadata.scrollable_viewport_size = active_tree_->ScrollableViewportSize(); |
| 1540 metadata.root_layer_size = active_tree_->ScrollableSize(); | 1540 metadata.root_layer_size = active_tree_->ScrollableSize(); |
| 1541 metadata.min_page_scale_factor = active_tree_->min_page_scale_factor(); | 1541 metadata.min_page_scale_factor = active_tree_->min_page_scale_factor(); |
| 1542 metadata.max_page_scale_factor = active_tree_->max_page_scale_factor(); | 1542 metadata.max_page_scale_factor = active_tree_->max_page_scale_factor(); |
| 1543 metadata.top_controls_height = top_controls_manager_->TopControlsHeight(); | 1543 metadata.top_controls_height = |
| 1544 browser_controls_offset_manager_->TopControlsHeight(); |
| 1544 metadata.top_controls_shown_ratio = | 1545 metadata.top_controls_shown_ratio = |
| 1545 top_controls_manager_->TopControlsShownRatio(); | 1546 browser_controls_offset_manager_->TopControlsShownRatio(); |
| 1546 metadata.bottom_controls_height = | 1547 metadata.bottom_controls_height = |
| 1547 top_controls_manager_->BottomControlsHeight(); | 1548 browser_controls_offset_manager_->BottomControlsHeight(); |
| 1548 metadata.bottom_controls_shown_ratio = | 1549 metadata.bottom_controls_shown_ratio = |
| 1549 top_controls_manager_->BottomControlsShownRatio(); | 1550 browser_controls_offset_manager_->BottomControlsShownRatio(); |
| 1550 metadata.root_background_color = active_tree_->background_color(); | 1551 metadata.root_background_color = active_tree_->background_color(); |
| 1551 | 1552 |
| 1552 active_tree_->GetViewportSelection(&metadata.selection); | 1553 active_tree_->GetViewportSelection(&metadata.selection); |
| 1553 | 1554 |
| 1554 if (OuterViewportScrollLayer()) { | 1555 if (OuterViewportScrollLayer()) { |
| 1555 metadata.root_overflow_x_hidden = | 1556 metadata.root_overflow_x_hidden = |
| 1556 !OuterViewportScrollLayer()->user_scrollable_horizontal(); | 1557 !OuterViewportScrollLayer()->user_scrollable_horizontal(); |
| 1557 metadata.root_overflow_y_hidden = | 1558 metadata.root_overflow_y_hidden = |
| 1558 !OuterViewportScrollLayer()->user_scrollable_vertical(); | 1559 !OuterViewportScrollLayer()->user_scrollable_vertical(); |
| 1559 } | 1560 } |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1852 void LayerTreeHostImpl::UpdateViewportContainerSizes() { | 1853 void LayerTreeHostImpl::UpdateViewportContainerSizes() { |
| 1853 LayerImpl* inner_container = active_tree_->InnerViewportContainerLayer(); | 1854 LayerImpl* inner_container = active_tree_->InnerViewportContainerLayer(); |
| 1854 LayerImpl* outer_container = active_tree_->OuterViewportContainerLayer(); | 1855 LayerImpl* outer_container = active_tree_->OuterViewportContainerLayer(); |
| 1855 | 1856 |
| 1856 if (!inner_container) | 1857 if (!inner_container) |
| 1857 return; | 1858 return; |
| 1858 | 1859 |
| 1859 ViewportAnchor anchor(InnerViewportScrollLayer(), OuterViewportScrollLayer()); | 1860 ViewportAnchor anchor(InnerViewportScrollLayer(), OuterViewportScrollLayer()); |
| 1860 | 1861 |
| 1861 float top_controls_layout_height = | 1862 float top_controls_layout_height = |
| 1862 active_tree_->top_controls_shrink_blink_size() | 1863 active_tree_->browser_controls_shrink_blink_size() |
| 1863 ? active_tree_->top_controls_height() | 1864 ? active_tree_->top_controls_height() |
| 1864 : 0.f; | 1865 : 0.f; |
| 1865 float delta_from_top_controls = | 1866 float delta_from_top_controls = |
| 1866 top_controls_layout_height - top_controls_manager_->ContentTopOffset(); | 1867 top_controls_layout_height - |
| 1868 browser_controls_offset_manager_->ContentTopOffset(); |
| 1867 float bottom_controls_layout_height = | 1869 float bottom_controls_layout_height = |
| 1868 active_tree_->top_controls_shrink_blink_size() | 1870 active_tree_->browser_controls_shrink_blink_size() |
| 1869 ? active_tree_->bottom_controls_height() | 1871 ? active_tree_->bottom_controls_height() |
| 1870 : 0.f; | 1872 : 0.f; |
| 1871 delta_from_top_controls += bottom_controls_layout_height - | 1873 delta_from_top_controls += |
| 1872 top_controls_manager_->ContentBottomOffset(); | 1874 bottom_controls_layout_height - |
| 1875 browser_controls_offset_manager_->ContentBottomOffset(); |
| 1873 | 1876 |
| 1874 // Adjust the viewport layers by shrinking/expanding the container to account | 1877 // Adjust the viewport layers by shrinking/expanding the container to account |
| 1875 // for changes in the size (e.g. top controls) since the last resize from | 1878 // for changes in the size (e.g. browser controls) since the last resize from |
| 1876 // Blink. | 1879 // Blink. |
| 1877 gfx::Vector2dF amount_to_expand(0.f, delta_from_top_controls); | 1880 gfx::Vector2dF amount_to_expand(0.f, delta_from_top_controls); |
| 1878 inner_container->SetBoundsDelta(amount_to_expand); | 1881 inner_container->SetBoundsDelta(amount_to_expand); |
| 1879 | 1882 |
| 1880 if (outer_container && !outer_container->BoundsForScrolling().IsEmpty()) { | 1883 if (outer_container && !outer_container->BoundsForScrolling().IsEmpty()) { |
| 1881 // Adjust the outer viewport container as well, since adjusting only the | 1884 // Adjust the outer viewport container as well, since adjusting only the |
| 1882 // inner may cause its bounds to exceed those of the outer, causing scroll | 1885 // inner may cause its bounds to exceed those of the outer, causing scroll |
| 1883 // clamping. | 1886 // clamping. |
| 1884 gfx::Vector2dF amount_to_expand_scaled = gfx::ScaleVector2d( | 1887 gfx::Vector2dF amount_to_expand_scaled = gfx::ScaleVector2d( |
| 1885 amount_to_expand, 1.f / active_tree_->min_page_scale_factor()); | 1888 amount_to_expand, 1.f / active_tree_->min_page_scale_factor()); |
| (...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2384 if (external_viewport_.IsEmpty()) | 2387 if (external_viewport_.IsEmpty()) |
| 2385 return gfx::Rect(device_viewport_size_); | 2388 return gfx::Rect(device_viewport_size_); |
| 2386 | 2389 |
| 2387 return external_viewport_; | 2390 return external_viewport_; |
| 2388 } | 2391 } |
| 2389 | 2392 |
| 2390 const gfx::Transform& LayerTreeHostImpl::DrawTransform() const { | 2393 const gfx::Transform& LayerTreeHostImpl::DrawTransform() const { |
| 2391 return external_transform_; | 2394 return external_transform_; |
| 2392 } | 2395 } |
| 2393 | 2396 |
| 2394 void LayerTreeHostImpl::DidChangeTopControlsPosition() { | 2397 void LayerTreeHostImpl::DidChangeBrowserControlsPosition() { |
| 2395 UpdateViewportContainerSizes(); | 2398 UpdateViewportContainerSizes(); |
| 2396 SetNeedsRedraw(); | 2399 SetNeedsRedraw(); |
| 2397 SetNeedsOneBeginImplFrame(); | 2400 SetNeedsOneBeginImplFrame(); |
| 2398 active_tree_->set_needs_update_draw_properties(); | 2401 active_tree_->set_needs_update_draw_properties(); |
| 2399 SetFullViewportDamage(); | 2402 SetFullViewportDamage(); |
| 2400 } | 2403 } |
| 2401 | 2404 |
| 2402 float LayerTreeHostImpl::TopControlsHeight() const { | 2405 float LayerTreeHostImpl::TopControlsHeight() const { |
| 2403 return active_tree_->top_controls_height(); | 2406 return active_tree_->top_controls_height(); |
| 2404 } | 2407 } |
| 2405 | 2408 |
| 2406 float LayerTreeHostImpl::BottomControlsHeight() const { | 2409 float LayerTreeHostImpl::BottomControlsHeight() const { |
| 2407 return active_tree_->bottom_controls_height(); | 2410 return active_tree_->bottom_controls_height(); |
| 2408 } | 2411 } |
| 2409 | 2412 |
| 2410 void LayerTreeHostImpl::SetCurrentTopControlsShownRatio(float ratio) { | 2413 void LayerTreeHostImpl::SetCurrentBrowserControlsShownRatio(float ratio) { |
| 2411 if (active_tree_->SetCurrentTopControlsShownRatio(ratio)) | 2414 if (active_tree_->SetCurrentBrowserControlsShownRatio(ratio)) |
| 2412 DidChangeTopControlsPosition(); | 2415 DidChangeBrowserControlsPosition(); |
| 2413 } | 2416 } |
| 2414 | 2417 |
| 2415 float LayerTreeHostImpl::CurrentTopControlsShownRatio() const { | 2418 float LayerTreeHostImpl::CurrentBrowserControlsShownRatio() const { |
| 2416 return active_tree_->CurrentTopControlsShownRatio(); | 2419 return active_tree_->CurrentBrowserControlsShownRatio(); |
| 2417 } | 2420 } |
| 2418 | 2421 |
| 2419 void LayerTreeHostImpl::BindToClient(InputHandlerClient* client) { | 2422 void LayerTreeHostImpl::BindToClient(InputHandlerClient* client) { |
| 2420 DCHECK(input_handler_client_ == NULL); | 2423 DCHECK(input_handler_client_ == NULL); |
| 2421 input_handler_client_ = client; | 2424 input_handler_client_ = client; |
| 2422 } | 2425 } |
| 2423 | 2426 |
| 2424 InputHandler::ScrollStatus LayerTreeHostImpl::TryScroll( | 2427 InputHandler::ScrollStatus LayerTreeHostImpl::TryScroll( |
| 2425 const gfx::PointF& screen_space_point, | 2428 const gfx::PointF& screen_space_point, |
| 2426 InputHandler::ScrollInputType type, | 2429 InputHandler::ScrollInputType type, |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2601 MainThreadScrollingReason::kNotScrollingOnMain; | 2604 MainThreadScrollingReason::kNotScrollingOnMain; |
| 2602 if (!scrolling_layer_impl) { | 2605 if (!scrolling_layer_impl) { |
| 2603 scroll_status.thread = SCROLL_IGNORED; | 2606 scroll_status.thread = SCROLL_IGNORED; |
| 2604 scroll_status.main_thread_scrolling_reasons = | 2607 scroll_status.main_thread_scrolling_reasons = |
| 2605 MainThreadScrollingReason::kNoScrollingLayer; | 2608 MainThreadScrollingReason::kNoScrollingLayer; |
| 2606 return scroll_status; | 2609 return scroll_status; |
| 2607 } | 2610 } |
| 2608 scroll_status.thread = SCROLL_ON_IMPL_THREAD; | 2611 scroll_status.thread = SCROLL_ON_IMPL_THREAD; |
| 2609 ScrollAnimationAbort(scrolling_layer_impl); | 2612 ScrollAnimationAbort(scrolling_layer_impl); |
| 2610 | 2613 |
| 2611 top_controls_manager_->ScrollBegin(); | 2614 browser_controls_offset_manager_->ScrollBegin(); |
| 2612 | 2615 |
| 2613 active_tree_->SetCurrentlyScrollingLayer(scrolling_layer_impl); | 2616 active_tree_->SetCurrentlyScrollingLayer(scrolling_layer_impl); |
| 2614 // TODO(majidvp): get rid of wheel_scrolling_ and set is_direct_manipulation | 2617 // TODO(majidvp): get rid of wheel_scrolling_ and set is_direct_manipulation |
| 2615 // in input_handler_proxy instead. | 2618 // in input_handler_proxy instead. |
| 2616 wheel_scrolling_ = IsWheelBasedScroll(type); | 2619 wheel_scrolling_ = IsWheelBasedScroll(type); |
| 2617 scroll_state->set_is_direct_manipulation(!wheel_scrolling_); | 2620 scroll_state->set_is_direct_manipulation(!wheel_scrolling_); |
| 2618 // Invoke |DistributeScrollDelta| even with zero delta and velocity to ensure | 2621 // Invoke |DistributeScrollDelta| even with zero delta and velocity to ensure |
| 2619 // scroll customization callbacks are invoked. | 2622 // scroll customization callbacks are invoked. |
| 2620 DistributeScrollDelta(scroll_state); | 2623 DistributeScrollDelta(scroll_state); |
| 2621 | 2624 |
| (...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3071 | 3074 |
| 3072 InputHandlerScrollResult LayerTreeHostImpl::ScrollBy( | 3075 InputHandlerScrollResult LayerTreeHostImpl::ScrollBy( |
| 3073 ScrollState* scroll_state) { | 3076 ScrollState* scroll_state) { |
| 3074 DCHECK(scroll_state); | 3077 DCHECK(scroll_state); |
| 3075 | 3078 |
| 3076 TRACE_EVENT0("cc", "LayerTreeHostImpl::ScrollBy"); | 3079 TRACE_EVENT0("cc", "LayerTreeHostImpl::ScrollBy"); |
| 3077 if (!CurrentlyScrollingLayer()) | 3080 if (!CurrentlyScrollingLayer()) |
| 3078 return InputHandlerScrollResult(); | 3081 return InputHandlerScrollResult(); |
| 3079 | 3082 |
| 3080 float initial_top_controls_offset = | 3083 float initial_top_controls_offset = |
| 3081 top_controls_manager_->ControlsTopOffset(); | 3084 browser_controls_offset_manager_->ControlsTopOffset(); |
| 3082 | 3085 |
| 3083 scroll_state->set_delta_consumed_for_scroll_sequence( | 3086 scroll_state->set_delta_consumed_for_scroll_sequence( |
| 3084 did_lock_scrolling_layer_); | 3087 did_lock_scrolling_layer_); |
| 3085 scroll_state->set_is_direct_manipulation(!wheel_scrolling_); | 3088 scroll_state->set_is_direct_manipulation(!wheel_scrolling_); |
| 3086 scroll_state->set_current_native_scrolling_node( | 3089 scroll_state->set_current_native_scrolling_node( |
| 3087 active_tree()->property_trees()->scroll_tree.CurrentlyScrollingNode()); | 3090 active_tree()->property_trees()->scroll_tree.CurrentlyScrollingNode()); |
| 3088 | 3091 |
| 3089 DistributeScrollDelta(scroll_state); | 3092 DistributeScrollDelta(scroll_state); |
| 3090 | 3093 |
| 3091 active_tree_->SetCurrentlyScrollingLayer(active_tree_->LayerById( | 3094 active_tree_->SetCurrentlyScrollingLayer(active_tree_->LayerById( |
| (...skipping 27 matching lines...) Expand all Loading... |
| 3119 if (InnerViewportScrollLayer()) { | 3122 if (InnerViewportScrollLayer()) { |
| 3120 if (!InnerViewportScrollLayer()->user_scrollable_horizontal()) | 3123 if (!InnerViewportScrollLayer()->user_scrollable_horizontal()) |
| 3121 unused_root_delta.set_x(0); | 3124 unused_root_delta.set_x(0); |
| 3122 if (!InnerViewportScrollLayer()->user_scrollable_vertical()) | 3125 if (!InnerViewportScrollLayer()->user_scrollable_vertical()) |
| 3123 unused_root_delta.set_y(0); | 3126 unused_root_delta.set_y(0); |
| 3124 } | 3127 } |
| 3125 | 3128 |
| 3126 accumulated_root_overscroll_ += unused_root_delta; | 3129 accumulated_root_overscroll_ += unused_root_delta; |
| 3127 | 3130 |
| 3128 bool did_scroll_top_controls = | 3131 bool did_scroll_top_controls = |
| 3129 initial_top_controls_offset != top_controls_manager_->ControlsTopOffset(); | 3132 initial_top_controls_offset != |
| 3133 browser_controls_offset_manager_->ControlsTopOffset(); |
| 3130 | 3134 |
| 3131 InputHandlerScrollResult scroll_result; | 3135 InputHandlerScrollResult scroll_result; |
| 3132 scroll_result.did_scroll = did_scroll_content || did_scroll_top_controls; | 3136 scroll_result.did_scroll = did_scroll_content || did_scroll_top_controls; |
| 3133 scroll_result.did_overscroll_root = !unused_root_delta.IsZero(); | 3137 scroll_result.did_overscroll_root = !unused_root_delta.IsZero(); |
| 3134 scroll_result.accumulated_root_overscroll = accumulated_root_overscroll_; | 3138 scroll_result.accumulated_root_overscroll = accumulated_root_overscroll_; |
| 3135 scroll_result.unused_scroll_delta = unused_root_delta; | 3139 scroll_result.unused_scroll_delta = unused_root_delta; |
| 3136 | 3140 |
| 3137 if (scroll_result.did_scroll) { | 3141 if (scroll_result.did_scroll) { |
| 3138 // Scrolling can change the root scroll offset, so inform the synchronous | 3142 // Scrolling can change the root scroll offset, so inform the synchronous |
| 3139 // input handler. | 3143 // input handler. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 3169 did_lock_scrolling_layer_ = false; | 3173 did_lock_scrolling_layer_ = false; |
| 3170 scroll_affects_scroll_handler_ = false; | 3174 scroll_affects_scroll_handler_ = false; |
| 3171 accumulated_root_overscroll_ = gfx::Vector2dF(); | 3175 accumulated_root_overscroll_ = gfx::Vector2dF(); |
| 3172 } | 3176 } |
| 3173 | 3177 |
| 3174 void LayerTreeHostImpl::ScrollEnd(ScrollState* scroll_state) { | 3178 void LayerTreeHostImpl::ScrollEnd(ScrollState* scroll_state) { |
| 3175 DCHECK(scroll_state); | 3179 DCHECK(scroll_state); |
| 3176 DCHECK(scroll_state->delta_x() == 0 && scroll_state->delta_y() == 0); | 3180 DCHECK(scroll_state->delta_x() == 0 && scroll_state->delta_y() == 0); |
| 3177 | 3181 |
| 3178 DistributeScrollDelta(scroll_state); | 3182 DistributeScrollDelta(scroll_state); |
| 3179 top_controls_manager_->ScrollEnd(); | 3183 browser_controls_offset_manager_->ScrollEnd(); |
| 3180 | 3184 |
| 3181 if (scroll_state->is_in_inertial_phase()) { | 3185 if (scroll_state->is_in_inertial_phase()) { |
| 3182 // Only clear the currently scrolling layer if we know the scroll is done. | 3186 // Only clear the currently scrolling layer if we know the scroll is done. |
| 3183 // A non-inertial scroll end could be followed by an inertial scroll. | 3187 // A non-inertial scroll end could be followed by an inertial scroll. |
| 3184 ClearCurrentlyScrollingLayer(); | 3188 ClearCurrentlyScrollingLayer(); |
| 3185 } | 3189 } |
| 3186 } | 3190 } |
| 3187 | 3191 |
| 3188 InputHandler::ScrollStatus LayerTreeHostImpl::FlingScrollBegin() { | 3192 InputHandler::ScrollStatus LayerTreeHostImpl::FlingScrollBegin() { |
| 3189 InputHandler::ScrollStatus scroll_status; | 3193 InputHandler::ScrollStatus scroll_status; |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3302 scroll_layer_id_when_mouse_over_scrollbar_); | 3306 scroll_layer_id_when_mouse_over_scrollbar_); |
| 3303 if (new_animation_controller) | 3307 if (new_animation_controller) |
| 3304 new_animation_controller->DidMouseMoveNear(0); | 3308 new_animation_controller->DidMouseMoveNear(0); |
| 3305 } | 3309 } |
| 3306 | 3310 |
| 3307 void LayerTreeHostImpl::PinchGestureBegin() { | 3311 void LayerTreeHostImpl::PinchGestureBegin() { |
| 3308 pinch_gesture_active_ = true; | 3312 pinch_gesture_active_ = true; |
| 3309 client_->RenewTreePriority(); | 3313 client_->RenewTreePriority(); |
| 3310 pinch_gesture_end_should_clear_scrolling_layer_ = !CurrentlyScrollingLayer(); | 3314 pinch_gesture_end_should_clear_scrolling_layer_ = !CurrentlyScrollingLayer(); |
| 3311 active_tree_->SetCurrentlyScrollingLayer(viewport()->MainScrollLayer()); | 3315 active_tree_->SetCurrentlyScrollingLayer(viewport()->MainScrollLayer()); |
| 3312 top_controls_manager_->PinchBegin(); | 3316 browser_controls_offset_manager_->PinchBegin(); |
| 3313 } | 3317 } |
| 3314 | 3318 |
| 3315 void LayerTreeHostImpl::PinchGestureUpdate(float magnify_delta, | 3319 void LayerTreeHostImpl::PinchGestureUpdate(float magnify_delta, |
| 3316 const gfx::Point& anchor) { | 3320 const gfx::Point& anchor) { |
| 3317 TRACE_EVENT0("cc", "LayerTreeHostImpl::PinchGestureUpdate"); | 3321 TRACE_EVENT0("cc", "LayerTreeHostImpl::PinchGestureUpdate"); |
| 3318 if (!InnerViewportScrollLayer()) | 3322 if (!InnerViewportScrollLayer()) |
| 3319 return; | 3323 return; |
| 3320 viewport()->PinchUpdate(magnify_delta, anchor); | 3324 viewport()->PinchUpdate(magnify_delta, anchor); |
| 3321 client_->SetNeedsCommitOnImplThread(); | 3325 client_->SetNeedsCommitOnImplThread(); |
| 3322 SetNeedsRedraw(); | 3326 SetNeedsRedraw(); |
| 3323 client_->RenewTreePriority(); | 3327 client_->RenewTreePriority(); |
| 3324 // Pinching can change the root scroll offset, so inform the synchronous input | 3328 // Pinching can change the root scroll offset, so inform the synchronous input |
| 3325 // handler. | 3329 // handler. |
| 3326 UpdateRootLayerStateForSynchronousInputHandler(); | 3330 UpdateRootLayerStateForSynchronousInputHandler(); |
| 3327 } | 3331 } |
| 3328 | 3332 |
| 3329 void LayerTreeHostImpl::PinchGestureEnd() { | 3333 void LayerTreeHostImpl::PinchGestureEnd() { |
| 3330 pinch_gesture_active_ = false; | 3334 pinch_gesture_active_ = false; |
| 3331 if (pinch_gesture_end_should_clear_scrolling_layer_) { | 3335 if (pinch_gesture_end_should_clear_scrolling_layer_) { |
| 3332 pinch_gesture_end_should_clear_scrolling_layer_ = false; | 3336 pinch_gesture_end_should_clear_scrolling_layer_ = false; |
| 3333 ClearCurrentlyScrollingLayer(); | 3337 ClearCurrentlyScrollingLayer(); |
| 3334 } | 3338 } |
| 3335 viewport()->PinchEnd(); | 3339 viewport()->PinchEnd(); |
| 3336 top_controls_manager_->PinchEnd(); | 3340 browser_controls_offset_manager_->PinchEnd(); |
| 3337 client_->SetNeedsCommitOnImplThread(); | 3341 client_->SetNeedsCommitOnImplThread(); |
| 3338 // When a pinch ends, we may be displaying content cached at incorrect scales, | 3342 // When a pinch ends, we may be displaying content cached at incorrect scales, |
| 3339 // so updating draw properties and drawing will ensure we are using the right | 3343 // so updating draw properties and drawing will ensure we are using the right |
| 3340 // scales that we want when we're not inside a pinch. | 3344 // scales that we want when we're not inside a pinch. |
| 3341 active_tree_->set_needs_update_draw_properties(); | 3345 active_tree_->set_needs_update_draw_properties(); |
| 3342 SetNeedsRedraw(); | 3346 SetNeedsRedraw(); |
| 3343 } | 3347 } |
| 3344 | 3348 |
| 3345 std::unique_ptr<BeginFrameCallbackList> | 3349 std::unique_ptr<BeginFrameCallbackList> |
| 3346 LayerTreeHostImpl::ProcessLayerTreeMutations() { | 3350 LayerTreeHostImpl::ProcessLayerTreeMutations() { |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3407 page_scale_animation_ = nullptr; | 3411 page_scale_animation_ = nullptr; |
| 3408 client_->SetNeedsCommitOnImplThread(); | 3412 client_->SetNeedsCommitOnImplThread(); |
| 3409 client_->RenewTreePriority(); | 3413 client_->RenewTreePriority(); |
| 3410 client_->DidCompletePageScaleAnimationOnImplThread(); | 3414 client_->DidCompletePageScaleAnimationOnImplThread(); |
| 3411 } else { | 3415 } else { |
| 3412 SetNeedsOneBeginImplFrame(); | 3416 SetNeedsOneBeginImplFrame(); |
| 3413 } | 3417 } |
| 3414 return true; | 3418 return true; |
| 3415 } | 3419 } |
| 3416 | 3420 |
| 3417 bool LayerTreeHostImpl::AnimateTopControls(base::TimeTicks time) { | 3421 bool LayerTreeHostImpl::AnimateBrowserControls(base::TimeTicks time) { |
| 3418 if (!top_controls_manager_->has_animation()) | 3422 if (!browser_controls_offset_manager_->has_animation()) |
| 3419 return false; | 3423 return false; |
| 3420 | 3424 |
| 3421 gfx::Vector2dF scroll = top_controls_manager_->Animate(time); | 3425 gfx::Vector2dF scroll = browser_controls_offset_manager_->Animate(time); |
| 3422 | 3426 |
| 3423 if (top_controls_manager_->has_animation()) | 3427 if (browser_controls_offset_manager_->has_animation()) |
| 3424 SetNeedsOneBeginImplFrame(); | 3428 SetNeedsOneBeginImplFrame(); |
| 3425 | 3429 |
| 3426 if (active_tree_->TotalScrollOffset().y() == 0.f) | 3430 if (active_tree_->TotalScrollOffset().y() == 0.f) |
| 3427 return false; | 3431 return false; |
| 3428 | 3432 |
| 3429 if (scroll.IsZero()) | 3433 if (scroll.IsZero()) |
| 3430 return false; | 3434 return false; |
| 3431 | 3435 |
| 3432 DCHECK(viewport()); | 3436 DCHECK(viewport()); |
| 3433 viewport()->ScrollBy(scroll, gfx::Point(), false, false); | 3437 viewport()->ScrollBy(scroll, gfx::Point(), false, false); |
| (...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4101 if (is_visible) { | 4105 if (is_visible) { |
| 4102 worker_context_visibility_ = | 4106 worker_context_visibility_ = |
| 4103 worker_context->CacheController()->ClientBecameVisible(); | 4107 worker_context->CacheController()->ClientBecameVisible(); |
| 4104 } else { | 4108 } else { |
| 4105 worker_context->CacheController()->ClientBecameNotVisible( | 4109 worker_context->CacheController()->ClientBecameNotVisible( |
| 4106 std::move(worker_context_visibility_)); | 4110 std::move(worker_context_visibility_)); |
| 4107 } | 4111 } |
| 4108 } | 4112 } |
| 4109 | 4113 |
| 4110 } // namespace cc | 4114 } // namespace cc |
| OLD | NEW |