Fix some unit tests that fail when we enable impl property trees

This patch fixes some unit tests that fail when we set the
default value of 'use_property_trees' to true for
CalcDrawPropsImplInputsForTesting.

BUG=551629
CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel

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

Cr-Commit-Position: refs/heads/master@{#358733}
diff --git a/cc/layers/layer_position_constraint_unittest.cc b/cc/layers/layer_position_constraint_unittest.cc
index 594dac2..9c15a650 100644
--- a/cc/layers/layer_position_constraint_unittest.cc
+++ b/cc/layers/layer_position_constraint_unittest.cc
@@ -224,6 +224,7 @@
 
   // Case 2: scroll delta of 10, 10
   child_impl_->SetScrollDelta(gfx::Vector2d(10, 10));
+  child_impl_->SetDrawsContent(true);
   ExecuteCalculateDrawProperties(root_impl_);
 
   // Here the child is affected by scroll delta, but the fixed position
@@ -277,6 +278,7 @@
 
   // Case 1: scroll delta of 0, 0
   child_impl_->SetScrollDelta(gfx::Vector2d(0, 0));
+  child_impl_->SetDrawsContent(true);
   ExecuteCalculateDrawProperties(root_impl_);
 
   gfx::Transform expected_child_transform;
@@ -361,6 +363,7 @@
 
   // Case 1: scroll delta of 0, 0
   child_impl_->SetScrollDelta(gfx::Vector2d(0, 0));
+  child_impl_->SetDrawsContent(true);
   ExecuteCalculateDrawProperties(root_impl_);
 
   gfx::Transform expected_child_transform;
@@ -451,6 +454,7 @@
 
   // Case 2: scroll delta of 10, 30
   child_impl_->SetScrollDelta(gfx::Vector2d(10, 30));
+  child_impl_->SetDrawsContent(true);
   ExecuteCalculateDrawProperties(root_impl_);
 
   // Here the grand_child remains unchanged, because it scrolls along with the
@@ -562,6 +566,7 @@
 
   // Case 1: scroll delta of 0, 0
   child_impl_->SetScrollDelta(gfx::Vector2d(0, 0));
+  child_impl_->SetDrawsContent(true);
   ExecuteCalculateDrawProperties(root_impl_);
 
   gfx::Transform expected_child_transform;
@@ -718,6 +723,7 @@
 
   // Case 1: scroll delta of 0, 0
   child_impl_->SetScrollDelta(gfx::Vector2d(0, 0));
+  child_impl_->SetDrawsContent(true);
   ExecuteCalculateDrawProperties(root_impl_);
 
   gfx::Transform expected_child_transform;
@@ -899,6 +905,7 @@
 
   // Case 1: scroll delta of 0, 0
   child_impl_->SetScrollDelta(gfx::Vector2d(0, 0));
+  child_impl_->SetDrawsContent(true);
   ExecuteCalculateDrawProperties(root_impl_);
 
   gfx::Transform expected_child_transform;
@@ -969,6 +976,7 @@
 
   // Case 1: scrollDelta
   child_impl_->SetScrollDelta(gfx::Vector2d(10, 10));
+  child_impl_->SetDrawsContent(true);
   ExecuteCalculateDrawProperties(root_impl_);
 
   // Here the child is affected by scroll delta, but the fixed position
@@ -1033,7 +1041,9 @@
   LayerImpl* fixed_to_container2 = container2->children()[0];
 
   container1->SetScrollDelta(gfx::Vector2d(0, 15));
+  container1->SetDrawsContent(true);
   container2->SetScrollDelta(gfx::Vector2d(30, 0));
+  container2->SetDrawsContent(true);
   ExecuteCalculateDrawProperties(root_impl_);
 
   gfx::Transform expected_container1_transform;
@@ -1079,6 +1089,7 @@
 
   // Case 1: fixed-container size delta of 20, 20
   scroll_layer_impl_->SetScrollDelta(gfx::Vector2d(10, 10));
+  scroll_layer_impl_->SetDrawsContent(true);
   SetFixedContainerSizeDelta(scroll_layer_impl_, gfx::Vector2d(20, 20));
   gfx::Transform expected_scroll_layer_transform;
   expected_scroll_layer_transform.Translate(-10.0, -10.0);
diff --git a/cc/trees/layer_tree_host_common_unittest.cc b/cc/trees/layer_tree_host_common_unittest.cc
index 5e862ef..98a70c5 100644
--- a/cc/trees/layer_tree_host_common_unittest.cc
+++ b/cc/trees/layer_tree_host_common_unittest.cc
@@ -146,6 +146,8 @@
   LayerImpl* parent = root_layer();
   LayerImpl* child = AddChild<LayerImpl>(parent);
   LayerImpl* grand_child = AddChild<LayerImpl>(child);
+  child->SetDrawsContent(true);
+  grand_child->SetDrawsContent(true);
 
   gfx::Transform identity_matrix;
   SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(),
@@ -468,6 +470,7 @@
 
   // Child is set up so that a new render surface should be created.
   child->SetOpacity(0.5f);
+  child->SetDrawsContent(true);
 
   gfx::Transform parent_layer_transform;
   parent_layer_transform.Scale3d(1.f, 0.9f, 1.f);
@@ -662,12 +665,19 @@
 
   LayerImpl* root = root_layer();
   LayerImpl* parent = AddChildToRoot<LayerImpl>();
+  parent->SetDrawsContent(true);
   LayerImpl* render_surface1 = AddChild<LayerImpl>(parent);
+  render_surface1->SetDrawsContent(true);
   LayerImpl* render_surface2 = AddChild<LayerImpl>(render_surface1);
+  render_surface2->SetDrawsContent(true);
   LayerImpl* child_of_root = AddChild<LayerImpl>(parent);
+  child_of_root->SetDrawsContent(true);
   LayerImpl* child_of_rs1 = AddChild<LayerImpl>(render_surface1);
+  child_of_rs1->SetDrawsContent(true);
   LayerImpl* child_of_rs2 = AddChild<LayerImpl>(render_surface2);
+  child_of_rs2->SetDrawsContent(true);
   LayerImpl* grand_child_of_root = AddChild<LayerImpl>(child_of_root);
+  grand_child_of_root->SetDrawsContent(true);
   LayerImpl* grand_child_of_rs1 = AddChild<LayerImpl>(child_of_rs1);
   grand_child_of_rs1->SetDrawsContent(true);
   LayerImpl* grand_child_of_rs2 = AddChild<LayerImpl>(child_of_rs2);
@@ -891,6 +901,7 @@
 
   LayerImpl* root = root_layer();
   LayerImpl* child = AddChildToRoot<LayerImpl>();
+  child->SetDrawsContent(true);
   LayerImpl* grand_child = AddChild<LayerImpl>(child);
   grand_child->SetDrawsContent(true);
   LayerImpl* great_grand_child = AddChild<LayerImpl>(grand_child);
@@ -1255,7 +1266,8 @@
   ASSERT_TRUE(parent->render_surface());
   EXPECT_EQ(1U, parent->render_surface()->layer_list().size());
   EXPECT_EQ(2U, render_surface_layer_list.size());
-  EXPECT_EQ(gfx::Rect(0, 0, 10, 10), parent->drawable_content_rect());
+  EXPECT_EQ(gfx::RectF(0, 0, 10, 10),
+            parent->render_surface()->DrawableContentRect());
 }
 
 TEST_F(LayerTreeHostCommonTest, RenderSurfaceForBlendMode) {
@@ -1614,9 +1626,13 @@
   const gfx::Transform identity_matrix;
   LayerImpl* root = root_layer();
   LayerImpl* parent = AddChild<LayerImpl>(root);
+  parent->SetDrawsContent(true);
   LayerImpl* child1 = AddChild<LayerImpl>(parent);
+  child1->SetDrawsContent(true);
   LayerImpl* child2 = AddChild<LayerImpl>(parent);
+  child2->SetDrawsContent(true);
   LayerImpl* grand_child = AddChild<LayerImpl>(child1);
+  grand_child->SetDrawsContent(true);
   LayerImpl* leaf_node1 = AddChild<LayerImpl>(grand_child);
   leaf_node1->SetDrawsContent(true);
   LayerImpl* leaf_node2 = AddChild<LayerImpl>(child2);
@@ -1893,9 +1909,13 @@
   LayerImpl* parent = root_layer();
   LayerImpl* child = AddChild<LayerImpl>(parent);
   LayerImpl* grand_child1 = AddChild<LayerImpl>(child);
+  grand_child1->SetDrawsContent(true);
   LayerImpl* grand_child2 = AddChild<LayerImpl>(child);
+  grand_child2->SetDrawsContent(true);
   LayerImpl* grand_child3 = AddChild<LayerImpl>(child);
+  grand_child3->SetDrawsContent(true);
   LayerImpl* grand_child4 = AddChild<LayerImpl>(child);
+  grand_child4->SetDrawsContent(true);
 
   SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(),
                                gfx::PointF(), gfx::Size(500, 500), true, false,
@@ -2207,8 +2227,15 @@
   LayerImpl* child_of_root = AddChildToRoot<LayerImpl>();
   LayerImpl* grand_child_of_root = AddChild<LayerImpl>(child_of_root);
 
+  parent->SetDrawsContent(true);
+  render_surface1->SetDrawsContent(true);
+  child_of_rs1->SetDrawsContent(true);
   grand_child_of_rs1->SetDrawsContent(true);
+  render_surface2->SetDrawsContent(true);
+  child_of_rs2->SetDrawsContent(true);
   grand_child_of_rs2->SetDrawsContent(true);
+  child_of_root->SetDrawsContent(true);
+  grand_child_of_root->SetDrawsContent(true);
 
   gfx::Transform layer_transform;
   layer_transform.Translate(1.0, 1.0);
@@ -2729,7 +2756,6 @@
 
   EXPECT_EQ(gfx::RectF(100.f, 100.f),
             root->render_surface()->DrawableContentRect());
-  EXPECT_EQ(gfx::Rect(100, 100), root->drawable_content_rect());
 
   // Layers that do not draw content should have empty visible_layer_rects.
   EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_layer_rect());
@@ -2778,7 +2804,6 @@
 
   EXPECT_EQ(gfx::RectF(100.f, 100.f),
             root->render_surface()->DrawableContentRect());
-  EXPECT_EQ(gfx::Rect(100, 100), root->drawable_content_rect());
 
   // Layers that do not draw content should have empty visible content rects.
   EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_layer_rect());
@@ -2861,7 +2886,6 @@
 
   EXPECT_EQ(gfx::RectF(100.f, 100.f),
             root->render_surface()->DrawableContentRect());
-  EXPECT_EQ(gfx::Rect(100, 100), root->drawable_content_rect());
 
   // Layers that do not draw content should have empty visible content rects.
   EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_layer_rect());
@@ -3388,7 +3412,6 @@
 
   EXPECT_EQ(gfx::RectF(100.f, 100.f),
             root->render_surface()->DrawableContentRect());
-  EXPECT_EQ(gfx::Rect(100, 100), root->drawable_content_rect());
 
   // Layers that do not draw content should have empty visible content rects.
   EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_layer_rect());
@@ -3453,7 +3476,6 @@
 
   EXPECT_EQ(gfx::RectF(100.f, 100.f),
             root->render_surface()->DrawableContentRect());
-  EXPECT_EQ(gfx::Rect(100, 100), root->drawable_content_rect());
 
   // Layers that do not draw content should have empty visible content rects.
   EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_layer_rect());
@@ -3746,7 +3768,6 @@
 
   EXPECT_EQ(gfx::RectF(100.f, 100.f),
             root->render_surface()->DrawableContentRect());
-  EXPECT_EQ(gfx::Rect(0, 0, 100, 100), root->drawable_content_rect());
 
   // Layers that do not draw content should have empty visible content rects.
   EXPECT_EQ(gfx::Rect(0, 0, 0, 0), root->visible_layer_rect());
@@ -3871,7 +3892,6 @@
   // device_scale_factor.
   EXPECT_EQ(gfx::RectF(200.f, 200.f),
             root->render_surface()->DrawableContentRect());
-  EXPECT_EQ(gfx::Rect(0, 0, 200, 200), root->drawable_content_rect());
   EXPECT_EQ(gfx::RectF(10.f, 10.f, 190.f, 190.f),
             render_surface1->render_surface()->DrawableContentRect());
 
@@ -4418,19 +4438,22 @@
   gfx::Transform identity_matrix;
 
   LayerImpl* parent = root_layer();
+  parent->SetDrawsContent(true);
   SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(),
                                gfx::PointF(), gfx::Size(100, 100), false, true,
                                true);
 
   LayerImpl* child = AddChildToRoot<LayerImpl>();
+  child->SetDrawsContent(true);
   SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(),
                                gfx::PointF(2.f, 2.f), gfx::Size(10, 10), false,
                                true, false);
 
-  LayerImpl* child_empty = AddChildToRoot<LayerImpl>();
-  SetLayerPropertiesForTesting(child_empty, identity_matrix, gfx::Point3F(),
-                               gfx::PointF(2.f, 2.f), gfx::Size(), false, true,
-                               false);
+  LayerImpl* child2 = AddChildToRoot<LayerImpl>();
+  child2->SetDrawsContent(true);
+  SetLayerPropertiesForTesting(child2, identity_matrix, gfx::Point3F(),
+                               gfx::PointF(2.f, 2.f), gfx::Size(5, 5), false,
+                               true, false);
 
   float device_scale_factor = 2.5f;
   gfx::Size viewport_size(100, 100);
@@ -4438,7 +4461,7 @@
 
   EXPECT_IDEAL_SCALE_EQ(device_scale_factor, parent);
   EXPECT_IDEAL_SCALE_EQ(device_scale_factor, child);
-  EXPECT_IDEAL_SCALE_EQ(device_scale_factor, child_empty);
+  EXPECT_IDEAL_SCALE_EQ(device_scale_factor, child2);
 
   EXPECT_EQ(1u, render_surface_layer_list_impl()->size());
 
@@ -4463,7 +4486,7 @@
   EXPECT_FLOAT_RECT_EQ(expected_parent_draw_rect, parent_draw_rect);
   EXPECT_FLOAT_RECT_EQ(expected_parent_draw_rect, parent_screen_space_rect);
 
-  // Verify child and child_empty transforms. They should match.
+  // Verify child and child2 transforms. They should match.
   gfx::Transform expected_child_transform;
   expected_child_transform.Scale(device_scale_factor, device_scale_factor);
   expected_child_transform.Translate(child->position().x(),
@@ -4473,11 +4496,11 @@
   EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform,
                                   child->screen_space_transform());
   EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform,
-                                  child_empty->draw_transform());
+                                  child2->draw_transform());
   EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform,
-                                  child_empty->screen_space_transform());
+                                  child2->screen_space_transform());
 
-  // Verify results of transformed child and child_empty rects. They should
+  // Verify results of transformed child and child2 rects. They should
   // match.
   gfx::RectF child_bounds(gfx::SizeF(child->bounds()));
 
@@ -4486,18 +4509,18 @@
   gfx::RectF child_screen_space_rect =
       MathUtil::MapClippedRect(child->screen_space_transform(), child_bounds);
 
-  gfx::RectF child_empty_draw_rect =
-      MathUtil::MapClippedRect(child_empty->draw_transform(), child_bounds);
-  gfx::RectF child_empty_screen_space_rect = MathUtil::MapClippedRect(
-      child_empty->screen_space_transform(), child_bounds);
+  gfx::RectF child2_draw_rect =
+      MathUtil::MapClippedRect(child2->draw_transform(), child_bounds);
+  gfx::RectF child2_screen_space_rect =
+      MathUtil::MapClippedRect(child2->screen_space_transform(), child_bounds);
 
   gfx::RectF expected_child_draw_rect(child->position(),
                                       gfx::SizeF(child->bounds()));
   expected_child_draw_rect.Scale(device_scale_factor);
   EXPECT_FLOAT_RECT_EQ(expected_child_draw_rect, child_draw_rect);
   EXPECT_FLOAT_RECT_EQ(expected_child_draw_rect, child_screen_space_rect);
-  EXPECT_FLOAT_RECT_EQ(expected_child_draw_rect, child_empty_draw_rect);
-  EXPECT_FLOAT_RECT_EQ(expected_child_draw_rect, child_empty_screen_space_rect);
+  EXPECT_FLOAT_RECT_EQ(expected_child_draw_rect, child2_draw_rect);
+  EXPECT_FLOAT_RECT_EQ(expected_child_draw_rect, child2_screen_space_rect);
 }
 
 TEST_F(LayerTreeHostCommonScalingTest, SurfaceLayerTransformsInHighDPI) {
@@ -4514,6 +4537,7 @@
                                gfx::PointF(), gfx::Size(100, 100), false, true,
                                false);
   LayerImpl* parent = AddChildToRoot<LayerImpl>();
+  parent->SetDrawsContent(true);
   SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(),
                                gfx::PointF(), gfx::Size(100, 100), false, true,
                                false);
@@ -4604,11 +4628,13 @@
   root->SetBounds(gfx::Size(100, 100));
 
   LayerImpl* parent = AddChildToRoot<LayerImpl>();
+  parent->SetDrawsContent(true);
   SetLayerPropertiesForTesting(parent, parent_scale_matrix, gfx::Point3F(),
                                gfx::PointF(), gfx::Size(100, 100), false, true,
                                false);
 
   LayerImpl* child_scale = AddChild<LayerImpl>(parent);
+  child_scale->SetDrawsContent(true);
   SetLayerPropertiesForTesting(child_scale, child_scale_matrix, gfx::Point3F(),
                                gfx::PointF(2.f, 2.f), gfx::Size(10, 10), false,
                                true, false);
@@ -4646,11 +4672,13 @@
   root->SetBounds(gfx::Size(100, 100));
 
   LayerImpl* parent = AddChildToRoot<LayerImpl>();
+  parent->SetDrawsContent(true);
   SetLayerPropertiesForTesting(parent, parent_scale_matrix, gfx::Point3F(),
                                gfx::PointF(), gfx::Size(100, 100), false, true,
                                false);
 
   LayerImpl* child_scale = AddChild<LayerImpl>(parent);
+  child_scale->SetDrawsContent(true);
   SetLayerPropertiesForTesting(child_scale, child_scale_matrix, gfx::Point3F(),
                                gfx::PointF(2.f, 2.f), gfx::Size(10, 10), false,
                                true, false);
@@ -5606,6 +5634,8 @@
   LayerImpl* intervening = AddChild<LayerImpl>(render_surface1);
   LayerImpl* render_surface2 = AddChild<LayerImpl>(intervening);
   LayerImpl* clip_child = AddChild<LayerImpl>(render_surface2);
+  render_surface1->SetDrawsContent(true);
+  render_surface2->SetDrawsContent(true);
   clip_child->SetDrawsContent(true);
 
   clip_child->SetClipParent(clip_parent);
@@ -5697,6 +5727,8 @@
   LayerImpl* intervening = AddChild<LayerImpl>(render_surface1);
   LayerImpl* render_surface2 = AddChild<LayerImpl>(intervening);
   LayerImpl* clip_child = AddChild<LayerImpl>(render_surface2);
+  render_surface1->SetDrawsContent(true);
+  render_surface2->SetDrawsContent(true);
   clip_child->SetDrawsContent(true);
 
   clip_child->SetClipParent(clip_parent);
@@ -5786,6 +5818,7 @@
   LayerImpl* intervening = AddChild<LayerImpl>(clip_parent);
   LayerImpl* clip_child = AddChild<LayerImpl>(intervening);
   LayerImpl* child = AddChild<LayerImpl>(clip_child);
+  clip_child->SetDrawsContent(true);
   child->SetDrawsContent(true);
 
   clip_child->SetClipParent(clip_parent);
@@ -6680,8 +6713,11 @@
 
   LayerPositionConstraint constraint;
   constraint.set_is_fixed_position(true);
+  container->SetDrawsContent(true);
+  fixed->SetDrawsContent(true);
   fixed->SetPositionConstraint(constraint);
 
+  scroller->SetDrawsContent(true);
   scroller->SetScrollClipLayer(container->id());
 
   gfx::Transform identity_transform;
@@ -9086,7 +9122,9 @@
                                gfx::PointF(), gfx::Size(50, 50), true, false,
                                false);
   root->SetMasksToBounds(true);
+  root->SetDrawsContent(true);
   render_surface->SetMasksToBounds(true);
+  render_surface->SetDrawsContent(true);
   test_layer->SetMasksToBounds(true);
   test_layer->SetDrawsContent(true);
   ExecuteCalculateDrawProperties(root);
@@ -9156,10 +9194,22 @@
 
   ExecuteCalculateDrawProperties(root);
 
-  EXPECT_TRUE(std::isinf(
-      render_surface2->render_surface()->draw_transform().matrix().get(0, 0)));
-  EXPECT_TRUE(std::isinf(
-      render_surface2->render_surface()->draw_transform().matrix().get(1, 1)));
+  bool is_inf_or_nan =
+      std::isinf(
+          render_surface2->render_surface()->draw_transform().matrix().get(
+              0, 0)) ||
+      std::isnan(
+          render_surface2->render_surface()->draw_transform().matrix().get(0,
+                                                                           0));
+  EXPECT_TRUE(is_inf_or_nan);
+  is_inf_or_nan =
+      std::isinf(
+          render_surface2->render_surface()->draw_transform().matrix().get(
+              1, 1)) ||
+      std::isnan(
+          render_surface2->render_surface()->draw_transform().matrix().get(1,
+                                                                           1));
+  EXPECT_TRUE(is_inf_or_nan);
   EXPECT_EQ(gfx::RectF(),
             render_surface2->render_surface()->DrawableContentRect());