diff options
-rw-r--r-- | cc/trees/layer_tree_host_common_unittest.cc | 38 | ||||
-rw-r--r-- | cc/trees/property_tree_builder.cc | 14 |
2 files changed, 51 insertions, 1 deletions
diff --git a/cc/trees/layer_tree_host_common_unittest.cc b/cc/trees/layer_tree_host_common_unittest.cc index c65a2cf..54f5534 100644 --- a/cc/trees/layer_tree_host_common_unittest.cc +++ b/cc/trees/layer_tree_host_common_unittest.cc @@ -6405,6 +6405,44 @@ TEST_F(LayerTreeHostCommonTest, ClippedByScrollParent) { EXPECT_TRUE(scroll_child->is_clipped()); } +TEST_F(LayerTreeHostCommonTest, ScrollChildAndScrollParentDifferentTargets) { + // Tests the computation of draw transform for the scroll child when its + // target is different from its scroll parent's target. + LayerImpl* root = root_layer(); + LayerImpl* scroll_child_target = AddChildToRoot<LayerImpl>(); + LayerImpl* scroll_child = AddChild<LayerImpl>(scroll_child_target); + LayerImpl* scroll_parent_target = AddChild<LayerImpl>(scroll_child_target); + LayerImpl* scroll_parent = AddChild<LayerImpl>(scroll_parent_target); + + scroll_parent->SetDrawsContent(true); + scroll_child->SetDrawsContent(true); + + scroll_child->SetScrollParent(scroll_parent); + scoped_ptr<std::set<LayerImpl*>> scroll_children(new std::set<LayerImpl*>); + scroll_children->insert(scroll_child); + scroll_parent->SetScrollChildren(scroll_children.release()); + + gfx::Transform identity_transform; + SetLayerPropertiesForTesting(root, identity_transform, gfx::Point3F(), + gfx::PointF(), gfx::Size(50, 50), true, false, + true); + SetLayerPropertiesForTesting(scroll_child_target, identity_transform, + gfx::Point3F(), gfx::PointF(), gfx::Size(50, 50), + true, false, true); + SetLayerPropertiesForTesting(scroll_child, identity_transform, gfx::Point3F(), + gfx::PointF(), gfx::Size(50, 50), true, false, + false); + SetLayerPropertiesForTesting(scroll_parent_target, identity_transform, + gfx::Point3F(), gfx::PointF(10, 10), + gfx::Size(50, 50), true, false, true); + SetLayerPropertiesForTesting(scroll_parent, identity_transform, + gfx::Point3F(), gfx::PointF(), gfx::Size(50, 50), + true, false, true); + + ExecuteCalculateDrawProperties(root); + EXPECT_EQ(scroll_child->DrawTransform(), identity_transform); +} + TEST_F(LayerTreeHostCommonTest, SingularTransformSubtreesDoNotDraw) { LayerImpl* root = root_layer(); root->SetDrawsContent(true); diff --git a/cc/trees/property_tree_builder.cc b/cc/trees/property_tree_builder.cc index 85bdbec..a27bd3c 100644 --- a/cc/trees/property_tree_builder.cc +++ b/cc/trees/property_tree_builder.cc @@ -224,9 +224,18 @@ bool AddTransformNodeIfNeeded( const bool has_surface = created_render_surface; + // A transform node is needed to change the render target for subtree when + // a scroll child's render target is different from the scroll parent's render + // target. + const bool scroll_child_has_different_target = + layer->scroll_parent() && + layer->parent()->effect_tree_index() != + layer->scroll_parent()->effect_tree_index(); + bool requires_node = is_root || is_scrollable || has_significant_transform || has_any_transform_animation || has_surface || is_fixed || - is_page_scale_layer || is_overscroll_elasticity_layer; + is_page_scale_layer || is_overscroll_elasticity_layer || + scroll_child_has_different_target; LayerType* transform_parent = GetTransformParent(data_from_ancestor, layer); DCHECK(is_root || transform_parent); @@ -659,6 +668,9 @@ void BuildPropertyTreesInternal( for (LayerType* scroll_child : *layer->scroll_children()) { DCHECK_EQ(scroll_child->scroll_parent(), layer); DataForRecursionFromChild<LayerType> data_from_child; + DCHECK(scroll_child->parent()); + data_for_children.render_target = + scroll_child->parent()->effect_tree_index(); BuildPropertyTreesInternal(scroll_child, data_for_children, &data_from_child); data_to_parent->Merge(data_from_child); |