| OLD | NEW | 
|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 #include "cc/trees/layer_tree_impl.h" | 5 #include "cc/trees/layer_tree_impl.h" | 
| 6 | 6 | 
| 7 #include "cc/layers/heads_up_display_layer_impl.h" | 7 #include "cc/layers/heads_up_display_layer_impl.h" | 
| 8 #include "cc/layers/layer.h" | 8 #include "cc/layers/layer.h" | 
| 9 #include "cc/layers/solid_color_scrollbar_layer_impl.h" | 9 #include "cc/layers/solid_color_scrollbar_layer_impl.h" | 
| 10 #include "cc/test/fake_impl_proxy.h" | 10 #include "cc/test/fake_impl_proxy.h" | 
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 60 | 60 | 
| 61   host_impl().SetViewportSize(root->bounds()); | 61   host_impl().SetViewportSize(root->bounds()); | 
| 62   host_impl().active_tree()->SetRootLayer(root.Pass()); | 62   host_impl().active_tree()->SetRootLayer(root.Pass()); | 
| 63   host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 63   host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 
| 64 | 64 | 
| 65   // Sanity check the scenario we just created. | 65   // Sanity check the scenario we just created. | 
| 66   ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 66   ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 
| 67   ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 67   ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 
| 68 | 68 | 
| 69   // Hit testing for a point outside the layer should return a null pointer. | 69   // Hit testing for a point outside the layer should return a null pointer. | 
| 70   gfx::Point test_point(101, 101); | 70   gfx::PointF test_point(101.f, 101.f); | 
| 71   LayerImpl* result_layer = | 71   LayerImpl* result_layer = | 
| 72       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 72       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 
| 73   EXPECT_FALSE(result_layer); | 73   EXPECT_FALSE(result_layer); | 
| 74 | 74 | 
| 75   test_point = gfx::Point(-1, -1); | 75   test_point = gfx::PointF(-1.f, -1.f); | 
| 76   result_layer = | 76   result_layer = | 
| 77       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 77       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 
| 78   EXPECT_FALSE(result_layer); | 78   EXPECT_FALSE(result_layer); | 
| 79 | 79 | 
| 80   // Hit testing for a point inside should return the root layer. | 80   // Hit testing for a point inside should return the root layer. | 
| 81   test_point = gfx::Point(1, 1); | 81   test_point = gfx::PointF(1.f, 1.f); | 
| 82   result_layer = | 82   result_layer = | 
| 83       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 83       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 
| 84   ASSERT_TRUE(result_layer); | 84   ASSERT_TRUE(result_layer); | 
| 85   EXPECT_EQ(12345, result_layer->id()); | 85   EXPECT_EQ(12345, result_layer->id()); | 
| 86 | 86 | 
| 87   test_point = gfx::Point(99, 99); | 87   test_point = gfx::PointF(99.f, 99.f); | 
| 88   result_layer = | 88   result_layer = | 
| 89       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 89       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 
| 90   ASSERT_TRUE(result_layer); | 90   ASSERT_TRUE(result_layer); | 
| 91   EXPECT_EQ(12345, result_layer->id()); | 91   EXPECT_EQ(12345, result_layer->id()); | 
| 92 } | 92 } | 
| 93 | 93 | 
| 94 TEST_F(LayerTreeImplTest, UpdateViewportAndHitTest) { | 94 TEST_F(LayerTreeImplTest, UpdateViewportAndHitTest) { | 
| 95   // Ensures that the viewport rect is correctly updated by the clip tree. | 95   // Ensures that the viewport rect is correctly updated by the clip tree. | 
| 96   TestSharedBitmapManager shared_bitmap_manager; | 96   TestSharedBitmapManager shared_bitmap_manager; | 
| 97   TestTaskGraphRunner task_graph_runner; | 97   TestTaskGraphRunner task_graph_runner; | 
| (...skipping 20 matching lines...) Expand all  Loading... | 
| 118   host_impl->active_tree()->SetRootLayer(root.Pass()); | 118   host_impl->active_tree()->SetRootLayer(root.Pass()); | 
| 119   host_impl->UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 119   host_impl->UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 
| 120   EXPECT_EQ( | 120   EXPECT_EQ( | 
| 121       gfx::RectF(gfx::SizeF(bounds)), | 121       gfx::RectF(gfx::SizeF(bounds)), | 
| 122       host_impl->active_tree()->property_trees()->clip_tree.ViewportClip()); | 122       host_impl->active_tree()->property_trees()->clip_tree.ViewportClip()); | 
| 123   EXPECT_EQ(gfx::Rect(bounds), | 123   EXPECT_EQ(gfx::Rect(bounds), | 
| 124             host_impl->RootLayer()->visible_rect_from_property_trees()); | 124             host_impl->RootLayer()->visible_rect_from_property_trees()); | 
| 125 | 125 | 
| 126   gfx::Size new_bounds(50, 50); | 126   gfx::Size new_bounds(50, 50); | 
| 127   host_impl->SetViewportSize(new_bounds); | 127   host_impl->SetViewportSize(new_bounds); | 
| 128   gfx::Point test_point(51, 51); | 128   gfx::PointF test_point(51.f, 51.f); | 
| 129   host_impl->active_tree()->FindLayerThatIsHitByPoint(test_point); | 129   host_impl->active_tree()->FindLayerThatIsHitByPoint(test_point); | 
| 130   EXPECT_EQ( | 130   EXPECT_EQ( | 
| 131       gfx::RectF(gfx::SizeF(new_bounds)), | 131       gfx::RectF(gfx::SizeF(new_bounds)), | 
| 132       host_impl->active_tree()->property_trees()->clip_tree.ViewportClip()); | 132       host_impl->active_tree()->property_trees()->clip_tree.ViewportClip()); | 
| 133   EXPECT_EQ(gfx::Rect(new_bounds), | 133   EXPECT_EQ(gfx::Rect(new_bounds), | 
| 134             host_impl->RootLayer()->visible_rect_from_property_trees()); | 134             host_impl->RootLayer()->visible_rect_from_property_trees()); | 
| 135 } | 135 } | 
| 136 | 136 | 
| 137 TEST_F(LayerTreeImplTest, HitTestingForSingleLayerAndHud) { | 137 TEST_F(LayerTreeImplTest, HitTestingForSingleLayerAndHud) { | 
| 138   scoped_ptr<LayerImpl> root = | 138   scoped_ptr<LayerImpl> root = | 
| (...skipping 20 matching lines...) Expand all  Loading... | 
| 159 | 159 | 
| 160   host_impl().SetViewportSize(hud_bounds); | 160   host_impl().SetViewportSize(hud_bounds); | 
| 161   host_impl().active_tree()->SetRootLayer(root.Pass()); | 161   host_impl().active_tree()->SetRootLayer(root.Pass()); | 
| 162   host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 162   host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 
| 163 | 163 | 
| 164   // Sanity check the scenario we just created. | 164   // Sanity check the scenario we just created. | 
| 165   ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 165   ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 
| 166   ASSERT_EQ(2u, root_layer()->render_surface()->layer_list().size()); | 166   ASSERT_EQ(2u, root_layer()->render_surface()->layer_list().size()); | 
| 167 | 167 | 
| 168   // Hit testing for a point inside HUD, but outside root should return null | 168   // Hit testing for a point inside HUD, but outside root should return null | 
| 169   gfx::Point test_point(101, 101); | 169   gfx::PointF test_point(101.f, 101.f); | 
| 170   LayerImpl* result_layer = | 170   LayerImpl* result_layer = | 
| 171       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 171       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 
| 172   EXPECT_FALSE(result_layer); | 172   EXPECT_FALSE(result_layer); | 
| 173 | 173 | 
| 174   test_point = gfx::Point(-1, -1); | 174   test_point = gfx::PointF(-1.f, -1.f); | 
| 175   result_layer = | 175   result_layer = | 
| 176       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 176       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 
| 177   EXPECT_FALSE(result_layer); | 177   EXPECT_FALSE(result_layer); | 
| 178 | 178 | 
| 179   // Hit testing for a point inside should return the root layer, never the HUD | 179   // Hit testing for a point inside should return the root layer, never the HUD | 
| 180   // layer. | 180   // layer. | 
| 181   test_point = gfx::Point(1, 1); | 181   test_point = gfx::PointF(1.f, 1.f); | 
| 182   result_layer = | 182   result_layer = | 
| 183       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 183       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 
| 184   ASSERT_TRUE(result_layer); | 184   ASSERT_TRUE(result_layer); | 
| 185   EXPECT_EQ(12345, result_layer->id()); | 185   EXPECT_EQ(12345, result_layer->id()); | 
| 186 | 186 | 
| 187   test_point = gfx::Point(99, 99); | 187   test_point = gfx::PointF(99.f, 99.f); | 
| 188   result_layer = | 188   result_layer = | 
| 189       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 189       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 
| 190   ASSERT_TRUE(result_layer); | 190   ASSERT_TRUE(result_layer); | 
| 191   EXPECT_EQ(12345, result_layer->id()); | 191   EXPECT_EQ(12345, result_layer->id()); | 
| 192 } | 192 } | 
| 193 | 193 | 
| 194 TEST_F(LayerTreeImplTest, HitTestingForUninvertibleTransform) { | 194 TEST_F(LayerTreeImplTest, HitTestingForUninvertibleTransform) { | 
| 195   scoped_ptr<LayerImpl> root = | 195   scoped_ptr<LayerImpl> root = | 
| 196       LayerImpl::Create(host_impl().active_tree(), 12345); | 196       LayerImpl::Create(host_impl().active_tree(), 12345); | 
| 197 | 197 | 
| (...skipping 17 matching lines...) Expand all  Loading... | 
| 215   host_impl().active_tree()->SetRootLayer(root.Pass()); | 215   host_impl().active_tree()->SetRootLayer(root.Pass()); | 
| 216   host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 216   host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 
| 217   // Sanity check the scenario we just created. | 217   // Sanity check the scenario we just created. | 
| 218   ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 218   ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 
| 219   ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 219   ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 
| 220   ASSERT_FALSE(root_layer()->screen_space_transform().IsInvertible()); | 220   ASSERT_FALSE(root_layer()->screen_space_transform().IsInvertible()); | 
| 221 | 221 | 
| 222   // Hit testing any point should not hit the layer. If the invertible matrix is | 222   // Hit testing any point should not hit the layer. If the invertible matrix is | 
| 223   // accidentally ignored and treated like an identity, then the hit testing | 223   // accidentally ignored and treated like an identity, then the hit testing | 
| 224   // will incorrectly hit the layer when it shouldn't. | 224   // will incorrectly hit the layer when it shouldn't. | 
| 225   gfx::Point test_point(1, 1); | 225   gfx::PointF test_point(1.f, 1.f); | 
| 226   LayerImpl* result_layer = | 226   LayerImpl* result_layer = | 
| 227       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 227       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 
| 228   EXPECT_FALSE(result_layer); | 228   EXPECT_FALSE(result_layer); | 
| 229 | 229 | 
| 230   test_point = gfx::Point(10, 10); | 230   test_point = gfx::PointF(10.f, 10.f); | 
| 231   result_layer = | 231   result_layer = | 
| 232       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 232       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 
| 233   EXPECT_FALSE(result_layer); | 233   EXPECT_FALSE(result_layer); | 
| 234 | 234 | 
| 235   test_point = gfx::Point(10, 30); | 235   test_point = gfx::PointF(10.f, 30.f); | 
| 236   result_layer = | 236   result_layer = | 
| 237       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 237       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 
| 238   EXPECT_FALSE(result_layer); | 238   EXPECT_FALSE(result_layer); | 
| 239 | 239 | 
| 240   test_point = gfx::Point(50, 50); | 240   test_point = gfx::PointF(50.f, 50.f); | 
| 241   result_layer = | 241   result_layer = | 
| 242       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 242       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 
| 243   EXPECT_FALSE(result_layer); | 243   EXPECT_FALSE(result_layer); | 
| 244 | 244 | 
| 245   test_point = gfx::Point(67, 48); | 245   test_point = gfx::PointF(67.f, 48.f); | 
| 246   result_layer = | 246   result_layer = | 
| 247       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 247       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 
| 248   EXPECT_FALSE(result_layer); | 248   EXPECT_FALSE(result_layer); | 
| 249 | 249 | 
| 250   test_point = gfx::Point(99, 99); | 250   test_point = gfx::PointF(99.f, 99.f); | 
| 251   result_layer = | 251   result_layer = | 
| 252       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 252       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 
| 253   EXPECT_FALSE(result_layer); | 253   EXPECT_FALSE(result_layer); | 
| 254 | 254 | 
| 255   test_point = gfx::Point(-1, -1); | 255   test_point = gfx::PointF(-1.f, -1.f); | 
| 256   result_layer = | 256   result_layer = | 
| 257       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 257       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 
| 258   EXPECT_FALSE(result_layer); | 258   EXPECT_FALSE(result_layer); | 
| 259 } | 259 } | 
| 260 | 260 | 
| 261 TEST_F(LayerTreeImplTest, HitTestingForSinglePositionedLayer) { | 261 TEST_F(LayerTreeImplTest, HitTestingForSinglePositionedLayer) { | 
| 262   scoped_ptr<LayerImpl> root = | 262   scoped_ptr<LayerImpl> root = | 
| 263       LayerImpl::Create(host_impl().active_tree(), 12345); | 263       LayerImpl::Create(host_impl().active_tree(), 12345); | 
| 264 | 264 | 
| 265   gfx::Transform identity_matrix; | 265   gfx::Transform identity_matrix; | 
| 266   gfx::Point3F transform_origin; | 266   gfx::Point3F transform_origin; | 
| 267   // this layer is positioned, and hit testing should correctly know where the | 267   // this layer is positioned, and hit testing should correctly know where the | 
| 268   // layer is located. | 268   // layer is located. | 
| 269   gfx::PointF position(50.f, 50.f); | 269   gfx::PointF position(50.f, 50.f); | 
| 270   gfx::Size bounds(100, 100); | 270   gfx::Size bounds(100, 100); | 
| 271   SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, | 271   SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, | 
| 272                                position, bounds, true, false, true); | 272                                position, bounds, true, false, true); | 
| 273   root->SetDrawsContent(true); | 273   root->SetDrawsContent(true); | 
| 274 | 274 | 
| 275   host_impl().SetViewportSize(root->bounds()); | 275   host_impl().SetViewportSize(root->bounds()); | 
| 276   host_impl().active_tree()->SetRootLayer(root.Pass()); | 276   host_impl().active_tree()->SetRootLayer(root.Pass()); | 
| 277   host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 277   host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 
| 278 | 278 | 
| 279   // Sanity check the scenario we just created. | 279   // Sanity check the scenario we just created. | 
| 280   ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 280   ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 
| 281   ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 281   ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 
| 282 | 282 | 
| 283   // Hit testing for a point outside the layer should return a null pointer. | 283   // Hit testing for a point outside the layer should return a null pointer. | 
| 284   gfx::Point test_point(49, 49); | 284   gfx::PointF test_point(49.f, 49.f); | 
| 285   LayerImpl* result_layer = | 285   LayerImpl* result_layer = | 
| 286       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 286       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 
| 287   EXPECT_FALSE(result_layer); | 287   EXPECT_FALSE(result_layer); | 
| 288 | 288 | 
| 289   // Even though the layer exists at (101, 101), it should not be visible there | 289   // Even though the layer exists at (101, 101), it should not be visible there | 
| 290   // since the root render surface would clamp it. | 290   // since the root render surface would clamp it. | 
| 291   test_point = gfx::Point(101, 101); | 291   test_point = gfx::PointF(101.f, 101.f); | 
| 292   result_layer = | 292   result_layer = | 
| 293       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 293       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 
| 294   EXPECT_FALSE(result_layer); | 294   EXPECT_FALSE(result_layer); | 
| 295 | 295 | 
| 296   // Hit testing for a point inside should return the root layer. | 296   // Hit testing for a point inside should return the root layer. | 
| 297   test_point = gfx::Point(51, 51); | 297   test_point = gfx::PointF(51.f, 51.f); | 
| 298   result_layer = | 298   result_layer = | 
| 299       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 299       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 
| 300   ASSERT_TRUE(result_layer); | 300   ASSERT_TRUE(result_layer); | 
| 301   EXPECT_EQ(12345, result_layer->id()); | 301   EXPECT_EQ(12345, result_layer->id()); | 
| 302 | 302 | 
| 303   test_point = gfx::Point(99, 99); | 303   test_point = gfx::PointF(99.f, 99.f); | 
| 304   result_layer = | 304   result_layer = | 
| 305       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 305       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 
| 306   ASSERT_TRUE(result_layer); | 306   ASSERT_TRUE(result_layer); | 
| 307   EXPECT_EQ(12345, result_layer->id()); | 307   EXPECT_EQ(12345, result_layer->id()); | 
| 308 } | 308 } | 
| 309 | 309 | 
| 310 TEST_F(LayerTreeImplTest, HitTestingForSingleRotatedLayer) { | 310 TEST_F(LayerTreeImplTest, HitTestingForSingleRotatedLayer) { | 
| 311   scoped_ptr<LayerImpl> root = | 311   scoped_ptr<LayerImpl> root = | 
| 312       LayerImpl::Create(host_impl().active_tree(), 12345); | 312       LayerImpl::Create(host_impl().active_tree(), 12345); | 
| 313 | 313 | 
| (...skipping 14 matching lines...) Expand all  Loading... | 
| 328   host_impl().active_tree()->SetRootLayer(root.Pass()); | 328   host_impl().active_tree()->SetRootLayer(root.Pass()); | 
| 329   host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 329   host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 
| 330 | 330 | 
| 331   // Sanity check the scenario we just created. | 331   // Sanity check the scenario we just created. | 
| 332   ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 332   ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 
| 333   ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 333   ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 
| 334 | 334 | 
| 335   // Hit testing for points outside the layer. | 335   // Hit testing for points outside the layer. | 
| 336   // These corners would have been inside the un-transformed layer, but they | 336   // These corners would have been inside the un-transformed layer, but they | 
| 337   // should not hit the correctly transformed layer. | 337   // should not hit the correctly transformed layer. | 
| 338   gfx::Point test_point(99, 99); | 338   gfx::PointF test_point(99.f, 99.f); | 
| 339   LayerImpl* result_layer = | 339   LayerImpl* result_layer = | 
| 340       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 340       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 
| 341   EXPECT_FALSE(result_layer); | 341   EXPECT_FALSE(result_layer); | 
| 342 | 342 | 
| 343   test_point = gfx::Point(1, 1); | 343   test_point = gfx::PointF(1.f, 1.f); | 
| 344   result_layer = | 344   result_layer = | 
| 345       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 345       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 
| 346   EXPECT_FALSE(result_layer); | 346   EXPECT_FALSE(result_layer); | 
| 347 | 347 | 
| 348   // Hit testing for a point inside should return the root layer. | 348   // Hit testing for a point inside should return the root layer. | 
| 349   test_point = gfx::Point(1, 50); | 349   test_point = gfx::PointF(1.f, 50.f); | 
| 350   result_layer = | 350   result_layer = | 
| 351       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 351       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 
| 352   ASSERT_TRUE(result_layer); | 352   ASSERT_TRUE(result_layer); | 
| 353   EXPECT_EQ(12345, result_layer->id()); | 353   EXPECT_EQ(12345, result_layer->id()); | 
| 354 | 354 | 
| 355   // Hit testing the corners that would overlap the unclipped layer, but are | 355   // Hit testing the corners that would overlap the unclipped layer, but are | 
| 356   // outside the clipped region. | 356   // outside the clipped region. | 
| 357   test_point = gfx::Point(50, -1); | 357   test_point = gfx::PointF(50.f, -1.f); | 
| 358   result_layer = | 358   result_layer = | 
| 359       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 359       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 
| 360   ASSERT_FALSE(result_layer); | 360   ASSERT_FALSE(result_layer); | 
| 361 | 361 | 
| 362   test_point = gfx::Point(-1, 50); | 362   test_point = gfx::PointF(-1.f, 50.f); | 
| 363   result_layer = | 363   result_layer = | 
| 364       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 364       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 
| 365   ASSERT_FALSE(result_layer); | 365   ASSERT_FALSE(result_layer); | 
| 366 } | 366 } | 
| 367 | 367 | 
| 368 TEST_F(LayerTreeImplTest, HitTestingForSinglePerspectiveLayer) { | 368 TEST_F(LayerTreeImplTest, HitTestingForSinglePerspectiveLayer) { | 
| 369   scoped_ptr<LayerImpl> root = | 369   scoped_ptr<LayerImpl> root = | 
| 370       LayerImpl::Create(host_impl().active_tree(), 12345); | 370       LayerImpl::Create(host_impl().active_tree(), 12345); | 
| 371 | 371 | 
| 372   gfx::Transform identity_matrix; | 372   gfx::Transform identity_matrix; | 
| (...skipping 19 matching lines...) Expand all  Loading... | 
| 392   host_impl().active_tree()->SetRootLayer(root.Pass()); | 392   host_impl().active_tree()->SetRootLayer(root.Pass()); | 
| 393   host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 393   host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 
| 394 | 394 | 
| 395   // Sanity check the scenario we just created. | 395   // Sanity check the scenario we just created. | 
| 396   ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 396   ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 
| 397   ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 397   ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 
| 398 | 398 | 
| 399   // Hit testing for points outside the layer. | 399   // Hit testing for points outside the layer. | 
| 400   // These corners would have been inside the un-transformed layer, but they | 400   // These corners would have been inside the un-transformed layer, but they | 
| 401   // should not hit the correctly transformed layer. | 401   // should not hit the correctly transformed layer. | 
| 402   gfx::Point test_point(24, 24); | 402   gfx::PointF test_point(24.f, 24.f); | 
| 403   LayerImpl* result_layer = | 403   LayerImpl* result_layer = | 
| 404       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 404       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 
| 405   EXPECT_FALSE(result_layer); | 405   EXPECT_FALSE(result_layer); | 
| 406 | 406 | 
| 407   test_point = gfx::Point(76, 76); | 407   test_point = gfx::PointF(76.f, 76.f); | 
| 408   result_layer = | 408   result_layer = | 
| 409       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 409       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 
| 410   EXPECT_FALSE(result_layer); | 410   EXPECT_FALSE(result_layer); | 
| 411 | 411 | 
| 412   // Hit testing for a point inside should return the root layer. | 412   // Hit testing for a point inside should return the root layer. | 
| 413   test_point = gfx::Point(26, 26); | 413   test_point = gfx::PointF(26.f, 26.f); | 
| 414   result_layer = | 414   result_layer = | 
| 415       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 415       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 
| 416   ASSERT_TRUE(result_layer); | 416   ASSERT_TRUE(result_layer); | 
| 417   EXPECT_EQ(12345, result_layer->id()); | 417   EXPECT_EQ(12345, result_layer->id()); | 
| 418 | 418 | 
| 419   test_point = gfx::Point(74, 74); | 419   test_point = gfx::PointF(74.f, 74.f); | 
| 420   result_layer = | 420   result_layer = | 
| 421       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 421       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 
| 422   ASSERT_TRUE(result_layer); | 422   ASSERT_TRUE(result_layer); | 
| 423   EXPECT_EQ(12345, result_layer->id()); | 423   EXPECT_EQ(12345, result_layer->id()); | 
| 424 } | 424 } | 
| 425 | 425 | 
| 426 TEST_F(LayerTreeImplTest, HitTestingForSimpleClippedLayer) { | 426 TEST_F(LayerTreeImplTest, HitTestingForSimpleClippedLayer) { | 
| 427   // Test that hit-testing will only work for the visible portion of a layer, | 427   // Test that hit-testing will only work for the visible portion of a layer, | 
| 428   // and not the entire layer bounds. Here we just test the simple axis-aligned | 428   // and not the entire layer bounds. Here we just test the simple axis-aligned | 
| 429   // case. | 429   // case. | 
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 462   host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 462   host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 
| 463 | 463 | 
| 464   // Sanity check the scenario we just created. | 464   // Sanity check the scenario we just created. | 
| 465   ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 465   ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 
| 466   ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 466   ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 
| 467   ASSERT_EQ(456, root_layer()->render_surface()->layer_list().at(0)->id()); | 467   ASSERT_EQ(456, root_layer()->render_surface()->layer_list().at(0)->id()); | 
| 468 | 468 | 
| 469   // Hit testing for a point outside the layer should return a null pointer. | 469   // Hit testing for a point outside the layer should return a null pointer. | 
| 470   // Despite the child layer being very large, it should be clipped to the root | 470   // Despite the child layer being very large, it should be clipped to the root | 
| 471   // layer's bounds. | 471   // layer's bounds. | 
| 472   gfx::Point test_point(24, 24); | 472   gfx::PointF test_point(24.f, 24.f); | 
| 473   LayerImpl* result_layer = | 473   LayerImpl* result_layer = | 
| 474       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 474       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 
| 475   EXPECT_FALSE(result_layer); | 475   EXPECT_FALSE(result_layer); | 
| 476 | 476 | 
| 477   // Even though the layer exists at (101, 101), it should not be visible there | 477   // Even though the layer exists at (101, 101), it should not be visible there | 
| 478   // since the clipping_layer would clamp it. | 478   // since the clipping_layer would clamp it. | 
| 479   test_point = gfx::Point(76, 76); | 479   test_point = gfx::PointF(76.f, 76.f); | 
| 480   result_layer = | 480   result_layer = | 
| 481       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 481       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 
| 482   EXPECT_FALSE(result_layer); | 482   EXPECT_FALSE(result_layer); | 
| 483 | 483 | 
| 484   // Hit testing for a point inside should return the child layer. | 484   // Hit testing for a point inside should return the child layer. | 
| 485   test_point = gfx::Point(26, 26); | 485   test_point = gfx::PointF(26.f, 26.f); | 
| 486   result_layer = | 486   result_layer = | 
| 487       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 487       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 
| 488   ASSERT_TRUE(result_layer); | 488   ASSERT_TRUE(result_layer); | 
| 489   EXPECT_EQ(456, result_layer->id()); | 489   EXPECT_EQ(456, result_layer->id()); | 
| 490 | 490 | 
| 491   test_point = gfx::Point(74, 74); | 491   test_point = gfx::PointF(74.f, 74.f); | 
| 492   result_layer = | 492   result_layer = | 
| 493       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 493       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 
| 494   ASSERT_TRUE(result_layer); | 494   ASSERT_TRUE(result_layer); | 
| 495   EXPECT_EQ(456, result_layer->id()); | 495   EXPECT_EQ(456, result_layer->id()); | 
| 496 } | 496 } | 
| 497 | 497 | 
| 498 TEST_F(LayerTreeImplTest, HitTestingForMultiClippedRotatedLayer) { | 498 TEST_F(LayerTreeImplTest, HitTestingForMultiClippedRotatedLayer) { | 
| 499   // This test checks whether hit testing correctly avoids hit testing with | 499   // This test checks whether hit testing correctly avoids hit testing with | 
| 500   // multiple ancestors that clip in non axis-aligned ways. To pass this test, | 500   // multiple ancestors that clip in non axis-aligned ways. To pass this test, | 
| 501   // the hit testing algorithm needs to recognize that multiple parent layers | 501   // the hit testing algorithm needs to recognize that multiple parent layers | 
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 563     child->AddChild(grand_child.Pass()); | 563     child->AddChild(grand_child.Pass()); | 
| 564     root->AddChild(child.Pass()); | 564     root->AddChild(child.Pass()); | 
| 565   } | 565   } | 
| 566 | 566 | 
| 567   host_impl().SetViewportSize(root->bounds()); | 567   host_impl().SetViewportSize(root->bounds()); | 
| 568   host_impl().active_tree()->SetRootLayer(root.Pass()); | 568   host_impl().active_tree()->SetRootLayer(root.Pass()); | 
| 569   host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 569   host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 
| 570 | 570 | 
| 571   // (11, 89) is close to the the bottom left corner within the clip, but it is | 571   // (11, 89) is close to the the bottom left corner within the clip, but it is | 
| 572   // not inside the layer. | 572   // not inside the layer. | 
| 573   gfx::Point test_point(11, 89); | 573   gfx::PointF test_point(11.f, 89.f); | 
| 574   LayerImpl* result_layer = | 574   LayerImpl* result_layer = | 
| 575       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 575       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 
| 576   EXPECT_FALSE(result_layer); | 576   EXPECT_FALSE(result_layer); | 
| 577 | 577 | 
| 578   // Closer inwards from the bottom left will overlap the layer. | 578   // Closer inwards from the bottom left will overlap the layer. | 
| 579   test_point = gfx::Point(25, 75); | 579   test_point = gfx::PointF(25.f, 75.f); | 
| 580   result_layer = | 580   result_layer = | 
| 581       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 581       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 
| 582   ASSERT_TRUE(result_layer); | 582   ASSERT_TRUE(result_layer); | 
| 583   EXPECT_EQ(2468, result_layer->id()); | 583   EXPECT_EQ(2468, result_layer->id()); | 
| 584 | 584 | 
| 585   // (4, 50) is inside the unclipped layer, but that corner of the layer should | 585   // (4, 50) is inside the unclipped layer, but that corner of the layer should | 
| 586   // be clipped away by the grandparent and should not get hit. If hit testing | 586   // be clipped away by the grandparent and should not get hit. If hit testing | 
| 587   // blindly uses visible content rect without considering how parent may clip | 587   // blindly uses visible content rect without considering how parent may clip | 
| 588   // the layer, then hit testing would accidentally think that the point | 588   // the layer, then hit testing would accidentally think that the point | 
| 589   // successfully hits the layer. | 589   // successfully hits the layer. | 
| 590   test_point = gfx::Point(4, 50); | 590   test_point = gfx::PointF(4.f, 50.f); | 
| 591   result_layer = | 591   result_layer = | 
| 592       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 592       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 
| 593   EXPECT_FALSE(result_layer); | 593   EXPECT_FALSE(result_layer); | 
| 594 | 594 | 
| 595   // (11, 50) is inside the layer and within the clipped area. | 595   // (11, 50) is inside the layer and within the clipped area. | 
| 596   test_point = gfx::Point(11, 50); | 596   test_point = gfx::PointF(11.f, 50.f); | 
| 597   result_layer = | 597   result_layer = | 
| 598       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 598       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 
| 599   ASSERT_TRUE(result_layer); | 599   ASSERT_TRUE(result_layer); | 
| 600   EXPECT_EQ(2468, result_layer->id()); | 600   EXPECT_EQ(2468, result_layer->id()); | 
| 601 | 601 | 
| 602   // Around the middle, just to the right and up, would have hit the layer | 602   // Around the middle, just to the right and up, would have hit the layer | 
| 603   // except that that area should be clipped away by the parent. | 603   // except that that area should be clipped away by the parent. | 
| 604   test_point = gfx::Point(51, 49); | 604   test_point = gfx::PointF(51.f, 49.f); | 
| 605   result_layer = | 605   result_layer = | 
| 606       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 606       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 
| 607   EXPECT_FALSE(result_layer); | 607   EXPECT_FALSE(result_layer); | 
| 608 | 608 | 
| 609   // Around the middle, just to the left and down, should successfully hit the | 609   // Around the middle, just to the left and down, should successfully hit the | 
| 610   // layer. | 610   // layer. | 
| 611   test_point = gfx::Point(49, 51); | 611   test_point = gfx::PointF(49.f, 51.f); | 
| 612   result_layer = | 612   result_layer = | 
| 613       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 613       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 
| 614   ASSERT_TRUE(result_layer); | 614   ASSERT_TRUE(result_layer); | 
| 615   EXPECT_EQ(2468, result_layer->id()); | 615   EXPECT_EQ(2468, result_layer->id()); | 
| 616 } | 616 } | 
| 617 | 617 | 
| 618 TEST_F(LayerTreeImplTest, HitTestingForNonClippingIntermediateLayer) { | 618 TEST_F(LayerTreeImplTest, HitTestingForNonClippingIntermediateLayer) { | 
| 619   // This test checks that hit testing code does not accidentally clip to layer | 619   // This test checks that hit testing code does not accidentally clip to layer | 
| 620   // bounds for a layer that actually does not clip. | 620   // bounds for a layer that actually does not clip. | 
| 621   gfx::Transform identity_matrix; | 621   gfx::Transform identity_matrix; | 
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 656   host_impl().SetViewportSize(root->bounds()); | 656   host_impl().SetViewportSize(root->bounds()); | 
| 657   host_impl().active_tree()->SetRootLayer(root.Pass()); | 657   host_impl().active_tree()->SetRootLayer(root.Pass()); | 
| 658   host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 658   host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 
| 659 | 659 | 
| 660   // Sanity check the scenario we just created. | 660   // Sanity check the scenario we just created. | 
| 661   ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 661   ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 
| 662   ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 662   ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 
| 663   ASSERT_EQ(456, root_layer()->render_surface()->layer_list().at(0)->id()); | 663   ASSERT_EQ(456, root_layer()->render_surface()->layer_list().at(0)->id()); | 
| 664 | 664 | 
| 665   // Hit testing for a point outside the layer should return a null pointer. | 665   // Hit testing for a point outside the layer should return a null pointer. | 
| 666   gfx::Point test_point(69, 69); | 666   gfx::PointF test_point(69.f, 69.f); | 
| 667   LayerImpl* result_layer = | 667   LayerImpl* result_layer = | 
| 668       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 668       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 
| 669   EXPECT_FALSE(result_layer); | 669   EXPECT_FALSE(result_layer); | 
| 670 | 670 | 
| 671   test_point = gfx::Point(91, 91); | 671   test_point = gfx::PointF(91.f, 91.f); | 
| 672   result_layer = | 672   result_layer = | 
| 673       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 673       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 
| 674   EXPECT_FALSE(result_layer); | 674   EXPECT_FALSE(result_layer); | 
| 675 | 675 | 
| 676   // Hit testing for a point inside should return the child layer. | 676   // Hit testing for a point inside should return the child layer. | 
| 677   test_point = gfx::Point(71, 71); | 677   test_point = gfx::PointF(71.f, 71.f); | 
| 678   result_layer = | 678   result_layer = | 
| 679       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 679       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 
| 680   ASSERT_TRUE(result_layer); | 680   ASSERT_TRUE(result_layer); | 
| 681   EXPECT_EQ(456, result_layer->id()); | 681   EXPECT_EQ(456, result_layer->id()); | 
| 682 | 682 | 
| 683   test_point = gfx::Point(89, 89); | 683   test_point = gfx::PointF(89.f, 89.f); | 
| 684   result_layer = | 684   result_layer = | 
| 685       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 685       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 
| 686   ASSERT_TRUE(result_layer); | 686   ASSERT_TRUE(result_layer); | 
| 687   EXPECT_EQ(456, result_layer->id()); | 687   EXPECT_EQ(456, result_layer->id()); | 
| 688 } | 688 } | 
| 689 | 689 | 
| 690 TEST_F(LayerTreeImplTest, HitTestingForMultipleLayers) { | 690 TEST_F(LayerTreeImplTest, HitTestingForMultipleLayers) { | 
| 691   scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); | 691   scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); | 
| 692 | 692 | 
| 693   gfx::Transform identity_matrix; | 693   gfx::Transform identity_matrix; | 
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 756 | 756 | 
| 757   RenderSurfaceImpl* root_render_surface = root_layer()->render_surface(); | 757   RenderSurfaceImpl* root_render_surface = root_layer()->render_surface(); | 
| 758   ASSERT_EQ(4u, root_render_surface->layer_list().size()); | 758   ASSERT_EQ(4u, root_render_surface->layer_list().size()); | 
| 759   ASSERT_EQ(1, root_render_surface->layer_list().at(0)->id());  // root layer | 759   ASSERT_EQ(1, root_render_surface->layer_list().at(0)->id());  // root layer | 
| 760   ASSERT_EQ(2, root_render_surface->layer_list().at(1)->id());  // child1 | 760   ASSERT_EQ(2, root_render_surface->layer_list().at(1)->id());  // child1 | 
| 761   ASSERT_EQ(4, root_render_surface->layer_list().at(2)->id());  // grand_child1 | 761   ASSERT_EQ(4, root_render_surface->layer_list().at(2)->id());  // grand_child1 | 
| 762   ASSERT_EQ(3, root_render_surface->layer_list().at(3)->id());  // child2 | 762   ASSERT_EQ(3, root_render_surface->layer_list().at(3)->id());  // child2 | 
| 763 | 763 | 
| 764   // Nothing overlaps the root_layer at (1, 1), so hit testing there should find | 764   // Nothing overlaps the root_layer at (1, 1), so hit testing there should find | 
| 765   // the root layer. | 765   // the root layer. | 
| 766   gfx::Point test_point = gfx::Point(1, 1); | 766   gfx::PointF test_point = gfx::PointF(1.f, 1.f); | 
| 767   LayerImpl* result_layer = | 767   LayerImpl* result_layer = | 
| 768       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 768       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 
| 769   ASSERT_TRUE(result_layer); | 769   ASSERT_TRUE(result_layer); | 
| 770   EXPECT_EQ(1, result_layer->id()); | 770   EXPECT_EQ(1, result_layer->id()); | 
| 771 | 771 | 
| 772   // At (15, 15), child1 and root are the only layers. child1 is expected to be | 772   // At (15, 15), child1 and root are the only layers. child1 is expected to be | 
| 773   // on top. | 773   // on top. | 
| 774   test_point = gfx::Point(15, 15); | 774   test_point = gfx::PointF(15.f, 15.f); | 
| 775   result_layer = | 775   result_layer = | 
| 776       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 776       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 
| 777   ASSERT_TRUE(result_layer); | 777   ASSERT_TRUE(result_layer); | 
| 778   EXPECT_EQ(2, result_layer->id()); | 778   EXPECT_EQ(2, result_layer->id()); | 
| 779 | 779 | 
| 780   // At (51, 20), child1 and child2 overlap. child2 is expected to be on top. | 780   // At (51, 20), child1 and child2 overlap. child2 is expected to be on top. | 
| 781   test_point = gfx::Point(51, 20); | 781   test_point = gfx::PointF(51.f, 20.f); | 
| 782   result_layer = | 782   result_layer = | 
| 783       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 783       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 
| 784   ASSERT_TRUE(result_layer); | 784   ASSERT_TRUE(result_layer); | 
| 785   EXPECT_EQ(3, result_layer->id()); | 785   EXPECT_EQ(3, result_layer->id()); | 
| 786 | 786 | 
| 787   // At (80, 51), child2 and grand_child1 overlap. child2 is expected to be on | 787   // At (80, 51), child2 and grand_child1 overlap. child2 is expected to be on | 
| 788   // top. | 788   // top. | 
| 789   test_point = gfx::Point(80, 51); | 789   test_point = gfx::PointF(80.f, 51.f); | 
| 790   result_layer = | 790   result_layer = | 
| 791       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 791       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 
| 792   ASSERT_TRUE(result_layer); | 792   ASSERT_TRUE(result_layer); | 
| 793   EXPECT_EQ(3, result_layer->id()); | 793   EXPECT_EQ(3, result_layer->id()); | 
| 794 | 794 | 
| 795   // At (51, 51), all layers overlap each other. child2 is expected to be on top | 795   // At (51, 51), all layers overlap each other. child2 is expected to be on top | 
| 796   // of all other layers. | 796   // of all other layers. | 
| 797   test_point = gfx::Point(51, 51); | 797   test_point = gfx::PointF(51.f, 51.f); | 
| 798   result_layer = | 798   result_layer = | 
| 799       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 799       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 
| 800   ASSERT_TRUE(result_layer); | 800   ASSERT_TRUE(result_layer); | 
| 801   EXPECT_EQ(3, result_layer->id()); | 801   EXPECT_EQ(3, result_layer->id()); | 
| 802 | 802 | 
| 803   // At (20, 51), child1 and grand_child1 overlap. grand_child1 is expected to | 803   // At (20, 51), child1 and grand_child1 overlap. grand_child1 is expected to | 
| 804   // be on top. | 804   // be on top. | 
| 805   test_point = gfx::Point(20, 51); | 805   test_point = gfx::PointF(20.f, 51.f); | 
| 806   result_layer = | 806   result_layer = | 
| 807       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 807       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 
| 808   ASSERT_TRUE(result_layer); | 808   ASSERT_TRUE(result_layer); | 
| 809   EXPECT_EQ(4, result_layer->id()); | 809   EXPECT_EQ(4, result_layer->id()); | 
| 810 } | 810 } | 
| 811 | 811 | 
| 812 TEST_F(LayerTreeImplTest, HitTestingForMultipleLayersAtVaryingDepths) { | 812 TEST_F(LayerTreeImplTest, HitTestingForMultipleLayersAtVaryingDepths) { | 
| 813   scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); | 813   scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); | 
| 814 | 814 | 
| 815   gfx::Transform identity_matrix; | 815   gfx::Transform identity_matrix; | 
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 879   host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 879   host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 
| 880 | 880 | 
| 881   // Sanity check the scenario we just created. | 881   // Sanity check the scenario we just created. | 
| 882   ASSERT_TRUE(child1); | 882   ASSERT_TRUE(child1); | 
| 883   ASSERT_TRUE(child2); | 883   ASSERT_TRUE(child2); | 
| 884   ASSERT_TRUE(grand_child1); | 884   ASSERT_TRUE(grand_child1); | 
| 885   ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 885   ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 
| 886 | 886 | 
| 887   // Nothing overlaps the root_layer at (1, 1), so hit testing there should find | 887   // Nothing overlaps the root_layer at (1, 1), so hit testing there should find | 
| 888   // the root layer. | 888   // the root layer. | 
| 889   gfx::Point test_point = gfx::Point(1, 1); | 889   gfx::PointF test_point = gfx::PointF(1.f, 1.f); | 
| 890   LayerImpl* result_layer = | 890   LayerImpl* result_layer = | 
| 891       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 891       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 
| 892   ASSERT_TRUE(result_layer); | 892   ASSERT_TRUE(result_layer); | 
| 893   EXPECT_EQ(1, result_layer->id()); | 893   EXPECT_EQ(1, result_layer->id()); | 
| 894 | 894 | 
| 895   // At (15, 15), child1 and root are the only layers. child1 is expected to be | 895   // At (15, 15), child1 and root are the only layers. child1 is expected to be | 
| 896   // on top. | 896   // on top. | 
| 897   test_point = gfx::Point(15, 15); | 897   test_point = gfx::PointF(15.f, 15.f); | 
| 898   result_layer = | 898   result_layer = | 
| 899       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 899       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 
| 900   ASSERT_TRUE(result_layer); | 900   ASSERT_TRUE(result_layer); | 
| 901   EXPECT_EQ(2, result_layer->id()); | 901   EXPECT_EQ(2, result_layer->id()); | 
| 902 | 902 | 
| 903   // At (51, 20), child1 and child2 overlap. child2 is expected to be on top. | 903   // At (51, 20), child1 and child2 overlap. child2 is expected to be on top. | 
| 904   // (because 3 is transformed to the back). | 904   // (because 3 is transformed to the back). | 
| 905   test_point = gfx::Point(51, 20); | 905   test_point = gfx::PointF(51.f, 20.f); | 
| 906   result_layer = | 906   result_layer = | 
| 907       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 907       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 
| 908   ASSERT_TRUE(result_layer); | 908   ASSERT_TRUE(result_layer); | 
| 909   EXPECT_EQ(2, result_layer->id()); | 909   EXPECT_EQ(2, result_layer->id()); | 
| 910 | 910 | 
| 911   // 3 Would have been on top if it hadn't been transformed to the background. | 911   // 3 Would have been on top if it hadn't been transformed to the background. | 
| 912   // Make sure that it isn't hit. | 912   // Make sure that it isn't hit. | 
| 913   test_point = gfx::Point(80, 51); | 913   test_point = gfx::PointF(80.f, 51.f); | 
| 914   result_layer = | 914   result_layer = | 
| 915       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 915       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 
| 916   ASSERT_TRUE(result_layer); | 916   ASSERT_TRUE(result_layer); | 
| 917   EXPECT_EQ(4, result_layer->id()); | 917   EXPECT_EQ(4, result_layer->id()); | 
| 918 | 918 | 
| 919   // 3 Would have been on top if it hadn't been transformed to the background. | 919   // 3 Would have been on top if it hadn't been transformed to the background. | 
| 920   // Make sure that it isn't hit. | 920   // Make sure that it isn't hit. | 
| 921   test_point = gfx::Point(51, 51); | 921   test_point = gfx::PointF(51.f, 51.f); | 
| 922   result_layer = | 922   result_layer = | 
| 923       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 923       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 
| 924   ASSERT_TRUE(result_layer); | 924   ASSERT_TRUE(result_layer); | 
| 925   EXPECT_EQ(4, result_layer->id()); | 925   EXPECT_EQ(4, result_layer->id()); | 
| 926 | 926 | 
| 927   // At (20, 51), child1 and grand_child1 overlap. grand_child1 is expected to | 927   // At (20, 51), child1 and grand_child1 overlap. grand_child1 is expected to | 
| 928   // be on top. | 928   // be on top. | 
| 929   test_point = gfx::Point(20, 51); | 929   test_point = gfx::PointF(20.f, 51.f); | 
| 930   result_layer = | 930   result_layer = | 
| 931       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 931       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 
| 932   ASSERT_TRUE(result_layer); | 932   ASSERT_TRUE(result_layer); | 
| 933   EXPECT_EQ(4, result_layer->id()); | 933   EXPECT_EQ(4, result_layer->id()); | 
| 934 } | 934 } | 
| 935 | 935 | 
| 936 TEST_F(LayerTreeImplTest, HitTestingRespectsClipParents) { | 936 TEST_F(LayerTreeImplTest, HitTestingRespectsClipParents) { | 
| 937   scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); | 937   scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); | 
| 938   gfx::Transform identity_matrix; | 938   gfx::Transform identity_matrix; | 
| 939   gfx::Point3F transform_origin; | 939   gfx::Point3F transform_origin; | 
| (...skipping 27 matching lines...) Expand all  Loading... | 
| 967     grand_child->SetClipParent(root.get()); | 967     grand_child->SetClipParent(root.get()); | 
| 968 | 968 | 
| 969     child->AddChild(grand_child.Pass()); | 969     child->AddChild(grand_child.Pass()); | 
| 970     root->AddChild(child.Pass()); | 970     root->AddChild(child.Pass()); | 
| 971   } | 971   } | 
| 972 | 972 | 
| 973   host_impl().SetViewportSize(root->bounds()); | 973   host_impl().SetViewportSize(root->bounds()); | 
| 974   host_impl().active_tree()->SetRootLayer(root.Pass()); | 974   host_impl().active_tree()->SetRootLayer(root.Pass()); | 
| 975   host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 975   host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 
| 976 | 976 | 
| 977   gfx::Point test_point = gfx::Point(12, 52); | 977   gfx::PointF test_point(12.f, 52.f); | 
| 978   LayerImpl* result_layer = | 978   LayerImpl* result_layer = | 
| 979       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 979       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 
| 980   ASSERT_TRUE(result_layer); | 980   ASSERT_TRUE(result_layer); | 
| 981   EXPECT_EQ(4, result_layer->id()); | 981   EXPECT_EQ(4, result_layer->id()); | 
| 982 } | 982 } | 
| 983 | 983 | 
| 984 TEST_F(LayerTreeImplTest, HitTestingRespectsScrollParents) { | 984 TEST_F(LayerTreeImplTest, HitTestingRespectsScrollParents) { | 
| 985   scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); | 985   scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); | 
| 986   gfx::Transform identity_matrix; | 986   gfx::Transform identity_matrix; | 
| 987   gfx::Point3F transform_origin; | 987   gfx::Point3F transform_origin; | 
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1027 | 1027 | 
| 1028     scroll_child->AddChild(grand_child.Pass()); | 1028     scroll_child->AddChild(grand_child.Pass()); | 
| 1029     root->AddChild(scroll_child.Pass()); | 1029     root->AddChild(scroll_child.Pass()); | 
| 1030     root->AddChild(child.Pass()); | 1030     root->AddChild(child.Pass()); | 
| 1031   } | 1031   } | 
| 1032 | 1032 | 
| 1033   host_impl().SetViewportSize(root->bounds()); | 1033   host_impl().SetViewportSize(root->bounds()); | 
| 1034   host_impl().active_tree()->SetRootLayer(root.Pass()); | 1034   host_impl().active_tree()->SetRootLayer(root.Pass()); | 
| 1035   host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 1035   host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 
| 1036 | 1036 | 
| 1037   gfx::Point test_point = gfx::Point(12, 52); | 1037   gfx::PointF test_point(12.f, 52.f); | 
| 1038   LayerImpl* result_layer = | 1038   LayerImpl* result_layer = | 
| 1039       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 1039       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 
| 1040   // The |test_point| should have been clipped away by |child|, the scroll | 1040   // The |test_point| should have been clipped away by |child|, the scroll | 
| 1041   // parent, so the only thing that should be hit is |root|. | 1041   // parent, so the only thing that should be hit is |root|. | 
| 1042   ASSERT_TRUE(result_layer); | 1042   ASSERT_TRUE(result_layer); | 
| 1043   ASSERT_EQ(1, result_layer->id()); | 1043   ASSERT_EQ(1, result_layer->id()); | 
| 1044 } | 1044 } | 
| 1045 TEST_F(LayerTreeImplTest, HitTestingForMultipleLayerLists) { | 1045 TEST_F(LayerTreeImplTest, HitTestingForMultipleLayerLists) { | 
| 1046   // | 1046   // | 
| 1047   // The geometry is set up similarly to the previous case, but | 1047   // The geometry is set up similarly to the previous case, but | 
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1125   ASSERT_EQ(2u, child1->render_surface()->layer_list().size()); | 1125   ASSERT_EQ(2u, child1->render_surface()->layer_list().size()); | 
| 1126   ASSERT_EQ(1u, child2->render_surface()->layer_list().size()); | 1126   ASSERT_EQ(1u, child2->render_surface()->layer_list().size()); | 
| 1127   ASSERT_EQ(1u, grand_child1->render_surface()->layer_list().size()); | 1127   ASSERT_EQ(1u, grand_child1->render_surface()->layer_list().size()); | 
| 1128   ASSERT_EQ(1, RenderSurfaceLayerList().at(0)->id());  // root layer | 1128   ASSERT_EQ(1, RenderSurfaceLayerList().at(0)->id());  // root layer | 
| 1129   ASSERT_EQ(2, RenderSurfaceLayerList()[1]->id());     // child1 | 1129   ASSERT_EQ(2, RenderSurfaceLayerList()[1]->id());     // child1 | 
| 1130   ASSERT_EQ(4, RenderSurfaceLayerList().at(2)->id());  // grand_child1 | 1130   ASSERT_EQ(4, RenderSurfaceLayerList().at(2)->id());  // grand_child1 | 
| 1131   ASSERT_EQ(3, RenderSurfaceLayerList()[3]->id());     // child2 | 1131   ASSERT_EQ(3, RenderSurfaceLayerList()[3]->id());     // child2 | 
| 1132 | 1132 | 
| 1133   // Nothing overlaps the root_layer at (1, 1), so hit testing there should find | 1133   // Nothing overlaps the root_layer at (1, 1), so hit testing there should find | 
| 1134   // the root layer. | 1134   // the root layer. | 
| 1135   gfx::Point test_point = gfx::Point(1, 1); | 1135   gfx::PointF test_point(1.f, 1.f); | 
| 1136   LayerImpl* result_layer = | 1136   LayerImpl* result_layer = | 
| 1137       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 1137       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 
| 1138   ASSERT_TRUE(result_layer); | 1138   ASSERT_TRUE(result_layer); | 
| 1139   EXPECT_EQ(1, result_layer->id()); | 1139   EXPECT_EQ(1, result_layer->id()); | 
| 1140 | 1140 | 
| 1141   // At (15, 15), child1 and root are the only layers. child1 is expected to be | 1141   // At (15, 15), child1 and root are the only layers. child1 is expected to be | 
| 1142   // on top. | 1142   // on top. | 
| 1143   test_point = gfx::Point(15, 15); | 1143   test_point = gfx::PointF(15.f, 15.f); | 
| 1144   result_layer = | 1144   result_layer = | 
| 1145       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 1145       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 
| 1146   ASSERT_TRUE(result_layer); | 1146   ASSERT_TRUE(result_layer); | 
| 1147   EXPECT_EQ(2, result_layer->id()); | 1147   EXPECT_EQ(2, result_layer->id()); | 
| 1148 | 1148 | 
| 1149   // At (51, 20), child1 and child2 overlap. child2 is expected to be on top. | 1149   // At (51, 20), child1 and child2 overlap. child2 is expected to be on top. | 
| 1150   test_point = gfx::Point(51, 20); | 1150   test_point = gfx::PointF(51.f, 20.f); | 
| 1151   result_layer = | 1151   result_layer = | 
| 1152       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 1152       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 
| 1153   ASSERT_TRUE(result_layer); | 1153   ASSERT_TRUE(result_layer); | 
| 1154   EXPECT_EQ(3, result_layer->id()); | 1154   EXPECT_EQ(3, result_layer->id()); | 
| 1155 | 1155 | 
| 1156   // At (80, 51), child2 and grand_child1 overlap. child2 is expected to be on | 1156   // At (80, 51), child2 and grand_child1 overlap. child2 is expected to be on | 
| 1157   // top. | 1157   // top. | 
| 1158   test_point = gfx::Point(80, 51); | 1158   test_point = gfx::PointF(80.f, 51.f); | 
| 1159   result_layer = | 1159   result_layer = | 
| 1160       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 1160       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 
| 1161   ASSERT_TRUE(result_layer); | 1161   ASSERT_TRUE(result_layer); | 
| 1162   EXPECT_EQ(3, result_layer->id()); | 1162   EXPECT_EQ(3, result_layer->id()); | 
| 1163 | 1163 | 
| 1164   // At (51, 51), all layers overlap each other. child2 is expected to be on top | 1164   // At (51, 51), all layers overlap each other. child2 is expected to be on top | 
| 1165   // of all other layers. | 1165   // of all other layers. | 
| 1166   test_point = gfx::Point(51, 51); | 1166   test_point = gfx::PointF(51.f, 51.f); | 
| 1167   result_layer = | 1167   result_layer = | 
| 1168       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 1168       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 
| 1169   ASSERT_TRUE(result_layer); | 1169   ASSERT_TRUE(result_layer); | 
| 1170   EXPECT_EQ(3, result_layer->id()); | 1170   EXPECT_EQ(3, result_layer->id()); | 
| 1171 | 1171 | 
| 1172   // At (20, 51), child1 and grand_child1 overlap. grand_child1 is expected to | 1172   // At (20, 51), child1 and grand_child1 overlap. grand_child1 is expected to | 
| 1173   // be on top. | 1173   // be on top. | 
| 1174   test_point = gfx::Point(20, 51); | 1174   test_point = gfx::PointF(20.f, 51.f); | 
| 1175   result_layer = | 1175   result_layer = | 
| 1176       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 1176       host_impl().active_tree()->FindLayerThatIsHitByPoint(test_point); | 
| 1177   ASSERT_TRUE(result_layer); | 1177   ASSERT_TRUE(result_layer); | 
| 1178   EXPECT_EQ(4, result_layer->id()); | 1178   EXPECT_EQ(4, result_layer->id()); | 
| 1179 } | 1179 } | 
| 1180 | 1180 | 
| 1181 TEST_F(LayerTreeImplTest, HitCheckingTouchHandlerRegionsForSingleLayer) { | 1181 TEST_F(LayerTreeImplTest, HitCheckingTouchHandlerRegionsForSingleLayer) { | 
| 1182   scoped_ptr<LayerImpl> root = | 1182   scoped_ptr<LayerImpl> root = | 
| 1183       LayerImpl::Create(host_impl().active_tree(), 12345); | 1183       LayerImpl::Create(host_impl().active_tree(), 12345); | 
| 1184 | 1184 | 
| 1185   gfx::Transform identity_matrix; | 1185   gfx::Transform identity_matrix; | 
| 1186   Region touch_handler_region(gfx::Rect(10, 10, 50, 50)); | 1186   Region touch_handler_region(gfx::Rect(10, 10, 50, 50)); | 
| 1187   gfx::Point3F transform_origin; | 1187   gfx::Point3F transform_origin; | 
| 1188   gfx::PointF position; | 1188   gfx::PointF position; | 
| 1189   gfx::Size bounds(100, 100); | 1189   gfx::Size bounds(100, 100); | 
| 1190   SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, | 1190   SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, | 
| 1191                                position, bounds, true, false, true); | 1191                                position, bounds, true, false, true); | 
| 1192   root->SetDrawsContent(true); | 1192   root->SetDrawsContent(true); | 
| 1193 | 1193 | 
| 1194   host_impl().SetViewportSize(root->bounds()); | 1194   host_impl().SetViewportSize(root->bounds()); | 
| 1195   host_impl().active_tree()->SetRootLayer(root.Pass()); | 1195   host_impl().active_tree()->SetRootLayer(root.Pass()); | 
| 1196   host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 1196   host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 
| 1197 | 1197 | 
| 1198   // Sanity check the scenario we just created. | 1198   // Sanity check the scenario we just created. | 
| 1199   ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 1199   ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 
| 1200   ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 1200   ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 
| 1201 | 1201 | 
| 1202   // Hit checking for any point should return a null pointer for a layer without | 1202   // Hit checking for any point should return a null pointer for a layer without | 
| 1203   // any touch event handler regions. | 1203   // any touch event handler regions. | 
| 1204   gfx::Point test_point(11, 11); | 1204   gfx::PointF test_point(11.f, 11.f); | 
| 1205   LayerImpl* result_layer = | 1205   LayerImpl* result_layer = | 
| 1206       host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 1206       host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 
| 1207           test_point); | 1207           test_point); | 
| 1208   EXPECT_FALSE(result_layer); | 1208   EXPECT_FALSE(result_layer); | 
| 1209 | 1209 | 
| 1210   host_impl().active_tree()->root_layer()->SetTouchEventHandlerRegion( | 1210   host_impl().active_tree()->root_layer()->SetTouchEventHandlerRegion( | 
| 1211       touch_handler_region); | 1211       touch_handler_region); | 
| 1212   // Hit checking for a point outside the layer should return a null pointer. | 1212   // Hit checking for a point outside the layer should return a null pointer. | 
| 1213   test_point = gfx::Point(101, 101); | 1213   test_point = gfx::PointF(101.f, 101.f); | 
| 1214   result_layer = | 1214   result_layer = | 
| 1215       host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 1215       host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 
| 1216           test_point); | 1216           test_point); | 
| 1217   EXPECT_FALSE(result_layer); | 1217   EXPECT_FALSE(result_layer); | 
| 1218 | 1218 | 
| 1219   test_point = gfx::Point(-1, -1); | 1219   test_point = gfx::PointF(-1.f, -1.f); | 
| 1220   result_layer = | 1220   result_layer = | 
| 1221       host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 1221       host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 
| 1222           test_point); | 1222           test_point); | 
| 1223   EXPECT_FALSE(result_layer); | 1223   EXPECT_FALSE(result_layer); | 
| 1224 | 1224 | 
| 1225   // Hit checking for a point inside the layer, but outside the touch handler | 1225   // Hit checking for a point inside the layer, but outside the touch handler | 
| 1226   // region should return a null pointer. | 1226   // region should return a null pointer. | 
| 1227   test_point = gfx::Point(1, 1); | 1227   test_point = gfx::PointF(1.f, 1.f); | 
| 1228   result_layer = | 1228   result_layer = | 
| 1229       host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 1229       host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 
| 1230           test_point); | 1230           test_point); | 
| 1231   EXPECT_FALSE(result_layer); | 1231   EXPECT_FALSE(result_layer); | 
| 1232 | 1232 | 
| 1233   test_point = gfx::Point(99, 99); | 1233   test_point = gfx::PointF(99.f, 99.f); | 
| 1234   result_layer = | 1234   result_layer = | 
| 1235       host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 1235       host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 
| 1236           test_point); | 1236           test_point); | 
| 1237   EXPECT_FALSE(result_layer); | 1237   EXPECT_FALSE(result_layer); | 
| 1238 | 1238 | 
| 1239   // Hit checking for a point inside the touch event handler region should | 1239   // Hit checking for a point inside the touch event handler region should | 
| 1240   // return the root layer. | 1240   // return the root layer. | 
| 1241   test_point = gfx::Point(11, 11); | 1241   test_point = gfx::PointF(11.f, 11.f); | 
| 1242   result_layer = | 1242   result_layer = | 
| 1243       host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 1243       host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 
| 1244           test_point); | 1244           test_point); | 
| 1245   ASSERT_TRUE(result_layer); | 1245   ASSERT_TRUE(result_layer); | 
| 1246   EXPECT_EQ(12345, result_layer->id()); | 1246   EXPECT_EQ(12345, result_layer->id()); | 
| 1247 | 1247 | 
| 1248   test_point = gfx::Point(59, 59); | 1248   test_point = gfx::PointF(59.f, 59.f); | 
| 1249   result_layer = | 1249   result_layer = | 
| 1250       host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 1250       host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 
| 1251           test_point); | 1251           test_point); | 
| 1252   ASSERT_TRUE(result_layer); | 1252   ASSERT_TRUE(result_layer); | 
| 1253   EXPECT_EQ(12345, result_layer->id()); | 1253   EXPECT_EQ(12345, result_layer->id()); | 
| 1254 } | 1254 } | 
| 1255 | 1255 | 
| 1256 TEST_F(LayerTreeImplTest, | 1256 TEST_F(LayerTreeImplTest, | 
| 1257        HitCheckingTouchHandlerRegionsForUninvertibleTransform) { | 1257        HitCheckingTouchHandlerRegionsForUninvertibleTransform) { | 
| 1258   scoped_ptr<LayerImpl> root = | 1258   scoped_ptr<LayerImpl> root = | 
| (...skipping 23 matching lines...) Expand all  Loading... | 
| 1282 | 1282 | 
| 1283   // Sanity check the scenario we just created. | 1283   // Sanity check the scenario we just created. | 
| 1284   ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 1284   ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 
| 1285   ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 1285   ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 
| 1286   ASSERT_FALSE(root_layer()->screen_space_transform().IsInvertible()); | 1286   ASSERT_FALSE(root_layer()->screen_space_transform().IsInvertible()); | 
| 1287 | 1287 | 
| 1288   // Hit checking any point should not hit the touch handler region on the | 1288   // Hit checking any point should not hit the touch handler region on the | 
| 1289   // layer. If the invertible matrix is accidentally ignored and treated like an | 1289   // layer. If the invertible matrix is accidentally ignored and treated like an | 
| 1290   // identity, then the hit testing will incorrectly hit the layer when it | 1290   // identity, then the hit testing will incorrectly hit the layer when it | 
| 1291   // shouldn't. | 1291   // shouldn't. | 
| 1292   gfx::Point test_point(1, 1); | 1292   gfx::PointF test_point(1.f, 1.f); | 
| 1293   LayerImpl* result_layer = | 1293   LayerImpl* result_layer = | 
| 1294       host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 1294       host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 
| 1295           test_point); | 1295           test_point); | 
| 1296   EXPECT_FALSE(result_layer); | 1296   EXPECT_FALSE(result_layer); | 
| 1297 | 1297 | 
| 1298   test_point = gfx::Point(10, 10); | 1298   test_point = gfx::PointF(10.f, 10.f); | 
| 1299   result_layer = | 1299   result_layer = | 
| 1300       host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 1300       host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 
| 1301           test_point); | 1301           test_point); | 
| 1302   EXPECT_FALSE(result_layer); | 1302   EXPECT_FALSE(result_layer); | 
| 1303 | 1303 | 
| 1304   test_point = gfx::Point(10, 30); | 1304   test_point = gfx::PointF(10.f, 30.f); | 
| 1305   result_layer = | 1305   result_layer = | 
| 1306       host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 1306       host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 
| 1307           test_point); | 1307           test_point); | 
| 1308   EXPECT_FALSE(result_layer); | 1308   EXPECT_FALSE(result_layer); | 
| 1309 | 1309 | 
| 1310   test_point = gfx::Point(50, 50); | 1310   test_point = gfx::PointF(50.f, 50.f); | 
| 1311   result_layer = | 1311   result_layer = | 
| 1312       host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 1312       host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 
| 1313           test_point); | 1313           test_point); | 
| 1314   EXPECT_FALSE(result_layer); | 1314   EXPECT_FALSE(result_layer); | 
| 1315 | 1315 | 
| 1316   test_point = gfx::Point(67, 48); | 1316   test_point = gfx::PointF(67.f, 48.f); | 
| 1317   result_layer = | 1317   result_layer = | 
| 1318       host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 1318       host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 
| 1319           test_point); | 1319           test_point); | 
| 1320   EXPECT_FALSE(result_layer); | 1320   EXPECT_FALSE(result_layer); | 
| 1321 | 1321 | 
| 1322   test_point = gfx::Point(99, 99); | 1322   test_point = gfx::PointF(99.f, 99.f); | 
| 1323   result_layer = | 1323   result_layer = | 
| 1324       host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 1324       host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 
| 1325           test_point); | 1325           test_point); | 
| 1326   EXPECT_FALSE(result_layer); | 1326   EXPECT_FALSE(result_layer); | 
| 1327 | 1327 | 
| 1328   test_point = gfx::Point(-1, -1); | 1328   test_point = gfx::PointF(-1.f, -1.f); | 
| 1329   result_layer = | 1329   result_layer = | 
| 1330       host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 1330       host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 
| 1331           test_point); | 1331           test_point); | 
| 1332   EXPECT_FALSE(result_layer); | 1332   EXPECT_FALSE(result_layer); | 
| 1333 } | 1333 } | 
| 1334 | 1334 | 
| 1335 TEST_F(LayerTreeImplTest, MakeScrollbarsInvisibleNearMinPageScale) { | 1335 TEST_F(LayerTreeImplTest, MakeScrollbarsInvisibleNearMinPageScale) { | 
| 1336   const int kThumbThickness = 10; | 1336   const int kThumbThickness = 10; | 
| 1337   const int kTrackStart = 0; | 1337   const int kTrackStart = 0; | 
| 1338   const bool kIsLeftSideVerticalScrollbar = false; | 1338   const bool kIsLeftSideVerticalScrollbar = false; | 
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1419 | 1419 | 
| 1420   host_impl().SetViewportSize(root->bounds()); | 1420   host_impl().SetViewportSize(root->bounds()); | 
| 1421   host_impl().active_tree()->SetRootLayer(root.Pass()); | 1421   host_impl().active_tree()->SetRootLayer(root.Pass()); | 
| 1422   host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 1422   host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 
| 1423 | 1423 | 
| 1424   // Sanity check the scenario we just created. | 1424   // Sanity check the scenario we just created. | 
| 1425   ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 1425   ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 
| 1426   ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 1426   ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 
| 1427 | 1427 | 
| 1428   // Hit checking for a point outside the layer should return a null pointer. | 1428   // Hit checking for a point outside the layer should return a null pointer. | 
| 1429   gfx::Point test_point(49, 49); | 1429   gfx::PointF test_point(49.f, 49.f); | 
| 1430   LayerImpl* result_layer = | 1430   LayerImpl* result_layer = | 
| 1431       host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 1431       host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 
| 1432           test_point); | 1432           test_point); | 
| 1433   EXPECT_FALSE(result_layer); | 1433   EXPECT_FALSE(result_layer); | 
| 1434 | 1434 | 
| 1435   // Even though the layer has a touch handler region containing (101, 101), it | 1435   // Even though the layer has a touch handler region containing (101, 101), it | 
| 1436   // should not be visible there since the root render surface would clamp it. | 1436   // should not be visible there since the root render surface would clamp it. | 
| 1437   test_point = gfx::Point(101, 101); | 1437   test_point = gfx::PointF(101.f, 101.f); | 
| 1438   result_layer = | 1438   result_layer = | 
| 1439       host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 1439       host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 
| 1440           test_point); | 1440           test_point); | 
| 1441   EXPECT_FALSE(result_layer); | 1441   EXPECT_FALSE(result_layer); | 
| 1442 | 1442 | 
| 1443   // Hit checking for a point inside the layer, but outside the touch handler | 1443   // Hit checking for a point inside the layer, but outside the touch handler | 
| 1444   // region should return a null pointer. | 1444   // region should return a null pointer. | 
| 1445   test_point = gfx::Point(51, 51); | 1445   test_point = gfx::PointF(51.f, 51.f); | 
| 1446   result_layer = | 1446   result_layer = | 
| 1447       host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 1447       host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 
| 1448           test_point); | 1448           test_point); | 
| 1449   EXPECT_FALSE(result_layer); | 1449   EXPECT_FALSE(result_layer); | 
| 1450 | 1450 | 
| 1451   // Hit checking for a point inside the touch event handler region should | 1451   // Hit checking for a point inside the touch event handler region should | 
| 1452   // return the root layer. | 1452   // return the root layer. | 
| 1453   test_point = gfx::Point(61, 61); | 1453   test_point = gfx::PointF(61.f, 61.f); | 
| 1454   result_layer = | 1454   result_layer = | 
| 1455       host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 1455       host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 
| 1456           test_point); | 1456           test_point); | 
| 1457   ASSERT_TRUE(result_layer); | 1457   ASSERT_TRUE(result_layer); | 
| 1458   EXPECT_EQ(12345, result_layer->id()); | 1458   EXPECT_EQ(12345, result_layer->id()); | 
| 1459 | 1459 | 
| 1460   test_point = gfx::Point(99, 99); | 1460   test_point = gfx::PointF(99.f, 99.f); | 
| 1461   result_layer = | 1461   result_layer = | 
| 1462       host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 1462       host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 
| 1463           test_point); | 1463           test_point); | 
| 1464   ASSERT_TRUE(result_layer); | 1464   ASSERT_TRUE(result_layer); | 
| 1465   EXPECT_EQ(12345, result_layer->id()); | 1465   EXPECT_EQ(12345, result_layer->id()); | 
| 1466 } | 1466 } | 
| 1467 | 1467 | 
| 1468 TEST_F(LayerTreeImplTest, | 1468 TEST_F(LayerTreeImplTest, | 
| 1469        HitCheckingTouchHandlerRegionsForSingleLayerWithDeviceScale) { | 1469        HitCheckingTouchHandlerRegionsForSingleLayerWithDeviceScale) { | 
| 1470   // The layer's device_scale_factor and page_scale_factor should scale the | 1470   // The layer's device_scale_factor and page_scale_factor should scale the | 
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1524   gfx::PointF test_point(76.f, 76.f); | 1524   gfx::PointF test_point(76.f, 76.f); | 
| 1525   test_point = | 1525   test_point = | 
| 1526       gfx::ScalePoint(test_point, device_scale_factor * page_scale_factor); | 1526       gfx::ScalePoint(test_point, device_scale_factor * page_scale_factor); | 
| 1527   LayerImpl* result_layer = | 1527   LayerImpl* result_layer = | 
| 1528       host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 1528       host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 
| 1529           test_point); | 1529           test_point); | 
| 1530   EXPECT_FALSE(result_layer); | 1530   EXPECT_FALSE(result_layer); | 
| 1531 | 1531 | 
| 1532   // Hit checking for a point inside the layer, but outside the touch handler | 1532   // Hit checking for a point inside the layer, but outside the touch handler | 
| 1533   // region should return a null pointer. | 1533   // region should return a null pointer. | 
| 1534   test_point = gfx::Point(26, 26); | 1534   test_point = gfx::PointF(26.f, 26.f); | 
| 1535   test_point = | 1535   test_point = | 
| 1536       gfx::ScalePoint(test_point, device_scale_factor * page_scale_factor); | 1536       gfx::ScalePoint(test_point, device_scale_factor * page_scale_factor); | 
| 1537   result_layer = | 1537   result_layer = | 
| 1538       host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 1538       host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 
| 1539           test_point); | 1539           test_point); | 
| 1540   EXPECT_FALSE(result_layer); | 1540   EXPECT_FALSE(result_layer); | 
| 1541 | 1541 | 
| 1542   test_point = gfx::Point(34, 34); | 1542   test_point = gfx::PointF(34.f, 34.f); | 
| 1543   test_point = | 1543   test_point = | 
| 1544       gfx::ScalePoint(test_point, device_scale_factor * page_scale_factor); | 1544       gfx::ScalePoint(test_point, device_scale_factor * page_scale_factor); | 
| 1545   result_layer = | 1545   result_layer = | 
| 1546       host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 1546       host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 
| 1547           test_point); | 1547           test_point); | 
| 1548   EXPECT_FALSE(result_layer); | 1548   EXPECT_FALSE(result_layer); | 
| 1549 | 1549 | 
| 1550   test_point = gfx::Point(65, 65); | 1550   test_point = gfx::PointF(65.f, 65.f); | 
| 1551   test_point = | 1551   test_point = | 
| 1552       gfx::ScalePoint(test_point, device_scale_factor * page_scale_factor); | 1552       gfx::ScalePoint(test_point, device_scale_factor * page_scale_factor); | 
| 1553   result_layer = | 1553   result_layer = | 
| 1554       host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 1554       host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 
| 1555           test_point); | 1555           test_point); | 
| 1556   EXPECT_FALSE(result_layer); | 1556   EXPECT_FALSE(result_layer); | 
| 1557 | 1557 | 
| 1558   test_point = gfx::Point(74, 74); | 1558   test_point = gfx::PointF(74.f, 74.f); | 
| 1559   test_point = | 1559   test_point = | 
| 1560       gfx::ScalePoint(test_point, device_scale_factor * page_scale_factor); | 1560       gfx::ScalePoint(test_point, device_scale_factor * page_scale_factor); | 
| 1561   result_layer = | 1561   result_layer = | 
| 1562       host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 1562       host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 
| 1563           test_point); | 1563           test_point); | 
| 1564   EXPECT_FALSE(result_layer); | 1564   EXPECT_FALSE(result_layer); | 
| 1565 | 1565 | 
| 1566   // Hit checking for a point inside the touch event handler region should | 1566   // Hit checking for a point inside the touch event handler region should | 
| 1567   // return the root layer. | 1567   // return the root layer. | 
| 1568   test_point = gfx::Point(35, 35); | 1568   test_point = gfx::PointF(35.f, 35.f); | 
| 1569   test_point = | 1569   test_point = | 
| 1570       gfx::ScalePoint(test_point, device_scale_factor * page_scale_factor); | 1570       gfx::ScalePoint(test_point, device_scale_factor * page_scale_factor); | 
| 1571   result_layer = | 1571   result_layer = | 
| 1572       host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 1572       host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 
| 1573           test_point); | 1573           test_point); | 
| 1574   ASSERT_TRUE(result_layer); | 1574   ASSERT_TRUE(result_layer); | 
| 1575   EXPECT_EQ(12345, result_layer->id()); | 1575   EXPECT_EQ(12345, result_layer->id()); | 
| 1576 | 1576 | 
| 1577   test_point = gfx::Point(64, 64); | 1577   test_point = gfx::PointF(64.f, 64.f); | 
| 1578   test_point = | 1578   test_point = | 
| 1579       gfx::ScalePoint(test_point, device_scale_factor * page_scale_factor); | 1579       gfx::ScalePoint(test_point, device_scale_factor * page_scale_factor); | 
| 1580   result_layer = | 1580   result_layer = | 
| 1581       host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 1581       host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 
| 1582           test_point); | 1582           test_point); | 
| 1583   ASSERT_TRUE(result_layer); | 1583   ASSERT_TRUE(result_layer); | 
| 1584   EXPECT_EQ(12345, result_layer->id()); | 1584   EXPECT_EQ(12345, result_layer->id()); | 
| 1585 } | 1585 } | 
| 1586 | 1586 | 
| 1587 TEST_F(LayerTreeImplTest, HitCheckingTouchHandlerRegionsForSimpleClippedLayer) { | 1587 TEST_F(LayerTreeImplTest, HitCheckingTouchHandlerRegionsForSimpleClippedLayer) { | 
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1625   host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 1625   host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 
| 1626 | 1626 | 
| 1627   // Sanity check the scenario we just created. | 1627   // Sanity check the scenario we just created. | 
| 1628   ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 1628   ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 
| 1629   ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 1629   ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 
| 1630   ASSERT_EQ(456, root_layer()->render_surface()->layer_list().at(0)->id()); | 1630   ASSERT_EQ(456, root_layer()->render_surface()->layer_list().at(0)->id()); | 
| 1631 | 1631 | 
| 1632   // Hit checking for a point outside the layer should return a null pointer. | 1632   // Hit checking for a point outside the layer should return a null pointer. | 
| 1633   // Despite the child layer being very large, it should be clipped to the root | 1633   // Despite the child layer being very large, it should be clipped to the root | 
| 1634   // layer's bounds. | 1634   // layer's bounds. | 
| 1635   gfx::Point test_point(24, 24); | 1635   gfx::PointF test_point(24.f, 24.f); | 
| 1636   LayerImpl* result_layer = | 1636   LayerImpl* result_layer = | 
| 1637       host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 1637       host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 
| 1638           test_point); | 1638           test_point); | 
| 1639   EXPECT_FALSE(result_layer); | 1639   EXPECT_FALSE(result_layer); | 
| 1640 | 1640 | 
| 1641   // Hit checking for a point inside the layer, but outside the touch handler | 1641   // Hit checking for a point inside the layer, but outside the touch handler | 
| 1642   // region should return a null pointer. | 1642   // region should return a null pointer. | 
| 1643   test_point = gfx::Point(35, 35); | 1643   test_point = gfx::PointF(35.f, 35.f); | 
| 1644   result_layer = | 1644   result_layer = | 
| 1645       host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 1645       host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 
| 1646           test_point); | 1646           test_point); | 
| 1647   EXPECT_FALSE(result_layer); | 1647   EXPECT_FALSE(result_layer); | 
| 1648 | 1648 | 
| 1649   test_point = gfx::Point(74, 74); | 1649   test_point = gfx::PointF(74.f, 74.f); | 
| 1650   result_layer = | 1650   result_layer = | 
| 1651       host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 1651       host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 
| 1652           test_point); | 1652           test_point); | 
| 1653   EXPECT_FALSE(result_layer); | 1653   EXPECT_FALSE(result_layer); | 
| 1654 | 1654 | 
| 1655   // Hit checking for a point inside the touch event handler region should | 1655   // Hit checking for a point inside the touch event handler region should | 
| 1656   // return the root layer. | 1656   // return the root layer. | 
| 1657   test_point = gfx::Point(25, 25); | 1657   test_point = gfx::PointF(25.f, 25.f); | 
| 1658   result_layer = | 1658   result_layer = | 
| 1659       host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 1659       host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 
| 1660           test_point); | 1660           test_point); | 
| 1661   ASSERT_TRUE(result_layer); | 1661   ASSERT_TRUE(result_layer); | 
| 1662   EXPECT_EQ(456, result_layer->id()); | 1662   EXPECT_EQ(456, result_layer->id()); | 
| 1663 | 1663 | 
| 1664   test_point = gfx::Point(34, 34); | 1664   test_point = gfx::PointF(34.f, 34.f); | 
| 1665   result_layer = | 1665   result_layer = | 
| 1666       host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 1666       host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 
| 1667           test_point); | 1667           test_point); | 
| 1668   ASSERT_TRUE(result_layer); | 1668   ASSERT_TRUE(result_layer); | 
| 1669   EXPECT_EQ(456, result_layer->id()); | 1669   EXPECT_EQ(456, result_layer->id()); | 
| 1670 } | 1670 } | 
| 1671 | 1671 | 
| 1672 TEST_F(LayerTreeImplTest, HitCheckingTouchHandlerOverlappingRegions) { | 1672 TEST_F(LayerTreeImplTest, HitCheckingTouchHandlerOverlappingRegions) { | 
| 1673   gfx::Transform identity_matrix; | 1673   gfx::Transform identity_matrix; | 
| 1674   gfx::Point3F transform_origin; | 1674   gfx::Point3F transform_origin; | 
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1709   host_impl().SetViewportSize(root->bounds()); | 1709   host_impl().SetViewportSize(root->bounds()); | 
| 1710   host_impl().active_tree()->SetRootLayer(root.Pass()); | 1710   host_impl().active_tree()->SetRootLayer(root.Pass()); | 
| 1711   host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 1711   host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 
| 1712 | 1712 | 
| 1713   // Sanity check the scenario we just created. | 1713   // Sanity check the scenario we just created. | 
| 1714   ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 1714   ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 
| 1715   ASSERT_EQ(2u, root_layer()->render_surface()->layer_list().size()); | 1715   ASSERT_EQ(2u, root_layer()->render_surface()->layer_list().size()); | 
| 1716   ASSERT_EQ(123, root_layer()->render_surface()->layer_list().at(0)->id()); | 1716   ASSERT_EQ(123, root_layer()->render_surface()->layer_list().at(0)->id()); | 
| 1717   ASSERT_EQ(1234, root_layer()->render_surface()->layer_list().at(1)->id()); | 1717   ASSERT_EQ(1234, root_layer()->render_surface()->layer_list().at(1)->id()); | 
| 1718 | 1718 | 
| 1719   gfx::Point test_point(35, 35); | 1719   gfx::PointF test_point(35.f, 35.f); | 
| 1720   LayerImpl* result_layer = | 1720   LayerImpl* result_layer = | 
| 1721       host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 1721       host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 
| 1722           test_point); | 1722           test_point); | 
| 1723 | 1723 | 
| 1724   // We should have passed through the no-touch layer and found the layer | 1724   // We should have passed through the no-touch layer and found the layer | 
| 1725   // behind it. | 1725   // behind it. | 
| 1726   EXPECT_TRUE(result_layer); | 1726   EXPECT_TRUE(result_layer); | 
| 1727 | 1727 | 
| 1728   host_impl().active_tree()->LayerById(1234)->SetContentsOpaque(true); | 1728   host_impl().active_tree()->LayerById(1234)->SetContentsOpaque(true); | 
| 1729   result_layer = | 1729   result_layer = | 
| 1730       host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 1730       host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 
| 1731           test_point); | 1731           test_point); | 
| 1732 | 1732 | 
| 1733   // Even with an opaque layer in the middle, we should still find the layer | 1733   // Even with an opaque layer in the middle, we should still find the layer | 
| 1734   // with | 1734   // with | 
| 1735   // the touch handler behind it (since we can't assume that opaque layers are | 1735   // the touch handler behind it (since we can't assume that opaque layers are | 
| 1736   // opaque to hit testing). | 1736   // opaque to hit testing). | 
| 1737   EXPECT_TRUE(result_layer); | 1737   EXPECT_TRUE(result_layer); | 
| 1738 | 1738 | 
| 1739   test_point = gfx::Point(35, 15); | 1739   test_point = gfx::PointF(35.f, 15.f); | 
| 1740   result_layer = | 1740   result_layer = | 
| 1741       host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 1741       host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 
| 1742           test_point); | 1742           test_point); | 
| 1743   ASSERT_TRUE(result_layer); | 1743   ASSERT_TRUE(result_layer); | 
| 1744   EXPECT_EQ(123, result_layer->id()); | 1744   EXPECT_EQ(123, result_layer->id()); | 
| 1745 | 1745 | 
| 1746   test_point = gfx::Point(35, 65); | 1746   test_point = gfx::PointF(35.f, 65.f); | 
| 1747   result_layer = | 1747   result_layer = | 
| 1748       host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 1748       host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( | 
| 1749           test_point); | 1749           test_point); | 
| 1750   EXPECT_FALSE(result_layer); | 1750   EXPECT_FALSE(result_layer); | 
| 1751 } | 1751 } | 
| 1752 | 1752 | 
| 1753 TEST_F(LayerTreeImplTest, SelectionBoundsForSingleLayer) { | 1753 TEST_F(LayerTreeImplTest, SelectionBoundsForSingleLayer) { | 
| 1754   int root_layer_id = 12345; | 1754   int root_layer_id = 12345; | 
| 1755   scoped_ptr<LayerImpl> root = | 1755   scoped_ptr<LayerImpl> root = | 
| 1756       LayerImpl::Create(host_impl().active_tree(), root_layer_id); | 1756       LayerImpl::Create(host_impl().active_tree(), root_layer_id); | 
| (...skipping 10 matching lines...) Expand all  Loading... | 
| 1767   host_impl().active_tree()->SetRootLayer(root.Pass()); | 1767   host_impl().active_tree()->SetRootLayer(root.Pass()); | 
| 1768   host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 1768   host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 
| 1769 | 1769 | 
| 1770   // Sanity check the scenario we just created. | 1770   // Sanity check the scenario we just created. | 
| 1771   ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 1771   ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 
| 1772   ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 1772   ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); | 
| 1773 | 1773 | 
| 1774   LayerSelection input; | 1774   LayerSelection input; | 
| 1775 | 1775 | 
| 1776   input.start.type = SELECTION_BOUND_LEFT; | 1776   input.start.type = SELECTION_BOUND_LEFT; | 
| 1777   input.start.edge_top = gfx::PointF(10, 10); | 1777   input.start.edge_top = gfx::Point(10, 10); | 
| 1778   input.start.edge_bottom = gfx::PointF(10, 20); | 1778   input.start.edge_bottom = gfx::Point(10, 20); | 
| 1779   input.start.layer_id = root_layer_id; | 1779   input.start.layer_id = root_layer_id; | 
| 1780 | 1780 | 
| 1781   input.end.type = SELECTION_BOUND_RIGHT; | 1781   input.end.type = SELECTION_BOUND_RIGHT; | 
| 1782   input.end.edge_top = gfx::PointF(50, 10); | 1782   input.end.edge_top = gfx::Point(50, 10); | 
| 1783   input.end.edge_bottom = gfx::PointF(50, 30); | 1783   input.end.edge_bottom = gfx::Point(50, 30); | 
| 1784   input.end.layer_id = root_layer_id; | 1784   input.end.layer_id = root_layer_id; | 
| 1785 | 1785 | 
| 1786   ViewportSelection output; | 1786   ViewportSelection output; | 
| 1787 | 1787 | 
| 1788   // Empty input bounds should produce empty output bounds. | 1788   // Empty input bounds should produce empty output bounds. | 
| 1789   host_impl().active_tree()->GetViewportSelection(&output); | 1789   host_impl().active_tree()->GetViewportSelection(&output); | 
| 1790   EXPECT_EQ(ViewportSelectionBound(), output.start); | 1790   EXPECT_EQ(ViewportSelectionBound(), output.start); | 
| 1791   EXPECT_EQ(ViewportSelectionBound(), output.end); | 1791   EXPECT_EQ(ViewportSelectionBound(), output.end); | 
| 1792 | 1792 | 
| 1793   // Selection bounds should produce distinct left and right bounds. | 1793   // Selection bounds should produce distinct left and right bounds. | 
| 1794   host_impl().active_tree()->RegisterSelection(input); | 1794   host_impl().active_tree()->RegisterSelection(input); | 
| 1795   host_impl().active_tree()->GetViewportSelection(&output); | 1795   host_impl().active_tree()->GetViewportSelection(&output); | 
| 1796   EXPECT_EQ(input.start.type, output.start.type); | 1796   EXPECT_EQ(input.start.type, output.start.type); | 
| 1797   EXPECT_EQ(input.start.edge_bottom, output.start.edge_bottom); | 1797   EXPECT_EQ(gfx::PointF(input.start.edge_bottom), output.start.edge_bottom); | 
| 1798   EXPECT_EQ(input.start.edge_top, output.start.edge_top); | 1798   EXPECT_EQ(gfx::PointF(input.start.edge_top), output.start.edge_top); | 
| 1799   EXPECT_TRUE(output.start.visible); | 1799   EXPECT_TRUE(output.start.visible); | 
| 1800   EXPECT_EQ(input.end.type, output.end.type); | 1800   EXPECT_EQ(input.end.type, output.end.type); | 
| 1801   EXPECT_EQ(input.end.edge_bottom, output.end.edge_bottom); | 1801   EXPECT_EQ(gfx::PointF(input.end.edge_bottom), output.end.edge_bottom); | 
| 1802   EXPECT_EQ(input.end.edge_top, output.end.edge_top); | 1802   EXPECT_EQ(gfx::PointF(input.end.edge_top), output.end.edge_top); | 
| 1803   EXPECT_TRUE(output.end.visible); | 1803   EXPECT_TRUE(output.end.visible); | 
| 1804   EXPECT_EQ(input.is_editable, output.is_editable); | 1804   EXPECT_EQ(input.is_editable, output.is_editable); | 
| 1805   EXPECT_EQ(input.is_empty_text_form_control, | 1805   EXPECT_EQ(input.is_empty_text_form_control, | 
| 1806             output.is_empty_text_form_control); | 1806             output.is_empty_text_form_control); | 
| 1807 | 1807 | 
| 1808   // Insertion bounds should produce identical left and right bounds. | 1808   // Insertion bounds should produce identical left and right bounds. | 
| 1809   LayerSelection insertion_input; | 1809   LayerSelection insertion_input; | 
| 1810   insertion_input.start.type = SELECTION_BOUND_CENTER; | 1810   insertion_input.start.type = SELECTION_BOUND_CENTER; | 
| 1811   insertion_input.start.edge_top = gfx::PointF(15, 10); | 1811   insertion_input.start.edge_top = gfx::Point(15, 10); | 
| 1812   insertion_input.start.edge_bottom = gfx::PointF(15, 30); | 1812   insertion_input.start.edge_bottom = gfx::Point(15, 30); | 
| 1813   insertion_input.start.layer_id = root_layer_id; | 1813   insertion_input.start.layer_id = root_layer_id; | 
| 1814   insertion_input.is_editable = true; | 1814   insertion_input.is_editable = true; | 
| 1815   insertion_input.is_empty_text_form_control = true; | 1815   insertion_input.is_empty_text_form_control = true; | 
| 1816   insertion_input.end = insertion_input.start; | 1816   insertion_input.end = insertion_input.start; | 
| 1817   host_impl().active_tree()->RegisterSelection(insertion_input); | 1817   host_impl().active_tree()->RegisterSelection(insertion_input); | 
| 1818   host_impl().active_tree()->GetViewportSelection(&output); | 1818   host_impl().active_tree()->GetViewportSelection(&output); | 
| 1819   EXPECT_EQ(insertion_input.start.type, output.start.type); | 1819   EXPECT_EQ(insertion_input.start.type, output.start.type); | 
| 1820   EXPECT_EQ(insertion_input.start.edge_bottom, output.start.edge_bottom); | 1820   EXPECT_EQ(gfx::PointF(insertion_input.start.edge_bottom), | 
| 1821   EXPECT_EQ(insertion_input.start.edge_top, output.start.edge_top); | 1821             output.start.edge_bottom); | 
|  | 1822   EXPECT_EQ(gfx::PointF(insertion_input.start.edge_top), output.start.edge_top); | 
| 1822   EXPECT_EQ(insertion_input.is_editable, output.is_editable); | 1823   EXPECT_EQ(insertion_input.is_editable, output.is_editable); | 
| 1823   EXPECT_EQ(insertion_input.is_empty_text_form_control, | 1824   EXPECT_EQ(insertion_input.is_empty_text_form_control, | 
| 1824             output.is_empty_text_form_control); | 1825             output.is_empty_text_form_control); | 
| 1825   EXPECT_TRUE(output.start.visible); | 1826   EXPECT_TRUE(output.start.visible); | 
| 1826   EXPECT_EQ(output.start, output.end); | 1827   EXPECT_EQ(output.start, output.end); | 
| 1827 } | 1828 } | 
| 1828 | 1829 | 
| 1829 TEST_F(LayerTreeImplTest, SelectionBoundsForPartialOccludedLayers) { | 1830 TEST_F(LayerTreeImplTest, SelectionBoundsForPartialOccludedLayers) { | 
| 1830   int root_layer_id = 12345; | 1831   int root_layer_id = 12345; | 
| 1831   int clip_layer_id = 1234; | 1832   int clip_layer_id = 1234; | 
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1867 | 1868 | 
| 1868   host_impl().SetViewportSize(root->bounds()); | 1869   host_impl().SetViewportSize(root->bounds()); | 
| 1869   host_impl().active_tree()->SetRootLayer(root.Pass()); | 1870   host_impl().active_tree()->SetRootLayer(root.Pass()); | 
| 1870   host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 1871   host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 
| 1871 | 1872 | 
| 1872   // Sanity check the scenario we just created. | 1873   // Sanity check the scenario we just created. | 
| 1873   ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 1874   ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 
| 1874 | 1875 | 
| 1875   LayerSelection input; | 1876   LayerSelection input; | 
| 1876   input.start.type = SELECTION_BOUND_LEFT; | 1877   input.start.type = SELECTION_BOUND_LEFT; | 
| 1877   input.start.edge_top = gfx::PointF(25, 10); | 1878   input.start.edge_top = gfx::Point(25, 10); | 
| 1878   input.start.edge_bottom = gfx::PointF(25, 30); | 1879   input.start.edge_bottom = gfx::Point(25, 30); | 
| 1879   input.start.layer_id = clipped_layer_id; | 1880   input.start.layer_id = clipped_layer_id; | 
| 1880 | 1881 | 
| 1881   input.end.type = SELECTION_BOUND_RIGHT; | 1882   input.end.type = SELECTION_BOUND_RIGHT; | 
| 1882   input.end.edge_top = gfx::PointF(75, 10); | 1883   input.end.edge_top = gfx::Point(75, 10); | 
| 1883   input.end.edge_bottom = gfx::PointF(75, 30); | 1884   input.end.edge_bottom = gfx::Point(75, 30); | 
| 1884   input.end.layer_id = clipped_layer_id; | 1885   input.end.layer_id = clipped_layer_id; | 
| 1885   host_impl().active_tree()->RegisterSelection(input); | 1886   host_impl().active_tree()->RegisterSelection(input); | 
| 1886 | 1887 | 
| 1887   // The left bound should be occluded by the clip layer. | 1888   // The left bound should be occluded by the clip layer. | 
| 1888   ViewportSelection output; | 1889   ViewportSelection output; | 
| 1889   host_impl().active_tree()->GetViewportSelection(&output); | 1890   host_impl().active_tree()->GetViewportSelection(&output); | 
| 1890   EXPECT_EQ(input.start.type, output.start.type); | 1891   EXPECT_EQ(input.start.type, output.start.type); | 
| 1891   gfx::PointF expected_output_start_top = input.start.edge_top; | 1892   auto expected_output_start_top = gfx::PointF(input.start.edge_top); | 
| 1892   gfx::PointF expected_output_edge_botom = input.start.edge_bottom; | 1893   auto expected_output_edge_botom = gfx::PointF(input.start.edge_bottom); | 
| 1893   expected_output_start_top.Offset(clipping_offset.x(), clipping_offset.y()); | 1894   expected_output_start_top.Offset(clipping_offset.x(), clipping_offset.y()); | 
| 1894   expected_output_edge_botom.Offset(clipping_offset.x(), clipping_offset.y()); | 1895   expected_output_edge_botom.Offset(clipping_offset.x(), clipping_offset.y()); | 
| 1895   EXPECT_EQ(expected_output_start_top, output.start.edge_top); | 1896   EXPECT_EQ(expected_output_start_top, output.start.edge_top); | 
| 1896   EXPECT_EQ(expected_output_edge_botom, output.start.edge_bottom); | 1897   EXPECT_EQ(expected_output_edge_botom, output.start.edge_bottom); | 
| 1897   EXPECT_TRUE(output.start.visible); | 1898   EXPECT_TRUE(output.start.visible); | 
| 1898   EXPECT_EQ(input.end.type, output.end.type); | 1899   EXPECT_EQ(input.end.type, output.end.type); | 
| 1899   gfx::PointF expected_output_end_top = input.end.edge_top; | 1900   auto expected_output_end_top = gfx::PointF(input.end.edge_top); | 
| 1900   gfx::PointF expected_output_end_bottom = input.end.edge_bottom; | 1901   auto expected_output_end_bottom = gfx::PointF(input.end.edge_bottom); | 
| 1901   expected_output_end_bottom.Offset(clipping_offset.x(), clipping_offset.y()); | 1902   expected_output_end_bottom.Offset(clipping_offset.x(), clipping_offset.y()); | 
| 1902   expected_output_end_top.Offset(clipping_offset.x(), clipping_offset.y()); | 1903   expected_output_end_top.Offset(clipping_offset.x(), clipping_offset.y()); | 
| 1903   EXPECT_EQ(expected_output_end_top, output.end.edge_top); | 1904   EXPECT_EQ(expected_output_end_top, output.end.edge_top); | 
| 1904   EXPECT_EQ(expected_output_end_bottom, output.end.edge_bottom); | 1905   EXPECT_EQ(expected_output_end_bottom, output.end.edge_bottom); | 
| 1905   EXPECT_FALSE(output.end.visible); | 1906   EXPECT_FALSE(output.end.visible); | 
| 1906 | 1907 | 
| 1907   // Handles outside the viewport bounds should be marked invisible. | 1908   // Handles outside the viewport bounds should be marked invisible. | 
| 1908   input.start.edge_top = gfx::PointF(-25, 0); | 1909   input.start.edge_top = gfx::Point(-25, 0); | 
| 1909   input.start.edge_bottom = gfx::PointF(-25, 20); | 1910   input.start.edge_bottom = gfx::Point(-25, 20); | 
| 1910   host_impl().active_tree()->RegisterSelection(input); | 1911   host_impl().active_tree()->RegisterSelection(input); | 
| 1911   host_impl().active_tree()->GetViewportSelection(&output); | 1912   host_impl().active_tree()->GetViewportSelection(&output); | 
| 1912   EXPECT_FALSE(output.start.visible); | 1913   EXPECT_FALSE(output.start.visible); | 
| 1913 | 1914 | 
| 1914   input.start.edge_top = gfx::PointF(0, -25); | 1915   input.start.edge_top = gfx::Point(0, -25); | 
| 1915   input.start.edge_bottom = gfx::PointF(0, -5); | 1916   input.start.edge_bottom = gfx::Point(0, -5); | 
| 1916   host_impl().active_tree()->RegisterSelection(input); | 1917   host_impl().active_tree()->RegisterSelection(input); | 
| 1917   host_impl().active_tree()->GetViewportSelection(&output); | 1918   host_impl().active_tree()->GetViewportSelection(&output); | 
| 1918   EXPECT_FALSE(output.start.visible); | 1919   EXPECT_FALSE(output.start.visible); | 
| 1919 | 1920 | 
| 1920   // If the handle bottom is partially visible, the handle is marked visible. | 1921   // If the handle bottom is partially visible, the handle is marked visible. | 
| 1921   input.start.edge_top = gfx::PointF(0, -20); | 1922   input.start.edge_top = gfx::Point(0, -20); | 
| 1922   input.start.edge_bottom = gfx::PointF(0, 1); | 1923   input.start.edge_bottom = gfx::Point(0, 1); | 
| 1923   host_impl().active_tree()->RegisterSelection(input); | 1924   host_impl().active_tree()->RegisterSelection(input); | 
| 1924   host_impl().active_tree()->GetViewportSelection(&output); | 1925   host_impl().active_tree()->GetViewportSelection(&output); | 
| 1925   EXPECT_TRUE(output.start.visible); | 1926   EXPECT_TRUE(output.start.visible); | 
| 1926 } | 1927 } | 
| 1927 | 1928 | 
| 1928 TEST_F(LayerTreeImplTest, SelectionBoundsForScaledLayers) { | 1929 TEST_F(LayerTreeImplTest, SelectionBoundsForScaledLayers) { | 
| 1929   int root_layer_id = 1; | 1930   int root_layer_id = 1; | 
| 1930   int sub_layer_id = 2; | 1931   int sub_layer_id = 2; | 
| 1931   scoped_ptr<LayerImpl> root = | 1932   scoped_ptr<LayerImpl> root = | 
| 1932       LayerImpl::Create(host_impl().active_tree(), root_layer_id); | 1933       LayerImpl::Create(host_impl().active_tree(), root_layer_id); | 
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1965   host_impl().active_tree()->SetRootLayer(root.Pass()); | 1966   host_impl().active_tree()->SetRootLayer(root.Pass()); | 
| 1966   host_impl().active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 1, | 1967   host_impl().active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 1, | 
| 1967                                                       Layer::INVALID_ID); | 1968                                                       Layer::INVALID_ID); | 
| 1968   host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 1969   host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 
| 1969 | 1970 | 
| 1970   // Sanity check the scenario we just created. | 1971   // Sanity check the scenario we just created. | 
| 1971   ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 1972   ASSERT_EQ(1u, RenderSurfaceLayerList().size()); | 
| 1972 | 1973 | 
| 1973   LayerSelection input; | 1974   LayerSelection input; | 
| 1974   input.start.type = SELECTION_BOUND_LEFT; | 1975   input.start.type = SELECTION_BOUND_LEFT; | 
| 1975   input.start.edge_top = gfx::PointF(10, 10); | 1976   input.start.edge_top = gfx::Point(10, 10); | 
| 1976   input.start.edge_bottom = gfx::PointF(10, 30); | 1977   input.start.edge_bottom = gfx::Point(10, 30); | 
| 1977   input.start.layer_id = root_layer_id; | 1978   input.start.layer_id = root_layer_id; | 
| 1978 | 1979 | 
| 1979   input.end.type = SELECTION_BOUND_RIGHT; | 1980   input.end.type = SELECTION_BOUND_RIGHT; | 
| 1980   input.end.edge_top = gfx::PointF(0, 0); | 1981   input.end.edge_top = gfx::Point(0, 0); | 
| 1981   input.end.edge_bottom = gfx::PointF(0, 20); | 1982   input.end.edge_bottom = gfx::Point(0, 20); | 
| 1982   input.end.layer_id = sub_layer_id; | 1983   input.end.layer_id = sub_layer_id; | 
| 1983   host_impl().active_tree()->RegisterSelection(input); | 1984   host_impl().active_tree()->RegisterSelection(input); | 
| 1984 | 1985 | 
| 1985   // The viewport bounds should be properly scaled by the page scale, but should | 1986   // The viewport bounds should be properly scaled by the page scale, but should | 
| 1986   // remain in DIP coordinates. | 1987   // remain in DIP coordinates. | 
| 1987   ViewportSelection output; | 1988   ViewportSelection output; | 
| 1988   host_impl().active_tree()->GetViewportSelection(&output); | 1989   host_impl().active_tree()->GetViewportSelection(&output); | 
| 1989   EXPECT_EQ(input.start.type, output.start.type); | 1990   EXPECT_EQ(input.start.type, output.start.type); | 
| 1990   gfx::PointF expected_output_start_top = input.start.edge_top; | 1991   auto expected_output_start_top = gfx::PointF(input.start.edge_top); | 
| 1991   gfx::PointF expected_output_edge_bottom = input.start.edge_bottom; | 1992   auto expected_output_edge_bottom = gfx::PointF(input.start.edge_bottom); | 
| 1992   expected_output_start_top.Scale(page_scale_factor); | 1993   expected_output_start_top.Scale(page_scale_factor); | 
| 1993   expected_output_edge_bottom.Scale(page_scale_factor); | 1994   expected_output_edge_bottom.Scale(page_scale_factor); | 
| 1994   EXPECT_EQ(expected_output_start_top, output.start.edge_top); | 1995   EXPECT_EQ(expected_output_start_top, output.start.edge_top); | 
| 1995   EXPECT_EQ(expected_output_edge_bottom, output.start.edge_bottom); | 1996   EXPECT_EQ(expected_output_edge_bottom, output.start.edge_bottom); | 
| 1996   EXPECT_TRUE(output.start.visible); | 1997   EXPECT_TRUE(output.start.visible); | 
| 1997   EXPECT_EQ(input.end.type, output.end.type); | 1998   EXPECT_EQ(input.end.type, output.end.type); | 
| 1998 | 1999 | 
| 1999   gfx::PointF expected_output_end_top = input.end.edge_top; | 2000   auto expected_output_end_top = gfx::PointF(input.end.edge_top); | 
| 2000   gfx::PointF expected_output_end_bottom = input.end.edge_bottom; | 2001   auto expected_output_end_bottom = gfx::PointF(input.end.edge_bottom); | 
| 2001   expected_output_end_top.Offset(sub_layer_offset.x(), sub_layer_offset.y()); | 2002   expected_output_end_top.Offset(sub_layer_offset.x(), sub_layer_offset.y()); | 
| 2002   expected_output_end_bottom.Offset(sub_layer_offset.x(), sub_layer_offset.y()); | 2003   expected_output_end_bottom.Offset(sub_layer_offset.x(), sub_layer_offset.y()); | 
| 2003   expected_output_end_top.Scale(page_scale_factor); | 2004   expected_output_end_top.Scale(page_scale_factor); | 
| 2004   expected_output_end_bottom.Scale(page_scale_factor); | 2005   expected_output_end_bottom.Scale(page_scale_factor); | 
| 2005   EXPECT_EQ(expected_output_end_top, output.end.edge_top); | 2006   EXPECT_EQ(expected_output_end_top, output.end.edge_top); | 
| 2006   EXPECT_EQ(expected_output_end_bottom, output.end.edge_bottom); | 2007   EXPECT_EQ(expected_output_end_bottom, output.end.edge_bottom); | 
| 2007   EXPECT_TRUE(output.end.visible); | 2008   EXPECT_TRUE(output.end.visible); | 
| 2008 } | 2009 } | 
| 2009 | 2010 | 
| 2010 TEST_F(LayerTreeImplTest, SelectionBoundsWithLargeTransforms) { | 2011 TEST_F(LayerTreeImplTest, SelectionBoundsWithLargeTransforms) { | 
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2043     root->AddChild(child.Pass()); | 2044     root->AddChild(child.Pass()); | 
| 2044   } | 2045   } | 
| 2045 | 2046 | 
| 2046   host_impl().SetViewportSize(root->bounds()); | 2047   host_impl().SetViewportSize(root->bounds()); | 
| 2047   host_impl().active_tree()->SetRootLayer(root.Pass()); | 2048   host_impl().active_tree()->SetRootLayer(root.Pass()); | 
| 2048   host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 2049   host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 
| 2049 | 2050 | 
| 2050   LayerSelection input; | 2051   LayerSelection input; | 
| 2051 | 2052 | 
| 2052   input.start.type = SELECTION_BOUND_LEFT; | 2053   input.start.type = SELECTION_BOUND_LEFT; | 
| 2053   input.start.edge_top = gfx::PointF(10, 10); | 2054   input.start.edge_top = gfx::Point(10, 10); | 
| 2054   input.start.edge_bottom = gfx::PointF(10, 20); | 2055   input.start.edge_bottom = gfx::Point(10, 20); | 
| 2055   input.start.layer_id = grand_child_id; | 2056   input.start.layer_id = grand_child_id; | 
| 2056 | 2057 | 
| 2057   input.end.type = SELECTION_BOUND_RIGHT; | 2058   input.end.type = SELECTION_BOUND_RIGHT; | 
| 2058   input.end.edge_top = gfx::PointF(50, 10); | 2059   input.end.edge_top = gfx::Point(50, 10); | 
| 2059   input.end.edge_bottom = gfx::PointF(50, 30); | 2060   input.end.edge_bottom = gfx::Point(50, 30); | 
| 2060   input.end.layer_id = grand_child_id; | 2061   input.end.layer_id = grand_child_id; | 
| 2061 | 2062 | 
| 2062   host_impl().active_tree()->RegisterSelection(input); | 2063   host_impl().active_tree()->RegisterSelection(input); | 
| 2063 | 2064 | 
| 2064   ViewportSelection output; | 2065   ViewportSelection output; | 
| 2065   host_impl().active_tree()->GetViewportSelection(&output); | 2066   host_impl().active_tree()->GetViewportSelection(&output); | 
| 2066 | 2067 | 
| 2067   // edge_bottom and edge_top aren't allowed to have NaNs, so the selection | 2068   // edge_bottom and edge_top aren't allowed to have NaNs, so the selection | 
| 2068   // should be empty. | 2069   // should be empty. | 
| 2069   EXPECT_EQ(ViewportSelectionBound(), output.start); | 2070   EXPECT_EQ(ViewportSelectionBound(), output.start); | 
| (...skipping 10 matching lines...) Expand all  Loading... | 
| 2080   EXPECT_EQ(0u, host_impl().active_tree()->NumLayers()); | 2081   EXPECT_EQ(0u, host_impl().active_tree()->NumLayers()); | 
| 2081   scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); | 2082   scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); | 
| 2082   root->AddChild(LayerImpl::Create(host_impl().active_tree(), 2)); | 2083   root->AddChild(LayerImpl::Create(host_impl().active_tree(), 2)); | 
| 2083   root->AddChild(LayerImpl::Create(host_impl().active_tree(), 3)); | 2084   root->AddChild(LayerImpl::Create(host_impl().active_tree(), 3)); | 
| 2084   root->child_at(1)->AddChild(LayerImpl::Create(host_impl().active_tree(), 4)); | 2085   root->child_at(1)->AddChild(LayerImpl::Create(host_impl().active_tree(), 4)); | 
| 2085   EXPECT_EQ(4u, host_impl().active_tree()->NumLayers()); | 2086   EXPECT_EQ(4u, host_impl().active_tree()->NumLayers()); | 
| 2086 } | 2087 } | 
| 2087 | 2088 | 
| 2088 }  // namespace | 2089 }  // namespace | 
| 2089 }  // namespace cc | 2090 }  // namespace cc | 
| OLD | NEW | 
|---|