Key scroll offsets on ElementIds instead of layer ids
Scroll offsets are stored on the ScrollTree but were keyed on layer
ids. This patch switches the scroll offsets to be keyed on ElementIds
which gets us closer to removing the Layer dependency from scrolling.
This patch removes 10 users of ScrollNode's owning_layer_id.
Bug: 693740
Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2
Change-Id: Ib6b9681518748fc223d19adce336ff9a889c9325
Reviewed-on: https://chromium-review.googlesource.com/527346
Commit-Queue: Philip Rogers <[email protected]>
Reviewed-by: Chris harrelson <[email protected]>
Reviewed-by: enne <[email protected]>
Cr-Commit-Position: refs/heads/master@{#478140}
diff --git a/cc/trees/layer_tree_host.cc b/cc/trees/layer_tree_host.cc
index 57c8142..9d6cb1de 100644
--- a/cc/trees/layer_tree_host.cc
+++ b/cc/trees/layer_tree_host.cc
@@ -753,7 +753,7 @@
void LayerTreeHost::ApplyViewportDeltas(ScrollAndScaleSet* info) {
gfx::Vector2dF inner_viewport_scroll_delta;
- if (info->inner_viewport_scroll.layer_id != Layer::INVALID_ID)
+ if (!info->inner_viewport_scroll.element_id)
inner_viewport_scroll_delta = info->inner_viewport_scroll.scroll_delta;
if (inner_viewport_scroll_delta.IsZero() && info->page_scale_delta == 1.f &&
@@ -803,7 +803,7 @@
if (root_layer_) {
for (size_t i = 0; i < info->scrolls.size(); ++i) {
- Layer* layer = LayerById(info->scrolls[i].layer_id);
+ Layer* layer = LayerByElementId(info->scrolls[i].element_id);
if (!layer)
continue;
layer->SetScrollOffsetFromImplSide(gfx::ScrollOffsetWithDelta(
diff --git a/cc/trees/layer_tree_host_common.cc b/cc/trees/layer_tree_host_common.cc
index 93b3335..ffac534 100644
--- a/cc/trees/layer_tree_host_common.cc
+++ b/cc/trees/layer_tree_host_common.cc
@@ -153,12 +153,9 @@
device_scale_factor,
render_surface_list) {}
-LayerTreeHostCommon::ScrollUpdateInfo::ScrollUpdateInfo()
- : layer_id(Layer::INVALID_ID) {}
-
bool LayerTreeHostCommon::ScrollUpdateInfo::operator==(
const LayerTreeHostCommon::ScrollUpdateInfo& other) const {
- return layer_id == other.layer_id && scroll_delta == other.scroll_delta;
+ return element_id == other.element_id && scroll_delta == other.scroll_delta;
}
LayerTreeHostCommon::ScrollbarsUpdateInfo::ScrollbarsUpdateInfo()
diff --git a/cc/trees/layer_tree_host_common.h b/cc/trees/layer_tree_host_common.h
index 522ef93c..56799bf 100644
--- a/cc/trees/layer_tree_host_common.h
+++ b/cc/trees/layer_tree_host_common.h
@@ -129,13 +129,11 @@
const Function& function);
struct CC_EXPORT ScrollUpdateInfo {
- int layer_id;
+ ElementId element_id;
// TODO(miletus): Use ScrollOffset once LayerTreeHost/Blink fully supports
// fractional scroll offset.
gfx::Vector2d scroll_delta;
- ScrollUpdateInfo();
-
bool operator==(const ScrollUpdateInfo& other) const;
};
diff --git a/cc/trees/layer_tree_host_common_unittest.cc b/cc/trees/layer_tree_host_common_unittest.cc
index ff0a6cc9..cb43d5ff 100644
--- a/cc/trees/layer_tree_host_common_unittest.cc
+++ b/cc/trees/layer_tree_host_common_unittest.cc
@@ -75,9 +75,10 @@
const gfx::Vector2dF& delta) {
if (layer_impl->layer_tree_impl()
->property_trees()
- ->scroll_tree.SetScrollOffsetDeltaForTesting(layer_impl->id(),
- delta))
- layer_impl->layer_tree_impl()->DidUpdateScrollOffset(layer_impl->id());
+ ->scroll_tree.SetScrollOffsetDeltaForTesting(
+ layer_impl->element_id(), delta))
+ layer_impl->layer_tree_impl()->DidUpdateScrollOffset(
+ layer_impl->element_id());
}
static float GetMaximumAnimationScale(LayerImpl* layer_impl) {
@@ -540,6 +541,7 @@
LayerImpl::Create(host_impl.active_tree(), 4));
LayerImpl* clip_layer = clip_layer_scoped_ptr.get();
+ scroll_layer->SetElementId(LayerIdToElementIdForTesting(scroll_layer->id()));
scroll_layer->SetScrollClipLayer(clip_layer->id());
clip_layer->SetBounds(
gfx::Size(scroll_layer->bounds().width() + kMaxScrollOffset.x(),
@@ -552,8 +554,8 @@
clip_layer->test_properties()->AddChild(std::move(scroll_layer_scoped_ptr));
scroll_layer_raw_ptr->layer_tree_impl()
->property_trees()
- ->scroll_tree.UpdateScrollOffsetBaseForTesting(scroll_layer_raw_ptr->id(),
- kScrollOffset);
+ ->scroll_tree.UpdateScrollOffsetBaseForTesting(
+ scroll_layer_raw_ptr->element_id(), kScrollOffset);
std::unique_ptr<LayerImpl> root(
LayerImpl::Create(host_impl.active_tree(), 3));
@@ -5321,6 +5323,7 @@
intervening->SetMasksToBounds(true);
clip_parent->SetMasksToBounds(true);
intervening->SetScrollClipLayer(clip_parent->id());
+ intervening->SetElementId(LayerIdToElementIdForTesting(intervening->id()));
intervening->SetCurrentScrollOffset(gfx::ScrollOffset(3, 3));
gfx::Transform translation_transform;
@@ -6122,6 +6125,7 @@
constraint.set_is_fixed_position(true);
fixed->test_properties()->position_constraint = constraint;
+ scroller->SetElementId(LayerIdToElementIdForTesting(scroller->id()));
scroller->SetScrollClipLayer(container->id());
gfx::Transform container_transform;
@@ -6245,6 +6249,7 @@
surface->test_properties()->force_render_surface = true;
container->SetBounds(gfx::Size(50, 50));
scroller->SetBounds(gfx::Size(100, 100));
+ scroller->SetElementId(LayerIdToElementIdForTesting(scroller->id()));
scroller->SetScrollClipLayer(container->id());
scroller->SetDrawsContent(true);
@@ -6287,6 +6292,7 @@
container->AddChild(scroller);
host()->SetRootLayer(root);
+ scroller->SetElementId(LayerIdToElementIdForTesting(scroller->id()));
scroller->SetScrollClipLayerId(container->id());
scroll_child->SetScrollParent(scroller.get());
@@ -6334,6 +6340,7 @@
container->AddChild(scroller);
scroller->AddChild(sticky_pos);
host()->SetRootLayer(root);
+ scroller->SetElementId(LayerIdToElementIdForTesting(scroller->id()));
scroller->SetScrollClipLayerId(container->id());
LayerStickyPositionConstraint sticky_position;
@@ -6406,6 +6413,7 @@
root->AddChild(sticky_pos);
sticky_pos->SetScrollParent(scroller.get());
host()->SetRootLayer(root);
+ scroller->SetElementId(LayerIdToElementIdForTesting(scroller->id()));
scroller->SetScrollClipLayerId(container->id());
// The sticky layer has already been scrolled on the main thread side, and has
@@ -6481,6 +6489,7 @@
container->AddChild(scroller);
scroller->AddChild(sticky_pos);
host()->SetRootLayer(root);
+ scroller->SetElementId(LayerIdToElementIdForTesting(scroller->id()));
scroller->SetScrollClipLayerId(container->id());
LayerStickyPositionConstraint sticky_position;
@@ -6526,6 +6535,7 @@
container->AddChild(scroller);
scroller->AddChild(sticky_pos);
host()->SetRootLayer(root);
+ scroller->SetElementId(LayerIdToElementIdForTesting(scroller->id()));
scroller->SetScrollClipLayerId(container->id());
LayerStickyPositionConstraint sticky_position;
@@ -6593,6 +6603,7 @@
root->AddChild(scroller);
scroller->AddChild(sticky_pos);
host()->SetRootLayer(root);
+ scroller->SetElementId(LayerIdToElementIdForTesting(scroller->id()));
scroller->SetScrollClipLayerId(root->id());
LayerTreeHost::ViewportLayers viewport_layers;
viewport_layers.page_scale = root;
@@ -6668,6 +6679,7 @@
outer_clip->AddChild(outer_viewport);
outer_viewport->AddChild(sticky_pos);
host()->SetRootLayer(root);
+ scroller->SetElementId(LayerIdToElementIdForTesting(scroller->id()));
scroller->SetScrollClipLayerId(root->id());
outer_viewport->SetScrollClipLayerId(outer_clip->id());
LayerTreeHost::ViewportLayers viewport_layers;
@@ -6750,6 +6762,7 @@
container->AddChild(scroller);
scroller->AddChild(sticky_pos);
host()->SetRootLayer(root);
+ scroller->SetElementId(LayerIdToElementIdForTesting(scroller->id()));
scroller->SetScrollClipLayerId(container->id());
LayerStickyPositionConstraint sticky_position;
@@ -6854,6 +6867,7 @@
container->AddChild(scroller);
scroller->AddChild(sticky_pos);
host()->SetRootLayer(root);
+ scroller->SetElementId(LayerIdToElementIdForTesting(scroller->id()));
scroller->SetScrollClipLayerId(container->id());
LayerStickyPositionConstraint sticky_position;
@@ -6947,6 +6961,7 @@
scroller->AddChild(sticky_container);
sticky_container->AddChild(sticky_pos);
host()->SetRootLayer(root);
+ scroller->SetElementId(LayerIdToElementIdForTesting(scroller->id()));
scroller->SetScrollClipLayerId(container->id());
LayerStickyPositionConstraint sticky_position;
@@ -7045,6 +7060,7 @@
container->AddChild(scroller);
scroller->AddChild(sticky_pos);
host()->SetRootLayer(root);
+ scroller->SetElementId(LayerIdToElementIdForTesting(scroller->id()));
scroller->SetScrollClipLayerId(container->id());
gfx::Transform t;
t.Scale(2, 2);
@@ -7123,6 +7139,7 @@
scroller->AddChild(sticky_container);
sticky_container->AddChild(sticky_pos);
host()->SetRootLayer(root);
+ scroller->SetElementId(LayerIdToElementIdForTesting(scroller->id()));
scroller->SetScrollClipLayerId(container->id());
gfx::Transform t;
t.Scale(2, 2);
@@ -7201,6 +7218,7 @@
scroller->AddChild(outer_sticky);
outer_sticky->AddChild(inner_sticky);
host()->SetRootLayer(root);
+ scroller->SetElementId(LayerIdToElementIdForTesting(scroller->id()));
scroller->SetScrollClipLayerId(container->id());
root->SetBounds(gfx::Size(100, 100));
@@ -7301,6 +7319,7 @@
LayerPositionConstraint fixed_position;
fixed_position.set_is_fixed_position(true);
+ scroller->SetElementId(LayerIdToElementIdForTesting(scroller->id()));
scroller->SetScrollClipLayerId(container->id());
fixed_pos->SetPositionConstraint(fixed_position);
@@ -7345,6 +7364,7 @@
LayerPositionConstraint fixed_position;
fixed_position.set_is_fixed_position(true);
+ scroller->SetElementId(LayerIdToElementIdForTesting(scroller->id()));
scroller->SetScrollClipLayerId(container->id());
fixed_pos->SetPositionConstraint(fixed_position);
@@ -8587,7 +8607,9 @@
frame_clip->SetMasksToBounds(true);
frame_clip->SetDrawsContent(true);
scroller->SetBounds(gfx::Size(1000, 1000));
+ scroller->SetElementId(LayerIdToElementIdForTesting(scroller->id()));
scroller->SetCurrentScrollOffset(gfx::ScrollOffset(100, 100));
+ scroller->SetElementId(LayerIdToElementIdForTesting(scroller->id()));
scroller->SetScrollClipLayer(frame_clip->id());
scroller->SetDrawsContent(true);
fixed->SetPosition(gfx::PointF(100, 100));
@@ -8676,6 +8698,8 @@
EXPECT_EQ(gfx::Rect(25, 25), scroll_child->visible_layer_rect());
scroll_child->SetPosition(gfx::PointF(0, -10.f));
+ scroll_parent->SetElementId(
+ LayerIdToElementIdForTesting(scroll_parent->id()));
scroll_parent->SetCurrentScrollOffset(gfx::ScrollOffset(0.f, 10.f));
root->layer_tree_impl()->property_trees()->needs_rebuild = true;
ExecuteCalculateDrawProperties(root);
@@ -10038,6 +10062,7 @@
MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects);
parent2->AddMainThreadScrollingReasons(
MainThreadScrollingReason::kScrollbarScrolling);
+ parent2->SetElementId(LayerIdToElementIdForTesting(parent2->id()));
parent2->SetScrollClipLayerId(root1->id());
child6->AddMainThreadScrollingReasons(
MainThreadScrollingReason::kScrollbarScrolling);
@@ -10045,9 +10070,12 @@
MainThreadScrollingReason::kScrollbarScrolling);
child7->SetScrollClipLayerId(parent3->id());
+ child7->SetElementId(LayerIdToElementIdForTesting(child7->id()));
child8->SetScrollParent(child7.get());
grand_child11->SetScrollClipLayerId(parent3->id());
+ grand_child11->SetElementId(
+ LayerIdToElementIdForTesting(grand_child11->id()));
parent5->SetNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50));
parent5->SetBounds(gfx::Size(10, 10));
@@ -10092,6 +10120,7 @@
ScrollNode scroll_parent2;
scroll_parent2.id = 2;
scroll_parent2.owning_layer_id = parent2->id();
+ scroll_parent2.element_id = parent2->element_id();
scroll_parent2.scrollable = true;
scroll_parent2.main_thread_scrolling_reasons =
parent2->main_thread_scrolling_reasons();
@@ -10124,6 +10153,7 @@
ScrollNode scroll_child7;
scroll_child7.id = 4;
scroll_child7.owning_layer_id = child7->id();
+ scroll_child7.element_id = child7->element_id();
scroll_child7.scrollable = true;
scroll_child7.scroll_clip_layer_bounds = parent3->bounds();
scroll_child7.bounds = child7->bounds();
@@ -10138,6 +10168,7 @@
ScrollNode scroll_grand_child11;
scroll_grand_child11.id = 5;
scroll_grand_child11.owning_layer_id = grand_child11->id();
+ scroll_grand_child11.element_id = grand_child11->element_id();
scroll_grand_child11.scrollable = true;
scroll_grand_child11.user_scrollable_horizontal = true;
scroll_grand_child11.user_scrollable_vertical = true;
@@ -10160,9 +10191,11 @@
expected_scroll_tree.SetOwningLayerIdForNode(expected_scroll_tree.back(),
parent5->id());
- expected_scroll_tree.SetScrollOffset(parent2->id(), gfx::ScrollOffset(0, 0));
- expected_scroll_tree.SetScrollOffset(child7->id(), gfx::ScrollOffset(0, 0));
- expected_scroll_tree.SetScrollOffset(grand_child11->id(),
+ expected_scroll_tree.SetScrollOffset(parent2->element_id(),
+ gfx::ScrollOffset(0, 0));
+ expected_scroll_tree.SetScrollOffset(child7->element_id(),
+ gfx::ScrollOffset(0, 0));
+ expected_scroll_tree.SetScrollOffset(grand_child11->element_id(),
gfx::ScrollOffset(0, 0));
expected_scroll_tree.set_needs_update(false);
diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc
index 52b6bc4..f55d4d6 100644
--- a/cc/trees/layer_tree_host_impl.cc
+++ b/cc/trees/layer_tree_host_impl.cc
@@ -2960,7 +2960,7 @@
adjusted_scroll.set_y(0);
gfx::ScrollOffset old_offset =
- scroll_tree.current_scroll_offset(scroll_node->owning_layer_id);
+ scroll_tree.current_scroll_offset(scroll_node->element_id);
gfx::ScrollOffset new_offset = scroll_tree.ClampScrollOffsetToLimits(
old_offset + gfx::ScrollOffset(adjusted_scroll), scroll_node);
@@ -2984,7 +2984,7 @@
scroll_tree.set_currently_scrolling_node(scroll_node->id);
gfx::ScrollOffset current_offset =
- scroll_tree.current_scroll_offset(scroll_node->owning_layer_id);
+ scroll_tree.current_scroll_offset(scroll_node->element_id);
gfx::ScrollOffset target_offset = scroll_tree.ClampScrollOffsetToLimits(
current_offset + gfx::ScrollOffset(delta), scroll_node);
DCHECK_EQ(
@@ -3152,11 +3152,11 @@
// Apply the scroll delta.
gfx::ScrollOffset previous_offset =
- scroll_tree->current_scroll_offset(scroll_node->owning_layer_id);
+ scroll_tree->current_scroll_offset(scroll_node->element_id);
scroll_tree->ScrollBy(scroll_node, local_end_point - local_start_point,
active_tree());
gfx::ScrollOffset scrolled =
- scroll_tree->current_scroll_offset(scroll_node->owning_layer_id) -
+ scroll_tree->current_scroll_offset(scroll_node->element_id) -
previous_offset;
// Get the end point in the layer's content space so we can apply its
@@ -3182,12 +3182,12 @@
LayerTreeImpl* layer_tree_impl) {
ScrollTree& scroll_tree = layer_tree_impl->property_trees()->scroll_tree;
gfx::ScrollOffset previous_offset =
- scroll_tree.current_scroll_offset(scroll_node->owning_layer_id);
+ scroll_tree.current_scroll_offset(scroll_node->element_id);
gfx::Vector2dF delta = local_delta;
delta.Scale(1.f / page_scale_factor);
scroll_tree.ScrollBy(scroll_node, delta, layer_tree_impl);
gfx::ScrollOffset scrolled =
- scroll_tree.current_scroll_offset(scroll_node->owning_layer_id) -
+ scroll_tree.current_scroll_offset(scroll_node->element_id) -
previous_offset;
gfx::Vector2dF consumed_scroll(scrolled.x(), scrolled.y());
consumed_scroll.Scale(page_scale_factor);
@@ -3596,13 +3596,13 @@
if (tree_impl->LayerListIsEmpty())
return;
- int inner_viewport_layer_id =
+ ElementId inner_viewport_scroll_element_id =
tree_impl->InnerViewportScrollLayer()
- ? tree_impl->InnerViewportScrollLayer()->id()
- : Layer::INVALID_ID;
+ ? tree_impl->InnerViewportScrollLayer()->element_id()
+ : ElementId();
tree_impl->property_trees()->scroll_tree.CollectScrollDeltas(
- scroll_info, inner_viewport_layer_id);
+ scroll_info, inner_viewport_scroll_element_id);
}
static void CollectScrollbarUpdates(
@@ -4140,14 +4140,13 @@
if (!tree)
return;
- const int layer_id = tree->LayerIdByElementId(element_id);
PropertyTrees* property_trees = tree->property_trees();
DCHECK_EQ(1u,
property_trees->element_id_to_scroll_node_index.count(element_id));
const int scroll_node_index =
property_trees->element_id_to_scroll_node_index[element_id];
property_trees->scroll_tree.OnScrollOffsetAnimated(
- layer_id, scroll_node_index, scroll_offset, tree);
+ element_id, scroll_node_index, scroll_offset, tree);
// Run mutation callbacks to respond to updated scroll offset.
Mutate(CurrentBeginFrameArgs().frame_time);
}
diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc
index 176e8b34..69fd2ff3 100644
--- a/cc/trees/layer_tree_host_impl_unittest.cc
+++ b/cc/trees/layer_tree_host_impl_unittest.cc
@@ -250,10 +250,10 @@
}
static gfx::Vector2dF ScrollDelta(LayerImpl* layer_impl) {
- gfx::ScrollOffset delta =
- layer_impl->layer_tree_impl()
- ->property_trees()
- ->scroll_tree.GetScrollOffsetDeltaForTesting(layer_impl->id());
+ gfx::ScrollOffset delta = layer_impl->layer_tree_impl()
+ ->property_trees()
+ ->scroll_tree.GetScrollOffsetDeltaForTesting(
+ layer_impl->element_id());
return gfx::Vector2dF(delta.x(), delta.y());
}
@@ -264,12 +264,12 @@
static ::testing::AssertionResult ScrollInfoContains(
const ScrollAndScaleSet& scroll_info,
- int id,
+ ElementId id,
const gfx::Vector2d& scroll_delta) {
int times_encountered = 0;
for (size_t i = 0; i < scroll_info.scrolls.size(); ++i) {
- if (scroll_info.scrolls[i].layer_id != id)
+ if (scroll_info.scrolls[i].element_id != id)
continue;
if (scroll_delta != scroll_info.scrolls[i].scroll_delta) {
@@ -280,7 +280,7 @@
times_encountered++;
}
- if (id == scroll_info.inner_viewport_scroll.layer_id) {
+ if (id == scroll_info.inner_viewport_scroll.element_id) {
if (scroll_delta != scroll_info.inner_viewport_scroll.scroll_delta) {
return ::testing::AssertionFailure()
<< "Expected " << scroll_delta.ToString() << ", not "
@@ -290,15 +290,15 @@
}
if (times_encountered != 1)
- return ::testing::AssertionFailure() << "No layer found with id " << id;
+ return ::testing::AssertionFailure() << "No scroll found with id " << id;
return ::testing::AssertionSuccess();
}
- static void ExpectNone(const ScrollAndScaleSet& scroll_info, int id) {
+ static void ExpectNone(const ScrollAndScaleSet& scroll_info, ElementId id) {
int times_encountered = 0;
for (size_t i = 0; i < scroll_info.scrolls.size(); ++i) {
- if (scroll_info.scrolls[i].layer_id != id)
+ if (scroll_info.scrolls[i].element_id != id)
continue;
times_encountered++;
}
@@ -333,8 +333,8 @@
true;
inner_scroll->layer_tree_impl()
->property_trees()
- ->scroll_tree.UpdateScrollOffsetBaseForTesting(inner_scroll->id(),
- gfx::ScrollOffset());
+ ->scroll_tree.UpdateScrollOffsetBaseForTesting(
+ inner_scroll->element_id(), gfx::ScrollOffset());
std::unique_ptr<LayerImpl> inner_clip =
LayerImpl::Create(layer_tree_impl, kInnerViewportClipLayerId);
@@ -363,8 +363,8 @@
LayerIdToElementIdForTesting(outer_scroll->id()));
outer_scroll->layer_tree_impl()
->property_trees()
- ->scroll_tree.UpdateScrollOffsetBaseForTesting(outer_scroll->id(),
- gfx::ScrollOffset());
+ ->scroll_tree.UpdateScrollOffsetBaseForTesting(
+ outer_scroll->element_id(), gfx::ScrollOffset());
outer_scroll->SetBounds(content_size);
outer_scroll->SetPosition(gfx::PointF());
@@ -515,9 +515,10 @@
const gfx::Vector2dF& delta) {
if (layer_impl->layer_tree_impl()
->property_trees()
- ->scroll_tree.SetScrollOffsetDeltaForTesting(layer_impl->id(),
- delta))
- layer_impl->layer_tree_impl()->DidUpdateScrollOffset(layer_impl->id());
+ ->scroll_tree.SetScrollOffsetDeltaForTesting(
+ layer_impl->element_id(), delta))
+ layer_impl->layer_tree_impl()->DidUpdateScrollOffset(
+ layer_impl->element_id());
}
void BeginImplFrameAndAnimate(BeginFrameArgs begin_frame_args,
@@ -741,7 +742,8 @@
root->SetElementId(LayerIdToElementIdForTesting(root->id()));
root->layer_tree_impl()
->property_trees()
- ->scroll_tree.UpdateScrollOffsetBaseForTesting(root->id(), scroll_offset);
+ ->scroll_tree.UpdateScrollOffsetBaseForTesting(root->element_id(),
+ scroll_offset);
host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_clip_owned));
host_impl_->active_tree()->BuildPropertyTreesForTesting();
@@ -750,18 +752,19 @@
root->ScrollBy(scroll_delta);
scroll_info = host_impl_->ProcessScrollDeltas();
ASSERT_EQ(scroll_info->scrolls.size(), 1u);
- EXPECT_TRUE(ScrollInfoContains(*scroll_info, root->id(), scroll_delta));
+ EXPECT_TRUE(
+ ScrollInfoContains(*scroll_info, root->element_id(), scroll_delta));
gfx::Vector2d scroll_delta2(-5, 27);
root->ScrollBy(scroll_delta2);
scroll_info = host_impl_->ProcessScrollDeltas();
ASSERT_EQ(scroll_info->scrolls.size(), 1u);
- EXPECT_TRUE(ScrollInfoContains(*scroll_info, root->id(),
+ EXPECT_TRUE(ScrollInfoContains(*scroll_info, root->element_id(),
scroll_delta + scroll_delta2));
root->ScrollBy(gfx::Vector2d());
scroll_info = host_impl_->ProcessScrollDeltas();
- EXPECT_TRUE(ScrollInfoContains(*scroll_info, root->id(),
+ EXPECT_TRUE(ScrollInfoContains(*scroll_info, root->element_id(),
scroll_delta + scroll_delta2));
}
@@ -922,8 +925,8 @@
host_impl_->ScrollEnd(EndState().get());
std::unique_ptr<ScrollAndScaleSet> scroll_info =
host_impl_->ProcessScrollDeltas();
- EXPECT_TRUE(
- ScrollInfoContains(*scroll_info, scroll_layer->id(), scroll_delta));
+ EXPECT_TRUE(ScrollInfoContains(*scroll_info, scroll_layer->element_id(),
+ scroll_delta));
}
TEST_F(LayerTreeHostImplTest, ScrollBlocksOnWheelEventHandlers) {
@@ -1428,7 +1431,7 @@
overflow->SetElementId(LayerIdToElementIdForTesting(overflow->id()));
overflow->layer_tree_impl()
->property_trees()
- ->scroll_tree.UpdateScrollOffsetBaseForTesting(overflow->id(),
+ ->scroll_tree.UpdateScrollOffsetBaseForTesting(overflow->element_id(),
gfx::ScrollOffset());
overflow->SetPosition(gfx::PointF());
host_impl_->active_tree()->BuildPropertyTreesForTesting();
@@ -1802,7 +1805,7 @@
std::unique_ptr<ScrollAndScaleSet> scroll_info =
host_impl_->ProcessScrollDeltas();
EXPECT_TRUE(ScrollInfoContains(
- *scroll_info.get(), scroll_layer->id(),
+ *scroll_info.get(), scroll_layer->element_id(),
gfx::Vector2d(0, scroll_delta.y() / page_scale_delta)));
}
}
@@ -2283,7 +2286,7 @@
scroll_layer->layer_tree_impl()
->property_trees()
->scroll_tree.UpdateScrollOffsetBaseForTesting(
- scroll_layer->id(), gfx::ScrollOffset(50, 50));
+ scroll_layer->element_id(), gfx::ScrollOffset(50, 50));
float page_scale_delta = 0.1f;
host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
@@ -2311,7 +2314,7 @@
scroll_layer->layer_tree_impl()
->property_trees()
->scroll_tree.UpdateScrollOffsetBaseForTesting(
- scroll_layer->id(), gfx::ScrollOffset(20, 20));
+ scroll_layer->element_id(), gfx::ScrollOffset(20, 20));
float page_scale_delta = 1.f;
host_impl_->ScrollBegin(BeginState(gfx::Point(10, 10)).get(),
@@ -2339,7 +2342,7 @@
scroll_layer->layer_tree_impl()
->property_trees()
->scroll_tree.UpdateScrollOffsetBaseForTesting(
- scroll_layer->id(), gfx::ScrollOffset(20, 20));
+ scroll_layer->element_id(), gfx::ScrollOffset(20, 20));
float page_scale_delta = 1.f;
host_impl_->ScrollBegin(BeginState(gfx::Point(10, 10)).get(),
@@ -2355,7 +2358,7 @@
std::unique_ptr<ScrollAndScaleSet> scroll_info =
host_impl_->ProcessScrollDeltas();
EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta);
- EXPECT_TRUE(ScrollInfoContains(*scroll_info, scroll_layer->id(),
+ EXPECT_TRUE(ScrollInfoContains(*scroll_info, scroll_layer->element_id(),
gfx::Vector2d(-10, -10)));
}
@@ -2368,8 +2371,8 @@
->scroll_tree.CollectScrollDeltasForTesting();
scroll_layer->layer_tree_impl()
->property_trees()
- ->scroll_tree.UpdateScrollOffsetBaseForTesting(scroll_layer->id(),
- gfx::ScrollOffset(0, 0));
+ ->scroll_tree.UpdateScrollOffsetBaseForTesting(
+ scroll_layer->element_id(), gfx::ScrollOffset(0, 0));
host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(),
InputHandler::TOUCHSCREEN);
@@ -2389,7 +2392,7 @@
std::unique_ptr<ScrollAndScaleSet> scroll_info =
host_impl_->ProcessScrollDeltas();
EXPECT_EQ(scroll_info->page_scale_delta, 2.f);
- EXPECT_TRUE(ScrollInfoContains(*scroll_info, scroll_layer->id(),
+ EXPECT_TRUE(ScrollInfoContains(*scroll_info, scroll_layer->element_id(),
gfx::Vector2d(10, 10)));
}
}
@@ -2420,7 +2423,7 @@
scroll_layer->layer_tree_impl()
->property_trees()
->scroll_tree.UpdateScrollOffsetBaseForTesting(
- scroll_layer->id(), gfx::ScrollOffset(50, 50));
+ scroll_layer->element_id(), gfx::ScrollOffset(50, 50));
did_request_redraw_ = false;
did_request_next_frame_ = false;
@@ -2466,7 +2469,7 @@
std::unique_ptr<ScrollAndScaleSet> scroll_info =
host_impl_->ProcessScrollDeltas();
EXPECT_EQ(scroll_info->page_scale_delta, 2);
- EXPECT_TRUE(ScrollInfoContains(*scroll_info, scroll_layer->id(),
+ EXPECT_TRUE(ScrollInfoContains(*scroll_info, scroll_layer->element_id(),
gfx::Vector2d(-50, -50)));
}
@@ -2481,7 +2484,7 @@
scroll_layer->layer_tree_impl()
->property_trees()
->scroll_tree.UpdateScrollOffsetBaseForTesting(
- scroll_layer->id(), gfx::ScrollOffset(50, 50));
+ scroll_layer->element_id(), gfx::ScrollOffset(50, 50));
did_request_redraw_ = false;
did_request_next_frame_ = false;
@@ -2519,7 +2522,7 @@
host_impl_->ProcessScrollDeltas();
EXPECT_EQ(scroll_info->page_scale_delta, min_page_scale);
// Pushed to (0,0) via clamping against contents layer size.
- EXPECT_TRUE(ScrollInfoContains(*scroll_info, scroll_layer->id(),
+ EXPECT_TRUE(ScrollInfoContains(*scroll_info, scroll_layer->element_id(),
gfx::Vector2d(-50, -50)));
}
}
@@ -2550,7 +2553,7 @@
scroll_layer->layer_tree_impl()
->property_trees()
->scroll_tree.UpdateScrollOffsetBaseForTesting(
- scroll_layer->id(), gfx::ScrollOffset(50, 50));
+ scroll_layer->element_id(), gfx::ScrollOffset(50, 50));
host_impl_->active_tree()->SetPendingPageScaleAnimation(
std::unique_ptr<PendingPageScaleAnimation>(
@@ -2580,7 +2583,7 @@
std::unique_ptr<ScrollAndScaleSet> scroll_info =
host_impl_->ProcessScrollDeltas();
EXPECT_EQ(scroll_info->page_scale_delta, 1);
- ExpectNone(*scroll_info, scroll_layer->id());
+ ExpectNone(*scroll_info, scroll_layer->element_id());
}
}
@@ -2615,7 +2618,7 @@
scroll_layer->layer_tree_impl()
->property_trees()
- ->scroll_tree.UpdateScrollOffsetBaseForTesting(scroll_layer->id(),
+ ->scroll_tree.UpdateScrollOffsetBaseForTesting(scroll_layer->element_id(),
gfx::ScrollOffset(50, 50));
// Make sure TakePageScaleAnimation works properly.
@@ -2705,7 +2708,7 @@
std::unique_ptr<ScrollAndScaleSet> scroll_info =
host_impl_->ProcessScrollDeltas();
EXPECT_EQ(scroll_info->page_scale_delta, target_scale);
- EXPECT_TRUE(ScrollInfoContains(*scroll_info, scroll_layer->id(),
+ EXPECT_TRUE(ScrollInfoContains(*scroll_info, scroll_layer->element_id(),
gfx::Vector2d(-50, -50)));
}
@@ -2729,7 +2732,7 @@
host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f);
scroll_layer->layer_tree_impl()
->property_trees()
- ->scroll_tree.UpdateScrollOffsetBaseForTesting(scroll_layer->id(),
+ ->scroll_tree.UpdateScrollOffsetBaseForTesting(scroll_layer->element_id(),
gfx::ScrollOffset(50, 50));
did_complete_page_scale_animation_ = false;
@@ -2990,10 +2993,10 @@
if (host_impl_->active_tree()
->property_trees()
->scroll_tree.UpdateScrollOffsetBaseForTesting(
- host_impl_->InnerViewportScrollLayer()->id(),
+ host_impl_->InnerViewportScrollLayer()->element_id(),
gfx::ScrollOffset(5, 5)))
host_impl_->active_tree()->DidUpdateScrollOffset(
- host_impl_->InnerViewportScrollLayer()->id());
+ host_impl_->InnerViewportScrollLayer()->element_id());
EXPECT_FALSE(did_request_next_frame_);
EXPECT_FALSE(did_request_redraw_);
EXPECT_EQ(base::TimeDelta(), requested_animation_delay_);
@@ -4175,8 +4178,8 @@
host_impl_->pending_tree()->OuterViewportScrollLayer();
pending_outer_layer->layer_tree_impl()
->property_trees()
- ->scroll_tree.UpdateScrollOffsetBaseForTesting(pending_outer_layer->id(),
- pending_scroll);
+ ->scroll_tree.UpdateScrollOffsetBaseForTesting(
+ pending_outer_layer->element_id(), pending_scroll);
host_impl_->ActivateSyncTree();
// Scrolloffsets on the active tree will be clamped after activation.
@@ -5219,7 +5222,7 @@
{
host_impl_->pending_tree()
->property_trees()
- ->scroll_tree.SetScrollOffsetDeltaForTesting(outer_scroll->id(),
+ ->scroll_tree.SetScrollOffsetDeltaForTesting(outer_scroll->element_id(),
gfx::Vector2dF(0, 1050));
host_impl_->ActivateSyncTree();
@@ -5424,7 +5427,7 @@
std::unique_ptr<ScrollAndScaleSet> scroll_info =
host_impl_->ProcessScrollDeltas();
- EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), inner_scroll->id(),
+ EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), inner_scroll->element_id(),
expected_scroll_delta));
// The scroll range should also have been updated.
@@ -5483,7 +5486,7 @@
// The scroll delta is not scaled because the main thread did not scale.
std::unique_ptr<ScrollAndScaleSet> scroll_info =
host_impl_->ProcessScrollDeltas();
- EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), inner_scroll->id(),
+ EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), inner_scroll->element_id(),
expected_scroll_delta));
// The scroll range should also have been updated.
@@ -5582,7 +5585,7 @@
std::unique_ptr<ScrollAndScaleSet> scroll_info =
host_impl_->ProcessScrollDeltas();
- EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), inner_scroll->id(),
+ EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), inner_scroll->element_id(),
expected_scroll_delta));
// The scroll range should not have changed.
@@ -5618,11 +5621,11 @@
grand_child_layer->layer_tree_impl()
->property_trees()
- ->scroll_tree.UpdateScrollOffsetBaseForTesting(grand_child_layer->id(),
- gfx::ScrollOffset(0, 5));
+ ->scroll_tree.UpdateScrollOffsetBaseForTesting(
+ grand_child_layer->element_id(), gfx::ScrollOffset(0, 5));
child_layer->layer_tree_impl()
->property_trees()
- ->scroll_tree.UpdateScrollOffsetBaseForTesting(child_layer->id(),
+ ->scroll_tree.UpdateScrollOffsetBaseForTesting(child_layer->element_id(),
gfx::ScrollOffset(3, 0));
host_impl_->SetViewportSize(surface_size);
@@ -5645,11 +5648,12 @@
->root_layer_for_testing()
->test_properties()
->children[0];
- EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), grand_child_layer->id(),
+ EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(),
+ grand_child_layer->element_id(),
gfx::Vector2d(0, -5)));
// The child should not have scrolled.
- ExpectNone(*scroll_info.get(), child->id());
+ ExpectNone(*scroll_info.get(), child->element_id());
}
}
@@ -5684,11 +5688,11 @@
grand_child_layer->layer_tree_impl()
->property_trees()
- ->scroll_tree.UpdateScrollOffsetBaseForTesting(grand_child_layer->id(),
- gfx::ScrollOffset(0, 30));
+ ->scroll_tree.UpdateScrollOffsetBaseForTesting(
+ grand_child_layer->element_id(), gfx::ScrollOffset(0, 30));
child_layer->layer_tree_impl()
->property_trees()
- ->scroll_tree.UpdateScrollOffsetBaseForTesting(child_layer->id(),
+ ->scroll_tree.UpdateScrollOffsetBaseForTesting(child_layer->element_id(),
gfx::ScrollOffset(0, 50));
host_impl_->SetViewportSize(surface_size);
@@ -5797,11 +5801,11 @@
grand_child_layer->layer_tree_impl()
->property_trees()
- ->scroll_tree.UpdateScrollOffsetBaseForTesting(grand_child_layer->id(),
- gfx::ScrollOffset(0, 2));
+ ->scroll_tree.UpdateScrollOffsetBaseForTesting(
+ grand_child_layer->element_id(), gfx::ScrollOffset(0, 2));
child_layer->layer_tree_impl()
->property_trees()
- ->scroll_tree.UpdateScrollOffsetBaseForTesting(child_layer->id(),
+ ->scroll_tree.UpdateScrollOffsetBaseForTesting(child_layer->element_id(),
gfx::ScrollOffset(0, 3));
DrawFrame();
@@ -5828,11 +5832,11 @@
->test_properties()
->children[0];
LayerImpl* grand_child = child->test_properties()->children[0];
- EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), grand_child->id(),
- gfx::Vector2d(0, -2)));
+ EXPECT_TRUE(ScrollInfoContains(
+ *scroll_info.get(), grand_child->element_id(), gfx::Vector2d(0, -2)));
// The child should not have scrolled.
- ExpectNone(*scroll_info.get(), child->id());
+ ExpectNone(*scroll_info.get(), child->element_id());
// The next time we scroll we should only scroll the parent.
scroll_delta = gfx::Vector2d(0, -3);
@@ -5851,12 +5855,12 @@
scroll_info = host_impl_->ProcessScrollDeltas();
// The child should have scrolled up to its limit.
- EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), child->id(),
+ EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), child->element_id(),
gfx::Vector2d(0, -3)));
// The grand child should not have scrolled.
- EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), grand_child->id(),
- gfx::Vector2d(0, -2)));
+ EXPECT_TRUE(ScrollInfoContains(
+ *scroll_info.get(), grand_child->element_id(), gfx::Vector2d(0, -2)));
// After scrolling the parent, another scroll on the opposite direction
// should still scroll the child.
@@ -5876,11 +5880,11 @@
scroll_info = host_impl_->ProcessScrollDeltas();
// The grand child should have scrolled.
- EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), grand_child->id(),
- gfx::Vector2d(0, 5)));
+ EXPECT_TRUE(ScrollInfoContains(
+ *scroll_info.get(), grand_child->element_id(), gfx::Vector2d(0, 5)));
// The child should not have scrolled.
- EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), child->id(),
+ EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), child->element_id(),
gfx::Vector2d(0, -3)));
// Scrolling should be adjusted from viewport space.
@@ -5901,8 +5905,8 @@
scroll_info = host_impl_->ProcessScrollDeltas();
// Should have scrolled by half the amount in layer space (5 - 2/2)
- EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), grand_child->id(),
- gfx::Vector2d(0, 4)));
+ EXPECT_TRUE(ScrollInfoContains(
+ *scroll_info.get(), grand_child->element_id(), gfx::Vector2d(0, 4)));
}
}
TEST_F(LayerTreeHostImplTest, ScrollEventBubbling) {
@@ -5927,7 +5931,7 @@
child->test_properties()->is_container_for_fixed_position_layers = true;
root_scroll->SetBounds(content_size);
- int root_scroll_id = root_scroll->id();
+ ElementId root_scroll_id = root_scroll->element_id();
root_scroll->test_properties()->AddChild(std::move(child));
root_clip->test_properties()->AddChild(std::move(root_scroll));
root_ptr->test_properties()->AddChild(std::move(root_clip));
@@ -6080,7 +6084,7 @@
// The layer should have scrolled down in its local coordinates.
std::unique_ptr<ScrollAndScaleSet> scroll_info =
host_impl_->ProcessScrollDeltas();
- EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), scroll_layer->id(),
+ EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), scroll_layer->element_id(),
gfx::Vector2d(0, gesture_scroll_delta.x())));
// Reset and scroll down with the wheel.
@@ -6096,7 +6100,7 @@
// The layer should have scrolled down in its local coordinates.
scroll_info = host_impl_->ProcessScrollDeltas();
- EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), scroll_layer->id(),
+ EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), scroll_layer->element_id(),
wheel_scroll_delta));
}
@@ -6130,6 +6134,8 @@
scroll_layer->test_properties()->AddChild(std::move(clip_layer));
host_impl_->active_tree()->BuildPropertyTreesForTesting();
+ ElementId child_scroll_id = LayerIdToElementIdForTesting(child_layer_id);
+
gfx::Size surface_size(50, 50);
host_impl_->SetViewportSize(surface_size);
DrawFrame();
@@ -6151,7 +6157,7 @@
std::cos(MathUtil::Deg2Rad(child_layer_angle)));
std::unique_ptr<ScrollAndScaleSet> scroll_info =
host_impl_->ProcessScrollDeltas();
- EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), child_layer_id,
+ EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), child_scroll_id,
expected_scroll_delta));
// The root scroll layer should not have scrolled, because the input delta
@@ -6176,11 +6182,11 @@
std::sin(MathUtil::Deg2Rad(child_layer_angle)));
std::unique_ptr<ScrollAndScaleSet> scroll_info =
host_impl_->ProcessScrollDeltas();
- EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), child_layer_id,
+ EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), child_scroll_id,
expected_scroll_delta));
// The root scroll layer shouldn't have scrolled.
- ExpectNone(*scroll_info.get(), scroll_layer->id());
+ ExpectNone(*scroll_info.get(), scroll_layer->element_id());
}
}
@@ -6255,7 +6261,8 @@
host_impl_->ScrollEnd(EndState().get());
scroll_info = host_impl_->ProcessScrollDeltas();
- EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), child_layer_id,
+ ElementId child_scroll_id = LayerIdToElementIdForTesting(child_layer_id);
+ EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), child_scroll_id,
expected_scroll_deltas[i]));
// The root scroll layer should not have scrolled, because the input delta
@@ -6293,7 +6300,7 @@
// amount.
std::unique_ptr<ScrollAndScaleSet> scroll_info =
host_impl_->ProcessScrollDeltas();
- EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), scroll_layer->id(),
+ EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), scroll_layer->element_id(),
gfx::Vector2d(0, scroll_delta.y() / scale)));
// Reset and scroll down with the wheel.
@@ -6309,7 +6316,7 @@
// It should apply the scale factor to the scroll delta for the wheel event.
scroll_info = host_impl_->ProcessScrollDeltas();
- EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), scroll_layer->id(),
+ EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), scroll_layer->element_id(),
wheel_scroll_delta));
}
@@ -6345,7 +6352,7 @@
gfx::Vector2dF initial_scroll_delta(10.f, 10.f);
scroll_layer->layer_tree_impl()
->property_trees()
- ->scroll_tree.UpdateScrollOffsetBaseForTesting(scroll_layer->id(),
+ ->scroll_tree.UpdateScrollOffsetBaseForTesting(scroll_layer->element_id(),
gfx::ScrollOffset());
SetScrollOffsetDelta(scroll_layer, initial_scroll_delta);
@@ -6637,12 +6644,12 @@
child_layer->layer_tree_impl()
->property_trees()
- ->scroll_tree.UpdateScrollOffsetBaseForTesting(child_layer->id(),
+ ->scroll_tree.UpdateScrollOffsetBaseForTesting(child_layer->element_id(),
gfx::ScrollOffset(0, 3));
grand_child_layer->layer_tree_impl()
->property_trees()
- ->scroll_tree.UpdateScrollOffsetBaseForTesting(grand_child_layer->id(),
- gfx::ScrollOffset(0, 2));
+ ->scroll_tree.UpdateScrollOffsetBaseForTesting(
+ grand_child_layer->element_id(), gfx::ScrollOffset(0, 2));
host_impl_->SetViewportSize(surface_size);
DrawFrame();
@@ -8514,8 +8521,8 @@
scrolling_layer->layer_tree_impl()
->property_trees()
- ->scroll_tree.UpdateScrollOffsetBaseForTesting(scrolling_layer->id(),
- scroll_offset);
+ ->scroll_tree.UpdateScrollOffsetBaseForTesting(
+ scrolling_layer->element_id(), scroll_offset);
host_impl_->ActivateSyncTree();
bool update_lcd_text = false;
@@ -8940,7 +8947,7 @@
CreateScrollableLayer(2, content_size, root_clip.get());
root_scroll->test_properties()->AddChild(std::move(child));
- int root_id = root_scroll->id();
+ ElementId root_id = root_scroll->element_id();
root_clip->test_properties()->AddChild(std::move(root_scroll));
root_ptr->test_properties()->AddChild(std::move(root_clip));
@@ -9007,11 +9014,11 @@
child->layer_tree_impl()
->property_trees()
- ->scroll_tree.UpdateScrollOffsetBaseForTesting(child->id(),
+ ->scroll_tree.UpdateScrollOffsetBaseForTesting(child->element_id(),
gfx::ScrollOffset(0, 4));
grand_child->layer_tree_impl()
->property_trees()
- ->scroll_tree.UpdateScrollOffsetBaseForTesting(grand_child->id(),
+ ->scroll_tree.UpdateScrollOffsetBaseForTesting(grand_child->element_id(),
gfx::ScrollOffset(0, 2));
host_impl_->SetViewportSize(surface_size);
@@ -9032,8 +9039,10 @@
// The grand child should have scrolled up to its limit.
scroll_info = host_impl_->ProcessScrollDeltas();
ASSERT_EQ(1u, scroll_info->scrolls.size());
+ ElementId grand_child_scroll_id =
+ LayerIdToElementIdForTesting(grand_child->id());
EXPECT_TRUE(
- ScrollInfoContains(*scroll_info, grand_child->id(), scroll_delta));
+ ScrollInfoContains(*scroll_info, grand_child_scroll_id, scroll_delta));
EXPECT_EQ(host_impl_->CurrentlyScrollingNode()->id,
grand_child->scroll_tree_index());
@@ -9044,8 +9053,8 @@
scroll_info = host_impl_->ProcessScrollDeltas();
ASSERT_EQ(1u, scroll_info->scrolls.size());
EXPECT_TRUE(
- ScrollInfoContains(*scroll_info, grand_child->id(), scroll_delta));
- ExpectNone(*scroll_info, child->id());
+ ScrollInfoContains(*scroll_info, grand_child_scroll_id, scroll_delta));
+ ExpectNone(*scroll_info, child->element_id());
EXPECT_EQ(host_impl_->CurrentlyScrollingNode()->id,
grand_child->scroll_tree_index());
@@ -9061,8 +9070,8 @@
scroll_info = host_impl_->ProcessScrollDeltas();
ASSERT_EQ(1u, scroll_info->scrolls.size());
EXPECT_TRUE(
- ScrollInfoContains(*scroll_info, grand_child->id(), scroll_delta));
- ExpectNone(*scroll_info, child->id());
+ ScrollInfoContains(*scroll_info, grand_child_scroll_id, scroll_delta));
+ ExpectNone(*scroll_info, child->element_id());
// As the locked layer is at it's limit, no further scrolling can occur.
EXPECT_FALSE(
@@ -9083,7 +9092,7 @@
root_clip->test_properties()->force_render_surface = true;
std::unique_ptr<LayerImpl> root_scroll =
CreateScrollableLayer(11, content_size, root_clip);
- int root_scroll_id = root_scroll->id();
+ ElementId root_scroll_id = root_scroll->element_id();
std::unique_ptr<LayerImpl> child =
CreateScrollableLayer(12, content_size, root_clip);
@@ -9461,7 +9470,7 @@
LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100));
scroll_layer->layer_tree_impl()
->property_trees()
- ->scroll_tree.UpdateScrollOffsetBaseForTesting(scroll_layer->id(),
+ ->scroll_tree.UpdateScrollOffsetBaseForTesting(scroll_layer->element_id(),
gfx::ScrollOffset(0, 10));
BeginFrameArgs begin_frame_args =
CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 2);
@@ -9502,7 +9511,7 @@
LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100));
scroll_layer->layer_tree_impl()
->property_trees()
- ->scroll_tree.UpdateScrollOffsetBaseForTesting(scroll_layer->id(),
+ ->scroll_tree.UpdateScrollOffsetBaseForTesting(scroll_layer->element_id(),
gfx::ScrollOffset(0, 10));
host_impl_->DidChangeBrowserControlsPosition();
EXPECT_TRUE(did_request_next_frame_);
@@ -9719,7 +9728,8 @@
scroll_layer->layer_tree_impl()
->property_trees()
->scroll_tree.UpdateScrollOffsetBaseForTesting(
- scroll_layer->id(), gfx::ScrollOffset(0, initial_scroll_offset));
+ scroll_layer->element_id(),
+ gfx::ScrollOffset(0, initial_scroll_offset));
DrawFrame();
EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
@@ -9796,7 +9806,8 @@
scroll_layer->layer_tree_impl()
->property_trees()
->scroll_tree.UpdateScrollOffsetBaseForTesting(
- scroll_layer->id(), gfx::ScrollOffset(0, initial_scroll_offset));
+ scroll_layer->element_id(),
+ gfx::ScrollOffset(0, initial_scroll_offset));
DrawFrame();
EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
@@ -10027,8 +10038,8 @@
true;
inner_scroll->layer_tree_impl()
->property_trees()
- ->scroll_tree.UpdateScrollOffsetBaseForTesting(inner_scroll->id(),
- gfx::ScrollOffset());
+ ->scroll_tree.UpdateScrollOffsetBaseForTesting(
+ inner_scroll->element_id(), gfx::ScrollOffset());
std::unique_ptr<LayerImpl> inner_clip =
LayerImpl::Create(layer_tree_impl, kInnerViewportClipLayerId);
@@ -10056,8 +10067,8 @@
LayerIdToElementIdForTesting(outer_scroll->id()));
outer_scroll->layer_tree_impl()
->property_trees()
- ->scroll_tree.UpdateScrollOffsetBaseForTesting(outer_scroll->id(),
- gfx::ScrollOffset());
+ ->scroll_tree.UpdateScrollOffsetBaseForTesting(
+ outer_scroll->element_id(), gfx::ScrollOffset());
outer_scroll->SetBounds(content_size);
outer_scroll->SetPosition(gfx::PointF());
@@ -10270,6 +10281,8 @@
std::move(child));
host_impl_->active_tree()->BuildPropertyTreesForTesting();
+ ElementId child_scroll_id = LayerIdToElementIdForTesting(child_scroll->id());
+
DrawFrame();
{
std::unique_ptr<ScrollAndScaleSet> scroll_info;
@@ -10290,7 +10303,7 @@
scroll_info = host_impl_->ProcessScrollDeltas();
ASSERT_EQ(1u, scroll_info->scrolls.size());
EXPECT_TRUE(
- ScrollInfoContains(*scroll_info, child_scroll->id(), scroll_delta));
+ ScrollInfoContains(*scroll_info, child_scroll_id, scroll_delta));
EXPECT_EQ(host_impl_->CurrentlyScrollingNode()->id,
child_scroll->scroll_tree_index());
@@ -10309,8 +10322,8 @@
scroll_info = host_impl_->ProcessScrollDeltas();
ASSERT_EQ(1u, scroll_info->scrolls.size());
EXPECT_TRUE(
- ScrollInfoContains(*scroll_info, child_scroll->id(), scroll_delta));
- ExpectNone(*scroll_info, inner_scroll->id());
+ ScrollInfoContains(*scroll_info, child_scroll_id, scroll_delta));
+ ExpectNone(*scroll_info, inner_scroll->element_id());
// As the locked layer is at its limit, no further scrolling can occur.
EXPECT_FALSE(
@@ -12146,11 +12159,11 @@
gfx::ScrollOffset pending_base =
pending_tree->property_trees()
->scroll_tree.GetScrollOffsetBaseForTesting(
- last_scrolled_layer->id());
+ last_scrolled_layer->element_id());
pending_tree->BuildPropertyTreesForTesting();
pending_tree->property_trees()
->scroll_tree.UpdateScrollOffsetBaseForTesting(
- last_scrolled_layer->id(), pending_base);
+ last_scrolled_layer->element_id(), pending_base);
pending_tree->LayerById(content_layer->id())->SetNeedsPushProperties();
pending_tree->set_needs_update_draw_properties();
diff --git a/cc/trees/layer_tree_host_unittest_scroll.cc b/cc/trees/layer_tree_host_unittest_scroll.cc
index e9a1e5d..d3ac199 100644
--- a/cc/trees/layer_tree_host_unittest_scroll.cc
+++ b/cc/trees/layer_tree_host_unittest_scroll.cc
@@ -134,14 +134,14 @@
case 0:
EXPECT_VECTOR_EQ(initial_scroll_, ScrollTreeForLayer(scroll_layer)
->GetScrollOffsetBaseForTesting(
- scroll_layer->id()));
+ scroll_layer->element_id()));
EXPECT_VECTOR_EQ(scroll_amount_, ScrollDelta(scroll_layer));
PostSetNeedsCommitToMainThread();
break;
case 1:
EXPECT_VECTOR_EQ(second_scroll_, ScrollTreeForLayer(scroll_layer)
->GetScrollOffsetBaseForTesting(
- scroll_layer->id()));
+ scroll_layer->element_id()));
EXPECT_VECTOR_EQ(scroll_amount_, ScrollDelta(scroll_layer));
EndTest();
break;
@@ -206,9 +206,9 @@
scroll_layer->ScrollBy(scroll_amount_);
EXPECT_VECTOR_EQ(scroll_amount_, ScrollDelta(scroll_layer));
- EXPECT_VECTOR_EQ(initial_scroll_,
- ScrollTreeForLayer(scroll_layer)
- ->GetScrollOffsetBaseForTesting(scroll_layer->id()));
+ EXPECT_VECTOR_EQ(initial_scroll_, ScrollTreeForLayer(scroll_layer)
+ ->GetScrollOffsetBaseForTesting(
+ scroll_layer->element_id()));
PostSetNeedsRedrawToMainThread();
} else if (impl->active_tree()->source_frame_number() == 0 &&
impl->SourceAnimationFrameNumberForTesting() == 2) {
@@ -348,9 +348,10 @@
EXPECT_VECTOR_EQ(gfx::Vector2d(), ScrollDelta(root_scroll_layer));
root_scroll_layer->ScrollBy(impl_scroll_);
EXPECT_VECTOR_EQ(impl_scroll_, ScrollDelta(root_scroll_layer));
- EXPECT_VECTOR_EQ(initial_scroll_, ScrollTreeForLayer(root_scroll_layer)
- ->GetScrollOffsetBaseForTesting(
- root_scroll_layer->id()));
+ EXPECT_VECTOR_EQ(
+ initial_scroll_,
+ ScrollTreeForLayer(root_scroll_layer)
+ ->GetScrollOffsetBaseForTesting(root_scroll_layer->element_id()));
EXPECT_EQ(1.f, impl->active_tree()->page_scale_delta());
EXPECT_EQ(1.f, impl->active_tree()->current_page_scale_factor());
@@ -371,7 +372,7 @@
EXPECT_VECTOR_EQ(
gfx::ScrollOffsetWithDelta(initial_scroll_, impl_scroll_),
ScrollTreeForLayer(root_scroll_layer)
- ->GetScrollOffsetBaseForTesting(root_scroll_layer->id()));
+ ->GetScrollOffsetBaseForTesting(root_scroll_layer->element_id()));
EXPECT_EQ(1.f, impl->active_tree()->page_scale_delta());
EXPECT_EQ(impl_scale_, impl->active_tree()->current_page_scale_factor());
@@ -395,7 +396,7 @@
EXPECT_VECTOR_EQ(
gfx::ScrollOffsetWithDelta(initial_scroll_, delta),
ScrollTreeForLayer(root_scroll_layer)
- ->GetScrollOffsetBaseForTesting(root_scroll_layer->id()));
+ ->GetScrollOffsetBaseForTesting(root_scroll_layer->element_id()));
} else if (impl->active_tree()->source_frame_number() == 2 &&
impl->SourceAnimationFrameNumberForTesting() == 4) {
// Final draw after the second aborted commit.
@@ -405,7 +406,7 @@
EXPECT_VECTOR_EQ(
gfx::ScrollOffsetWithDelta(initial_scroll_, delta),
ScrollTreeForLayer(root_scroll_layer)
- ->GetScrollOffsetBaseForTesting(root_scroll_layer->id()));
+ ->GetScrollOffsetBaseForTesting(root_scroll_layer->element_id()));
EndTest();
} else {
// Commit for source frame 3 is aborted.
@@ -462,7 +463,7 @@
EXPECT_VECTOR_EQ(
gfx::Vector2d(0, 0),
ScrollTreeForLayer(scroll_layer)
- ->GetScrollOffsetBaseForTesting(scroll_layer->id()));
+ ->GetScrollOffsetBaseForTesting(scroll_layer->element_id()));
EXPECT_VECTOR_EQ(gfx::Vector2d(0, 0), ScrollDelta(scroll_layer));
PostSetNeedsCommitToMainThread();
break;
@@ -470,7 +471,7 @@
EXPECT_VECTOR_EQ(
gfx::ToFlooredVector2d(scroll_amount_),
ScrollTreeForLayer(scroll_layer)
- ->GetScrollOffsetBaseForTesting(scroll_layer->id()));
+ ->GetScrollOffsetBaseForTesting(scroll_layer->element_id()));
EXPECT_VECTOR_EQ(gfx::Vector2dF(fmod(scroll_amount_.x(), 1.0f), 0.0f),
ScrollDelta(scroll_layer));
PostSetNeedsCommitToMainThread();
@@ -479,7 +480,7 @@
EXPECT_VECTOR_EQ(
gfx::ToFlooredVector2d(scroll_amount_ + scroll_amount_),
ScrollTreeForLayer(scroll_layer)
- ->GetScrollOffsetBaseForTesting(scroll_layer->id()));
+ ->GetScrollOffsetBaseForTesting(scroll_layer->element_id()));
EXPECT_VECTOR_EQ(
gfx::Vector2dF(fmod(2.0f * scroll_amount_.x(), 1.0f), 0.0f),
ScrollDelta(scroll_layer));
@@ -715,7 +716,7 @@
EXPECT_VECTOR_EQ(initial_offset_,
ScrollTreeForLayer(expected_scroll_layer_impl)
->GetScrollOffsetBaseForTesting(
- expected_scroll_layer_impl->id()));
+ expected_scroll_layer_impl->element_id()));
EXPECT_VECTOR_EQ(scroll_amount_,
ScrollDelta(expected_scroll_layer_impl));
break;
@@ -735,7 +736,7 @@
EXPECT_VECTOR_EQ(javascript_scroll_,
ScrollTreeForLayer(expected_scroll_layer_impl)
->GetScrollOffsetBaseForTesting(
- expected_scroll_layer_impl->id()));
+ expected_scroll_layer_impl->element_id()));
EXPECT_VECTOR_EQ(scroll_amount_,
ScrollDelta(expected_scroll_layer_impl));
break;
@@ -746,7 +747,7 @@
gfx::ScrollOffsetWithDelta(javascript_scroll_, scroll_amount_),
ScrollTreeForLayer(expected_scroll_layer_impl)
->GetScrollOffsetBaseForTesting(
- expected_scroll_layer_impl->id()));
+ expected_scroll_layer_impl->element_id()));
EXPECT_VECTOR_EQ(gfx::Vector2d(),
ScrollDelta(expected_scroll_layer_impl));
@@ -887,9 +888,10 @@
EXPECT_VECTOR_EQ(gfx::Vector2d(), ScrollDelta(scroll_layer));
scroll_layer->ScrollBy(impl_thread_scroll1_);
- EXPECT_VECTOR_EQ(initial_scroll_, ScrollTreeForLayer(scroll_layer)
- ->GetScrollOffsetBaseForTesting(
- scroll_layer->id()));
+ EXPECT_VECTOR_EQ(
+ initial_scroll_,
+ ScrollTreeForLayer(scroll_layer)
+ ->GetScrollOffsetBaseForTesting(scroll_layer->element_id()));
EXPECT_VECTOR_EQ(impl_thread_scroll1_, ScrollDelta(scroll_layer));
PostSetNeedsCommitToMainThread();
@@ -901,9 +903,10 @@
EXPECT_EQ(impl->pending_tree()->source_frame_number(), 1);
scroll_layer->ScrollBy(impl_thread_scroll2_);
- EXPECT_VECTOR_EQ(initial_scroll_, ScrollTreeForLayer(scroll_layer)
- ->GetScrollOffsetBaseForTesting(
- scroll_layer->id()));
+ EXPECT_VECTOR_EQ(
+ initial_scroll_,
+ ScrollTreeForLayer(scroll_layer)
+ ->GetScrollOffsetBaseForTesting(scroll_layer->element_id()));
EXPECT_VECTOR_EQ(impl_thread_scroll1_ + impl_thread_scroll2_,
ScrollDelta(scroll_layer));
@@ -913,7 +916,8 @@
gfx::ScrollOffsetWithDelta(
initial_scroll_, main_thread_scroll_ + impl_thread_scroll1_),
ScrollTreeForLayer(pending_scroll_layer)
- ->GetScrollOffsetBaseForTesting(pending_scroll_layer->id()));
+ ->GetScrollOffsetBaseForTesting(
+ pending_scroll_layer->element_id()));
EXPECT_VECTOR_EQ(impl_thread_scroll2_,
ScrollDelta(pending_scroll_layer));
}
@@ -924,7 +928,7 @@
gfx::ScrollOffsetWithDelta(
initial_scroll_, main_thread_scroll_ + impl_thread_scroll1_),
ScrollTreeForLayer(scroll_layer)
- ->GetScrollOffsetBaseForTesting(scroll_layer->id()));
+ ->GetScrollOffsetBaseForTesting(scroll_layer->element_id()));
EXPECT_VECTOR_EQ(impl_thread_scroll2_, ScrollDelta(scroll_layer));
EndTest();
break;
@@ -1011,27 +1015,27 @@
ASSERT_TRUE(pending_scroll_layer);
switch (impl->pending_tree()->source_frame_number()) {
case 0:
- EXPECT_VECTOR_EQ(
- initial_scroll_,
- ScrollTreeForLayer(pending_scroll_layer)
- ->GetScrollOffsetBaseForTesting(pending_scroll_layer->id()));
+ EXPECT_VECTOR_EQ(initial_scroll_,
+ ScrollTreeForLayer(pending_scroll_layer)
+ ->GetScrollOffsetBaseForTesting(
+ pending_scroll_layer->element_id()));
EXPECT_VECTOR_EQ(gfx::Vector2d(), ScrollDelta(pending_scroll_layer));
EXPECT_FALSE(active_root);
break;
case 1:
// Even though the scroll happened during the commit, both layers
// should have the appropriate scroll delta.
- EXPECT_VECTOR_EQ(
- initial_scroll_,
- ScrollTreeForLayer(pending_scroll_layer)
- ->GetScrollOffsetBaseForTesting(pending_scroll_layer->id()));
+ EXPECT_VECTOR_EQ(initial_scroll_,
+ ScrollTreeForLayer(pending_scroll_layer)
+ ->GetScrollOffsetBaseForTesting(
+ pending_scroll_layer->element_id()));
EXPECT_VECTOR_EQ(impl_thread_scroll_,
ScrollDelta(pending_scroll_layer));
ASSERT_TRUE(active_root);
- EXPECT_VECTOR_EQ(
- initial_scroll_,
- ScrollTreeForLayer(active_scroll_layer)
- ->GetScrollOffsetBaseForTesting(active_scroll_layer->id()));
+ EXPECT_VECTOR_EQ(initial_scroll_,
+ ScrollTreeForLayer(active_scroll_layer)
+ ->GetScrollOffsetBaseForTesting(
+ active_scroll_layer->element_id()));
EXPECT_VECTOR_EQ(impl_thread_scroll_, ScrollDelta(active_scroll_layer));
break;
case 2:
@@ -1039,7 +1043,8 @@
EXPECT_VECTOR_EQ(
gfx::ScrollOffsetWithDelta(initial_scroll_, impl_thread_scroll_),
ScrollTreeForLayer(pending_scroll_layer)
- ->GetScrollOffsetBaseForTesting(pending_scroll_layer->id()));
+ ->GetScrollOffsetBaseForTesting(
+ pending_scroll_layer->element_id()));
EXPECT_VECTOR_EQ(gfx::Vector2d(), ScrollDelta(pending_scroll_layer));
break;
}
@@ -1055,7 +1060,7 @@
case 0:
EXPECT_VECTOR_EQ(initial_scroll_, ScrollTreeForLayer(scroll_layer)
->GetScrollOffsetBaseForTesting(
- scroll_layer->id()));
+ scroll_layer->element_id()));
EXPECT_VECTOR_EQ(gfx::Vector2d(), ScrollDelta(scroll_layer));
EXPECT_EQ(1.f, impl->active_tree()->page_scale_delta());
EXPECT_EQ(1.f, impl->active_tree()->current_page_scale_factor());
@@ -1064,7 +1069,7 @@
case 1:
EXPECT_VECTOR_EQ(initial_scroll_, ScrollTreeForLayer(scroll_layer)
->GetScrollOffsetBaseForTesting(
- scroll_layer->id()));
+ scroll_layer->element_id()));
EXPECT_VECTOR_EQ(impl_thread_scroll_, ScrollDelta(scroll_layer));
EXPECT_EQ(impl_scale_, impl->active_tree()->page_scale_delta());
EXPECT_EQ(impl_scale_,
@@ -1457,9 +1462,10 @@
const gfx::Vector2dF& delta) {
if (layer_impl->layer_tree_impl()
->property_trees()
- ->scroll_tree.SetScrollOffsetDeltaForTesting(layer_impl->id(),
- delta))
- layer_impl->layer_tree_impl()->DidUpdateScrollOffset(layer_impl->id());
+ ->scroll_tree.SetScrollOffsetDeltaForTesting(
+ layer_impl->element_id(), delta))
+ layer_impl->layer_tree_impl()->DidUpdateScrollOffset(
+ layer_impl->element_id());
}
FakeLayerScrollClient root_scroll_layer_client_;
@@ -1556,7 +1562,7 @@
EXPECT_VECTOR_EQ(gfx::Vector2d(), ScrollDelta(scroll_layer));
EXPECT_VECTOR_EQ(initial_scroll_, ScrollTreeForLayer(scroll_layer)
->GetScrollOffsetBaseForTesting(
- scroll_layer->id()));
+ scroll_layer->element_id()));
Scroll(impl);
EXPECT_VECTOR_EQ(scroll_amount_, ScrollDelta(scroll_layer));
// Ask for commit after we've scrolled.
@@ -1566,7 +1572,7 @@
EXPECT_VECTOR_EQ(gfx::Vector2d(), ScrollDelta(scroll_layer));
EXPECT_VECTOR_EQ(second_scroll_, ScrollTreeForLayer(scroll_layer)
->GetScrollOffsetBaseForTesting(
- scroll_layer->id()));
+ scroll_layer->element_id()));
Scroll(impl);
EXPECT_VECTOR_EQ(scroll_amount_, ScrollDelta(scroll_layer));
break;
@@ -1575,7 +1581,7 @@
EXPECT_VECTOR_EQ(scroll_amount_, ScrollDelta(scroll_layer));
EXPECT_VECTOR_EQ(third_scroll_, ScrollTreeForLayer(scroll_layer)
->GetScrollOffsetBaseForTesting(
- scroll_layer->id()));
+ scroll_layer->element_id()));
EndTest();
break;
}
@@ -1738,10 +1744,10 @@
EXPECT_VECTOR_EQ(gfx::Vector2d(), ScrollDelta(root_scroll_layer));
root_scroll_layer->ScrollBy(impl_scroll_);
EXPECT_VECTOR_EQ(impl_scroll_, ScrollDelta(root_scroll_layer));
- EXPECT_VECTOR_EQ(
- initial_scroll_,
- ScrollTreeForLayer(root_scroll_layer)
- ->GetScrollOffsetBaseForTesting(root_scroll_layer->id()));
+ EXPECT_VECTOR_EQ(initial_scroll_,
+ ScrollTreeForLayer(root_scroll_layer)
+ ->GetScrollOffsetBaseForTesting(
+ root_scroll_layer->element_id()));
impl->SetNeedsCommit();
break;
}
@@ -1751,10 +1757,10 @@
root_scroll_layer->ScrollBy(impl_scroll_);
EXPECT_VECTOR_EQ(impl_scroll_ + impl_scroll_,
ScrollDelta(root_scroll_layer));
- EXPECT_VECTOR_EQ(
- initial_scroll_,
- ScrollTreeForLayer(root_scroll_layer)
- ->GetScrollOffsetBaseForTesting(root_scroll_layer->id()));
+ EXPECT_VECTOR_EQ(initial_scroll_,
+ ScrollTreeForLayer(root_scroll_layer)
+ ->GetScrollOffsetBaseForTesting(
+ root_scroll_layer->element_id()));
// Ask for another commit (which will abort).
impl->SetNeedsCommit();
break;
@@ -1777,7 +1783,8 @@
EXPECT_VECTOR_EQ(
gfx::ScrollOffsetWithDelta(initial_scroll_, prev_delta),
ScrollTreeForLayer(root_scroll_layer)
- ->GetScrollOffsetBaseForTesting(root_scroll_layer->id()));
+ ->GetScrollOffsetBaseForTesting(
+ root_scroll_layer->element_id()));
// Ask for another commit (which will abort).
impl->SetNeedsCommit();
break;
@@ -1785,10 +1792,10 @@
case 2: {
gfx::Vector2dF delta = impl_scroll_ + impl_scroll_ + impl_scroll_ +
second_main_scroll_;
- EXPECT_VECTOR_EQ(
- gfx::ScrollOffsetWithDelta(initial_scroll_, delta),
- ScrollTreeForLayer(root_scroll_layer)
- ->GetScrollOffsetBaseForTesting(root_scroll_layer->id()));
+ EXPECT_VECTOR_EQ(gfx::ScrollOffsetWithDelta(initial_scroll_, delta),
+ ScrollTreeForLayer(root_scroll_layer)
+ ->GetScrollOffsetBaseForTesting(
+ root_scroll_layer->element_id()));
// End test after second aborted commit (fourth commit request).
EndTest();
break;
@@ -2046,7 +2053,7 @@
case 0:
EXPECT_VECTOR_EQ(initial_scroll_, ScrollTreeForLayer(scroll_layer)
->GetScrollOffsetBaseForTesting(
- scroll_layer->id()));
+ scroll_layer->element_id()));
EXPECT_VECTOR_EQ(
initial_scroll_,
scroll_layer->layer_tree_impl()
@@ -2058,7 +2065,7 @@
case 1:
EXPECT_VECTOR_EQ(second_scroll_, ScrollTreeForLayer(scroll_layer)
->GetScrollOffsetBaseForTesting(
- scroll_layer->id()));
+ scroll_layer->element_id()));
EXPECT_VECTOR_EQ(
second_scroll_,
scroll_layer->layer_tree_impl()
diff --git a/cc/trees/layer_tree_impl.cc b/cc/trees/layer_tree_impl.cc
index 94023cd..014c4ab 100644
--- a/cc/trees/layer_tree_impl.cc
+++ b/cc/trees/layer_tree_impl.cc
@@ -151,7 +151,7 @@
}
}
-void LayerTreeImpl::DidUpdateScrollOffset(int layer_id) {
+void LayerTreeImpl::DidUpdateScrollOffset(ElementId id) {
// Scrollbar positions depend on the current scroll offset.
SetScrollbarGeometriesNeedUpdate();
@@ -163,7 +163,10 @@
// If pending tree topology changed and we still want to notify the pending
// tree about scroll offset in the active tree, we may not find the
// corresponding pending layer.
- if (auto* layer = LayerById(layer_id)) {
+ // TODO(pdr): Remove this use of LayerByElementId and instead look up the
+ // scroll node via ElementId and then set transform_id to the scroll node's
+ // transform node index.
+ if (auto* layer = LayerByElementId(id)) {
// TODO(sunxd): when we have a layer_id to property_tree index map in
// property trees, use the transform_id parameter instead of looking for
// indices from LayerImpls.
@@ -175,8 +178,8 @@
if (transform_id != TransformTree::kInvalidNodeId) {
TransformNode* node = transform_tree.Node(transform_id);
- if (node->scroll_offset != scroll_tree.current_scroll_offset(layer_id)) {
- node->scroll_offset = scroll_tree.current_scroll_offset(layer_id);
+ if (node->scroll_offset != scroll_tree.current_scroll_offset(id)) {
+ node->scroll_offset = scroll_tree.current_scroll_offset(id);
node->needs_local_transform_update = true;
transform_tree.set_needs_update(true);
}
@@ -186,7 +189,7 @@
}
if (IsActiveTree() && layer_tree_host_impl_->pending_tree())
- layer_tree_host_impl_->pending_tree()->DidUpdateScrollOffset(layer_id);
+ layer_tree_host_impl_->pending_tree()->DidUpdateScrollOffset(id);
}
void LayerTreeImpl::UpdateScrollbarGeometries() {
diff --git a/cc/trees/layer_tree_impl.h b/cc/trees/layer_tree_impl.h
index 29e9c097..d78f1b7 100644
--- a/cc/trees/layer_tree_impl.h
+++ b/cc/trees/layer_tree_impl.h
@@ -497,7 +497,7 @@
std::unique_ptr<PendingPageScaleAnimation> pending_animation);
std::unique_ptr<PendingPageScaleAnimation> TakePendingPageScaleAnimation();
- void DidUpdateScrollOffset(int layer_id);
+ void DidUpdateScrollOffset(ElementId id);
// Mark the scrollbar geometries (e.g., thumb size and position) as needing an
// update.
diff --git a/cc/trees/property_tree.cc b/cc/trees/property_tree.cc
index 51d0d0d..fc84ecf 100644
--- a/cc/trees/property_tree.cc
+++ b/cc/trees/property_tree.cc
@@ -365,7 +365,7 @@
property_trees.transform_tree.Node(scroll_node->transform_id);
const auto& scroll_offset = transform_node->scroll_offset;
DCHECK(property_trees.scroll_tree.current_scroll_offset(
- scroll_node->owning_layer_id) == scroll_offset);
+ scroll_node->element_id) == scroll_offset);
gfx::PointF scroll_position(scroll_offset.x(), scroll_offset.y());
if (transform_node->scrolls) {
// The scroll position does not include snapping which shifts the scroll
@@ -1172,7 +1172,7 @@
ScrollTree::ScrollTree()
: currently_scrolling_node_id_(kInvalidNodeId),
- layer_id_to_scroll_offset_map_(ScrollTree::ScrollOffsetMap()) {}
+ scroll_offset_map_(ScrollTree::ScrollOffsetMap()) {}
ScrollTree::~ScrollTree() {}
@@ -1188,10 +1188,9 @@
}
bool ScrollTree::operator==(const ScrollTree& other) const {
- if (layer_id_to_scroll_offset_map_ != other.layer_id_to_scroll_offset_map_)
+ if (scroll_offset_map_ != other.scroll_offset_map_)
return false;
- if (layer_id_to_synced_scroll_offset_map_ !=
- other.layer_id_to_synced_scroll_offset_map_)
+ if (synced_scroll_offset_map_ != other.synced_scroll_offset_map_)
return false;
bool is_currently_scrolling_node_equal =
@@ -1203,9 +1202,8 @@
#if DCHECK_IS_ON()
void ScrollTree::CopyCompleteTreeState(const ScrollTree& other) {
currently_scrolling_node_id_ = other.currently_scrolling_node_id_;
- layer_id_to_scroll_offset_map_ = other.layer_id_to_scroll_offset_map_;
- layer_id_to_synced_scroll_offset_map_ =
- other.layer_id_to_synced_scroll_offset_map_;
+ scroll_offset_map_ = other.scroll_offset_map_;
+ synced_scroll_offset_map_ = other.synced_scroll_offset_map_;
}
#endif
@@ -1222,16 +1220,15 @@
if (property_trees()->is_main_thread) {
currently_scrolling_node_id_ = kInvalidNodeId;
- layer_id_to_scroll_offset_map_.clear();
+ scroll_offset_map_.clear();
}
#if DCHECK_IS_ON()
ScrollTree tree;
if (!property_trees()->is_main_thread) {
- DCHECK(layer_id_to_scroll_offset_map_.empty());
+ DCHECK(scroll_offset_map_.empty());
tree.currently_scrolling_node_id_ = currently_scrolling_node_id_;
- tree.layer_id_to_synced_scroll_offset_map_ =
- layer_id_to_synced_scroll_offset_map_;
+ tree.synced_scroll_offset_map_ = synced_scroll_offset_map_;
}
DCHECK(tree == *this);
#endif
@@ -1271,7 +1268,7 @@
return max_offset;
}
-void ScrollTree::OnScrollOffsetAnimated(int layer_id,
+void ScrollTree::OnScrollOffsetAnimated(ElementId id,
int scroll_tree_index,
const gfx::ScrollOffset& scroll_offset,
LayerTreeImpl* layer_tree_impl) {
@@ -1281,9 +1278,9 @@
return;
ScrollNode* scroll_node = Node(scroll_tree_index);
- if (SetScrollOffset(layer_id,
+ if (SetScrollOffset(id,
ClampScrollOffsetToLimits(scroll_offset, scroll_node)))
- layer_tree_impl->DidUpdateScrollOffset(layer_id);
+ layer_tree_impl->DidUpdateScrollOffset(id);
layer_tree_impl->DidAnimateScrollOffset();
}
@@ -1343,33 +1340,28 @@
return screen_space_transform;
}
-SyncedScrollOffset* ScrollTree::GetOrCreateSyncedScrollOffset(int layer_id) {
+SyncedScrollOffset* ScrollTree::GetOrCreateSyncedScrollOffset(ElementId id) {
DCHECK(!property_trees()->is_main_thread);
- if (layer_id_to_synced_scroll_offset_map_.find(layer_id) ==
- layer_id_to_synced_scroll_offset_map_.end()) {
- layer_id_to_synced_scroll_offset_map_[layer_id] = new SyncedScrollOffset;
+ if (synced_scroll_offset_map_.find(id) == synced_scroll_offset_map_.end()) {
+ synced_scroll_offset_map_[id] = new SyncedScrollOffset;
}
- return layer_id_to_synced_scroll_offset_map_[layer_id].get();
+ return synced_scroll_offset_map_[id].get();
}
const SyncedScrollOffset* ScrollTree::GetSyncedScrollOffset(
- int layer_id) const {
+ ElementId id) const {
DCHECK(!property_trees()->is_main_thread);
- auto it = layer_id_to_synced_scroll_offset_map_.find(layer_id);
- return it != layer_id_to_synced_scroll_offset_map_.end() ? it->second.get()
- : nullptr;
+ auto it = synced_scroll_offset_map_.find(id);
+ return it != synced_scroll_offset_map_.end() ? it->second.get() : nullptr;
}
-const gfx::ScrollOffset ScrollTree::current_scroll_offset(int layer_id) const {
+const gfx::ScrollOffset ScrollTree::current_scroll_offset(ElementId id) const {
if (property_trees()->is_main_thread) {
- ScrollOffsetMap::const_iterator it =
- layer_id_to_scroll_offset_map_.find(layer_id);
- return it != layer_id_to_scroll_offset_map_.end() ? it->second
- : gfx::ScrollOffset();
+ ScrollOffsetMap::const_iterator it = scroll_offset_map_.find(id);
+ return it != scroll_offset_map_.end() ? it->second : gfx::ScrollOffset();
}
- return GetSyncedScrollOffset(layer_id)
- ? GetSyncedScrollOffset(layer_id)->Current(
- property_trees()->is_active)
+ return GetSyncedScrollOffset(id)
+ ? GetSyncedScrollOffset(id)->Current(property_trees()->is_active)
: gfx::ScrollOffset();
}
@@ -1392,24 +1384,25 @@
return delta;
}
-void ScrollTree::CollectScrollDeltas(ScrollAndScaleSet* scroll_info,
- int inner_viewport_layer_id) {
+void ScrollTree::CollectScrollDeltas(
+ ScrollAndScaleSet* scroll_info,
+ ElementId inner_viewport_scroll_element_id) {
DCHECK(!property_trees()->is_main_thread);
- for (auto map_entry : layer_id_to_synced_scroll_offset_map_) {
+ for (auto map_entry : synced_scroll_offset_map_) {
gfx::ScrollOffset scroll_delta =
PullDeltaForMainThread(map_entry.second.get());
gfx::Vector2d scroll_delta_vector(scroll_delta.x(), scroll_delta.y());
- int layer_id = map_entry.first;
+ ElementId id = map_entry.first;
if (!scroll_delta.IsZero()) {
- if (layer_id == inner_viewport_layer_id) {
+ if (id == inner_viewport_scroll_element_id) {
// Inner (visual) viewport is stored separately.
- scroll_info->inner_viewport_scroll.layer_id = layer_id;
+ scroll_info->inner_viewport_scroll.element_id = id;
scroll_info->inner_viewport_scroll.scroll_delta = scroll_delta_vector;
} else {
LayerTreeHostCommon::ScrollUpdateInfo scroll;
- scroll.layer_id = layer_id;
+ scroll.element_id = id;
scroll.scroll_delta = scroll_delta_vector;
scroll_info->scrolls.push_back(scroll);
}
@@ -1418,7 +1411,7 @@
}
void ScrollTree::CollectScrollDeltasForTesting() {
- for (auto map_entry : layer_id_to_synced_scroll_offset_map_) {
+ for (auto map_entry : synced_scroll_offset_map_) {
PullDeltaForMainThread(map_entry.second.get());
}
}
@@ -1428,23 +1421,23 @@
LayerTreeImpl* sync_tree) {
DCHECK(!property_trees()->is_main_thread);
const ScrollOffsetMap& main_scroll_offset_map =
- main_property_trees->scroll_tree.layer_id_to_scroll_offset_map_;
+ main_property_trees->scroll_tree.scroll_offset_map_;
// We first want to clear SyncedProperty instances for layers which were
// destroyed or became non-scrollable on the main thread.
- for (auto map_entry = layer_id_to_synced_scroll_offset_map_.begin();
- map_entry != layer_id_to_synced_scroll_offset_map_.end();) {
- int layer_id = map_entry->first;
- if (main_scroll_offset_map.find(layer_id) == main_scroll_offset_map.end())
- map_entry = layer_id_to_synced_scroll_offset_map_.erase(map_entry);
+ for (auto map_entry = synced_scroll_offset_map_.begin();
+ map_entry != synced_scroll_offset_map_.end();) {
+ ElementId id = map_entry->first;
+ if (main_scroll_offset_map.find(id) == main_scroll_offset_map.end())
+ map_entry = synced_scroll_offset_map_.erase(map_entry);
else
map_entry++;
}
for (auto map_entry : main_scroll_offset_map) {
- int layer_id = map_entry.first;
+ ElementId id = map_entry.first;
SyncedScrollOffset* synced_scroll_offset =
- GetOrCreateSyncedScrollOffset(layer_id);
+ GetOrCreateSyncedScrollOffset(id);
bool changed = synced_scroll_offset->PushFromMainThread(map_entry.second);
// If we are committing directly to the active tree, push pending to active
@@ -1453,7 +1446,7 @@
changed |= synced_scroll_offset->PushPendingToActive();
if (changed)
- sync_tree->DidUpdateScrollOffset(layer_id);
+ sync_tree->DidUpdateScrollOffset(id);
}
}
@@ -1467,10 +1460,10 @@
// When pushing to the active tree, we can simply copy over the map from the
// pending tree. The pending and active tree hold a reference to the same
// SyncedProperty instances.
- layer_id_to_synced_scroll_offset_map_.clear();
- for (auto map_entry : pending_property_trees->scroll_tree
- .layer_id_to_synced_scroll_offset_map_) {
- layer_id_to_synced_scroll_offset_map_[map_entry.first] = map_entry.second;
+ synced_scroll_offset_map_.clear();
+ for (auto map_entry :
+ pending_property_trees->scroll_tree.synced_scroll_offset_map_) {
+ synced_scroll_offset_map_[map_entry.first] = map_entry.second;
if (map_entry.second->PushPendingToActive())
active_tree->DidUpdateScrollOffset(map_entry.first);
}
@@ -1478,77 +1471,75 @@
void ScrollTree::ApplySentScrollDeltasFromAbortedCommit() {
DCHECK(property_trees()->is_active);
- for (auto& map_entry : layer_id_to_synced_scroll_offset_map_)
+ for (auto& map_entry : synced_scroll_offset_map_)
map_entry.second->AbortCommit();
}
-bool ScrollTree::SetBaseScrollOffset(int layer_id,
+bool ScrollTree::SetBaseScrollOffset(ElementId id,
const gfx::ScrollOffset& scroll_offset) {
if (property_trees()->is_main_thread) {
- layer_id_to_scroll_offset_map_[layer_id] = scroll_offset;
+ scroll_offset_map_[id] = scroll_offset;
return true;
}
// Scroll offset updates on the impl thread should only be for layers which
// were created on the main thread. But this method is called when we build
// PropertyTrees on the impl thread from LayerTreeImpl.
- return GetOrCreateSyncedScrollOffset(layer_id)->PushFromMainThread(
- scroll_offset);
+ return GetOrCreateSyncedScrollOffset(id)->PushFromMainThread(scroll_offset);
}
-bool ScrollTree::SetScrollOffset(int layer_id,
+bool ScrollTree::SetScrollOffset(ElementId id,
const gfx::ScrollOffset& scroll_offset) {
if (property_trees()->is_main_thread) {
- if (layer_id_to_scroll_offset_map_[layer_id] == scroll_offset)
+ if (scroll_offset_map_[id] == scroll_offset)
return false;
- layer_id_to_scroll_offset_map_[layer_id] = scroll_offset;
+ scroll_offset_map_[id] = scroll_offset;
return true;
}
if (property_trees()->is_active) {
- return GetOrCreateSyncedScrollOffset(layer_id)->SetCurrent(scroll_offset);
+ return GetOrCreateSyncedScrollOffset(id)->SetCurrent(scroll_offset);
}
return false;
}
bool ScrollTree::UpdateScrollOffsetBaseForTesting(
- int layer_id,
+ ElementId id,
const gfx::ScrollOffset& offset) {
DCHECK(!property_trees()->is_main_thread);
- SyncedScrollOffset* synced_scroll_offset =
- GetOrCreateSyncedScrollOffset(layer_id);
+ SyncedScrollOffset* synced_scroll_offset = GetOrCreateSyncedScrollOffset(id);
bool changed = synced_scroll_offset->PushFromMainThread(offset);
if (property_trees()->is_active)
changed |= synced_scroll_offset->PushPendingToActive();
return changed;
}
-bool ScrollTree::SetScrollOffsetDeltaForTesting(int layer_id,
+bool ScrollTree::SetScrollOffsetDeltaForTesting(ElementId id,
const gfx::Vector2dF& delta) {
- return GetOrCreateSyncedScrollOffset(layer_id)->SetCurrent(
- GetOrCreateSyncedScrollOffset(layer_id)->ActiveBase() +
+ return GetOrCreateSyncedScrollOffset(id)->SetCurrent(
+ GetOrCreateSyncedScrollOffset(id)->ActiveBase() +
gfx::ScrollOffset(delta));
}
const gfx::ScrollOffset ScrollTree::GetScrollOffsetBaseForTesting(
- int layer_id) const {
+ ElementId id) const {
DCHECK(!property_trees()->is_main_thread);
- if (GetSyncedScrollOffset(layer_id))
+ if (GetSyncedScrollOffset(id))
return property_trees()->is_active
- ? GetSyncedScrollOffset(layer_id)->ActiveBase()
- : GetSyncedScrollOffset(layer_id)->PendingBase();
+ ? GetSyncedScrollOffset(id)->ActiveBase()
+ : GetSyncedScrollOffset(id)->PendingBase();
else
return gfx::ScrollOffset();
}
const gfx::ScrollOffset ScrollTree::GetScrollOffsetDeltaForTesting(
- int layer_id) const {
+ ElementId id) const {
DCHECK(!property_trees()->is_main_thread);
- if (GetSyncedScrollOffset(layer_id))
+ if (GetSyncedScrollOffset(id))
return property_trees()->is_active
- ? GetSyncedScrollOffset(layer_id)->Delta()
- : GetSyncedScrollOffset(layer_id)->PendingDelta().get();
+ ? GetSyncedScrollOffset(id)->Delta()
+ : GetSyncedScrollOffset(id)->PendingDelta().get();
else
return gfx::ScrollOffset();
}
@@ -1581,12 +1572,11 @@
if (!scroll_node->user_scrollable_vertical)
adjusted_scroll.set_y(0);
DCHECK(scroll_node->scrollable);
- gfx::ScrollOffset old_offset =
- current_scroll_offset(scroll_node->owning_layer_id);
+ gfx::ScrollOffset old_offset = current_scroll_offset(scroll_node->element_id);
gfx::ScrollOffset new_offset =
ClampScrollOffsetToLimits(old_offset + adjusted_scroll, scroll_node);
- if (SetScrollOffset(scroll_node->owning_layer_id, new_offset))
- layer_tree_impl->DidUpdateScrollOffset(scroll_node->owning_layer_id);
+ if (SetScrollOffset(scroll_node->element_id, new_offset))
+ layer_tree_impl->DidUpdateScrollOffset(scroll_node->element_id);
gfx::ScrollOffset unscrolled =
old_offset + gfx::ScrollOffset(scroll) - new_offset;
diff --git a/cc/trees/property_tree.h b/cc/trees/property_tree.h
index 2efdf72..d7273fb 100644
--- a/cc/trees/property_tree.h
+++ b/cc/trees/property_tree.h
@@ -455,7 +455,7 @@
void clear();
gfx::ScrollOffset MaxScrollOffset(int scroll_node_id) const;
- void OnScrollOffsetAnimated(int layer_id,
+ void OnScrollOffsetAnimated(ElementId id,
int scroll_tree_index,
const gfx::ScrollOffset& scroll_offset,
LayerTreeImpl* layer_tree_impl);
@@ -471,13 +471,13 @@
// Returns the current scroll offset. On the main thread this would return the
// value for the LayerTree while on the impl thread this is the current value
// on the active tree.
- const gfx::ScrollOffset current_scroll_offset(int layer_id) const;
+ const gfx::ScrollOffset current_scroll_offset(ElementId id) const;
// Collects deltas for scroll changes on the impl thread that need to be
// reported to the main thread during the main frame. As such, should only be
// called on the impl thread side PropertyTrees.
void CollectScrollDeltas(ScrollAndScaleSet* scroll_info,
- int inner_viewport_layer_id);
+ ElementId inner_viewport_scroll_element_id);
// Applies deltas sent in the previous main frame onto the impl thread state.
// Should only be called on the impl thread side PropertyTrees.
@@ -493,18 +493,18 @@
void PushScrollUpdatesFromPendingTree(PropertyTrees* pending_property_trees,
LayerTreeImpl* active_tree);
- bool SetBaseScrollOffset(int layer_id,
+ bool SetBaseScrollOffset(ElementId id,
const gfx::ScrollOffset& scroll_offset);
- bool SetScrollOffset(int layer_id, const gfx::ScrollOffset& scroll_offset);
- void SetScrollOffsetClobberActiveValue(int layer_id) {
- GetOrCreateSyncedScrollOffset(layer_id)->set_clobber_active_value();
+ bool SetScrollOffset(ElementId id, const gfx::ScrollOffset& scroll_offset);
+ void SetScrollOffsetClobberActiveValue(ElementId id) {
+ GetOrCreateSyncedScrollOffset(id)->set_clobber_active_value();
}
- bool UpdateScrollOffsetBaseForTesting(int layer_id,
+ bool UpdateScrollOffsetBaseForTesting(ElementId id,
const gfx::ScrollOffset& offset);
- bool SetScrollOffsetDeltaForTesting(int layer_id,
+ bool SetScrollOffsetDeltaForTesting(ElementId id,
const gfx::Vector2dF& delta);
- const gfx::ScrollOffset GetScrollOffsetBaseForTesting(int layer_id) const;
- const gfx::ScrollOffset GetScrollOffsetDeltaForTesting(int layer_id) const;
+ const gfx::ScrollOffset GetScrollOffsetBaseForTesting(ElementId id) const;
+ const gfx::ScrollOffset GetScrollOffsetDeltaForTesting(ElementId id) const;
void CollectScrollDeltasForTesting();
void DistributeScroll(ScrollNode* scroll_node, ScrollState* scroll_state);
@@ -514,7 +514,7 @@
gfx::ScrollOffset ClampScrollOffsetToLimits(gfx::ScrollOffset offset,
ScrollNode* scroll_node) const;
- const SyncedScrollOffset* GetSyncedScrollOffset(int layer_id) const;
+ const SyncedScrollOffset* GetSyncedScrollOffset(ElementId id) const;
#if DCHECK_IS_ON()
void CopyCompleteTreeState(const ScrollTree& other);
@@ -523,9 +523,9 @@
ScrollNode* FindNodeFromElementId(ElementId id);
private:
- using ScrollOffsetMap = base::flat_map<int, gfx::ScrollOffset>;
+ using ScrollOffsetMap = base::flat_map<ElementId, gfx::ScrollOffset>;
using SyncedScrollOffsetMap =
- base::flat_map<int, scoped_refptr<SyncedScrollOffset>>;
+ base::flat_map<ElementId, scoped_refptr<SyncedScrollOffset>>;
int currently_scrolling_node_id_;
@@ -534,10 +534,10 @@
// thread stores a map of SyncedProperty instances in order to track
// additional state necessary to synchronize scroll changes between the main
// and impl threads.
- ScrollOffsetMap layer_id_to_scroll_offset_map_;
- SyncedScrollOffsetMap layer_id_to_synced_scroll_offset_map_;
+ ScrollOffsetMap scroll_offset_map_;
+ SyncedScrollOffsetMap synced_scroll_offset_map_;
- SyncedScrollOffset* GetOrCreateSyncedScrollOffset(int layer_id);
+ SyncedScrollOffset* GetOrCreateSyncedScrollOffset(ElementId id);
gfx::ScrollOffset PullDeltaForMainThread(SyncedScrollOffset* scroll_offset);
};
diff --git a/cc/trees/property_tree_builder.cc b/cc/trees/property_tree_builder.cc
index dd1642bc..4ad6e53 100644
--- a/cc/trees/property_tree_builder.cc
+++ b/cc/trees/property_tree_builder.cc
@@ -1089,7 +1089,7 @@
if (node.scrollable) {
data_for_children->property_trees->scroll_tree.SetBaseScrollOffset(
- layer->id(), layer->CurrentScrollOffset());
+ layer->element_id(), layer->CurrentScrollOffset());
}
}
diff --git a/cc/trees/tree_synchronizer_unittest.cc b/cc/trees/tree_synchronizer_unittest.cc
index 1def71a2..18ab0a7 100644
--- a/cc/trees/tree_synchronizer_unittest.cc
+++ b/cc/trees/tree_synchronizer_unittest.cc
@@ -559,6 +559,9 @@
transient_scroll_layer->AddChild(scroll_clip_layer);
scroll_clip_layer->AddChild(scroll_layer);
+ ElementId transient_scroll_element_id = ElementId(7);
+ transient_scroll_layer->SetElementId(transient_scroll_element_id);
+
transient_scroll_layer->SetScrollClipLayerId(
transient_scroll_clip_layer->id());
scroll_layer->SetScrollClipLayerId(scroll_clip_layer->id());
@@ -585,37 +588,38 @@
scroll_layer_offset.get(),
host_impl->active_tree()
->property_trees()
- ->scroll_tree.GetSyncedScrollOffset(scroll_layer->id())));
+ ->scroll_tree.GetSyncedScrollOffset(scroll_layer->element_id())));
scoped_refptr<SyncedScrollOffset> transient_scroll_layer_offset =
new SyncedScrollOffset;
transient_scroll_layer_offset->PushFromMainThread(
transient_scroll_layer->scroll_offset());
transient_scroll_layer_offset->PushPendingToActive();
- EXPECT_TRUE(AreScrollOffsetsEqual(
- transient_scroll_layer_offset.get(),
- host_impl->active_tree()
- ->property_trees()
- ->scroll_tree.GetSyncedScrollOffset(transient_scroll_layer->id())));
+ EXPECT_TRUE(
+ AreScrollOffsetsEqual(transient_scroll_layer_offset.get(),
+ host_impl->active_tree()
+ ->property_trees()
+ ->scroll_tree.GetSyncedScrollOffset(
+ transient_scroll_layer->element_id())));
// Set ScrollOffset active delta: gfx::ScrollOffset(10, 10)
LayerImpl* scroll_layer_impl =
host_impl->active_tree()->LayerById(scroll_layer->id());
ScrollTree& scroll_tree =
host_impl->active_tree()->property_trees()->scroll_tree;
- scroll_tree.SetScrollOffset(scroll_layer_impl->id(),
+ scroll_tree.SetScrollOffset(scroll_layer_impl->element_id(),
gfx::ScrollOffset(20, 30));
// Pull ScrollOffset delta for main thread, and change offset on main thread
std::unique_ptr<ScrollAndScaleSet> scroll_info(new ScrollAndScaleSet());
- scroll_tree.CollectScrollDeltas(scroll_info.get(), Layer::INVALID_ID);
+ scroll_tree.CollectScrollDeltas(scroll_info.get(), ElementId());
host_->proxy()->SetNeedsCommit();
host_->ApplyScrollAndScale(scroll_info.get());
EXPECT_EQ(gfx::ScrollOffset(20, 30), scroll_layer->scroll_offset());
scroll_layer->SetScrollOffset(gfx::ScrollOffset(100, 100));
// More update to ScrollOffset active delta: gfx::ScrollOffset(20, 20)
- scroll_tree.SetScrollOffset(scroll_layer_impl->id(),
+ scroll_tree.SetScrollOffset(scroll_layer_impl->element_id(),
gfx::ScrollOffset(40, 50));
host_impl->active_tree()->SetCurrentlyScrollingNode(
scroll_tree.Node(scroll_layer_impl->scroll_tree_index()));
@@ -639,11 +643,11 @@
scroll_layer_offset.get(),
host_impl->active_tree()
->property_trees()
- ->scroll_tree.GetSyncedScrollOffset(scroll_layer->id())));
+ ->scroll_tree.GetSyncedScrollOffset(scroll_layer->element_id())));
EXPECT_EQ(nullptr, host_impl->active_tree()
->property_trees()
->scroll_tree.GetSyncedScrollOffset(
- transient_scroll_layer->id()));
+ transient_scroll_layer->element_id()));
}
TEST_F(TreeSynchronizerTest, RefreshPropertyTreesCachedData) {