| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/layers/layer_position_constraint.h" | 5 #include "cc/layers/layer_position_constraint.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "cc/layers/layer.h" | 9 #include "cc/layers/layer.h" |
| 10 #include "cc/layers/layer_impl.h" | 10 #include "cc/layers/layer_impl.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 bool flatten_transform) { | 43 bool flatten_transform) { |
| 44 layer->SetTransform(transform); | 44 layer->SetTransform(transform); |
| 45 layer->SetTransformOrigin(transform_origin); | 45 layer->SetTransformOrigin(transform_origin); |
| 46 layer->SetPosition(position); | 46 layer->SetPosition(position); |
| 47 layer->SetBounds(bounds); | 47 layer->SetBounds(bounds); |
| 48 layer->SetShouldFlattenTransform(flatten_transform); | 48 layer->SetShouldFlattenTransform(flatten_transform); |
| 49 } | 49 } |
| 50 | 50 |
| 51 void ExecuteCalculateDrawProperties(LayerImpl* root_layer) { | 51 void ExecuteCalculateDrawProperties(LayerImpl* root_layer) { |
| 52 std::vector<LayerImpl*> dummy_render_surface_layer_list; | 52 std::vector<LayerImpl*> dummy_render_surface_layer_list; |
| 53 root_layer->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); |
| 53 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 54 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
| 54 root_layer, root_layer->bounds(), &dummy_render_surface_layer_list); | 55 root_layer, root_layer->bounds(), &dummy_render_surface_layer_list, |
| 56 root_layer->layer_tree_impl()->current_render_surface_list_id()); |
| 55 inputs.inner_viewport_scroll_layer = | 57 inputs.inner_viewport_scroll_layer = |
| 56 root_layer->layer_tree_impl()->InnerViewportScrollLayer(); | 58 root_layer->layer_tree_impl()->InnerViewportScrollLayer(); |
| 57 inputs.outer_viewport_scroll_layer = | 59 inputs.outer_viewport_scroll_layer = |
| 58 root_layer->layer_tree_impl()->OuterViewportScrollLayer(); | 60 root_layer->layer_tree_impl()->OuterViewportScrollLayer(); |
| 59 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 61 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
| 60 } | 62 } |
| 61 | 63 |
| 62 class LayerPositionConstraintTest : public testing::Test { | 64 class LayerPositionConstraintTest : public testing::Test { |
| 63 public: | 65 public: |
| 64 LayerPositionConstraintTest() | 66 LayerPositionConstraintTest() |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 CommitAndUpdateImplPointers(); | 219 CommitAndUpdateImplPointers(); |
| 218 | 220 |
| 219 // Case 1: scroll delta of 0, 0 | 221 // Case 1: scroll delta of 0, 0 |
| 220 child_impl_->SetScrollDelta(gfx::Vector2d(0, 0)); | 222 child_impl_->SetScrollDelta(gfx::Vector2d(0, 0)); |
| 221 ExecuteCalculateDrawProperties(root_impl_); | 223 ExecuteCalculateDrawProperties(root_impl_); |
| 222 | 224 |
| 223 gfx::Transform expected_child_transform; | 225 gfx::Transform expected_child_transform; |
| 224 gfx::Transform expected_grand_child_transform = expected_child_transform; | 226 gfx::Transform expected_grand_child_transform = expected_child_transform; |
| 225 | 227 |
| 226 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, | 228 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, |
| 227 child_impl_->draw_transform()); | 229 child_impl_->DrawTransform()); |
| 228 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, | 230 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, |
| 229 grand_child_impl_->draw_transform()); | 231 grand_child_impl_->DrawTransform()); |
| 230 | 232 |
| 231 // Case 2: scroll delta of 10, 10 | 233 // Case 2: scroll delta of 10, 10 |
| 232 child_impl_->SetScrollDelta(gfx::Vector2d(10, 10)); | 234 child_impl_->SetScrollDelta(gfx::Vector2d(10, 10)); |
| 233 child_impl_->SetDrawsContent(true); | 235 child_impl_->SetDrawsContent(true); |
| 234 ExecuteCalculateDrawProperties(root_impl_); | 236 ExecuteCalculateDrawProperties(root_impl_); |
| 235 | 237 |
| 236 // Here the child is affected by scroll delta, but the fixed position | 238 // Here the child is affected by scroll delta, but the fixed position |
| 237 // grand_child should not be affected. | 239 // grand_child should not be affected. |
| 238 expected_child_transform.MakeIdentity(); | 240 expected_child_transform.MakeIdentity(); |
| 239 expected_child_transform.Translate(-10.0, -10.0); | 241 expected_child_transform.Translate(-10.0, -10.0); |
| 240 | 242 |
| 241 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, | 243 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, |
| 242 child_impl_->draw_transform()); | 244 child_impl_->DrawTransform()); |
| 243 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, | 245 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, |
| 244 grand_child_impl_->draw_transform()); | 246 grand_child_impl_->DrawTransform()); |
| 245 | 247 |
| 246 // Case 3: fixed-container size delta of 20, 20 | 248 // Case 3: fixed-container size delta of 20, 20 |
| 247 SetFixedContainerSizeDelta(child_impl_, gfx::Vector2d(20, 20)); | 249 SetFixedContainerSizeDelta(child_impl_, gfx::Vector2d(20, 20)); |
| 248 ExecuteCalculateDrawProperties(root_impl_); | 250 ExecuteCalculateDrawProperties(root_impl_); |
| 249 | 251 |
| 250 // Top-left fixed-position layer should not be affected by container size. | 252 // Top-left fixed-position layer should not be affected by container size. |
| 251 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, | 253 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, |
| 252 child_impl_->draw_transform()); | 254 child_impl_->DrawTransform()); |
| 253 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, | 255 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, |
| 254 grand_child_impl_->draw_transform()); | 256 grand_child_impl_->DrawTransform()); |
| 255 | 257 |
| 256 // Case 4: Bottom-right fixed-position layer. | 258 // Case 4: Bottom-right fixed-position layer. |
| 257 grand_child_->SetPositionConstraint(fixed_to_bottom_right_); | 259 grand_child_->SetPositionConstraint(fixed_to_bottom_right_); |
| 258 CommitAndUpdateImplPointers(); | 260 CommitAndUpdateImplPointers(); |
| 259 | 261 |
| 260 child_impl_->SetScrollDelta(gfx::Vector2d(10, 10)); | 262 child_impl_->SetScrollDelta(gfx::Vector2d(10, 10)); |
| 261 SetFixedContainerSizeDelta(child_impl_, gfx::Vector2d(20, 20)); | 263 SetFixedContainerSizeDelta(child_impl_, gfx::Vector2d(20, 20)); |
| 262 ExecuteCalculateDrawProperties(root_impl_); | 264 ExecuteCalculateDrawProperties(root_impl_); |
| 263 | 265 |
| 264 // Bottom-right fixed-position layer moves as container resizes. | 266 // Bottom-right fixed-position layer moves as container resizes. |
| 265 expected_grand_child_transform.MakeIdentity(); | 267 expected_grand_child_transform.MakeIdentity(); |
| 266 // Apply size delta from the child(container) layer. | 268 // Apply size delta from the child(container) layer. |
| 267 expected_grand_child_transform.Translate(20.0, 20.0); | 269 expected_grand_child_transform.Translate(20.0, 20.0); |
| 268 | 270 |
| 269 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, | 271 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, |
| 270 child_impl_->draw_transform()); | 272 child_impl_->DrawTransform()); |
| 271 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, | 273 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, |
| 272 grand_child_impl_->draw_transform()); | 274 grand_child_impl_->DrawTransform()); |
| 273 } | 275 } |
| 274 | 276 |
| 275 TEST_F(LayerPositionConstraintTest, | 277 TEST_F(LayerPositionConstraintTest, |
| 276 ScrollCompensationForFixedPositionLayerWithDistantContainer) { | 278 ScrollCompensationForFixedPositionLayerWithDistantContainer) { |
| 277 // This test checks for correct scroll compensation when the fixed-position | 279 // This test checks for correct scroll compensation when the fixed-position |
| 278 // container is NOT the direct parent of the fixed-position layer. | 280 // container is NOT the direct parent of the fixed-position layer. |
| 279 child_->SetIsContainerForFixedPositionLayers(true); | 281 child_->SetIsContainerForFixedPositionLayers(true); |
| 280 grand_child_->SetPosition(gfx::PointF(8.f, 6.f)); | 282 grand_child_->SetPosition(gfx::PointF(8.f, 6.f)); |
| 281 great_grand_child_->SetPositionConstraint(fixed_to_top_left_); | 283 great_grand_child_->SetPositionConstraint(fixed_to_top_left_); |
| 282 | 284 |
| 283 CommitAndUpdateImplPointers(); | 285 CommitAndUpdateImplPointers(); |
| 284 | 286 |
| 285 // Case 1: scroll delta of 0, 0 | 287 // Case 1: scroll delta of 0, 0 |
| 286 child_impl_->SetScrollDelta(gfx::Vector2d(0, 0)); | 288 child_impl_->SetScrollDelta(gfx::Vector2d(0, 0)); |
| 287 child_impl_->SetDrawsContent(true); | 289 child_impl_->SetDrawsContent(true); |
| 288 ExecuteCalculateDrawProperties(root_impl_); | 290 ExecuteCalculateDrawProperties(root_impl_); |
| 289 | 291 |
| 290 gfx::Transform expected_child_transform; | 292 gfx::Transform expected_child_transform; |
| 291 gfx::Transform expected_grand_child_transform; | 293 gfx::Transform expected_grand_child_transform; |
| 292 expected_grand_child_transform.Translate(8.0, 6.0); | 294 expected_grand_child_transform.Translate(8.0, 6.0); |
| 293 | 295 |
| 294 gfx::Transform expected_great_grand_child_transform = | 296 gfx::Transform expected_great_grand_child_transform = |
| 295 expected_grand_child_transform; | 297 expected_grand_child_transform; |
| 296 | 298 |
| 297 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, | 299 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, |
| 298 child_impl_->draw_transform()); | 300 child_impl_->DrawTransform()); |
| 299 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, | 301 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, |
| 300 grand_child_impl_->draw_transform()); | 302 grand_child_impl_->DrawTransform()); |
| 301 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, | 303 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, |
| 302 great_grand_child_impl_->draw_transform()); | 304 great_grand_child_impl_->DrawTransform()); |
| 303 | 305 |
| 304 // Case 2: scroll delta of 10, 10 | 306 // Case 2: scroll delta of 10, 10 |
| 305 child_impl_->SetScrollDelta(gfx::Vector2d(10, 10)); | 307 child_impl_->SetScrollDelta(gfx::Vector2d(10, 10)); |
| 306 ExecuteCalculateDrawProperties(root_impl_); | 308 ExecuteCalculateDrawProperties(root_impl_); |
| 307 | 309 |
| 308 // Here the child and grand_child are affected by scroll delta, but the fixed | 310 // Here the child and grand_child are affected by scroll delta, but the fixed |
| 309 // position great_grand_child should not be affected. | 311 // position great_grand_child should not be affected. |
| 310 expected_child_transform.MakeIdentity(); | 312 expected_child_transform.MakeIdentity(); |
| 311 expected_child_transform.Translate(-10.0, -10.0); | 313 expected_child_transform.Translate(-10.0, -10.0); |
| 312 expected_grand_child_transform.MakeIdentity(); | 314 expected_grand_child_transform.MakeIdentity(); |
| 313 expected_grand_child_transform.Translate(-2.0, -4.0); | 315 expected_grand_child_transform.Translate(-2.0, -4.0); |
| 314 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, | 316 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, |
| 315 child_impl_->draw_transform()); | 317 child_impl_->DrawTransform()); |
| 316 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, | 318 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, |
| 317 grand_child_impl_->draw_transform()); | 319 grand_child_impl_->DrawTransform()); |
| 318 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, | 320 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, |
| 319 great_grand_child_impl_->draw_transform()); | 321 great_grand_child_impl_->DrawTransform()); |
| 320 | 322 |
| 321 // Case 3: fixed-container size delta of 20, 20 | 323 // Case 3: fixed-container size delta of 20, 20 |
| 322 SetFixedContainerSizeDelta(child_impl_, gfx::Vector2d(20, 20)); | 324 SetFixedContainerSizeDelta(child_impl_, gfx::Vector2d(20, 20)); |
| 323 ExecuteCalculateDrawProperties(root_impl_); | 325 ExecuteCalculateDrawProperties(root_impl_); |
| 324 | 326 |
| 325 // Top-left fixed-position layer should not be affected by container size. | 327 // Top-left fixed-position layer should not be affected by container size. |
| 326 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, | 328 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, |
| 327 child_impl_->draw_transform()); | 329 child_impl_->DrawTransform()); |
| 328 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, | 330 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, |
| 329 grand_child_impl_->draw_transform()); | 331 grand_child_impl_->DrawTransform()); |
| 330 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, | 332 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, |
| 331 great_grand_child_impl_->draw_transform()); | 333 great_grand_child_impl_->DrawTransform()); |
| 332 | 334 |
| 333 // Case 4: Bottom-right fixed-position layer. | 335 // Case 4: Bottom-right fixed-position layer. |
| 334 great_grand_child_->SetPositionConstraint(fixed_to_bottom_right_); | 336 great_grand_child_->SetPositionConstraint(fixed_to_bottom_right_); |
| 335 CommitAndUpdateImplPointers(); | 337 CommitAndUpdateImplPointers(); |
| 336 child_impl_->SetScrollDelta(gfx::Vector2d(10, 10)); | 338 child_impl_->SetScrollDelta(gfx::Vector2d(10, 10)); |
| 337 SetFixedContainerSizeDelta(child_impl_, gfx::Vector2d(20, 20)); | 339 SetFixedContainerSizeDelta(child_impl_, gfx::Vector2d(20, 20)); |
| 338 ExecuteCalculateDrawProperties(root_impl_); | 340 ExecuteCalculateDrawProperties(root_impl_); |
| 339 | 341 |
| 340 // Bottom-right fixed-position layer moves as container resizes. | 342 // Bottom-right fixed-position layer moves as container resizes. |
| 341 expected_great_grand_child_transform.MakeIdentity(); | 343 expected_great_grand_child_transform.MakeIdentity(); |
| 342 // Apply size delta from the child(container) layer. | 344 // Apply size delta from the child(container) layer. |
| 343 expected_great_grand_child_transform.Translate(20.0, 20.0); | 345 expected_great_grand_child_transform.Translate(20.0, 20.0); |
| 344 // Apply layer position from the grand child layer. | 346 // Apply layer position from the grand child layer. |
| 345 expected_great_grand_child_transform.Translate(8.0, 6.0); | 347 expected_great_grand_child_transform.Translate(8.0, 6.0); |
| 346 | 348 |
| 347 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, | 349 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, |
| 348 child_impl_->draw_transform()); | 350 child_impl_->DrawTransform()); |
| 349 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, | 351 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, |
| 350 grand_child_impl_->draw_transform()); | 352 grand_child_impl_->DrawTransform()); |
| 351 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, | 353 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, |
| 352 great_grand_child_impl_->draw_transform()); | 354 great_grand_child_impl_->DrawTransform()); |
| 353 } | 355 } |
| 354 | 356 |
| 355 TEST_F(LayerPositionConstraintTest, | 357 TEST_F(LayerPositionConstraintTest, |
| 356 ScrollCompensationForFixedPositionLayerWithMultipleScrollDeltas) { | 358 ScrollCompensationForFixedPositionLayerWithMultipleScrollDeltas) { |
| 357 // This test checks for correct scroll compensation when the fixed-position | 359 // This test checks for correct scroll compensation when the fixed-position |
| 358 // container has multiple ancestors that have nonzero scroll delta before | 360 // container has multiple ancestors that have nonzero scroll delta before |
| 359 // reaching the space where the layer is fixed. | 361 // reaching the space where the layer is fixed. |
| 360 gfx::Transform rotation_about_z; | 362 gfx::Transform rotation_about_z; |
| 361 rotation_about_z.RotateAboutZAxis(90.0); | 363 rotation_about_z.RotateAboutZAxis(90.0); |
| 362 | 364 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 378 gfx::Transform expected_grand_child_transform; | 380 gfx::Transform expected_grand_child_transform; |
| 379 expected_grand_child_transform.PreconcatTransform( | 381 expected_grand_child_transform.PreconcatTransform( |
| 380 rotation_about_z); // child's local transform is inherited | 382 rotation_about_z); // child's local transform is inherited |
| 381 // translation because of position occurs before layer's local transform. | 383 // translation because of position occurs before layer's local transform. |
| 382 expected_grand_child_transform.Translate(8.0, 6.0); | 384 expected_grand_child_transform.Translate(8.0, 6.0); |
| 383 | 385 |
| 384 gfx::Transform expected_great_grand_child_transform = | 386 gfx::Transform expected_great_grand_child_transform = |
| 385 expected_grand_child_transform; | 387 expected_grand_child_transform; |
| 386 | 388 |
| 387 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, | 389 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, |
| 388 child_impl_->draw_transform()); | 390 child_impl_->DrawTransform()); |
| 389 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, | 391 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, |
| 390 grand_child_impl_->draw_transform()); | 392 grand_child_impl_->DrawTransform()); |
| 391 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, | 393 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, |
| 392 great_grand_child_impl_->draw_transform()); | 394 great_grand_child_impl_->DrawTransform()); |
| 393 | 395 |
| 394 // Case 2: scroll delta of 10, 20 | 396 // Case 2: scroll delta of 10, 20 |
| 395 child_impl_->SetScrollDelta(gfx::Vector2d(10, 0)); | 397 child_impl_->SetScrollDelta(gfx::Vector2d(10, 0)); |
| 396 grand_child_impl_->SetScrollDelta(gfx::Vector2d(5, 0)); | 398 grand_child_impl_->SetScrollDelta(gfx::Vector2d(5, 0)); |
| 397 ExecuteCalculateDrawProperties(root_impl_); | 399 ExecuteCalculateDrawProperties(root_impl_); |
| 398 | 400 |
| 399 // Here the child and grand_child are affected by scroll delta, but the fixed | 401 // Here the child and grand_child are affected by scroll delta, but the fixed |
| 400 // position great_grand_child should not be affected. | 402 // position great_grand_child should not be affected. |
| 401 expected_child_transform.MakeIdentity(); | 403 expected_child_transform.MakeIdentity(); |
| 402 expected_child_transform.PreconcatTransform(rotation_about_z); | 404 expected_child_transform.PreconcatTransform(rotation_about_z); |
| 403 expected_child_transform.Translate(-10.0, 0.0); // scroll delta | 405 expected_child_transform.Translate(-10.0, 0.0); // scroll delta |
| 404 | 406 |
| 405 expected_grand_child_transform.MakeIdentity(); | 407 expected_grand_child_transform.MakeIdentity(); |
| 406 expected_grand_child_transform.PreconcatTransform( | 408 expected_grand_child_transform.PreconcatTransform( |
| 407 rotation_about_z); // child's local transform is inherited | 409 rotation_about_z); // child's local transform is inherited |
| 408 expected_grand_child_transform.Translate( | 410 expected_grand_child_transform.Translate( |
| 409 -10.0, 0.0); // child's scroll delta is inherited | 411 -10.0, 0.0); // child's scroll delta is inherited |
| 410 expected_grand_child_transform.Translate(-5.0, | 412 expected_grand_child_transform.Translate(-5.0, |
| 411 0.0); // grand_child's scroll delta | 413 0.0); // grand_child's scroll delta |
| 412 // translation because of position | 414 // translation because of position |
| 413 expected_grand_child_transform.Translate(8.0, 6.0); | 415 expected_grand_child_transform.Translate(8.0, 6.0); |
| 414 | 416 |
| 415 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, | 417 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, |
| 416 child_impl_->draw_transform()); | 418 child_impl_->DrawTransform()); |
| 417 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, | 419 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, |
| 418 grand_child_impl_->draw_transform()); | 420 grand_child_impl_->DrawTransform()); |
| 419 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, | 421 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, |
| 420 great_grand_child_impl_->draw_transform()); | 422 great_grand_child_impl_->DrawTransform()); |
| 421 } | 423 } |
| 422 | 424 |
| 423 TEST_F(LayerPositionConstraintTest, | 425 TEST_F(LayerPositionConstraintTest, |
| 424 ScrollCompensationForFixedPositionWithIntermediateSurfaceAndTransforms) { | 426 ScrollCompensationForFixedPositionWithIntermediateSurfaceAndTransforms) { |
| 425 // This test checks for correct scroll compensation when the fixed-position | 427 // This test checks for correct scroll compensation when the fixed-position |
| 426 // container contributes to a different render surface than the fixed-position | 428 // container contributes to a different render surface than the fixed-position |
| 427 // layer. In this case, the surface draw transforms also have to be accounted | 429 // layer. In this case, the surface draw transforms also have to be accounted |
| 428 // for when checking the scroll delta. | 430 // for when checking the scroll delta. |
| 429 child_->SetIsContainerForFixedPositionLayers(true); | 431 child_->SetIsContainerForFixedPositionLayers(true); |
| 430 grand_child_->SetPosition(gfx::PointF(8.f, 6.f)); | 432 grand_child_->SetPosition(gfx::PointF(8.f, 6.f)); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 442 ExecuteCalculateDrawProperties(root_impl_); | 444 ExecuteCalculateDrawProperties(root_impl_); |
| 443 | 445 |
| 444 gfx::Transform expected_child_transform; | 446 gfx::Transform expected_child_transform; |
| 445 gfx::Transform expected_surface_draw_transform; | 447 gfx::Transform expected_surface_draw_transform; |
| 446 expected_surface_draw_transform.Translate(8.0, 6.0); | 448 expected_surface_draw_transform.Translate(8.0, 6.0); |
| 447 gfx::Transform expected_grand_child_transform; | 449 gfx::Transform expected_grand_child_transform; |
| 448 gfx::Transform expected_great_grand_child_transform; | 450 gfx::Transform expected_great_grand_child_transform; |
| 449 expected_great_grand_child_transform.PreconcatTransform(rotation_about_z); | 451 expected_great_grand_child_transform.PreconcatTransform(rotation_about_z); |
| 450 EXPECT_TRUE(grand_child_impl_->render_surface()); | 452 EXPECT_TRUE(grand_child_impl_->render_surface()); |
| 451 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, | 453 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, |
| 452 child_impl_->draw_transform()); | 454 child_impl_->DrawTransform()); |
| 453 EXPECT_TRANSFORMATION_MATRIX_EQ( | 455 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 454 expected_surface_draw_transform, | 456 expected_surface_draw_transform, |
| 455 grand_child_impl_->render_surface()->draw_transform()); | 457 grand_child_impl_->render_surface()->draw_transform()); |
| 456 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, | 458 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, |
| 457 grand_child_impl_->draw_transform()); | 459 grand_child_impl_->DrawTransform()); |
| 458 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, | 460 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, |
| 459 great_grand_child_impl_->draw_transform()); | 461 great_grand_child_impl_->DrawTransform()); |
| 460 | 462 |
| 461 // Case 2: scroll delta of 10, 30 | 463 // Case 2: scroll delta of 10, 30 |
| 462 child_impl_->SetScrollDelta(gfx::Vector2d(10, 30)); | 464 child_impl_->SetScrollDelta(gfx::Vector2d(10, 30)); |
| 463 child_impl_->SetDrawsContent(true); | 465 child_impl_->SetDrawsContent(true); |
| 464 ExecuteCalculateDrawProperties(root_impl_); | 466 ExecuteCalculateDrawProperties(root_impl_); |
| 465 | 467 |
| 466 // Here the grand_child remains unchanged, because it scrolls along with the | 468 // Here the grand_child remains unchanged, because it scrolls along with the |
| 467 // render surface, and the translation is actually in the render surface. But, | 469 // render surface, and the translation is actually in the render surface. But, |
| 468 // the fixed position great_grand_child is more awkward: its actually being | 470 // the fixed position great_grand_child is more awkward: its actually being |
| 469 // drawn with respect to the render surface, but it needs to remain fixed with | 471 // drawn with respect to the render surface, but it needs to remain fixed with |
| 470 // resepct to a container beyond that surface. So, the net result is that, | 472 // resepct to a container beyond that surface. So, the net result is that, |
| 471 // unlike previous tests where the fixed position layer's transform remains | 473 // unlike previous tests where the fixed position layer's transform remains |
| 472 // unchanged, here the fixed position layer's transform explicitly contains | 474 // unchanged, here the fixed position layer's transform explicitly contains |
| 473 // the translation that cancels out the scroll. | 475 // the translation that cancels out the scroll. |
| 474 expected_child_transform.MakeIdentity(); | 476 expected_child_transform.MakeIdentity(); |
| 475 expected_child_transform.Translate(-10.0, -30.0); // scroll delta | 477 expected_child_transform.Translate(-10.0, -30.0); // scroll delta |
| 476 | 478 |
| 477 expected_surface_draw_transform.MakeIdentity(); | 479 expected_surface_draw_transform.MakeIdentity(); |
| 478 expected_surface_draw_transform.Translate(-10.0, -30.0); // scroll delta | 480 expected_surface_draw_transform.Translate(-10.0, -30.0); // scroll delta |
| 479 expected_surface_draw_transform.Translate(8.0, 6.0); | 481 expected_surface_draw_transform.Translate(8.0, 6.0); |
| 480 | 482 |
| 481 expected_great_grand_child_transform.MakeIdentity(); | 483 expected_great_grand_child_transform.MakeIdentity(); |
| 482 // explicit canceling out the scroll delta that gets embedded in the fixed | 484 // explicit canceling out the scroll delta that gets embedded in the fixed |
| 483 // position layer's surface. | 485 // position layer's surface. |
| 484 expected_great_grand_child_transform.Translate(10.0, 30.0); | 486 expected_great_grand_child_transform.Translate(10.0, 30.0); |
| 485 expected_great_grand_child_transform.PreconcatTransform(rotation_about_z); | 487 expected_great_grand_child_transform.PreconcatTransform(rotation_about_z); |
| 486 | 488 |
| 487 EXPECT_TRUE(grand_child_impl_->render_surface()); | 489 EXPECT_TRUE(grand_child_impl_->render_surface()); |
| 488 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, | 490 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, |
| 489 child_impl_->draw_transform()); | 491 child_impl_->DrawTransform()); |
| 490 EXPECT_TRANSFORMATION_MATRIX_EQ( | 492 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 491 expected_surface_draw_transform, | 493 expected_surface_draw_transform, |
| 492 grand_child_impl_->render_surface()->draw_transform()); | 494 grand_child_impl_->render_surface()->draw_transform()); |
| 493 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, | 495 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, |
| 494 grand_child_impl_->draw_transform()); | 496 grand_child_impl_->DrawTransform()); |
| 495 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, | 497 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, |
| 496 great_grand_child_impl_->draw_transform()); | 498 great_grand_child_impl_->DrawTransform()); |
| 497 | 499 |
| 498 // Case 3: fixed-container size delta of 20, 20 | 500 // Case 3: fixed-container size delta of 20, 20 |
| 499 SetFixedContainerSizeDelta(child_impl_, gfx::Vector2d(20, 20)); | 501 SetFixedContainerSizeDelta(child_impl_, gfx::Vector2d(20, 20)); |
| 500 ExecuteCalculateDrawProperties(root_impl_); | 502 ExecuteCalculateDrawProperties(root_impl_); |
| 501 | 503 |
| 502 // Top-left fixed-position layer should not be affected by container size. | 504 // Top-left fixed-position layer should not be affected by container size. |
| 503 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, | 505 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, |
| 504 child_impl_->draw_transform()); | 506 child_impl_->DrawTransform()); |
| 505 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, | 507 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, |
| 506 grand_child_impl_->draw_transform()); | 508 grand_child_impl_->DrawTransform()); |
| 507 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, | 509 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, |
| 508 great_grand_child_impl_->draw_transform()); | 510 great_grand_child_impl_->DrawTransform()); |
| 509 | 511 |
| 510 // Case 4: Bottom-right fixed-position layer. | 512 // Case 4: Bottom-right fixed-position layer. |
| 511 great_grand_child_->SetPositionConstraint(fixed_to_bottom_right_); | 513 great_grand_child_->SetPositionConstraint(fixed_to_bottom_right_); |
| 512 | 514 |
| 513 CommitAndUpdateImplPointers(); | 515 CommitAndUpdateImplPointers(); |
| 514 child_impl_->SetScrollDelta(gfx::Vector2d(10, 30)); | 516 child_impl_->SetScrollDelta(gfx::Vector2d(10, 30)); |
| 515 SetFixedContainerSizeDelta(child_impl_, gfx::Vector2d(20, 20)); | 517 SetFixedContainerSizeDelta(child_impl_, gfx::Vector2d(20, 20)); |
| 516 | 518 |
| 517 ExecuteCalculateDrawProperties(root_impl_); | 519 ExecuteCalculateDrawProperties(root_impl_); |
| 518 | 520 |
| 519 // Bottom-right fixed-position layer moves as container resizes. | 521 // Bottom-right fixed-position layer moves as container resizes. |
| 520 expected_great_grand_child_transform.MakeIdentity(); | 522 expected_great_grand_child_transform.MakeIdentity(); |
| 521 // explicit canceling out the scroll delta that gets embedded in the fixed | 523 // explicit canceling out the scroll delta that gets embedded in the fixed |
| 522 // position layer's surface. | 524 // position layer's surface. |
| 523 expected_great_grand_child_transform.Translate(10.0, 30.0); | 525 expected_great_grand_child_transform.Translate(10.0, 30.0); |
| 524 // Also apply size delta in the child(container) layer space. | 526 // Also apply size delta in the child(container) layer space. |
| 525 expected_great_grand_child_transform.Translate(20.0, 20.0); | 527 expected_great_grand_child_transform.Translate(20.0, 20.0); |
| 526 expected_great_grand_child_transform.PreconcatTransform(rotation_about_z); | 528 expected_great_grand_child_transform.PreconcatTransform(rotation_about_z); |
| 527 | 529 |
| 528 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, | 530 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, |
| 529 child_impl_->draw_transform()); | 531 child_impl_->DrawTransform()); |
| 530 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, | 532 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, |
| 531 grand_child_impl_->draw_transform()); | 533 grand_child_impl_->DrawTransform()); |
| 532 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, | 534 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, |
| 533 great_grand_child_impl_->draw_transform()); | 535 great_grand_child_impl_->DrawTransform()); |
| 534 } | 536 } |
| 535 | 537 |
| 536 TEST_F(LayerPositionConstraintTest, | 538 TEST_F(LayerPositionConstraintTest, |
| 537 ScrollCompensationForFixedPositionLayerWithMultipleIntermediateSurfaces) { | 539 ScrollCompensationForFixedPositionLayerWithMultipleIntermediateSurfaces) { |
| 538 // This test checks for correct scroll compensation when the fixed-position | 540 // This test checks for correct scroll compensation when the fixed-position |
| 539 // container contributes to a different render surface than the fixed-position | 541 // container contributes to a different render surface than the fixed-position |
| 540 // layer, with additional render surfaces in-between. This checks that the | 542 // layer, with additional render surfaces in-between. This checks that the |
| 541 // conversion to ancestor surfaces is accumulated properly in the final matrix | 543 // conversion to ancestor surfaces is accumulated properly in the final matrix |
| 542 // transform. | 544 // transform. |
| 543 | 545 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 expected_great_grand_child_surface_draw_transform.Translate(40.0, 60.0); | 589 expected_great_grand_child_surface_draw_transform.Translate(40.0, 60.0); |
| 588 | 590 |
| 589 gfx::Transform expected_great_grand_child_transform; | 591 gfx::Transform expected_great_grand_child_transform; |
| 590 | 592 |
| 591 gfx::Transform expected_fixed_position_child_transform; | 593 gfx::Transform expected_fixed_position_child_transform; |
| 592 expected_fixed_position_child_transform.PreconcatTransform(rotation_about_z); | 594 expected_fixed_position_child_transform.PreconcatTransform(rotation_about_z); |
| 593 | 595 |
| 594 EXPECT_TRUE(grand_child_impl_->render_surface()); | 596 EXPECT_TRUE(grand_child_impl_->render_surface()); |
| 595 EXPECT_TRUE(great_grand_child_impl_->render_surface()); | 597 EXPECT_TRUE(great_grand_child_impl_->render_surface()); |
| 596 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, | 598 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, |
| 597 child_impl_->draw_transform()); | 599 child_impl_->DrawTransform()); |
| 598 EXPECT_TRANSFORMATION_MATRIX_EQ( | 600 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 599 expected_grand_child_surface_draw_transform, | 601 expected_grand_child_surface_draw_transform, |
| 600 grand_child_impl_->render_surface()->draw_transform()); | 602 grand_child_impl_->render_surface()->draw_transform()); |
| 601 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, | 603 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, |
| 602 grand_child_impl_->draw_transform()); | 604 grand_child_impl_->DrawTransform()); |
| 603 EXPECT_TRANSFORMATION_MATRIX_EQ( | 605 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 604 expected_great_grand_child_surface_draw_transform, | 606 expected_great_grand_child_surface_draw_transform, |
| 605 great_grand_child_impl_->render_surface()->draw_transform()); | 607 great_grand_child_impl_->render_surface()->draw_transform()); |
| 606 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, | 608 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, |
| 607 great_grand_child_impl_->draw_transform()); | 609 great_grand_child_impl_->DrawTransform()); |
| 608 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_fixed_position_child_transform, | 610 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_fixed_position_child_transform, |
| 609 fixed_position_child_impl->draw_transform()); | 611 fixed_position_child_impl->DrawTransform()); |
| 610 | 612 |
| 611 // Case 2: scroll delta of 10, 30 | 613 // Case 2: scroll delta of 10, 30 |
| 612 child_impl_->SetScrollDelta(gfx::Vector2d(10, 30)); | 614 child_impl_->SetScrollDelta(gfx::Vector2d(10, 30)); |
| 613 ExecuteCalculateDrawProperties(root_impl_); | 615 ExecuteCalculateDrawProperties(root_impl_); |
| 614 | 616 |
| 615 expected_child_transform.MakeIdentity(); | 617 expected_child_transform.MakeIdentity(); |
| 616 expected_child_transform.Translate(-10.0, -30.0); // scroll delta | 618 expected_child_transform.Translate(-10.0, -30.0); // scroll delta |
| 617 | 619 |
| 618 expected_grand_child_surface_draw_transform.MakeIdentity(); | 620 expected_grand_child_surface_draw_transform.MakeIdentity(); |
| 619 expected_grand_child_surface_draw_transform.Translate(-10.0, | 621 expected_grand_child_surface_draw_transform.Translate(-10.0, |
| 620 -30.0); // scroll delta | 622 -30.0); // scroll delta |
| 621 expected_grand_child_surface_draw_transform.Translate(8.0, 6.0); | 623 expected_grand_child_surface_draw_transform.Translate(8.0, 6.0); |
| 622 | 624 |
| 623 // grand_child, great_grand_child, and great_grand_child's surface are not | 625 // grand_child, great_grand_child, and great_grand_child's surface are not |
| 624 // expected to change, since they are all not fixed, and they are all drawn | 626 // expected to change, since they are all not fixed, and they are all drawn |
| 625 // with respect to grand_child's surface that already has the scroll delta | 627 // with respect to grand_child's surface that already has the scroll delta |
| 626 // accounted for. | 628 // accounted for. |
| 627 | 629 |
| 628 // But the great-great grandchild, "fixed_position_child", should have a | 630 // But the great-great grandchild, "fixed_position_child", should have a |
| 629 // transform that explicitly cancels out the scroll delta. | 631 // transform that explicitly cancels out the scroll delta. |
| 630 expected_fixed_position_child_transform.MakeIdentity(); | 632 expected_fixed_position_child_transform.MakeIdentity(); |
| 631 expected_fixed_position_child_transform.Translate(10.0, 30.0); | 633 expected_fixed_position_child_transform.Translate(10.0, 30.0); |
| 632 expected_fixed_position_child_transform.PreconcatTransform(rotation_about_z); | 634 expected_fixed_position_child_transform.PreconcatTransform(rotation_about_z); |
| 633 | 635 |
| 634 EXPECT_TRUE(grand_child_impl_->render_surface()); | 636 EXPECT_TRUE(grand_child_impl_->render_surface()); |
| 635 EXPECT_TRUE(great_grand_child_impl_->render_surface()); | 637 EXPECT_TRUE(great_grand_child_impl_->render_surface()); |
| 636 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, | 638 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, |
| 637 child_impl_->draw_transform()); | 639 child_impl_->DrawTransform()); |
| 638 EXPECT_TRANSFORMATION_MATRIX_EQ( | 640 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 639 expected_grand_child_surface_draw_transform, | 641 expected_grand_child_surface_draw_transform, |
| 640 grand_child_impl_->render_surface()->draw_transform()); | 642 grand_child_impl_->render_surface()->draw_transform()); |
| 641 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, | 643 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, |
| 642 grand_child_impl_->draw_transform()); | 644 grand_child_impl_->DrawTransform()); |
| 643 EXPECT_TRANSFORMATION_MATRIX_EQ( | 645 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 644 expected_great_grand_child_surface_draw_transform, | 646 expected_great_grand_child_surface_draw_transform, |
| 645 great_grand_child_impl_->render_surface()->draw_transform()); | 647 great_grand_child_impl_->render_surface()->draw_transform()); |
| 646 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, | 648 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, |
| 647 great_grand_child_impl_->draw_transform()); | 649 great_grand_child_impl_->DrawTransform()); |
| 648 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_fixed_position_child_transform, | 650 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_fixed_position_child_transform, |
| 649 fixed_position_child_impl->draw_transform()); | 651 fixed_position_child_impl->DrawTransform()); |
| 650 | 652 |
| 651 // Case 3: fixed-container size delta of 20, 20 | 653 // Case 3: fixed-container size delta of 20, 20 |
| 652 SetFixedContainerSizeDelta(child_impl_, gfx::Vector2d(20, 20)); | 654 SetFixedContainerSizeDelta(child_impl_, gfx::Vector2d(20, 20)); |
| 653 ExecuteCalculateDrawProperties(root_impl_); | 655 ExecuteCalculateDrawProperties(root_impl_); |
| 654 | 656 |
| 655 // Top-left fixed-position layer should not be affected by container size. | 657 // Top-left fixed-position layer should not be affected by container size. |
| 656 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, | 658 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, |
| 657 child_impl_->draw_transform()); | 659 child_impl_->DrawTransform()); |
| 658 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, | 660 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, |
| 659 grand_child_impl_->draw_transform()); | 661 grand_child_impl_->DrawTransform()); |
| 660 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, | 662 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, |
| 661 great_grand_child_impl_->draw_transform()); | 663 great_grand_child_impl_->DrawTransform()); |
| 662 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_fixed_position_child_transform, | 664 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_fixed_position_child_transform, |
| 663 fixed_position_child_impl->draw_transform()); | 665 fixed_position_child_impl->DrawTransform()); |
| 664 | 666 |
| 665 // Case 4: Bottom-right fixed-position layer. | 667 // Case 4: Bottom-right fixed-position layer. |
| 666 fixed_position_child->SetPositionConstraint(fixed_to_bottom_right_); | 668 fixed_position_child->SetPositionConstraint(fixed_to_bottom_right_); |
| 667 CommitAndUpdateImplPointers(); | 669 CommitAndUpdateImplPointers(); |
| 668 fixed_position_child_impl = great_grand_child_impl_->children()[0].get(); | 670 fixed_position_child_impl = great_grand_child_impl_->children()[0].get(); |
| 669 child_impl_->SetScrollDelta(gfx::Vector2d(10, 30)); | 671 child_impl_->SetScrollDelta(gfx::Vector2d(10, 30)); |
| 670 SetFixedContainerSizeDelta(child_impl_, gfx::Vector2d(20, 20)); | 672 SetFixedContainerSizeDelta(child_impl_, gfx::Vector2d(20, 20)); |
| 671 ExecuteCalculateDrawProperties(root_impl_); | 673 ExecuteCalculateDrawProperties(root_impl_); |
| 672 | 674 |
| 673 // Bottom-right fixed-position layer moves as container resizes. | 675 // Bottom-right fixed-position layer moves as container resizes. |
| 674 expected_fixed_position_child_transform.MakeIdentity(); | 676 expected_fixed_position_child_transform.MakeIdentity(); |
| 675 // explicit canceling out the scroll delta that gets embedded in the fixed | 677 // explicit canceling out the scroll delta that gets embedded in the fixed |
| 676 // position layer's surface. | 678 // position layer's surface. |
| 677 expected_fixed_position_child_transform.Translate(10.0, 30.0); | 679 expected_fixed_position_child_transform.Translate(10.0, 30.0); |
| 678 // Also apply size delta in the child(container) layer space. | 680 // Also apply size delta in the child(container) layer space. |
| 679 expected_fixed_position_child_transform.Translate(20.0, 20.0); | 681 expected_fixed_position_child_transform.Translate(20.0, 20.0); |
| 680 expected_fixed_position_child_transform.PreconcatTransform(rotation_about_z); | 682 expected_fixed_position_child_transform.PreconcatTransform(rotation_about_z); |
| 681 | 683 |
| 682 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, | 684 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, |
| 683 child_impl_->draw_transform()); | 685 child_impl_->DrawTransform()); |
| 684 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, | 686 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, |
| 685 grand_child_impl_->draw_transform()); | 687 grand_child_impl_->DrawTransform()); |
| 686 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, | 688 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, |
| 687 great_grand_child_impl_->draw_transform()); | 689 great_grand_child_impl_->DrawTransform()); |
| 688 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_fixed_position_child_transform, | 690 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_fixed_position_child_transform, |
| 689 fixed_position_child_impl->draw_transform()); | 691 fixed_position_child_impl->DrawTransform()); |
| 690 } | 692 } |
| 691 | 693 |
| 692 TEST_F( | 694 TEST_F( |
| 693 LayerPositionConstraintTest, | 695 LayerPositionConstraintTest, |
| 694 ScrollCompensationForFixedPositionLayerWithMultipleSurfacesAndTransforms) { | 696 ScrollCompensationForFixedPositionLayerWithMultipleSurfacesAndTransforms) { |
| 695 // This test checks for correct scroll compensation when the fixed-position | 697 // This test checks for correct scroll compensation when the fixed-position |
| 696 // container contributes to a different render surface than the fixed-position | 698 // container contributes to a different render surface than the fixed-position |
| 697 // layer, with additional render surfaces in-between, and the fixed-position | 699 // layer, with additional render surfaces in-between, and the fixed-position |
| 698 // container is transformed. This checks that the conversion to ancestor | 700 // container is transformed. This checks that the conversion to ancestor |
| 699 // surfaces is accumulated properly in the final matrix transform. | 701 // surfaces is accumulated properly in the final matrix transform. |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 748 expected_great_grand_child_surface_draw_transform.Translate(40.0, 60.0); | 750 expected_great_grand_child_surface_draw_transform.Translate(40.0, 60.0); |
| 749 | 751 |
| 750 gfx::Transform expected_great_grand_child_transform; | 752 gfx::Transform expected_great_grand_child_transform; |
| 751 | 753 |
| 752 gfx::Transform expected_fixed_position_child_transform; | 754 gfx::Transform expected_fixed_position_child_transform; |
| 753 expected_fixed_position_child_transform.PreconcatTransform(rotation_about_z); | 755 expected_fixed_position_child_transform.PreconcatTransform(rotation_about_z); |
| 754 | 756 |
| 755 EXPECT_TRUE(grand_child_impl_->render_surface()); | 757 EXPECT_TRUE(grand_child_impl_->render_surface()); |
| 756 EXPECT_TRUE(great_grand_child_impl_->render_surface()); | 758 EXPECT_TRUE(great_grand_child_impl_->render_surface()); |
| 757 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, | 759 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, |
| 758 child_impl_->draw_transform()); | 760 child_impl_->DrawTransform()); |
| 759 EXPECT_TRANSFORMATION_MATRIX_EQ( | 761 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 760 expected_grand_child_surface_draw_transform, | 762 expected_grand_child_surface_draw_transform, |
| 761 grand_child_impl_->render_surface()->draw_transform()); | 763 grand_child_impl_->render_surface()->draw_transform()); |
| 762 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, | 764 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, |
| 763 grand_child_impl_->draw_transform()); | 765 grand_child_impl_->DrawTransform()); |
| 764 EXPECT_TRANSFORMATION_MATRIX_EQ( | 766 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 765 expected_great_grand_child_surface_draw_transform, | 767 expected_great_grand_child_surface_draw_transform, |
| 766 great_grand_child_impl_->render_surface()->draw_transform()); | 768 great_grand_child_impl_->render_surface()->draw_transform()); |
| 767 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, | 769 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, |
| 768 great_grand_child_impl_->draw_transform()); | 770 great_grand_child_impl_->DrawTransform()); |
| 769 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_fixed_position_child_transform, | 771 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_fixed_position_child_transform, |
| 770 fixed_position_child_impl->draw_transform()); | 772 fixed_position_child_impl->DrawTransform()); |
| 771 | 773 |
| 772 // Case 2: scroll delta of 10, 30 | 774 // Case 2: scroll delta of 10, 30 |
| 773 child_impl_->SetScrollDelta(gfx::Vector2d(10, 30)); | 775 child_impl_->SetScrollDelta(gfx::Vector2d(10, 30)); |
| 774 ExecuteCalculateDrawProperties(root_impl_); | 776 ExecuteCalculateDrawProperties(root_impl_); |
| 775 | 777 |
| 776 expected_child_transform.MakeIdentity(); | 778 expected_child_transform.MakeIdentity(); |
| 777 expected_child_transform.PreconcatTransform(rotation_about_z); | 779 expected_child_transform.PreconcatTransform(rotation_about_z); |
| 778 expected_child_transform.Translate(-10.0, -30.0); // scroll delta | 780 expected_child_transform.Translate(-10.0, -30.0); // scroll delta |
| 779 | 781 |
| 780 expected_grand_child_surface_draw_transform.MakeIdentity(); | 782 expected_grand_child_surface_draw_transform.MakeIdentity(); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 793 // transform that explicitly cancels out the scroll delta. | 795 // transform that explicitly cancels out the scroll delta. |
| 794 expected_fixed_position_child_transform.MakeIdentity(); | 796 expected_fixed_position_child_transform.MakeIdentity(); |
| 795 // explicit canceling out the scroll delta that gets embedded in the fixed | 797 // explicit canceling out the scroll delta that gets embedded in the fixed |
| 796 // position layer's surface. | 798 // position layer's surface. |
| 797 expected_fixed_position_child_transform.Translate(10.0, 30.0); | 799 expected_fixed_position_child_transform.Translate(10.0, 30.0); |
| 798 expected_fixed_position_child_transform.PreconcatTransform(rotation_about_z); | 800 expected_fixed_position_child_transform.PreconcatTransform(rotation_about_z); |
| 799 | 801 |
| 800 EXPECT_TRUE(grand_child_impl_->render_surface()); | 802 EXPECT_TRUE(grand_child_impl_->render_surface()); |
| 801 EXPECT_TRUE(great_grand_child_impl_->render_surface()); | 803 EXPECT_TRUE(great_grand_child_impl_->render_surface()); |
| 802 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, | 804 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, |
| 803 child_impl_->draw_transform()); | 805 child_impl_->DrawTransform()); |
| 804 EXPECT_TRANSFORMATION_MATRIX_EQ( | 806 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 805 expected_grand_child_surface_draw_transform, | 807 expected_grand_child_surface_draw_transform, |
| 806 grand_child_impl_->render_surface()->draw_transform()); | 808 grand_child_impl_->render_surface()->draw_transform()); |
| 807 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, | 809 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, |
| 808 grand_child_impl_->draw_transform()); | 810 grand_child_impl_->DrawTransform()); |
| 809 EXPECT_TRANSFORMATION_MATRIX_EQ( | 811 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 810 expected_great_grand_child_surface_draw_transform, | 812 expected_great_grand_child_surface_draw_transform, |
| 811 great_grand_child_impl_->render_surface()->draw_transform()); | 813 great_grand_child_impl_->render_surface()->draw_transform()); |
| 812 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, | 814 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, |
| 813 great_grand_child_impl_->draw_transform()); | 815 great_grand_child_impl_->DrawTransform()); |
| 814 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_fixed_position_child_transform, | 816 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_fixed_position_child_transform, |
| 815 fixed_position_child_impl->draw_transform()); | 817 fixed_position_child_impl->DrawTransform()); |
| 816 } | 818 } |
| 817 | 819 |
| 818 TEST_F(LayerPositionConstraintTest, | 820 TEST_F(LayerPositionConstraintTest, |
| 819 ScrollCompensationForFixedPositionLayerWithContainerLayerThatHasSurface) { | 821 ScrollCompensationForFixedPositionLayerWithContainerLayerThatHasSurface) { |
| 820 // This test checks for correct scroll compensation when the fixed-position | 822 // This test checks for correct scroll compensation when the fixed-position |
| 821 // container itself has a render surface. In this case, the container layer | 823 // container itself has a render surface. In this case, the container layer |
| 822 // should be treated like a layer that contributes to a render target, and | 824 // should be treated like a layer that contributes to a render target, and |
| 823 // that render target is completely irrelevant; it should not affect the | 825 // that render target is completely irrelevant; it should not affect the |
| 824 // scroll compensation. | 826 // scroll compensation. |
| 825 child_->SetIsContainerForFixedPositionLayers(true); | 827 child_->SetIsContainerForFixedPositionLayers(true); |
| 826 child_->SetForceRenderSurface(true); | 828 child_->SetForceRenderSurface(true); |
| 827 grand_child_->SetPositionConstraint(fixed_to_top_left_); | 829 grand_child_->SetPositionConstraint(fixed_to_top_left_); |
| 828 | 830 |
| 829 CommitAndUpdateImplPointers(); | 831 CommitAndUpdateImplPointers(); |
| 830 | 832 |
| 831 // Case 1: scroll delta of 0, 0 | 833 // Case 1: scroll delta of 0, 0 |
| 832 child_impl_->SetScrollDelta(gfx::Vector2d(0, 0)); | 834 child_impl_->SetScrollDelta(gfx::Vector2d(0, 0)); |
| 833 ExecuteCalculateDrawProperties(root_impl_); | 835 ExecuteCalculateDrawProperties(root_impl_); |
| 834 | 836 |
| 835 gfx::Transform expected_surface_draw_transform; | 837 gfx::Transform expected_surface_draw_transform; |
| 836 gfx::Transform expected_child_transform; | 838 gfx::Transform expected_child_transform; |
| 837 gfx::Transform expected_grand_child_transform; | 839 gfx::Transform expected_grand_child_transform; |
| 838 EXPECT_TRUE(child_impl_->render_surface()); | 840 EXPECT_TRUE(child_impl_->render_surface()); |
| 839 EXPECT_TRANSFORMATION_MATRIX_EQ( | 841 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 840 expected_surface_draw_transform, | 842 expected_surface_draw_transform, |
| 841 child_impl_->render_surface()->draw_transform()); | 843 child_impl_->render_surface()->draw_transform()); |
| 842 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, | 844 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, |
| 843 child_impl_->draw_transform()); | 845 child_impl_->DrawTransform()); |
| 844 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, | 846 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, |
| 845 grand_child_impl_->draw_transform()); | 847 grand_child_impl_->DrawTransform()); |
| 846 | 848 |
| 847 // Case 2: scroll delta of 10, 10 | 849 // Case 2: scroll delta of 10, 10 |
| 848 child_impl_->SetScrollDelta(gfx::Vector2d(10, 10)); | 850 child_impl_->SetScrollDelta(gfx::Vector2d(10, 10)); |
| 849 ExecuteCalculateDrawProperties(root_impl_); | 851 ExecuteCalculateDrawProperties(root_impl_); |
| 850 | 852 |
| 851 // The surface is translated by scroll delta, the child transform doesn't | 853 // The surface is translated by scroll delta, the child transform doesn't |
| 852 // change because it scrolls along with the surface, but the fixed position | 854 // change because it scrolls along with the surface, but the fixed position |
| 853 // grand_child needs to compensate for the scroll translation. | 855 // grand_child needs to compensate for the scroll translation. |
| 854 expected_surface_draw_transform.MakeIdentity(); | 856 expected_surface_draw_transform.MakeIdentity(); |
| 855 expected_surface_draw_transform.Translate(-10.0, -10.0); | 857 expected_surface_draw_transform.Translate(-10.0, -10.0); |
| 856 expected_grand_child_transform.MakeIdentity(); | 858 expected_grand_child_transform.MakeIdentity(); |
| 857 expected_grand_child_transform.Translate(10.0, 10.0); | 859 expected_grand_child_transform.Translate(10.0, 10.0); |
| 858 | 860 |
| 859 EXPECT_TRUE(child_impl_->render_surface()); | 861 EXPECT_TRUE(child_impl_->render_surface()); |
| 860 EXPECT_TRANSFORMATION_MATRIX_EQ( | 862 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 861 expected_surface_draw_transform, | 863 expected_surface_draw_transform, |
| 862 child_impl_->render_surface()->draw_transform()); | 864 child_impl_->render_surface()->draw_transform()); |
| 863 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, | 865 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, |
| 864 child_impl_->draw_transform()); | 866 child_impl_->DrawTransform()); |
| 865 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, | 867 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, |
| 866 grand_child_impl_->draw_transform()); | 868 grand_child_impl_->DrawTransform()); |
| 867 | 869 |
| 868 // Case 3: fixed-container size delta of 20, 20 | 870 // Case 3: fixed-container size delta of 20, 20 |
| 869 SetFixedContainerSizeDelta(child_impl_, gfx::Vector2d(20, 20)); | 871 SetFixedContainerSizeDelta(child_impl_, gfx::Vector2d(20, 20)); |
| 870 ExecuteCalculateDrawProperties(root_impl_); | 872 ExecuteCalculateDrawProperties(root_impl_); |
| 871 | 873 |
| 872 // Top-left fixed-position layer should not be affected by container size. | 874 // Top-left fixed-position layer should not be affected by container size. |
| 873 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, | 875 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, |
| 874 child_impl_->draw_transform()); | 876 child_impl_->DrawTransform()); |
| 875 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, | 877 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, |
| 876 grand_child_impl_->draw_transform()); | 878 grand_child_impl_->DrawTransform()); |
| 877 | 879 |
| 878 // Case 4: Bottom-right fixed-position layer. | 880 // Case 4: Bottom-right fixed-position layer. |
| 879 grand_child_->SetPositionConstraint(fixed_to_bottom_right_); | 881 grand_child_->SetPositionConstraint(fixed_to_bottom_right_); |
| 880 CommitAndUpdateImplPointers(); | 882 CommitAndUpdateImplPointers(); |
| 881 child_impl_->SetScrollDelta(gfx::Vector2d(10, 10)); | 883 child_impl_->SetScrollDelta(gfx::Vector2d(10, 10)); |
| 882 SetFixedContainerSizeDelta(child_impl_, gfx::Vector2d(20, 20)); | 884 SetFixedContainerSizeDelta(child_impl_, gfx::Vector2d(20, 20)); |
| 883 ExecuteCalculateDrawProperties(root_impl_); | 885 ExecuteCalculateDrawProperties(root_impl_); |
| 884 | 886 |
| 885 // Bottom-right fixed-position layer moves as container resizes. | 887 // Bottom-right fixed-position layer moves as container resizes. |
| 886 expected_grand_child_transform.MakeIdentity(); | 888 expected_grand_child_transform.MakeIdentity(); |
| 887 // The surface is translated by scroll delta, the child transform doesn't | 889 // The surface is translated by scroll delta, the child transform doesn't |
| 888 // change because it scrolls along with the surface, but the fixed position | 890 // change because it scrolls along with the surface, but the fixed position |
| 889 // grand_child needs to compensate for the scroll translation. | 891 // grand_child needs to compensate for the scroll translation. |
| 890 expected_grand_child_transform.Translate(10.0, 10.0); | 892 expected_grand_child_transform.Translate(10.0, 10.0); |
| 891 // Apply size delta from the child(container) layer. | 893 // Apply size delta from the child(container) layer. |
| 892 expected_grand_child_transform.Translate(20.0, 20.0); | 894 expected_grand_child_transform.Translate(20.0, 20.0); |
| 893 | 895 |
| 894 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, | 896 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, |
| 895 child_impl_->draw_transform()); | 897 child_impl_->DrawTransform()); |
| 896 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, | 898 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, |
| 897 grand_child_impl_->draw_transform()); | 899 grand_child_impl_->DrawTransform()); |
| 898 } | 900 } |
| 899 | 901 |
| 900 TEST_F(LayerPositionConstraintTest, | 902 TEST_F(LayerPositionConstraintTest, |
| 901 ScrollCompensationForFixedPositionLayerThatIsAlsoFixedPositionContainer) { | 903 ScrollCompensationForFixedPositionLayerThatIsAlsoFixedPositionContainer) { |
| 902 // This test checks the scenario where a fixed-position layer also happens to | 904 // This test checks the scenario where a fixed-position layer also happens to |
| 903 // be a container itself for a descendant fixed position layer. In particular, | 905 // be a container itself for a descendant fixed position layer. In particular, |
| 904 // the layer should not accidentally be fixed to itself. | 906 // the layer should not accidentally be fixed to itself. |
| 905 child_->SetIsContainerForFixedPositionLayers(true); | 907 child_->SetIsContainerForFixedPositionLayers(true); |
| 906 grand_child_->SetPositionConstraint(fixed_to_top_left_); | 908 grand_child_->SetPositionConstraint(fixed_to_top_left_); |
| 907 | 909 |
| 908 // This should not confuse the grand_child. If correct, the grand_child would | 910 // This should not confuse the grand_child. If correct, the grand_child would |
| 909 // still be considered fixed to its container (i.e. "child"). | 911 // still be considered fixed to its container (i.e. "child"). |
| 910 grand_child_->SetIsContainerForFixedPositionLayers(true); | 912 grand_child_->SetIsContainerForFixedPositionLayers(true); |
| 911 | 913 |
| 912 CommitAndUpdateImplPointers(); | 914 CommitAndUpdateImplPointers(); |
| 913 | 915 |
| 914 // Case 1: scroll delta of 0, 0 | 916 // Case 1: scroll delta of 0, 0 |
| 915 child_impl_->SetScrollDelta(gfx::Vector2d(0, 0)); | 917 child_impl_->SetScrollDelta(gfx::Vector2d(0, 0)); |
| 916 child_impl_->SetDrawsContent(true); | 918 child_impl_->SetDrawsContent(true); |
| 917 ExecuteCalculateDrawProperties(root_impl_); | 919 ExecuteCalculateDrawProperties(root_impl_); |
| 918 | 920 |
| 919 gfx::Transform expected_child_transform; | 921 gfx::Transform expected_child_transform; |
| 920 gfx::Transform expected_grand_child_transform; | 922 gfx::Transform expected_grand_child_transform; |
| 921 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, | 923 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, |
| 922 child_impl_->draw_transform()); | 924 child_impl_->DrawTransform()); |
| 923 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, | 925 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, |
| 924 grand_child_impl_->draw_transform()); | 926 grand_child_impl_->DrawTransform()); |
| 925 | 927 |
| 926 // Case 2: scroll delta of 10, 10 | 928 // Case 2: scroll delta of 10, 10 |
| 927 child_impl_->SetScrollDelta(gfx::Vector2d(10, 10)); | 929 child_impl_->SetScrollDelta(gfx::Vector2d(10, 10)); |
| 928 ExecuteCalculateDrawProperties(root_impl_); | 930 ExecuteCalculateDrawProperties(root_impl_); |
| 929 | 931 |
| 930 // Here the child is affected by scroll delta, but the fixed position | 932 // Here the child is affected by scroll delta, but the fixed position |
| 931 // grand_child should not be affected. | 933 // grand_child should not be affected. |
| 932 expected_child_transform.MakeIdentity(); | 934 expected_child_transform.MakeIdentity(); |
| 933 expected_child_transform.Translate(-10.0, -10.0); | 935 expected_child_transform.Translate(-10.0, -10.0); |
| 934 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, | 936 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, |
| 935 child_impl_->draw_transform()); | 937 child_impl_->DrawTransform()); |
| 936 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, | 938 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, |
| 937 grand_child_impl_->draw_transform()); | 939 grand_child_impl_->DrawTransform()); |
| 938 | 940 |
| 939 // Case 3: fixed-container size delta of 20, 20 | 941 // Case 3: fixed-container size delta of 20, 20 |
| 940 SetFixedContainerSizeDelta(child_impl_, gfx::Vector2d(20, 20)); | 942 SetFixedContainerSizeDelta(child_impl_, gfx::Vector2d(20, 20)); |
| 941 ExecuteCalculateDrawProperties(root_impl_); | 943 ExecuteCalculateDrawProperties(root_impl_); |
| 942 | 944 |
| 943 // Top-left fixed-position layer should not be affected by container size. | 945 // Top-left fixed-position layer should not be affected by container size. |
| 944 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, | 946 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, |
| 945 child_impl_->draw_transform()); | 947 child_impl_->DrawTransform()); |
| 946 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, | 948 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, |
| 947 grand_child_impl_->draw_transform()); | 949 grand_child_impl_->DrawTransform()); |
| 948 | 950 |
| 949 // Case 4: Bottom-right fixed-position layer. | 951 // Case 4: Bottom-right fixed-position layer. |
| 950 grand_child_->SetPositionConstraint(fixed_to_bottom_right_); | 952 grand_child_->SetPositionConstraint(fixed_to_bottom_right_); |
| 951 CommitAndUpdateImplPointers(); | 953 CommitAndUpdateImplPointers(); |
| 952 child_impl_->SetScrollDelta(gfx::Vector2d(10, 10)); | 954 child_impl_->SetScrollDelta(gfx::Vector2d(10, 10)); |
| 953 SetFixedContainerSizeDelta(child_impl_, gfx::Vector2d(20, 20)); | 955 SetFixedContainerSizeDelta(child_impl_, gfx::Vector2d(20, 20)); |
| 954 | 956 |
| 955 ExecuteCalculateDrawProperties(root_impl_); | 957 ExecuteCalculateDrawProperties(root_impl_); |
| 956 | 958 |
| 957 // Bottom-right fixed-position layer moves as container resizes. | 959 // Bottom-right fixed-position layer moves as container resizes. |
| 958 expected_grand_child_transform.MakeIdentity(); | 960 expected_grand_child_transform.MakeIdentity(); |
| 959 // Apply size delta from the child(container) layer. | 961 // Apply size delta from the child(container) layer. |
| 960 expected_grand_child_transform.Translate(20.0, 20.0); | 962 expected_grand_child_transform.Translate(20.0, 20.0); |
| 961 | 963 |
| 962 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, | 964 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, |
| 963 child_impl_->draw_transform()); | 965 child_impl_->DrawTransform()); |
| 964 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, | 966 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, |
| 965 grand_child_impl_->draw_transform()); | 967 grand_child_impl_->DrawTransform()); |
| 966 } | 968 } |
| 967 | 969 |
| 968 TEST_F(LayerPositionConstraintTest, | 970 TEST_F(LayerPositionConstraintTest, |
| 969 ScrollCompensationForFixedWithinFixedWithSameContainer) { | 971 ScrollCompensationForFixedWithinFixedWithSameContainer) { |
| 970 // This test checks scroll compensation for a fixed-position layer that is | 972 // This test checks scroll compensation for a fixed-position layer that is |
| 971 // inside of another fixed-position layer and both share the same container. | 973 // inside of another fixed-position layer and both share the same container. |
| 972 // In this situation, the parent fixed-position layer will receive | 974 // In this situation, the parent fixed-position layer will receive |
| 973 // the scroll compensation, and the child fixed-position layer does not | 975 // the scroll compensation, and the child fixed-position layer does not |
| 974 // need to compensate further. | 976 // need to compensate further. |
| 975 child_->SetIsContainerForFixedPositionLayers(true); | 977 child_->SetIsContainerForFixedPositionLayers(true); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 989 | 991 |
| 990 // Here the child is affected by scroll delta, but the fixed position | 992 // Here the child is affected by scroll delta, but the fixed position |
| 991 // grand_child should not be affected. | 993 // grand_child should not be affected. |
| 992 gfx::Transform expected_child_transform; | 994 gfx::Transform expected_child_transform; |
| 993 expected_child_transform.Translate(-10.0, -10.0); | 995 expected_child_transform.Translate(-10.0, -10.0); |
| 994 | 996 |
| 995 gfx::Transform expected_grand_child_transform; | 997 gfx::Transform expected_grand_child_transform; |
| 996 gfx::Transform expected_great_grand_child_transform; | 998 gfx::Transform expected_great_grand_child_transform; |
| 997 | 999 |
| 998 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, | 1000 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, |
| 999 child_impl_->draw_transform()); | 1001 child_impl_->DrawTransform()); |
| 1000 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, | 1002 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, |
| 1001 grand_child_impl_->draw_transform()); | 1003 grand_child_impl_->DrawTransform()); |
| 1002 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, | 1004 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, |
| 1003 great_grand_child_impl_->draw_transform()); | 1005 great_grand_child_impl_->DrawTransform()); |
| 1004 | 1006 |
| 1005 // Case 2: sizeDelta | 1007 // Case 2: sizeDelta |
| 1006 child_impl_->SetScrollDelta(gfx::Vector2d(0, 0)); | 1008 child_impl_->SetScrollDelta(gfx::Vector2d(0, 0)); |
| 1007 SetFixedContainerSizeDelta(child_impl_, gfx::Vector2d(20, 20)); | 1009 SetFixedContainerSizeDelta(child_impl_, gfx::Vector2d(20, 20)); |
| 1008 ExecuteCalculateDrawProperties(root_impl_); | 1010 ExecuteCalculateDrawProperties(root_impl_); |
| 1009 | 1011 |
| 1010 expected_child_transform.MakeIdentity(); | 1012 expected_child_transform.MakeIdentity(); |
| 1011 | 1013 |
| 1012 expected_grand_child_transform.MakeIdentity(); | 1014 expected_grand_child_transform.MakeIdentity(); |
| 1013 | 1015 |
| 1014 // Fixed to bottom-right, size-delta compensation is applied. | 1016 // Fixed to bottom-right, size-delta compensation is applied. |
| 1015 expected_great_grand_child_transform.MakeIdentity(); | 1017 expected_great_grand_child_transform.MakeIdentity(); |
| 1016 expected_great_grand_child_transform.Translate(20.0, 20.0); | 1018 expected_great_grand_child_transform.Translate(20.0, 20.0); |
| 1017 | 1019 |
| 1018 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, | 1020 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, |
| 1019 child_impl_->draw_transform()); | 1021 child_impl_->DrawTransform()); |
| 1020 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, | 1022 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, |
| 1021 grand_child_impl_->draw_transform()); | 1023 grand_child_impl_->DrawTransform()); |
| 1022 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, | 1024 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, |
| 1023 great_grand_child_impl_->draw_transform()); | 1025 great_grand_child_impl_->DrawTransform()); |
| 1024 } | 1026 } |
| 1025 | 1027 |
| 1026 TEST_F(LayerPositionConstraintTest, | 1028 TEST_F(LayerPositionConstraintTest, |
| 1027 ScrollCompensationForFixedWithinFixedWithInterveningContainer) { | 1029 ScrollCompensationForFixedWithinFixedWithInterveningContainer) { |
| 1028 // This test checks scroll compensation for a fixed-position layer that is | 1030 // This test checks scroll compensation for a fixed-position layer that is |
| 1029 // inside of another fixed-position layer, but they have different fixed | 1031 // inside of another fixed-position layer, but they have different fixed |
| 1030 // position containers. In this situation, the child fixed-position element | 1032 // position containers. In this situation, the child fixed-position element |
| 1031 // would still have to compensate with respect to its container. | 1033 // would still have to compensate with respect to its container. |
| 1032 | 1034 |
| 1033 // Add one more layer to the hierarchy for this test. | 1035 // Add one more layer to the hierarchy for this test. |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1061 | 1063 |
| 1062 // Since the container is a descendant of the fixed layer above, | 1064 // Since the container is a descendant of the fixed layer above, |
| 1063 // the expected draw transform for container2 would not | 1065 // the expected draw transform for container2 would not |
| 1064 // include the scrollDelta that was applied to container1. | 1066 // include the scrollDelta that was applied to container1. |
| 1065 gfx::Transform expected_container2_transform; | 1067 gfx::Transform expected_container2_transform; |
| 1066 expected_container2_transform.Translate(-30.0, 0.0); | 1068 expected_container2_transform.Translate(-30.0, 0.0); |
| 1067 | 1069 |
| 1068 gfx::Transform expected_fixed_to_container2_transform; | 1070 gfx::Transform expected_fixed_to_container2_transform; |
| 1069 | 1071 |
| 1070 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_container1_transform, | 1072 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_container1_transform, |
| 1071 container1->draw_transform()); | 1073 container1->DrawTransform()); |
| 1072 | 1074 |
| 1073 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_fixed_to_container1_transform, | 1075 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_fixed_to_container1_transform, |
| 1074 fixed_to_container1->draw_transform()); | 1076 fixed_to_container1->DrawTransform()); |
| 1075 | 1077 |
| 1076 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_container2_transform, | 1078 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_container2_transform, |
| 1077 container2->draw_transform()); | 1079 container2->DrawTransform()); |
| 1078 | 1080 |
| 1079 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_fixed_to_container2_transform, | 1081 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_fixed_to_container2_transform, |
| 1080 fixed_to_container2->draw_transform()); | 1082 fixed_to_container2->DrawTransform()); |
| 1081 } | 1083 } |
| 1082 | 1084 |
| 1083 TEST_F(LayerPositionConstraintTest, | 1085 TEST_F(LayerPositionConstraintTest, |
| 1084 ScrollCompensationForInnerViewportBoundsDelta) { | 1086 ScrollCompensationForInnerViewportBoundsDelta) { |
| 1085 // This test checks for correct scroll compensation when the fixed-position | 1087 // This test checks for correct scroll compensation when the fixed-position |
| 1086 // container is the inner viewport scroll layer and has non-zero bounds delta. | 1088 // container is the inner viewport scroll layer and has non-zero bounds delta. |
| 1087 scoped_refptr<Layer> fixed_child = | 1089 scoped_refptr<Layer> fixed_child = |
| 1088 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings_)); | 1090 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings_)); |
| 1089 fixed_child->SetBounds(gfx::Size(300, 300)); | 1091 fixed_child->SetBounds(gfx::Size(300, 300)); |
| 1090 scroll_layer_->AddChild(fixed_child); | 1092 scroll_layer_->AddChild(fixed_child); |
| 1091 fixed_child->SetPositionConstraint(fixed_to_top_left_); | 1093 fixed_child->SetPositionConstraint(fixed_to_top_left_); |
| 1092 | 1094 |
| 1093 CommitAndUpdateImplPointers(); | 1095 CommitAndUpdateImplPointers(); |
| 1094 | 1096 |
| 1095 LayerImpl* fixed_child_impl = | 1097 LayerImpl* fixed_child_impl = |
| 1096 root_impl_->layer_tree_impl()->FindActiveTreeLayerById(fixed_child->id()); | 1098 root_impl_->layer_tree_impl()->FindActiveTreeLayerById(fixed_child->id()); |
| 1097 | 1099 |
| 1098 // Case 1: fixed-container size delta of 20, 20 | 1100 // Case 1: fixed-container size delta of 20, 20 |
| 1099 scroll_layer_impl_->SetScrollDelta(gfx::Vector2d(10, 10)); | 1101 scroll_layer_impl_->SetScrollDelta(gfx::Vector2d(10, 10)); |
| 1100 scroll_layer_impl_->SetDrawsContent(true); | 1102 scroll_layer_impl_->SetDrawsContent(true); |
| 1101 SetFixedContainerSizeDelta(scroll_layer_impl_, gfx::Vector2d(20, 20)); | 1103 SetFixedContainerSizeDelta(scroll_layer_impl_, gfx::Vector2d(20, 20)); |
| 1102 gfx::Transform expected_scroll_layer_transform; | 1104 gfx::Transform expected_scroll_layer_transform; |
| 1103 expected_scroll_layer_transform.Translate(-10.0, -10.0); | 1105 expected_scroll_layer_transform.Translate(-10.0, -10.0); |
| 1104 gfx::Transform expected_fixed_child_transform; | 1106 gfx::Transform expected_fixed_child_transform; |
| 1105 | 1107 |
| 1106 ExecuteCalculateDrawProperties(root_impl_); | 1108 ExecuteCalculateDrawProperties(root_impl_); |
| 1107 | 1109 |
| 1108 // Top-left fixed-position layer should not be affected by container size. | 1110 // Top-left fixed-position layer should not be affected by container size. |
| 1109 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_scroll_layer_transform, | 1111 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_scroll_layer_transform, |
| 1110 scroll_layer_impl_->draw_transform()); | 1112 scroll_layer_impl_->DrawTransform()); |
| 1111 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_fixed_child_transform, | 1113 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_fixed_child_transform, |
| 1112 fixed_child_impl->draw_transform()); | 1114 fixed_child_impl->DrawTransform()); |
| 1113 | 1115 |
| 1114 // Case 2: Bottom-right fixed-position layer. | 1116 // Case 2: Bottom-right fixed-position layer. |
| 1115 fixed_child->SetPositionConstraint(fixed_to_bottom_right_); | 1117 fixed_child->SetPositionConstraint(fixed_to_bottom_right_); |
| 1116 CommitAndUpdateImplPointers(); | 1118 CommitAndUpdateImplPointers(); |
| 1117 fixed_child_impl = | 1119 fixed_child_impl = |
| 1118 root_impl_->layer_tree_impl()->FindActiveTreeLayerById(fixed_child->id()); | 1120 root_impl_->layer_tree_impl()->FindActiveTreeLayerById(fixed_child->id()); |
| 1119 | 1121 |
| 1120 scroll_layer_impl_->SetScrollDelta(gfx::Vector2d(10, 10)); | 1122 scroll_layer_impl_->SetScrollDelta(gfx::Vector2d(10, 10)); |
| 1121 SetFixedContainerSizeDelta(scroll_layer_impl_, gfx::Vector2d(20, 20)); | 1123 SetFixedContainerSizeDelta(scroll_layer_impl_, gfx::Vector2d(20, 20)); |
| 1122 ExecuteCalculateDrawProperties(root_impl_); | 1124 ExecuteCalculateDrawProperties(root_impl_); |
| 1123 | 1125 |
| 1124 // Bottom-right fixed-position layer moves as container resizes. | 1126 // Bottom-right fixed-position layer moves as container resizes. |
| 1125 expected_fixed_child_transform.MakeIdentity(); | 1127 expected_fixed_child_transform.MakeIdentity(); |
| 1126 // Apply size delta. | 1128 // Apply size delta. |
| 1127 expected_fixed_child_transform.Translate(20.0, 20.0); | 1129 expected_fixed_child_transform.Translate(20.0, 20.0); |
| 1128 | 1130 |
| 1129 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_scroll_layer_transform, | 1131 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_scroll_layer_transform, |
| 1130 scroll_layer_impl_->draw_transform()); | 1132 scroll_layer_impl_->DrawTransform()); |
| 1131 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_fixed_child_transform, | 1133 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_fixed_child_transform, |
| 1132 fixed_child_impl->draw_transform()); | 1134 fixed_child_impl->DrawTransform()); |
| 1133 } | 1135 } |
| 1134 | 1136 |
| 1135 void VerifySerializeAndDeserializeProto(bool is_fixed_position, | 1137 void VerifySerializeAndDeserializeProto(bool is_fixed_position, |
| 1136 bool is_fixed_to_right_edge, | 1138 bool is_fixed_to_right_edge, |
| 1137 bool is_fixed_to_bottom_edge) { | 1139 bool is_fixed_to_bottom_edge) { |
| 1138 LayerPositionConstraint constraint; | 1140 LayerPositionConstraint constraint; |
| 1139 constraint.set_is_fixed_position(is_fixed_position); | 1141 constraint.set_is_fixed_position(is_fixed_position); |
| 1140 constraint.set_is_fixed_to_right_edge(is_fixed_to_right_edge); | 1142 constraint.set_is_fixed_to_right_edge(is_fixed_to_right_edge); |
| 1141 constraint.set_is_fixed_to_bottom_edge(is_fixed_to_bottom_edge); | 1143 constraint.set_is_fixed_to_bottom_edge(is_fixed_to_bottom_edge); |
| 1142 proto::LayerPositionConstraint proto; | 1144 proto::LayerPositionConstraint proto; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1153 VerifySerializeAndDeserializeProto(true, false, true); | 1155 VerifySerializeAndDeserializeProto(true, false, true); |
| 1154 VerifySerializeAndDeserializeProto(true, false, false); | 1156 VerifySerializeAndDeserializeProto(true, false, false); |
| 1155 VerifySerializeAndDeserializeProto(false, true, true); | 1157 VerifySerializeAndDeserializeProto(false, true, true); |
| 1156 VerifySerializeAndDeserializeProto(false, true, false); | 1158 VerifySerializeAndDeserializeProto(false, true, false); |
| 1157 VerifySerializeAndDeserializeProto(false, false, true); | 1159 VerifySerializeAndDeserializeProto(false, false, true); |
| 1158 VerifySerializeAndDeserializeProto(false, false, false); | 1160 VerifySerializeAndDeserializeProto(false, false, false); |
| 1159 } | 1161 } |
| 1160 | 1162 |
| 1161 } // namespace | 1163 } // namespace |
| 1162 } // namespace cc | 1164 } // namespace cc |
| OLD | NEW |