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/animation/animation_host.h" | 9 #include "cc/animation/animation_host.h" |
10 #include "cc/layers/layer.h" | 10 #include "cc/layers/layer.h" |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 static void SetScrollOffsetDelta(LayerImpl* layer_impl, | 200 static void SetScrollOffsetDelta(LayerImpl* layer_impl, |
201 const gfx::Vector2dF& delta) { | 201 const gfx::Vector2dF& delta) { |
202 if (layer_impl->layer_tree_impl() | 202 if (layer_impl->layer_tree_impl() |
203 ->property_trees() | 203 ->property_trees() |
204 ->scroll_tree.SetScrollOffsetDeltaForTesting(layer_impl->id(), | 204 ->scroll_tree.SetScrollOffsetDeltaForTesting(layer_impl->id(), |
205 delta)) | 205 delta)) |
206 layer_impl->layer_tree_impl()->DidUpdateScrollOffset(layer_impl->id()); | 206 layer_impl->layer_tree_impl()->DidUpdateScrollOffset(layer_impl->id()); |
207 } | 207 } |
208 }; | 208 }; |
209 | 209 |
210 namespace { | |
211 | |
212 void SetFixedContainerSizeDelta(LayerImpl* scroll_layer, | |
213 const gfx::Vector2d& delta) { | |
214 DCHECK(scroll_layer); | |
215 DCHECK(scroll_layer->scrollable()); | |
216 | |
217 LayerImpl* container_layer = scroll_layer->scroll_clip_layer(); | |
218 container_layer->SetViewportBoundsDelta(delta); | |
219 } | |
220 } // namespace | |
221 | |
222 TEST_F(LayerPositionConstraintTest, | 210 TEST_F(LayerPositionConstraintTest, |
223 ScrollCompensationForFixedPositionLayerWithDirectContainer) { | 211 ScrollCompensationForFixedPositionLayerWithDirectContainer) { |
224 // This test checks for correct scroll compensation when the fixed-position | 212 // This test checks for correct scroll compensation when the fixed-position |
225 // container is the direct parent of the fixed-position layer. | 213 // container is the direct parent of the fixed-position layer. |
226 child_->SetIsContainerForFixedPositionLayers(true); | 214 child_->SetIsContainerForFixedPositionLayers(true); |
227 grand_child_->SetPositionConstraint(fixed_to_top_left_); | 215 grand_child_->SetPositionConstraint(fixed_to_top_left_); |
228 | 216 |
229 CommitAndUpdateImplPointers(); | 217 CommitAndUpdateImplPointers(); |
230 | 218 |
231 // Case 1: scroll delta of 0, 0 | 219 // Case 1: scroll delta of 0, 0 |
(...skipping 17 matching lines...) Expand all Loading... |
249 // grand_child should not be affected. | 237 // grand_child should not be affected. |
250 expected_child_transform.MakeIdentity(); | 238 expected_child_transform.MakeIdentity(); |
251 expected_child_transform.Translate(-10.0, -10.0); | 239 expected_child_transform.Translate(-10.0, -10.0); |
252 | 240 |
253 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, | 241 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, |
254 child_impl_->DrawTransform()); | 242 child_impl_->DrawTransform()); |
255 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, | 243 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, |
256 grand_child_impl_->DrawTransform()); | 244 grand_child_impl_->DrawTransform()); |
257 | 245 |
258 // Case 3: fixed-container size delta of 20, 20 | 246 // Case 3: fixed-container size delta of 20, 20 |
259 SetFixedContainerSizeDelta(child_impl_, gfx::Vector2d(20, 20)); | 247 outer_viewport_container_layer_impl_->SetViewportBoundsDelta( |
| 248 gfx::Vector2d(20, 20)); |
260 ExecuteCalculateDrawProperties(root_impl_); | 249 ExecuteCalculateDrawProperties(root_impl_); |
261 | 250 |
262 // Top-left fixed-position layer should not be affected by container size. | 251 // Top-left fixed-position layer should not be affected by container size. |
263 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, | 252 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, |
264 child_impl_->DrawTransform()); | 253 child_impl_->DrawTransform()); |
265 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, | 254 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, |
266 grand_child_impl_->DrawTransform()); | 255 grand_child_impl_->DrawTransform()); |
267 | 256 |
268 // Case 4: Bottom-right fixed-position layer. | 257 // Case 4: Bottom-right fixed-position layer. |
269 grand_child_->SetPositionConstraint(fixed_to_bottom_right_); | 258 grand_child_->SetPositionConstraint(fixed_to_bottom_right_); |
270 CommitAndUpdateImplPointers(); | 259 CommitAndUpdateImplPointers(); |
271 | 260 |
272 SetScrollOffsetDelta(child_impl_, gfx::Vector2d(10, 10)); | 261 SetScrollOffsetDelta(child_impl_, gfx::Vector2d(10, 10)); |
273 SetFixedContainerSizeDelta(child_impl_, gfx::Vector2d(20, 20)); | 262 outer_viewport_container_layer_impl_->SetViewportBoundsDelta( |
| 263 gfx::Vector2d(20, 20)); |
274 ExecuteCalculateDrawProperties(root_impl_); | 264 ExecuteCalculateDrawProperties(root_impl_); |
275 | 265 |
276 // Bottom-right fixed-position layer moves as container resizes. | 266 // Bottom-right fixed-position layer moves as container resizes. |
277 expected_grand_child_transform.MakeIdentity(); | 267 expected_grand_child_transform.MakeIdentity(); |
278 // Apply size delta from the child(container) layer. | 268 // Apply size delta from the child(container) layer. |
279 expected_grand_child_transform.Translate(20.0, 20.0); | 269 expected_grand_child_transform.Translate(20.0, 20.0); |
280 | 270 |
281 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, | 271 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, |
282 child_impl_->DrawTransform()); | 272 child_impl_->DrawTransform()); |
283 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, | 273 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 expected_grand_child_transform.MakeIdentity(); | 314 expected_grand_child_transform.MakeIdentity(); |
325 expected_grand_child_transform.Translate(-2.0, -4.0); | 315 expected_grand_child_transform.Translate(-2.0, -4.0); |
326 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, | 316 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, |
327 child_impl_->DrawTransform()); | 317 child_impl_->DrawTransform()); |
328 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, | 318 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, |
329 grand_child_impl_->DrawTransform()); | 319 grand_child_impl_->DrawTransform()); |
330 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, | 320 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, |
331 great_grand_child_impl_->DrawTransform()); | 321 great_grand_child_impl_->DrawTransform()); |
332 | 322 |
333 // Case 3: fixed-container size delta of 20, 20 | 323 // Case 3: fixed-container size delta of 20, 20 |
334 SetFixedContainerSizeDelta(child_impl_, gfx::Vector2d(20, 20)); | 324 outer_viewport_container_layer_impl_->SetViewportBoundsDelta( |
| 325 gfx::Vector2d(20, 20)); |
335 ExecuteCalculateDrawProperties(root_impl_); | 326 ExecuteCalculateDrawProperties(root_impl_); |
336 | 327 |
337 // Top-left fixed-position layer should not be affected by container size. | 328 // Top-left fixed-position layer should not be affected by container size. |
338 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, | 329 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, |
339 child_impl_->DrawTransform()); | 330 child_impl_->DrawTransform()); |
340 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, | 331 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, |
341 grand_child_impl_->DrawTransform()); | 332 grand_child_impl_->DrawTransform()); |
342 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, | 333 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, |
343 great_grand_child_impl_->DrawTransform()); | 334 great_grand_child_impl_->DrawTransform()); |
344 | 335 |
345 // Case 4: Bottom-right fixed-position layer. | 336 // Case 4: Bottom-right fixed-position layer. |
346 great_grand_child_->SetPositionConstraint(fixed_to_bottom_right_); | 337 great_grand_child_->SetPositionConstraint(fixed_to_bottom_right_); |
347 CommitAndUpdateImplPointers(); | 338 CommitAndUpdateImplPointers(); |
348 SetScrollOffsetDelta(child_impl_, gfx::Vector2d(10, 10)); | 339 SetScrollOffsetDelta(child_impl_, gfx::Vector2d(10, 10)); |
349 SetFixedContainerSizeDelta(child_impl_, gfx::Vector2d(20, 20)); | 340 outer_viewport_container_layer_impl_->SetViewportBoundsDelta( |
| 341 gfx::Vector2d(20, 20)); |
350 ExecuteCalculateDrawProperties(root_impl_); | 342 ExecuteCalculateDrawProperties(root_impl_); |
351 | 343 |
352 // Bottom-right fixed-position layer moves as container resizes. | 344 // Bottom-right fixed-position layer moves as container resizes. |
353 expected_great_grand_child_transform.MakeIdentity(); | 345 expected_great_grand_child_transform.MakeIdentity(); |
354 // Apply size delta from the child(container) layer. | 346 // Apply size delta from the child(container) layer. |
355 expected_great_grand_child_transform.Translate(20.0, 20.0); | 347 expected_great_grand_child_transform.Translate(20.0, 20.0); |
356 // Apply layer position from the grand child layer. | 348 // Apply layer position from the grand child layer. |
357 expected_great_grand_child_transform.Translate(8.0, 6.0); | 349 expected_great_grand_child_transform.Translate(8.0, 6.0); |
358 | 350 |
359 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, | 351 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 child_impl_->DrawTransform()); | 493 child_impl_->DrawTransform()); |
502 EXPECT_TRANSFORMATION_MATRIX_EQ( | 494 EXPECT_TRANSFORMATION_MATRIX_EQ( |
503 expected_surface_draw_transform, | 495 expected_surface_draw_transform, |
504 grand_child_impl_->GetRenderSurface()->draw_transform()); | 496 grand_child_impl_->GetRenderSurface()->draw_transform()); |
505 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, | 497 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, |
506 grand_child_impl_->DrawTransform()); | 498 grand_child_impl_->DrawTransform()); |
507 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, | 499 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, |
508 great_grand_child_impl_->DrawTransform()); | 500 great_grand_child_impl_->DrawTransform()); |
509 | 501 |
510 // Case 3: fixed-container size delta of 20, 20 | 502 // Case 3: fixed-container size delta of 20, 20 |
511 SetFixedContainerSizeDelta(child_impl_, gfx::Vector2d(20, 20)); | 503 outer_viewport_container_layer_impl_->SetViewportBoundsDelta( |
| 504 gfx::Vector2d(20, 20)); |
512 ExecuteCalculateDrawProperties(root_impl_); | 505 ExecuteCalculateDrawProperties(root_impl_); |
513 | 506 |
514 // Top-left fixed-position layer should not be affected by container size. | 507 // Top-left fixed-position layer should not be affected by container size. |
515 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, | 508 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, |
516 child_impl_->DrawTransform()); | 509 child_impl_->DrawTransform()); |
517 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, | 510 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, |
518 grand_child_impl_->DrawTransform()); | 511 grand_child_impl_->DrawTransform()); |
519 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, | 512 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, |
520 great_grand_child_impl_->DrawTransform()); | 513 great_grand_child_impl_->DrawTransform()); |
521 | 514 |
522 // Case 4: Bottom-right fixed-position layer. | 515 // Case 4: Bottom-right fixed-position layer. |
523 great_grand_child_->SetPositionConstraint(fixed_to_bottom_right_); | 516 great_grand_child_->SetPositionConstraint(fixed_to_bottom_right_); |
524 | 517 |
525 CommitAndUpdateImplPointers(); | 518 CommitAndUpdateImplPointers(); |
526 SetScrollOffsetDelta(child_impl_, gfx::Vector2d(10, 30)); | 519 SetScrollOffsetDelta(child_impl_, gfx::Vector2d(10, 30)); |
527 SetFixedContainerSizeDelta(child_impl_, gfx::Vector2d(20, 20)); | 520 outer_viewport_container_layer_impl_->SetViewportBoundsDelta( |
| 521 gfx::Vector2d(20, 20)); |
528 | 522 |
529 ExecuteCalculateDrawProperties(root_impl_); | 523 ExecuteCalculateDrawProperties(root_impl_); |
530 | 524 |
531 // Bottom-right fixed-position layer moves as container resizes. | 525 // Bottom-right fixed-position layer moves as container resizes. |
532 expected_great_grand_child_transform.MakeIdentity(); | 526 expected_great_grand_child_transform.MakeIdentity(); |
533 // explicit canceling out the scroll delta that gets embedded in the fixed | 527 // explicit canceling out the scroll delta that gets embedded in the fixed |
534 // position layer's surface. | 528 // position layer's surface. |
535 expected_great_grand_child_transform.Translate(10.0, 30.0); | 529 expected_great_grand_child_transform.Translate(10.0, 30.0); |
536 // Also apply size delta in the child(container) layer space. | 530 // Also apply size delta in the child(container) layer space. |
537 expected_great_grand_child_transform.Translate(20.0, 20.0); | 531 expected_great_grand_child_transform.Translate(20.0, 20.0); |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
654 grand_child_impl_->DrawTransform()); | 648 grand_child_impl_->DrawTransform()); |
655 EXPECT_TRANSFORMATION_MATRIX_EQ( | 649 EXPECT_TRANSFORMATION_MATRIX_EQ( |
656 expected_great_grand_child_surface_draw_transform, | 650 expected_great_grand_child_surface_draw_transform, |
657 great_grand_child_impl_->GetRenderSurface()->draw_transform()); | 651 great_grand_child_impl_->GetRenderSurface()->draw_transform()); |
658 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, | 652 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, |
659 great_grand_child_impl_->DrawTransform()); | 653 great_grand_child_impl_->DrawTransform()); |
660 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_fixed_position_child_transform, | 654 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_fixed_position_child_transform, |
661 fixed_position_child_impl->DrawTransform()); | 655 fixed_position_child_impl->DrawTransform()); |
662 | 656 |
663 // Case 3: fixed-container size delta of 20, 20 | 657 // Case 3: fixed-container size delta of 20, 20 |
664 SetFixedContainerSizeDelta(child_impl_, gfx::Vector2d(20, 20)); | 658 outer_viewport_container_layer_impl_->SetViewportBoundsDelta( |
| 659 gfx::Vector2d(20, 20)); |
665 ExecuteCalculateDrawProperties(root_impl_); | 660 ExecuteCalculateDrawProperties(root_impl_); |
666 | 661 |
667 // Top-left fixed-position layer should not be affected by container size. | 662 // Top-left fixed-position layer should not be affected by container size. |
668 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, | 663 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, |
669 child_impl_->DrawTransform()); | 664 child_impl_->DrawTransform()); |
670 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, | 665 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, |
671 grand_child_impl_->DrawTransform()); | 666 grand_child_impl_->DrawTransform()); |
672 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, | 667 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, |
673 great_grand_child_impl_->DrawTransform()); | 668 great_grand_child_impl_->DrawTransform()); |
674 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_fixed_position_child_transform, | 669 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_fixed_position_child_transform, |
675 fixed_position_child_impl->DrawTransform()); | 670 fixed_position_child_impl->DrawTransform()); |
676 | 671 |
677 // Case 4: Bottom-right fixed-position layer. | 672 // Case 4: Bottom-right fixed-position layer. |
678 fixed_position_child->SetPositionConstraint(fixed_to_bottom_right_); | 673 fixed_position_child->SetPositionConstraint(fixed_to_bottom_right_); |
679 CommitAndUpdateImplPointers(); | 674 CommitAndUpdateImplPointers(); |
680 fixed_position_child_impl = | 675 fixed_position_child_impl = |
681 layer_tree_impl_->LayerById(fixed_position_child->id()); | 676 layer_tree_impl_->LayerById(fixed_position_child->id()); |
682 SetScrollOffsetDelta(child_impl_, gfx::Vector2d(10, 30)); | 677 SetScrollOffsetDelta(child_impl_, gfx::Vector2d(10, 30)); |
683 SetFixedContainerSizeDelta(child_impl_, gfx::Vector2d(20, 20)); | 678 outer_viewport_container_layer_impl_->SetViewportBoundsDelta( |
| 679 gfx::Vector2d(20, 20)); |
684 ExecuteCalculateDrawProperties(root_impl_); | 680 ExecuteCalculateDrawProperties(root_impl_); |
685 | 681 |
686 // Bottom-right fixed-position layer moves as container resizes. | 682 // Bottom-right fixed-position layer moves as container resizes. |
687 expected_fixed_position_child_transform.MakeIdentity(); | 683 expected_fixed_position_child_transform.MakeIdentity(); |
688 // explicit canceling out the scroll delta that gets embedded in the fixed | 684 // explicit canceling out the scroll delta that gets embedded in the fixed |
689 // position layer's surface. | 685 // position layer's surface. |
690 expected_fixed_position_child_transform.Translate(10.0, 30.0); | 686 expected_fixed_position_child_transform.Translate(10.0, 30.0); |
691 // Also apply size delta in the child(container) layer space. | 687 // Also apply size delta in the child(container) layer space. |
692 expected_fixed_position_child_transform.Translate(20.0, 20.0); | 688 expected_fixed_position_child_transform.Translate(20.0, 20.0); |
693 expected_fixed_position_child_transform.PreconcatTransform(rotation_about_z); | 689 expected_fixed_position_child_transform.PreconcatTransform(rotation_about_z); |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
872 EXPECT_TRUE(child_impl_->GetRenderSurface()); | 868 EXPECT_TRUE(child_impl_->GetRenderSurface()); |
873 EXPECT_TRANSFORMATION_MATRIX_EQ( | 869 EXPECT_TRANSFORMATION_MATRIX_EQ( |
874 expected_surface_draw_transform, | 870 expected_surface_draw_transform, |
875 child_impl_->GetRenderSurface()->draw_transform()); | 871 child_impl_->GetRenderSurface()->draw_transform()); |
876 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, | 872 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, |
877 child_impl_->DrawTransform()); | 873 child_impl_->DrawTransform()); |
878 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, | 874 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, |
879 grand_child_impl_->DrawTransform()); | 875 grand_child_impl_->DrawTransform()); |
880 | 876 |
881 // Case 3: fixed-container size delta of 20, 20 | 877 // Case 3: fixed-container size delta of 20, 20 |
882 SetFixedContainerSizeDelta(child_impl_, gfx::Vector2d(20, 20)); | 878 outer_viewport_container_layer_impl_->SetViewportBoundsDelta( |
| 879 gfx::Vector2d(20, 20)); |
883 ExecuteCalculateDrawProperties(root_impl_); | 880 ExecuteCalculateDrawProperties(root_impl_); |
884 | 881 |
885 // Top-left fixed-position layer should not be affected by container size. | 882 // Top-left fixed-position layer should not be affected by container size. |
886 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, | 883 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, |
887 child_impl_->DrawTransform()); | 884 child_impl_->DrawTransform()); |
888 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, | 885 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, |
889 grand_child_impl_->DrawTransform()); | 886 grand_child_impl_->DrawTransform()); |
890 | 887 |
891 // Case 4: Bottom-right fixed-position layer. | 888 // Case 4: Bottom-right fixed-position layer. |
892 grand_child_->SetPositionConstraint(fixed_to_bottom_right_); | 889 grand_child_->SetPositionConstraint(fixed_to_bottom_right_); |
893 CommitAndUpdateImplPointers(); | 890 CommitAndUpdateImplPointers(); |
894 SetScrollOffsetDelta(child_impl_, gfx::Vector2d(10, 10)); | 891 SetScrollOffsetDelta(child_impl_, gfx::Vector2d(10, 10)); |
895 SetFixedContainerSizeDelta(child_impl_, gfx::Vector2d(20, 20)); | 892 outer_viewport_container_layer_impl_->SetViewportBoundsDelta( |
| 893 gfx::Vector2d(20, 20)); |
896 ExecuteCalculateDrawProperties(root_impl_); | 894 ExecuteCalculateDrawProperties(root_impl_); |
897 | 895 |
898 // Bottom-right fixed-position layer moves as container resizes. | 896 // Bottom-right fixed-position layer moves as container resizes. |
899 expected_grand_child_transform.MakeIdentity(); | 897 expected_grand_child_transform.MakeIdentity(); |
900 // The surface is translated by scroll delta, the child transform doesn't | 898 // The surface is translated by scroll delta, the child transform doesn't |
901 // change because it scrolls along with the surface, but the fixed position | 899 // change because it scrolls along with the surface, but the fixed position |
902 // grand_child needs to compensate for the scroll translation. | 900 // grand_child needs to compensate for the scroll translation. |
903 expected_grand_child_transform.Translate(10.0, 10.0); | 901 expected_grand_child_transform.Translate(10.0, 10.0); |
904 // Apply size delta from the child(container) layer. | 902 // Apply size delta from the child(container) layer. |
905 expected_grand_child_transform.Translate(20.0, 20.0); | 903 expected_grand_child_transform.Translate(20.0, 20.0); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
943 // Here the child is affected by scroll delta, but the fixed position | 941 // Here the child is affected by scroll delta, but the fixed position |
944 // grand_child should not be affected. | 942 // grand_child should not be affected. |
945 expected_child_transform.MakeIdentity(); | 943 expected_child_transform.MakeIdentity(); |
946 expected_child_transform.Translate(-10.0, -10.0); | 944 expected_child_transform.Translate(-10.0, -10.0); |
947 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, | 945 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, |
948 child_impl_->DrawTransform()); | 946 child_impl_->DrawTransform()); |
949 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, | 947 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, |
950 grand_child_impl_->DrawTransform()); | 948 grand_child_impl_->DrawTransform()); |
951 | 949 |
952 // Case 3: fixed-container size delta of 20, 20 | 950 // Case 3: fixed-container size delta of 20, 20 |
953 SetFixedContainerSizeDelta(child_impl_, gfx::Vector2d(20, 20)); | 951 outer_viewport_container_layer_impl_->SetViewportBoundsDelta( |
| 952 gfx::Vector2d(20, 20)); |
954 ExecuteCalculateDrawProperties(root_impl_); | 953 ExecuteCalculateDrawProperties(root_impl_); |
955 | 954 |
956 // Top-left fixed-position layer should not be affected by container size. | 955 // Top-left fixed-position layer should not be affected by container size. |
957 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, | 956 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, |
958 child_impl_->DrawTransform()); | 957 child_impl_->DrawTransform()); |
959 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, | 958 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, |
960 grand_child_impl_->DrawTransform()); | 959 grand_child_impl_->DrawTransform()); |
961 | 960 |
962 // Case 4: Bottom-right fixed-position layer. | 961 // Case 4: Bottom-right fixed-position layer. |
963 grand_child_->SetPositionConstraint(fixed_to_bottom_right_); | 962 grand_child_->SetPositionConstraint(fixed_to_bottom_right_); |
964 CommitAndUpdateImplPointers(); | 963 CommitAndUpdateImplPointers(); |
965 SetScrollOffsetDelta(child_impl_, gfx::Vector2d(10, 10)); | 964 SetScrollOffsetDelta(child_impl_, gfx::Vector2d(10, 10)); |
966 SetFixedContainerSizeDelta(child_impl_, gfx::Vector2d(20, 20)); | 965 outer_viewport_container_layer_impl_->SetViewportBoundsDelta( |
| 966 gfx::Vector2d(20, 20)); |
967 | 967 |
968 ExecuteCalculateDrawProperties(root_impl_); | 968 ExecuteCalculateDrawProperties(root_impl_); |
969 | 969 |
970 // Bottom-right fixed-position layer moves as container resizes. | 970 // Bottom-right fixed-position layer moves as container resizes. |
971 expected_grand_child_transform.MakeIdentity(); | 971 expected_grand_child_transform.MakeIdentity(); |
972 // Apply size delta from the child(container) layer. | 972 // Apply size delta from the child(container) layer. |
973 expected_grand_child_transform.Translate(20.0, 20.0); | 973 expected_grand_child_transform.Translate(20.0, 20.0); |
974 | 974 |
975 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, | 975 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, |
976 child_impl_->DrawTransform()); | 976 child_impl_->DrawTransform()); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1010 | 1010 |
1011 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, | 1011 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_child_transform, |
1012 child_impl_->DrawTransform()); | 1012 child_impl_->DrawTransform()); |
1013 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, | 1013 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_grand_child_transform, |
1014 grand_child_impl_->DrawTransform()); | 1014 grand_child_impl_->DrawTransform()); |
1015 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, | 1015 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_great_grand_child_transform, |
1016 great_grand_child_impl_->DrawTransform()); | 1016 great_grand_child_impl_->DrawTransform()); |
1017 | 1017 |
1018 // Case 2: sizeDelta | 1018 // Case 2: sizeDelta |
1019 SetScrollOffsetDelta(child_impl_, gfx::Vector2d(0, 0)); | 1019 SetScrollOffsetDelta(child_impl_, gfx::Vector2d(0, 0)); |
1020 SetFixedContainerSizeDelta(child_impl_, gfx::Vector2d(20, 20)); | 1020 outer_viewport_container_layer_impl_->SetViewportBoundsDelta( |
| 1021 gfx::Vector2d(20, 20)); |
1021 ExecuteCalculateDrawProperties(root_impl_); | 1022 ExecuteCalculateDrawProperties(root_impl_); |
1022 | 1023 |
1023 expected_child_transform.MakeIdentity(); | 1024 expected_child_transform.MakeIdentity(); |
1024 | 1025 |
1025 expected_grand_child_transform.MakeIdentity(); | 1026 expected_grand_child_transform.MakeIdentity(); |
1026 | 1027 |
1027 // Fixed to bottom-right, size-delta compensation is applied. | 1028 // Fixed to bottom-right, size-delta compensation is applied. |
1028 expected_great_grand_child_transform.MakeIdentity(); | 1029 expected_great_grand_child_transform.MakeIdentity(); |
1029 expected_great_grand_child_transform.Translate(20.0, 20.0); | 1030 expected_great_grand_child_transform.Translate(20.0, 20.0); |
1030 | 1031 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1105 fixed_child->SetPositionConstraint(fixed_to_top_left_); | 1106 fixed_child->SetPositionConstraint(fixed_to_top_left_); |
1106 | 1107 |
1107 CommitAndUpdateImplPointers(); | 1108 CommitAndUpdateImplPointers(); |
1108 | 1109 |
1109 LayerImpl* fixed_child_impl = | 1110 LayerImpl* fixed_child_impl = |
1110 root_impl_->layer_tree_impl()->FindActiveTreeLayerById(fixed_child->id()); | 1111 root_impl_->layer_tree_impl()->FindActiveTreeLayerById(fixed_child->id()); |
1111 | 1112 |
1112 // Case 1: fixed-container size delta of 20, 20 | 1113 // Case 1: fixed-container size delta of 20, 20 |
1113 SetScrollOffsetDelta(scroll_layer_impl_, gfx::Vector2d(10, 10)); | 1114 SetScrollOffsetDelta(scroll_layer_impl_, gfx::Vector2d(10, 10)); |
1114 scroll_layer_impl_->SetDrawsContent(true); | 1115 scroll_layer_impl_->SetDrawsContent(true); |
1115 SetFixedContainerSizeDelta(scroll_layer_impl_, gfx::Vector2d(20, 20)); | 1116 inner_viewport_container_layer_impl_->SetViewportBoundsDelta( |
| 1117 gfx::Vector2d(20, 20)); |
1116 gfx::Transform expected_scroll_layer_transform; | 1118 gfx::Transform expected_scroll_layer_transform; |
1117 expected_scroll_layer_transform.Translate(-10.0, -10.0); | 1119 expected_scroll_layer_transform.Translate(-10.0, -10.0); |
1118 gfx::Transform expected_fixed_child_transform; | 1120 gfx::Transform expected_fixed_child_transform; |
1119 | 1121 |
1120 ExecuteCalculateDrawProperties(root_impl_); | 1122 ExecuteCalculateDrawProperties(root_impl_); |
1121 | 1123 |
1122 // Top-left fixed-position layer should not be affected by container size. | 1124 // Top-left fixed-position layer should not be affected by container size. |
1123 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_scroll_layer_transform, | 1125 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_scroll_layer_transform, |
1124 scroll_layer_impl_->DrawTransform()); | 1126 scroll_layer_impl_->DrawTransform()); |
1125 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_fixed_child_transform, | 1127 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_fixed_child_transform, |
1126 fixed_child_impl->DrawTransform()); | 1128 fixed_child_impl->DrawTransform()); |
1127 | 1129 |
1128 // Case 2: Bottom-right fixed-position layer. | 1130 // Case 2: Bottom-right fixed-position layer. |
1129 fixed_child->SetPositionConstraint(fixed_to_bottom_right_); | 1131 fixed_child->SetPositionConstraint(fixed_to_bottom_right_); |
1130 CommitAndUpdateImplPointers(); | 1132 CommitAndUpdateImplPointers(); |
1131 fixed_child_impl = | 1133 fixed_child_impl = |
1132 root_impl_->layer_tree_impl()->FindActiveTreeLayerById(fixed_child->id()); | 1134 root_impl_->layer_tree_impl()->FindActiveTreeLayerById(fixed_child->id()); |
1133 | 1135 |
1134 SetScrollOffsetDelta(scroll_layer_impl_, gfx::Vector2d(10, 10)); | 1136 SetScrollOffsetDelta(scroll_layer_impl_, gfx::Vector2d(10, 10)); |
1135 SetFixedContainerSizeDelta(scroll_layer_impl_, gfx::Vector2d(20, 20)); | 1137 inner_viewport_container_layer_impl_->SetViewportBoundsDelta( |
| 1138 gfx::Vector2d(20, 20)); |
1136 ExecuteCalculateDrawProperties(root_impl_); | 1139 ExecuteCalculateDrawProperties(root_impl_); |
1137 | 1140 |
1138 // Bottom-right fixed-position layer moves as container resizes. | 1141 // Bottom-right fixed-position layer moves as container resizes. |
1139 expected_fixed_child_transform.MakeIdentity(); | 1142 expected_fixed_child_transform.MakeIdentity(); |
1140 // Apply size delta. | 1143 // Apply size delta. |
1141 expected_fixed_child_transform.Translate(20.0, 20.0); | 1144 expected_fixed_child_transform.Translate(20.0, 20.0); |
1142 | 1145 |
1143 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_scroll_layer_transform, | 1146 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_scroll_layer_transform, |
1144 scroll_layer_impl_->DrawTransform()); | 1147 scroll_layer_impl_->DrawTransform()); |
1145 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_fixed_child_transform, | 1148 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_fixed_child_transform, |
1146 fixed_child_impl->DrawTransform()); | 1149 fixed_child_impl->DrawTransform()); |
1147 } | 1150 } |
1148 | 1151 |
1149 } // namespace | 1152 } // namespace |
1150 } // namespace cc | 1153 } // namespace cc |
OLD | NEW |