Commit 71dbda7b authored by Xianzhu Wang's avatar Xianzhu Wang Committed by Commit Bot

Stop scrolling when the scrolling node disappears in the new tree

We need to reset the scrolling status (especially LayerTreeHostImpl::
did_lock_scrolling_layer_) when activating the pending tree in which
the currently scrolling node no longer exists.

Previously the situation caused DCHECK failure.

Change-Id: I23b9105ded1767ee27fa37fb75f67c13e81d5699
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1882301Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#710530}
parent dadbe6af
...@@ -2974,6 +2974,10 @@ void LayerTreeHostImpl::ActivateSyncTree() { ...@@ -2974,6 +2974,10 @@ void LayerTreeHostImpl::ActivateSyncTree() {
active_tree_->lifecycle().AdvanceTo(LayerTreeLifecycle::kNotSyncing); active_tree_->lifecycle().AdvanceTo(LayerTreeLifecycle::kNotSyncing);
// The previous scrolling node no longer exists in the new tree.
if (!active_tree_->CurrentlyScrollingNode())
ClearCurrentlyScrollingNode();
// Now that we've synced everything from the pending tree to the active // Now that we've synced everything from the pending tree to the active
// tree, rename the pending tree the recycle tree so we can reuse it on the // tree, rename the pending tree the recycle tree so we can reuse it on the
// next sync. // next sync.
......
...@@ -806,6 +806,10 @@ class CC_EXPORT LayerTreeHostImpl : public InputHandler, ...@@ -806,6 +806,10 @@ class CC_EXPORT LayerTreeHostImpl : public InputHandler,
return paint_worklet_tracker_; return paint_worklet_tracker_;
} }
bool did_lock_scrolling_layer_for_testing() const {
return did_lock_scrolling_layer_;
}
protected: protected:
LayerTreeHostImpl( LayerTreeHostImpl(
const LayerTreeSettings& settings, const LayerTreeSettings& settings,
......
...@@ -1147,6 +1147,34 @@ TEST_F(LayerTreeHostImplTest, ReplaceTreeWhileScrolling) { ...@@ -1147,6 +1147,34 @@ TEST_F(LayerTreeHostImplTest, ReplaceTreeWhileScrolling) {
scroll_delta)); scroll_delta));
} }
TEST_F(LayerTreeHostImplTest, ActivateTreeScrollingNodeDisappeared) {
SetupViewportLayersOuterScrolls(gfx::Size(100, 100), gfx::Size(1000, 1000));
auto status = host_impl_->ScrollBegin(BeginState(gfx::Point(30, 30)).get(),
InputHandler::WHEEL);
EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread);
EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain,
status.main_thread_scrolling_reasons);
host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get());
EXPECT_TRUE(host_impl_->active_tree()->CurrentlyScrollingNode());
EXPECT_TRUE(host_impl_->did_lock_scrolling_layer_for_testing());
EXPECT_TRUE(host_impl_->IsActivelyScrolling());
// Create the pending tree containing only the root layer.
CreatePendingTree();
PropertyTrees pending_property_trees;
pending_property_trees.sequence_number =
host_impl_->active_tree()->property_trees()->sequence_number + 1;
host_impl_->pending_tree()->SetPropertyTrees(&pending_property_trees);
SetupRootLayer<LayerImpl>(host_impl_->pending_tree(), gfx::Size(100, 100));
host_impl_->ActivateSyncTree();
// The scroll should stop.
EXPECT_FALSE(host_impl_->active_tree()->CurrentlyScrollingNode());
EXPECT_FALSE(host_impl_->did_lock_scrolling_layer_for_testing());
EXPECT_FALSE(host_impl_->IsActivelyScrolling());
}
TEST_F(LayerTreeHostImplTest, ScrollBlocksOnWheelEventHandlers) { TEST_F(LayerTreeHostImplTest, ScrollBlocksOnWheelEventHandlers) {
SetupViewportLayersInnerScrolls(gfx::Size(50, 50), gfx::Size(100, 100)); SetupViewportLayersInnerScrolls(gfx::Size(50, 50), gfx::Size(100, 100));
auto* scroll = InnerViewportScrollLayer(); auto* scroll = InnerViewportScrollLayer();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment