OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/trees/layer_tree_host_common.h" | 5 #include "cc/trees/layer_tree_host_common.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <memory> | 10 #include <memory> |
(...skipping 6322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6333 root->AddChild(container); | 6333 root->AddChild(container); |
6334 container->AddChild(scroller); | 6334 container->AddChild(scroller); |
6335 scroller->AddChild(sticky_pos); | 6335 scroller->AddChild(sticky_pos); |
6336 host()->SetRootLayer(root); | 6336 host()->SetRootLayer(root); |
6337 scroller->SetScrollClipLayerId(container->id()); | 6337 scroller->SetScrollClipLayerId(container->id()); |
6338 | 6338 |
6339 LayerStickyPositionConstraint sticky_position; | 6339 LayerStickyPositionConstraint sticky_position; |
6340 sticky_position.is_sticky = true; | 6340 sticky_position.is_sticky = true; |
6341 sticky_position.is_anchored_top = true; | 6341 sticky_position.is_anchored_top = true; |
6342 sticky_position.top_offset = 10.0f; | 6342 sticky_position.top_offset = 10.0f; |
6343 sticky_position.parent_relative_sticky_box_offset = gfx::Point(10, 20); | |
6344 sticky_position.scroll_container_relative_sticky_box_rect = | 6343 sticky_position.scroll_container_relative_sticky_box_rect = |
6345 gfx::Rect(10, 20, 10, 10); | 6344 gfx::Rect(10, 20, 10, 10); |
6346 sticky_position.scroll_container_relative_containing_block_rect = | 6345 sticky_position.scroll_container_relative_containing_block_rect = |
6347 gfx::Rect(0, 0, 50, 50); | 6346 gfx::Rect(0, 0, 50, 50); |
6348 sticky_pos->SetStickyPositionConstraint(sticky_position); | 6347 sticky_pos->SetStickyPositionConstraint(sticky_position); |
6349 | 6348 |
6350 root->SetBounds(gfx::Size(100, 100)); | 6349 root->SetBounds(gfx::Size(100, 100)); |
6351 container->SetBounds(gfx::Size(100, 100)); | 6350 container->SetBounds(gfx::Size(100, 100)); |
6352 scroller->SetBounds(gfx::Size(1000, 1000)); | 6351 scroller->SetBounds(gfx::Size(1000, 1000)); |
6353 sticky_pos->SetBounds(gfx::Size(10, 10)); | 6352 sticky_pos->SetBounds(gfx::Size(10, 10)); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6409 host()->SetRootLayer(root); | 6408 host()->SetRootLayer(root); |
6410 scroller->SetScrollClipLayerId(container->id()); | 6409 scroller->SetScrollClipLayerId(container->id()); |
6411 | 6410 |
6412 // The sticky layer has already been scrolled on the main thread side, and has | 6411 // The sticky layer has already been scrolled on the main thread side, and has |
6413 // stuck. This test then checks that further changes from cc-only scrolling | 6412 // stuck. This test then checks that further changes from cc-only scrolling |
6414 // are handled correctly. | 6413 // are handled correctly. |
6415 LayerStickyPositionConstraint sticky_position; | 6414 LayerStickyPositionConstraint sticky_position; |
6416 sticky_position.is_sticky = true; | 6415 sticky_position.is_sticky = true; |
6417 sticky_position.is_anchored_top = true; | 6416 sticky_position.is_anchored_top = true; |
6418 sticky_position.top_offset = 10.0f; | 6417 sticky_position.top_offset = 10.0f; |
6419 sticky_position.parent_relative_sticky_box_offset = gfx::Point(10, 20); | |
6420 sticky_position.scroll_container_relative_sticky_box_rect = | 6418 sticky_position.scroll_container_relative_sticky_box_rect = |
6421 gfx::Rect(10, 20, 10, 10); | 6419 gfx::Rect(10, 20, 10, 10); |
6422 sticky_position.scroll_container_relative_containing_block_rect = | 6420 sticky_position.scroll_container_relative_containing_block_rect = |
6423 gfx::Rect(0, 0, 50, 50); | 6421 gfx::Rect(0, 0, 50, 50); |
6424 sticky_pos->SetStickyPositionConstraint(sticky_position); | 6422 sticky_pos->SetStickyPositionConstraint(sticky_position); |
6425 | 6423 |
6426 root->SetBounds(gfx::Size(200, 200)); | 6424 root->SetBounds(gfx::Size(200, 200)); |
6427 container->SetBounds(gfx::Size(100, 100)); | 6425 container->SetBounds(gfx::Size(100, 100)); |
6428 container->SetPosition(gfx::PointF(50, 50)); | 6426 container->SetPosition(gfx::PointF(50, 50)); |
6429 scroller->SetBounds(gfx::Size(1000, 1000)); | 6427 scroller->SetBounds(gfx::Size(1000, 1000)); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6482 root->AddChild(container); | 6480 root->AddChild(container); |
6483 container->AddChild(scroller); | 6481 container->AddChild(scroller); |
6484 scroller->AddChild(sticky_pos); | 6482 scroller->AddChild(sticky_pos); |
6485 host()->SetRootLayer(root); | 6483 host()->SetRootLayer(root); |
6486 scroller->SetScrollClipLayerId(container->id()); | 6484 scroller->SetScrollClipLayerId(container->id()); |
6487 | 6485 |
6488 LayerStickyPositionConstraint sticky_position; | 6486 LayerStickyPositionConstraint sticky_position; |
6489 sticky_position.is_sticky = true; | 6487 sticky_position.is_sticky = true; |
6490 sticky_position.is_anchored_bottom = true; | 6488 sticky_position.is_anchored_bottom = true; |
6491 sticky_position.bottom_offset = 10.0f; | 6489 sticky_position.bottom_offset = 10.0f; |
6492 sticky_position.parent_relative_sticky_box_offset = gfx::Point(0, 200); | |
6493 sticky_position.scroll_container_relative_sticky_box_rect = | 6490 sticky_position.scroll_container_relative_sticky_box_rect = |
6494 gfx::Rect(0, 200, 10, 10); | 6491 gfx::Rect(0, 200, 10, 10); |
6495 sticky_position.scroll_container_relative_containing_block_rect = | 6492 sticky_position.scroll_container_relative_containing_block_rect = |
6496 gfx::Rect(0, 0, 100, 500); | 6493 gfx::Rect(0, 0, 100, 500); |
6497 sticky_pos->SetStickyPositionConstraint(sticky_position); | 6494 sticky_pos->SetStickyPositionConstraint(sticky_position); |
6498 | 6495 |
6499 root->SetBounds(gfx::Size(100, 100)); | 6496 root->SetBounds(gfx::Size(100, 100)); |
6500 container->SetBounds(gfx::Size(100, 100)); | 6497 container->SetBounds(gfx::Size(100, 100)); |
6501 scroller->SetBounds(gfx::Size(100, 1000)); | 6498 scroller->SetBounds(gfx::Size(100, 1000)); |
6502 sticky_pos->SetBounds(gfx::Size(10, 10)); | 6499 sticky_pos->SetBounds(gfx::Size(10, 10)); |
(...skipping 25 matching lines...) Expand all Loading... |
6528 root->AddChild(container); | 6525 root->AddChild(container); |
6529 container->AddChild(scroller); | 6526 container->AddChild(scroller); |
6530 scroller->AddChild(sticky_pos); | 6527 scroller->AddChild(sticky_pos); |
6531 host()->SetRootLayer(root); | 6528 host()->SetRootLayer(root); |
6532 scroller->SetScrollClipLayerId(container->id()); | 6529 scroller->SetScrollClipLayerId(container->id()); |
6533 | 6530 |
6534 LayerStickyPositionConstraint sticky_position; | 6531 LayerStickyPositionConstraint sticky_position; |
6535 sticky_position.is_sticky = true; | 6532 sticky_position.is_sticky = true; |
6536 sticky_position.is_anchored_bottom = true; | 6533 sticky_position.is_anchored_bottom = true; |
6537 sticky_position.bottom_offset = 10.0f; | 6534 sticky_position.bottom_offset = 10.0f; |
6538 sticky_position.parent_relative_sticky_box_offset = gfx::Point(0, 150); | |
6539 sticky_position.scroll_container_relative_sticky_box_rect = | 6535 sticky_position.scroll_container_relative_sticky_box_rect = |
6540 gfx::Rect(0, 150, 10, 10); | 6536 gfx::Rect(0, 150, 10, 10); |
6541 sticky_position.scroll_container_relative_containing_block_rect = | 6537 sticky_position.scroll_container_relative_containing_block_rect = |
6542 gfx::Rect(0, 100, 50, 50); | 6538 gfx::Rect(0, 100, 50, 50); |
6543 sticky_pos->SetStickyPositionConstraint(sticky_position); | 6539 sticky_pos->SetStickyPositionConstraint(sticky_position); |
6544 | 6540 |
6545 root->SetBounds(gfx::Size(100, 100)); | 6541 root->SetBounds(gfx::Size(100, 100)); |
6546 container->SetBounds(gfx::Size(100, 100)); | 6542 container->SetBounds(gfx::Size(100, 100)); |
6547 scroller->SetBounds(gfx::Size(1000, 1000)); | 6543 scroller->SetBounds(gfx::Size(1000, 1000)); |
6548 sticky_pos->SetBounds(gfx::Size(10, 10)); | 6544 sticky_pos->SetBounds(gfx::Size(10, 10)); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6601 LayerTreeHost::ViewportLayers viewport_layers; | 6597 LayerTreeHost::ViewportLayers viewport_layers; |
6602 viewport_layers.page_scale = root; | 6598 viewport_layers.page_scale = root; |
6603 viewport_layers.inner_viewport_container = root; | 6599 viewport_layers.inner_viewport_container = root; |
6604 viewport_layers.inner_viewport_scroll = scroller; | 6600 viewport_layers.inner_viewport_scroll = scroller; |
6605 host()->RegisterViewportLayers(viewport_layers); | 6601 host()->RegisterViewportLayers(viewport_layers); |
6606 | 6602 |
6607 LayerStickyPositionConstraint sticky_position; | 6603 LayerStickyPositionConstraint sticky_position; |
6608 sticky_position.is_sticky = true; | 6604 sticky_position.is_sticky = true; |
6609 sticky_position.is_anchored_bottom = true; | 6605 sticky_position.is_anchored_bottom = true; |
6610 sticky_position.bottom_offset = 10.0f; | 6606 sticky_position.bottom_offset = 10.0f; |
6611 sticky_position.parent_relative_sticky_box_offset = gfx::Point(0, 70); | |
6612 sticky_position.scroll_container_relative_sticky_box_rect = | 6607 sticky_position.scroll_container_relative_sticky_box_rect = |
6613 gfx::Rect(0, 70, 10, 10); | 6608 gfx::Rect(0, 70, 10, 10); |
6614 sticky_position.scroll_container_relative_containing_block_rect = | 6609 sticky_position.scroll_container_relative_containing_block_rect = |
6615 gfx::Rect(0, 60, 100, 100); | 6610 gfx::Rect(0, 60, 100, 100); |
6616 sticky_pos->SetStickyPositionConstraint(sticky_position); | 6611 sticky_pos->SetStickyPositionConstraint(sticky_position); |
6617 | 6612 |
6618 root->SetBounds(gfx::Size(100, 100)); | 6613 root->SetBounds(gfx::Size(100, 100)); |
6619 scroller->SetBounds(gfx::Size(100, 1000)); | 6614 scroller->SetBounds(gfx::Size(100, 1000)); |
6620 sticky_pos->SetBounds(gfx::Size(10, 10)); | 6615 sticky_pos->SetBounds(gfx::Size(10, 10)); |
6621 sticky_pos->SetPosition(gfx::PointF(0, 70)); | 6616 sticky_pos->SetPosition(gfx::PointF(0, 70)); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6680 viewport_layers.inner_viewport_container = root; | 6675 viewport_layers.inner_viewport_container = root; |
6681 viewport_layers.outer_viewport_container = outer_clip; | 6676 viewport_layers.outer_viewport_container = outer_clip; |
6682 viewport_layers.inner_viewport_scroll = scroller; | 6677 viewport_layers.inner_viewport_scroll = scroller; |
6683 viewport_layers.outer_viewport_scroll = outer_viewport; | 6678 viewport_layers.outer_viewport_scroll = outer_viewport; |
6684 host()->RegisterViewportLayers(viewport_layers); | 6679 host()->RegisterViewportLayers(viewport_layers); |
6685 | 6680 |
6686 LayerStickyPositionConstraint sticky_position; | 6681 LayerStickyPositionConstraint sticky_position; |
6687 sticky_position.is_sticky = true; | 6682 sticky_position.is_sticky = true; |
6688 sticky_position.is_anchored_bottom = true; | 6683 sticky_position.is_anchored_bottom = true; |
6689 sticky_position.bottom_offset = 10.0f; | 6684 sticky_position.bottom_offset = 10.0f; |
6690 sticky_position.parent_relative_sticky_box_offset = gfx::Point(0, 70); | |
6691 sticky_position.scroll_container_relative_sticky_box_rect = | 6685 sticky_position.scroll_container_relative_sticky_box_rect = |
6692 gfx::Rect(0, 70, 10, 10); | 6686 gfx::Rect(0, 70, 10, 10); |
6693 sticky_position.scroll_container_relative_containing_block_rect = | 6687 sticky_position.scroll_container_relative_containing_block_rect = |
6694 gfx::Rect(0, 60, 100, 100); | 6688 gfx::Rect(0, 60, 100, 100); |
6695 sticky_pos->SetStickyPositionConstraint(sticky_position); | 6689 sticky_pos->SetStickyPositionConstraint(sticky_position); |
6696 | 6690 |
6697 root->SetBounds(gfx::Size(100, 100)); | 6691 root->SetBounds(gfx::Size(100, 100)); |
6698 scroller->SetBounds(gfx::Size(100, 1000)); | 6692 scroller->SetBounds(gfx::Size(100, 1000)); |
6699 outer_clip->SetBounds(gfx::Size(100, 100)); | 6693 outer_clip->SetBounds(gfx::Size(100, 100)); |
6700 sticky_pos->SetBounds(gfx::Size(10, 10)); | 6694 sticky_pos->SetBounds(gfx::Size(10, 10)); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6757 scroller->AddChild(sticky_pos); | 6751 scroller->AddChild(sticky_pos); |
6758 host()->SetRootLayer(root); | 6752 host()->SetRootLayer(root); |
6759 scroller->SetScrollClipLayerId(container->id()); | 6753 scroller->SetScrollClipLayerId(container->id()); |
6760 | 6754 |
6761 LayerStickyPositionConstraint sticky_position; | 6755 LayerStickyPositionConstraint sticky_position; |
6762 sticky_position.is_sticky = true; | 6756 sticky_position.is_sticky = true; |
6763 sticky_position.is_anchored_left = true; | 6757 sticky_position.is_anchored_left = true; |
6764 sticky_position.is_anchored_right = true; | 6758 sticky_position.is_anchored_right = true; |
6765 sticky_position.left_offset = 10.f; | 6759 sticky_position.left_offset = 10.f; |
6766 sticky_position.right_offset = 10.f; | 6760 sticky_position.right_offset = 10.f; |
6767 sticky_position.parent_relative_sticky_box_offset = gfx::Point(145, 0); | |
6768 sticky_position.scroll_container_relative_sticky_box_rect = | 6761 sticky_position.scroll_container_relative_sticky_box_rect = |
6769 gfx::Rect(145, 0, 10, 10); | 6762 gfx::Rect(145, 0, 10, 10); |
6770 sticky_position.scroll_container_relative_containing_block_rect = | 6763 sticky_position.scroll_container_relative_containing_block_rect = |
6771 gfx::Rect(100, 0, 100, 100); | 6764 gfx::Rect(100, 0, 100, 100); |
6772 sticky_pos->SetStickyPositionConstraint(sticky_position); | 6765 sticky_pos->SetStickyPositionConstraint(sticky_position); |
6773 | 6766 |
6774 root->SetBounds(gfx::Size(100, 100)); | 6767 root->SetBounds(gfx::Size(100, 100)); |
6775 container->SetBounds(gfx::Size(100, 100)); | 6768 container->SetBounds(gfx::Size(100, 100)); |
6776 scroller->SetBounds(gfx::Size(1000, 1000)); | 6769 scroller->SetBounds(gfx::Size(1000, 1000)); |
6777 sticky_pos->SetBounds(gfx::Size(10, 10)); | 6770 sticky_pos->SetBounds(gfx::Size(10, 10)); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6860 root->AddChild(container); | 6853 root->AddChild(container); |
6861 container->AddChild(scroller); | 6854 container->AddChild(scroller); |
6862 scroller->AddChild(sticky_pos); | 6855 scroller->AddChild(sticky_pos); |
6863 host()->SetRootLayer(root); | 6856 host()->SetRootLayer(root); |
6864 scroller->SetScrollClipLayerId(container->id()); | 6857 scroller->SetScrollClipLayerId(container->id()); |
6865 | 6858 |
6866 LayerStickyPositionConstraint sticky_position; | 6859 LayerStickyPositionConstraint sticky_position; |
6867 sticky_position.is_sticky = true; | 6860 sticky_position.is_sticky = true; |
6868 sticky_position.is_anchored_top = true; | 6861 sticky_position.is_anchored_top = true; |
6869 sticky_position.top_offset = 10.0f; | 6862 sticky_position.top_offset = 10.0f; |
6870 sticky_position.parent_relative_sticky_box_offset = gfx::Point(10, 20); | |
6871 sticky_position.scroll_container_relative_sticky_box_rect = | 6863 sticky_position.scroll_container_relative_sticky_box_rect = |
6872 gfx::Rect(10, 20, 10, 10); | 6864 gfx::Rect(10, 20, 10, 10); |
6873 sticky_position.scroll_container_relative_containing_block_rect = | 6865 sticky_position.scroll_container_relative_containing_block_rect = |
6874 gfx::Rect(0, 0, 50, 50); | 6866 gfx::Rect(0, 0, 50, 50); |
6875 sticky_pos->SetStickyPositionConstraint(sticky_position); | 6867 sticky_pos->SetStickyPositionConstraint(sticky_position); |
| 6868 sticky_pos->SetElementId(LayerIdToElementIdForTesting(sticky_pos->id())); |
6876 | 6869 |
6877 root->SetBounds(gfx::Size(100, 100)); | 6870 root->SetBounds(gfx::Size(100, 100)); |
6878 container->SetBounds(gfx::Size(100, 100)); | 6871 container->SetBounds(gfx::Size(100, 100)); |
6879 scroller->SetBounds(gfx::Size(1000, 1000)); | 6872 scroller->SetBounds(gfx::Size(1000, 1000)); |
6880 sticky_pos->SetBounds(gfx::Size(10, 10)); | 6873 sticky_pos->SetBounds(gfx::Size(10, 10)); |
6881 sticky_pos->SetPosition(gfx::PointF(10, 20)); | 6874 sticky_pos->SetPosition(gfx::PointF(10, 20)); |
6882 | 6875 |
6883 ExecuteCalculateDrawProperties(root.get()); | 6876 ExecuteCalculateDrawProperties(root.get()); |
6884 host()->host_impl()->CreatePendingTree(); | 6877 host()->host_impl()->CreatePendingTree(); |
6885 host()->CommitAndCreatePendingTree(); | 6878 host()->CommitAndCreatePendingTree(); |
(...skipping 20 matching lines...) Expand all Loading... |
6906 // Scroll past the sticking point, the Y coordinate should now be clamped. | 6899 // Scroll past the sticking point, the Y coordinate should now be clamped. |
6907 SetScrollOffsetDelta(scroller_impl, gfx::Vector2dF(15.f, 15.f)); | 6900 SetScrollOffsetDelta(scroller_impl, gfx::Vector2dF(15.f, 15.f)); |
6908 ExecuteCalculateDrawProperties(root_impl); | 6901 ExecuteCalculateDrawProperties(root_impl); |
6909 EXPECT_VECTOR2DF_EQ( | 6902 EXPECT_VECTOR2DF_EQ( |
6910 gfx::Vector2dF(-5.f, 10.f), | 6903 gfx::Vector2dF(-5.f, 10.f), |
6911 sticky_pos_impl->ScreenSpaceTransform().To2dTranslation()); | 6904 sticky_pos_impl->ScreenSpaceTransform().To2dTranslation()); |
6912 | 6905 |
6913 // Now the main thread commits the new position of the sticky element. | 6906 // Now the main thread commits the new position of the sticky element. |
6914 scroller->SetScrollOffset(gfx::ScrollOffset(15, 15)); | 6907 scroller->SetScrollOffset(gfx::ScrollOffset(15, 15)); |
6915 sticky_pos->SetPosition(gfx::PointF(10, 25)); | 6908 sticky_pos->SetPosition(gfx::PointF(10, 25)); |
| 6909 sticky_pos->SetOffsetForStickyPositionFromMainThread(gfx::Size(0, 5)); |
6916 ExecuteCalculateDrawProperties(root.get()); | 6910 ExecuteCalculateDrawProperties(root.get()); |
6917 host()->host_impl()->CreatePendingTree(); | 6911 host()->host_impl()->CreatePendingTree(); |
6918 host()->CommitAndCreatePendingTree(); | 6912 host()->CommitAndCreatePendingTree(); |
6919 host()->host_impl()->ActivateSyncTree(); | 6913 host()->host_impl()->ActivateSyncTree(); |
6920 layer_tree_impl = host()->host_impl()->active_tree(); | 6914 layer_tree_impl = host()->host_impl()->active_tree(); |
6921 root_impl = layer_tree_impl->LayerById(root->id()); | 6915 root_impl = layer_tree_impl->LayerById(root->id()); |
6922 scroller_impl = layer_tree_impl->LayerById(scroller->id()); | 6916 scroller_impl = layer_tree_impl->LayerById(scroller->id()); |
6923 sticky_pos_impl = layer_tree_impl->LayerById(sticky_pos->id()); | 6917 sticky_pos_impl = layer_tree_impl->LayerById(sticky_pos->id()); |
6924 | 6918 |
6925 // The element should still be where it was before. We reset the delta to | 6919 // The element should still be where it was before. We reset the delta to |
(...skipping 26 matching lines...) Expand all Loading... |
6952 container->AddChild(scroller); | 6946 container->AddChild(scroller); |
6953 scroller->AddChild(sticky_container); | 6947 scroller->AddChild(sticky_container); |
6954 sticky_container->AddChild(sticky_pos); | 6948 sticky_container->AddChild(sticky_pos); |
6955 host()->SetRootLayer(root); | 6949 host()->SetRootLayer(root); |
6956 scroller->SetScrollClipLayerId(container->id()); | 6950 scroller->SetScrollClipLayerId(container->id()); |
6957 | 6951 |
6958 LayerStickyPositionConstraint sticky_position; | 6952 LayerStickyPositionConstraint sticky_position; |
6959 sticky_position.is_sticky = true; | 6953 sticky_position.is_sticky = true; |
6960 sticky_position.is_anchored_top = true; | 6954 sticky_position.is_anchored_top = true; |
6961 sticky_position.top_offset = 10.0f; | 6955 sticky_position.top_offset = 10.0f; |
6962 // The sticky position layer is only offset by (0, 10) from its parent | |
6963 // layer, this position is used to determine the offset applied by the main | |
6964 // thread. | |
6965 sticky_position.parent_relative_sticky_box_offset = gfx::Point(0, 10); | |
6966 sticky_position.scroll_container_relative_sticky_box_rect = | 6956 sticky_position.scroll_container_relative_sticky_box_rect = |
6967 gfx::Rect(20, 30, 10, 10); | 6957 gfx::Rect(20, 30, 10, 10); |
6968 sticky_position.scroll_container_relative_containing_block_rect = | 6958 sticky_position.scroll_container_relative_containing_block_rect = |
6969 gfx::Rect(20, 20, 30, 30); | 6959 gfx::Rect(20, 20, 30, 30); |
6970 sticky_pos->SetStickyPositionConstraint(sticky_position); | 6960 sticky_pos->SetStickyPositionConstraint(sticky_position); |
| 6961 sticky_pos->SetElementId(LayerIdToElementIdForTesting(sticky_pos->id())); |
6971 | 6962 |
6972 root->SetBounds(gfx::Size(100, 100)); | 6963 root->SetBounds(gfx::Size(100, 100)); |
6973 container->SetBounds(gfx::Size(100, 100)); | 6964 container->SetBounds(gfx::Size(100, 100)); |
6974 scroller->SetBounds(gfx::Size(1000, 1000)); | 6965 scroller->SetBounds(gfx::Size(1000, 1000)); |
6975 sticky_container->SetPosition(gfx::PointF(20, 20)); | 6966 sticky_container->SetPosition(gfx::PointF(20, 20)); |
6976 sticky_container->SetBounds(gfx::Size(30, 30)); | 6967 sticky_container->SetBounds(gfx::Size(30, 30)); |
6977 sticky_pos->SetBounds(gfx::Size(10, 10)); | 6968 sticky_pos->SetBounds(gfx::Size(10, 10)); |
6978 sticky_pos->SetPosition(gfx::PointF(0, 10)); | 6969 sticky_pos->SetPosition(gfx::PointF(0, 10)); |
6979 | 6970 |
6980 ExecuteCalculateDrawProperties(root.get()); | 6971 ExecuteCalculateDrawProperties(root.get()); |
(...skipping 22 matching lines...) Expand all Loading... |
7003 // Scroll past the sticking point, the Y coordinate should now be clamped. | 6994 // Scroll past the sticking point, the Y coordinate should now be clamped. |
7004 SetScrollOffsetDelta(scroller_impl, gfx::Vector2dF(0.f, 25.f)); | 6995 SetScrollOffsetDelta(scroller_impl, gfx::Vector2dF(0.f, 25.f)); |
7005 ExecuteCalculateDrawProperties(root_impl); | 6996 ExecuteCalculateDrawProperties(root_impl); |
7006 EXPECT_VECTOR2DF_EQ( | 6997 EXPECT_VECTOR2DF_EQ( |
7007 gfx::Vector2dF(20.f, 10.f), | 6998 gfx::Vector2dF(20.f, 10.f), |
7008 sticky_pos_impl->ScreenSpaceTransform().To2dTranslation()); | 6999 sticky_pos_impl->ScreenSpaceTransform().To2dTranslation()); |
7009 | 7000 |
7010 // Now the main thread commits the new position of the sticky element. | 7001 // Now the main thread commits the new position of the sticky element. |
7011 scroller->SetScrollOffset(gfx::ScrollOffset(0, 25)); | 7002 scroller->SetScrollOffset(gfx::ScrollOffset(0, 25)); |
7012 sticky_pos->SetPosition(gfx::PointF(0, 15)); | 7003 sticky_pos->SetPosition(gfx::PointF(0, 15)); |
| 7004 sticky_pos->SetOffsetForStickyPositionFromMainThread(gfx::Size(0, 5)); |
7013 ExecuteCalculateDrawProperties(root.get()); | 7005 ExecuteCalculateDrawProperties(root.get()); |
7014 host()->host_impl()->CreatePendingTree(); | 7006 host()->host_impl()->CreatePendingTree(); |
7015 host()->CommitAndCreatePendingTree(); | 7007 host()->CommitAndCreatePendingTree(); |
7016 host()->host_impl()->ActivateSyncTree(); | 7008 host()->host_impl()->ActivateSyncTree(); |
7017 layer_tree_impl = host()->host_impl()->active_tree(); | 7009 layer_tree_impl = host()->host_impl()->active_tree(); |
7018 root_impl = layer_tree_impl->LayerById(root->id()); | 7010 root_impl = layer_tree_impl->LayerById(root->id()); |
7019 scroller_impl = layer_tree_impl->LayerById(scroller->id()); | 7011 scroller_impl = layer_tree_impl->LayerById(scroller->id()); |
7020 sticky_pos_impl = layer_tree_impl->LayerById(sticky_pos->id()); | 7012 sticky_pos_impl = layer_tree_impl->LayerById(sticky_pos->id()); |
7021 | 7013 |
7022 // The element should still be where it was before. We reset the delta to | 7014 // The element should still be where it was before. We reset the delta to |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7055 host()->SetRootLayer(root); | 7047 host()->SetRootLayer(root); |
7056 scroller->SetScrollClipLayerId(container->id()); | 7048 scroller->SetScrollClipLayerId(container->id()); |
7057 gfx::Transform t; | 7049 gfx::Transform t; |
7058 t.Scale(2, 2); | 7050 t.Scale(2, 2); |
7059 sticky_pos->SetTransform(t); | 7051 sticky_pos->SetTransform(t); |
7060 | 7052 |
7061 LayerStickyPositionConstraint sticky_position; | 7053 LayerStickyPositionConstraint sticky_position; |
7062 sticky_position.is_sticky = true; | 7054 sticky_position.is_sticky = true; |
7063 sticky_position.is_anchored_top = true; | 7055 sticky_position.is_anchored_top = true; |
7064 sticky_position.top_offset = 0.0f; | 7056 sticky_position.top_offset = 0.0f; |
7065 sticky_position.parent_relative_sticky_box_offset = gfx::Point(0, 20); | |
7066 sticky_position.scroll_container_relative_sticky_box_rect = | 7057 sticky_position.scroll_container_relative_sticky_box_rect = |
7067 gfx::Rect(0, 20, 10, 10); | 7058 gfx::Rect(0, 20, 10, 10); |
7068 sticky_position.scroll_container_relative_containing_block_rect = | 7059 sticky_position.scroll_container_relative_containing_block_rect = |
7069 gfx::Rect(0, 0, 50, 50); | 7060 gfx::Rect(0, 0, 50, 50); |
7070 sticky_pos->SetStickyPositionConstraint(sticky_position); | 7061 sticky_pos->SetStickyPositionConstraint(sticky_position); |
7071 | 7062 |
7072 root->SetBounds(gfx::Size(100, 100)); | 7063 root->SetBounds(gfx::Size(100, 100)); |
7073 container->SetBounds(gfx::Size(100, 100)); | 7064 container->SetBounds(gfx::Size(100, 100)); |
7074 scroller->SetBounds(gfx::Size(1000, 1000)); | 7065 scroller->SetBounds(gfx::Size(1000, 1000)); |
7075 sticky_pos->SetBounds(gfx::Size(10, 10)); | 7066 sticky_pos->SetBounds(gfx::Size(10, 10)); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7134 host()->SetRootLayer(root); | 7125 host()->SetRootLayer(root); |
7135 scroller->SetScrollClipLayerId(container->id()); | 7126 scroller->SetScrollClipLayerId(container->id()); |
7136 gfx::Transform t; | 7127 gfx::Transform t; |
7137 t.Scale(2, 2); | 7128 t.Scale(2, 2); |
7138 sticky_container->SetTransform(t); | 7129 sticky_container->SetTransform(t); |
7139 | 7130 |
7140 LayerStickyPositionConstraint sticky_position; | 7131 LayerStickyPositionConstraint sticky_position; |
7141 sticky_position.is_sticky = true; | 7132 sticky_position.is_sticky = true; |
7142 sticky_position.is_anchored_top = true; | 7133 sticky_position.is_anchored_top = true; |
7143 sticky_position.top_offset = 0.0f; | 7134 sticky_position.top_offset = 0.0f; |
7144 sticky_position.parent_relative_sticky_box_offset = gfx::Point(0, 20); | |
7145 sticky_position.scroll_container_relative_sticky_box_rect = | 7135 sticky_position.scroll_container_relative_sticky_box_rect = |
7146 gfx::Rect(0, 20, 10, 10); | 7136 gfx::Rect(0, 20, 10, 10); |
7147 sticky_position.scroll_container_relative_containing_block_rect = | 7137 sticky_position.scroll_container_relative_containing_block_rect = |
7148 gfx::Rect(0, 0, 50, 50); | 7138 gfx::Rect(0, 0, 50, 50); |
7149 sticky_pos->SetStickyPositionConstraint(sticky_position); | 7139 sticky_pos->SetStickyPositionConstraint(sticky_position); |
7150 | 7140 |
7151 root->SetBounds(gfx::Size(100, 100)); | 7141 root->SetBounds(gfx::Size(100, 100)); |
7152 container->SetBounds(gfx::Size(100, 100)); | 7142 container->SetBounds(gfx::Size(100, 100)); |
7153 scroller->SetBounds(gfx::Size(1000, 1000)); | 7143 scroller->SetBounds(gfx::Size(1000, 1000)); |
7154 sticky_container->SetBounds(gfx::Size(50, 50)); | 7144 sticky_container->SetBounds(gfx::Size(50, 50)); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7218 scroller->SetBounds(gfx::Size(100, 1000)); | 7208 scroller->SetBounds(gfx::Size(100, 1000)); |
7219 outer_sticky->SetBounds(gfx::Size(10, 50)); | 7209 outer_sticky->SetBounds(gfx::Size(10, 50)); |
7220 outer_sticky->SetPosition(gfx::PointF(0, 50)); | 7210 outer_sticky->SetPosition(gfx::PointF(0, 50)); |
7221 inner_sticky->SetBounds(gfx::Size(10, 10)); | 7211 inner_sticky->SetBounds(gfx::Size(10, 10)); |
7222 inner_sticky->SetPosition(gfx::PointF(0, 0)); | 7212 inner_sticky->SetPosition(gfx::PointF(0, 0)); |
7223 | 7213 |
7224 LayerStickyPositionConstraint outer_sticky_pos; | 7214 LayerStickyPositionConstraint outer_sticky_pos; |
7225 outer_sticky_pos.is_sticky = true; | 7215 outer_sticky_pos.is_sticky = true; |
7226 outer_sticky_pos.is_anchored_top = true; | 7216 outer_sticky_pos.is_anchored_top = true; |
7227 outer_sticky_pos.top_offset = 10.0f; | 7217 outer_sticky_pos.top_offset = 10.0f; |
7228 outer_sticky_pos.parent_relative_sticky_box_offset = gfx::Point(0, 50); | |
7229 outer_sticky_pos.scroll_container_relative_sticky_box_rect = | 7218 outer_sticky_pos.scroll_container_relative_sticky_box_rect = |
7230 gfx::Rect(0, 50, 10, 50); | 7219 gfx::Rect(0, 50, 10, 50); |
7231 outer_sticky_pos.scroll_container_relative_containing_block_rect = | 7220 outer_sticky_pos.scroll_container_relative_containing_block_rect = |
7232 gfx::Rect(0, 0, 50, 400); | 7221 gfx::Rect(0, 0, 50, 400); |
7233 outer_sticky->SetStickyPositionConstraint(outer_sticky_pos); | 7222 outer_sticky->SetStickyPositionConstraint(outer_sticky_pos); |
7234 | 7223 |
7235 LayerStickyPositionConstraint inner_sticky_pos; | 7224 LayerStickyPositionConstraint inner_sticky_pos; |
7236 inner_sticky_pos.is_sticky = true; | 7225 inner_sticky_pos.is_sticky = true; |
7237 inner_sticky_pos.is_anchored_top = true; | 7226 inner_sticky_pos.is_anchored_top = true; |
7238 inner_sticky_pos.top_offset = 25.0f; | 7227 inner_sticky_pos.top_offset = 25.0f; |
7239 inner_sticky_pos.parent_relative_sticky_box_offset = gfx::Point(0, 0); | |
7240 inner_sticky_pos.scroll_container_relative_sticky_box_rect = | 7228 inner_sticky_pos.scroll_container_relative_sticky_box_rect = |
7241 gfx::Rect(0, 50, 10, 10); | 7229 gfx::Rect(0, 50, 10, 10); |
7242 inner_sticky_pos.scroll_container_relative_containing_block_rect = | 7230 inner_sticky_pos.scroll_container_relative_containing_block_rect = |
7243 gfx::Rect(0, 50, 10, 50); | 7231 gfx::Rect(0, 50, 10, 50); |
7244 inner_sticky_pos.nearest_layer_shifting_containing_block = outer_sticky->id(); | 7232 inner_sticky_pos.nearest_layer_shifting_containing_block = outer_sticky->id(); |
7245 inner_sticky->SetStickyPositionConstraint(inner_sticky_pos); | 7233 inner_sticky->SetStickyPositionConstraint(inner_sticky_pos); |
7246 | 7234 |
7247 ExecuteCalculateDrawProperties(root.get()); | 7235 ExecuteCalculateDrawProperties(root.get()); |
7248 host()->host_impl()->CreatePendingTree(); | 7236 host()->host_impl()->CreatePendingTree(); |
7249 host()->CommitAndCreatePendingTree(); | 7237 host()->CommitAndCreatePendingTree(); |
(...skipping 2968 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10218 | 10206 |
10219 // Check child layer draw properties. | 10207 // Check child layer draw properties. |
10220 EXPECT_EQ(gfx::Rect(10, 10), child->visible_layer_rect()); | 10208 EXPECT_EQ(gfx::Rect(10, 10), child->visible_layer_rect()); |
10221 EXPECT_EQ(gfx::Transform(), child->DrawTransform()); | 10209 EXPECT_EQ(gfx::Transform(), child->DrawTransform()); |
10222 EXPECT_EQ(gfx::Rect(10, 10), child->clip_rect()); | 10210 EXPECT_EQ(gfx::Rect(10, 10), child->clip_rect()); |
10223 EXPECT_EQ(gfx::Rect(10, 10), child->drawable_content_rect()); | 10211 EXPECT_EQ(gfx::Rect(10, 10), child->drawable_content_rect()); |
10224 } | 10212 } |
10225 | 10213 |
10226 } // namespace | 10214 } // namespace |
10227 } // namespace cc | 10215 } // namespace cc |
OLD | NEW |