Commit c687507f authored by bokan's avatar bokan Committed by Commit bot

Fix double subtraction of sent_delta on sync tree activation.

When PushPropertiesTo sets the active layer's delta to delta - sent_delta,
LayerImpl attempts to mirror this to the pending twin. However, in doing
so it again subtracts pending_delta. This patch saves the sent_delta and
clears it before setting the scroll offset and delta on the active layer.

BUG=428327

Review URL: https://codereview.chromium.org/698003006

Cr-Commit-Position: refs/heads/master@{#302709}
parent a907c318
......@@ -550,10 +550,14 @@ void LayerImpl::PushPropertiesTo(LayerImpl* layer) {
: Layer::INVALID_ID);
layer->set_user_scrollable_horizontal(user_scrollable_horizontal_);
layer->set_user_scrollable_vertical(user_scrollable_vertical_);
layer->SetScrollOffsetAndDelta(
scroll_offset_,
layer->ScrollDelta() - layer->sent_scroll_delta());
// Save the difference but clear the sent delta so that we don't subtract
// it again in SetScrollOffsetAndDelta's pending twin mirroring logic.
gfx::Vector2dF remaining_delta =
layer->ScrollDelta() - layer->sent_scroll_delta();
layer->SetSentScrollDelta(gfx::Vector2dF());
layer->SetScrollOffsetAndDelta(scroll_offset_, remaining_delta);
layer->Set3dSortingContextId(sorting_context_id_);
layer->SetNumDescendantsThatDrawContent(num_descendants_that_draw_content_);
......
......@@ -434,6 +434,8 @@ class LayerImplScrollTest : public testing::Test {
return host_impl_.active_tree()->root_layer()->children()[0];
}
LayerTreeHostImpl& host_impl() { return host_impl_; }
LayerTreeImpl* tree() { return host_impl_.active_tree(); }
LayerTreeSettings settings() {
......@@ -675,6 +677,31 @@ TEST_F(LayerImplScrollTest, ScrollUserUnscrollableLayer) {
EXPECT_VECTOR_EQ(gfx::Vector2dF(30.5f, 5), layer()->TotalScrollOffset());
}
TEST_F(LayerImplScrollTest, PushPropertiesToMirrorsTotalScrollOffset) {
gfx::ScrollOffset scroll_offset(10, 5);
gfx::Vector2dF scroll_delta(12, 18);
host_impl().CreatePendingTree();
layer()->SetScrollOffset(scroll_offset);
gfx::Vector2dF unscrolled = layer()->ScrollBy(scroll_delta);
EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), unscrolled);
EXPECT_VECTOR_EQ(gfx::Vector2dF(22, 23), layer()->TotalScrollOffset());
layer()->SetSentScrollDelta(scroll_delta);
scoped_ptr<LayerImpl> pending_layer =
LayerImpl::Create(host_impl().sync_tree(), layer()->id());
pending_layer->SetScrollOffset(layer()->TotalScrollOffset());
pending_layer->PushPropertiesTo(layer());
EXPECT_VECTOR_EQ(gfx::Vector2dF(22, 23), layer()->TotalScrollOffset());
EXPECT_VECTOR_EQ(layer()->TotalScrollOffset(),
pending_layer->TotalScrollOffset());
}
TEST_F(LayerImplScrollTest, SetNewScrollbarParameters) {
gfx::ScrollOffset scroll_offset(10, 5);
layer()->SetScrollOffset(scroll_offset);
......
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