Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(597)

Side by Side Diff: cc/trees/layer_tree_host_common_unittest.cc

Issue 2911463002: Unify the calculation of main thread offset of sticky element (Closed)
Patch Set: Remove parent_relative_sticky_box_offset related logic Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 6313 matching lines...) Expand 10 before | Expand all | Expand 10 after
6324 root->AddChild(container); 6324 root->AddChild(container);
6325 container->AddChild(scroller); 6325 container->AddChild(scroller);
6326 scroller->AddChild(sticky_pos); 6326 scroller->AddChild(sticky_pos);
6327 host()->SetRootLayer(root); 6327 host()->SetRootLayer(root);
6328 scroller->SetScrollClipLayerId(container->id()); 6328 scroller->SetScrollClipLayerId(container->id());
6329 6329
6330 LayerStickyPositionConstraint sticky_position; 6330 LayerStickyPositionConstraint sticky_position;
6331 sticky_position.is_sticky = true; 6331 sticky_position.is_sticky = true;
6332 sticky_position.is_anchored_top = true; 6332 sticky_position.is_anchored_top = true;
6333 sticky_position.top_offset = 10.0f; 6333 sticky_position.top_offset = 10.0f;
6334 sticky_position.parent_relative_sticky_box_offset = gfx::Point(10, 20);
6335 sticky_position.scroll_container_relative_sticky_box_rect = 6334 sticky_position.scroll_container_relative_sticky_box_rect =
6336 gfx::Rect(10, 20, 10, 10); 6335 gfx::Rect(10, 20, 10, 10);
6337 sticky_position.scroll_container_relative_containing_block_rect = 6336 sticky_position.scroll_container_relative_containing_block_rect =
6338 gfx::Rect(0, 0, 50, 50); 6337 gfx::Rect(0, 0, 50, 50);
6339 sticky_pos->SetStickyPositionConstraint(sticky_position); 6338 sticky_pos->SetStickyPositionConstraint(sticky_position);
6340 6339
6341 root->SetBounds(gfx::Size(100, 100)); 6340 root->SetBounds(gfx::Size(100, 100));
6342 container->SetBounds(gfx::Size(100, 100)); 6341 container->SetBounds(gfx::Size(100, 100));
6343 scroller->SetBounds(gfx::Size(1000, 1000)); 6342 scroller->SetBounds(gfx::Size(1000, 1000));
6344 sticky_pos->SetBounds(gfx::Size(10, 10)); 6343 sticky_pos->SetBounds(gfx::Size(10, 10));
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
6400 host()->SetRootLayer(root); 6399 host()->SetRootLayer(root);
6401 scroller->SetScrollClipLayerId(container->id()); 6400 scroller->SetScrollClipLayerId(container->id());
6402 6401
6403 // The sticky layer has already been scrolled on the main thread side, and has 6402 // The sticky layer has already been scrolled on the main thread side, and has
6404 // stuck. This test then checks that further changes from cc-only scrolling 6403 // stuck. This test then checks that further changes from cc-only scrolling
6405 // are handled correctly. 6404 // are handled correctly.
6406 LayerStickyPositionConstraint sticky_position; 6405 LayerStickyPositionConstraint sticky_position;
6407 sticky_position.is_sticky = true; 6406 sticky_position.is_sticky = true;
6408 sticky_position.is_anchored_top = true; 6407 sticky_position.is_anchored_top = true;
6409 sticky_position.top_offset = 10.0f; 6408 sticky_position.top_offset = 10.0f;
6410 sticky_position.parent_relative_sticky_box_offset = gfx::Point(10, 20);
6411 sticky_position.scroll_container_relative_sticky_box_rect = 6409 sticky_position.scroll_container_relative_sticky_box_rect =
6412 gfx::Rect(10, 20, 10, 10); 6410 gfx::Rect(10, 20, 10, 10);
6413 sticky_position.scroll_container_relative_containing_block_rect = 6411 sticky_position.scroll_container_relative_containing_block_rect =
6414 gfx::Rect(0, 0, 50, 50); 6412 gfx::Rect(0, 0, 50, 50);
6415 sticky_pos->SetStickyPositionConstraint(sticky_position); 6413 sticky_pos->SetStickyPositionConstraint(sticky_position);
6416 6414
6417 root->SetBounds(gfx::Size(200, 200)); 6415 root->SetBounds(gfx::Size(200, 200));
6418 container->SetBounds(gfx::Size(100, 100)); 6416 container->SetBounds(gfx::Size(100, 100));
6419 container->SetPosition(gfx::PointF(50, 50)); 6417 container->SetPosition(gfx::PointF(50, 50));
6420 scroller->SetBounds(gfx::Size(1000, 1000)); 6418 scroller->SetBounds(gfx::Size(1000, 1000));
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
6473 root->AddChild(container); 6471 root->AddChild(container);
6474 container->AddChild(scroller); 6472 container->AddChild(scroller);
6475 scroller->AddChild(sticky_pos); 6473 scroller->AddChild(sticky_pos);
6476 host()->SetRootLayer(root); 6474 host()->SetRootLayer(root);
6477 scroller->SetScrollClipLayerId(container->id()); 6475 scroller->SetScrollClipLayerId(container->id());
6478 6476
6479 LayerStickyPositionConstraint sticky_position; 6477 LayerStickyPositionConstraint sticky_position;
6480 sticky_position.is_sticky = true; 6478 sticky_position.is_sticky = true;
6481 sticky_position.is_anchored_bottom = true; 6479 sticky_position.is_anchored_bottom = true;
6482 sticky_position.bottom_offset = 10.0f; 6480 sticky_position.bottom_offset = 10.0f;
6483 sticky_position.parent_relative_sticky_box_offset = gfx::Point(0, 200);
6484 sticky_position.scroll_container_relative_sticky_box_rect = 6481 sticky_position.scroll_container_relative_sticky_box_rect =
6485 gfx::Rect(0, 200, 10, 10); 6482 gfx::Rect(0, 200, 10, 10);
6486 sticky_position.scroll_container_relative_containing_block_rect = 6483 sticky_position.scroll_container_relative_containing_block_rect =
6487 gfx::Rect(0, 0, 100, 500); 6484 gfx::Rect(0, 0, 100, 500);
6488 sticky_pos->SetStickyPositionConstraint(sticky_position); 6485 sticky_pos->SetStickyPositionConstraint(sticky_position);
6489 6486
6490 root->SetBounds(gfx::Size(100, 100)); 6487 root->SetBounds(gfx::Size(100, 100));
6491 container->SetBounds(gfx::Size(100, 100)); 6488 container->SetBounds(gfx::Size(100, 100));
6492 scroller->SetBounds(gfx::Size(100, 1000)); 6489 scroller->SetBounds(gfx::Size(100, 1000));
6493 sticky_pos->SetBounds(gfx::Size(10, 10)); 6490 sticky_pos->SetBounds(gfx::Size(10, 10));
(...skipping 25 matching lines...) Expand all
6519 root->AddChild(container); 6516 root->AddChild(container);
6520 container->AddChild(scroller); 6517 container->AddChild(scroller);
6521 scroller->AddChild(sticky_pos); 6518 scroller->AddChild(sticky_pos);
6522 host()->SetRootLayer(root); 6519 host()->SetRootLayer(root);
6523 scroller->SetScrollClipLayerId(container->id()); 6520 scroller->SetScrollClipLayerId(container->id());
6524 6521
6525 LayerStickyPositionConstraint sticky_position; 6522 LayerStickyPositionConstraint sticky_position;
6526 sticky_position.is_sticky = true; 6523 sticky_position.is_sticky = true;
6527 sticky_position.is_anchored_bottom = true; 6524 sticky_position.is_anchored_bottom = true;
6528 sticky_position.bottom_offset = 10.0f; 6525 sticky_position.bottom_offset = 10.0f;
6529 sticky_position.parent_relative_sticky_box_offset = gfx::Point(0, 150);
6530 sticky_position.scroll_container_relative_sticky_box_rect = 6526 sticky_position.scroll_container_relative_sticky_box_rect =
6531 gfx::Rect(0, 150, 10, 10); 6527 gfx::Rect(0, 150, 10, 10);
6532 sticky_position.scroll_container_relative_containing_block_rect = 6528 sticky_position.scroll_container_relative_containing_block_rect =
6533 gfx::Rect(0, 100, 50, 50); 6529 gfx::Rect(0, 100, 50, 50);
6534 sticky_pos->SetStickyPositionConstraint(sticky_position); 6530 sticky_pos->SetStickyPositionConstraint(sticky_position);
6535 6531
6536 root->SetBounds(gfx::Size(100, 100)); 6532 root->SetBounds(gfx::Size(100, 100));
6537 container->SetBounds(gfx::Size(100, 100)); 6533 container->SetBounds(gfx::Size(100, 100));
6538 scroller->SetBounds(gfx::Size(1000, 1000)); 6534 scroller->SetBounds(gfx::Size(1000, 1000));
6539 sticky_pos->SetBounds(gfx::Size(10, 10)); 6535 sticky_pos->SetBounds(gfx::Size(10, 10));
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
6592 LayerTreeHost::ViewportLayers viewport_layers; 6588 LayerTreeHost::ViewportLayers viewport_layers;
6593 viewport_layers.page_scale = root; 6589 viewport_layers.page_scale = root;
6594 viewport_layers.inner_viewport_container = root; 6590 viewport_layers.inner_viewport_container = root;
6595 viewport_layers.inner_viewport_scroll = scroller; 6591 viewport_layers.inner_viewport_scroll = scroller;
6596 host()->RegisterViewportLayers(viewport_layers); 6592 host()->RegisterViewportLayers(viewport_layers);
6597 6593
6598 LayerStickyPositionConstraint sticky_position; 6594 LayerStickyPositionConstraint sticky_position;
6599 sticky_position.is_sticky = true; 6595 sticky_position.is_sticky = true;
6600 sticky_position.is_anchored_bottom = true; 6596 sticky_position.is_anchored_bottom = true;
6601 sticky_position.bottom_offset = 10.0f; 6597 sticky_position.bottom_offset = 10.0f;
6602 sticky_position.parent_relative_sticky_box_offset = gfx::Point(0, 70);
6603 sticky_position.scroll_container_relative_sticky_box_rect = 6598 sticky_position.scroll_container_relative_sticky_box_rect =
6604 gfx::Rect(0, 70, 10, 10); 6599 gfx::Rect(0, 70, 10, 10);
6605 sticky_position.scroll_container_relative_containing_block_rect = 6600 sticky_position.scroll_container_relative_containing_block_rect =
6606 gfx::Rect(0, 60, 100, 100); 6601 gfx::Rect(0, 60, 100, 100);
6607 sticky_pos->SetStickyPositionConstraint(sticky_position); 6602 sticky_pos->SetStickyPositionConstraint(sticky_position);
6608 6603
6609 root->SetBounds(gfx::Size(100, 100)); 6604 root->SetBounds(gfx::Size(100, 100));
6610 scroller->SetBounds(gfx::Size(100, 1000)); 6605 scroller->SetBounds(gfx::Size(100, 1000));
6611 sticky_pos->SetBounds(gfx::Size(10, 10)); 6606 sticky_pos->SetBounds(gfx::Size(10, 10));
6612 sticky_pos->SetPosition(gfx::PointF(0, 70)); 6607 sticky_pos->SetPosition(gfx::PointF(0, 70));
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
6671 viewport_layers.inner_viewport_container = root; 6666 viewport_layers.inner_viewport_container = root;
6672 viewport_layers.outer_viewport_container = outer_clip; 6667 viewport_layers.outer_viewport_container = outer_clip;
6673 viewport_layers.inner_viewport_scroll = scroller; 6668 viewport_layers.inner_viewport_scroll = scroller;
6674 viewport_layers.outer_viewport_scroll = outer_viewport; 6669 viewport_layers.outer_viewport_scroll = outer_viewport;
6675 host()->RegisterViewportLayers(viewport_layers); 6670 host()->RegisterViewportLayers(viewport_layers);
6676 6671
6677 LayerStickyPositionConstraint sticky_position; 6672 LayerStickyPositionConstraint sticky_position;
6678 sticky_position.is_sticky = true; 6673 sticky_position.is_sticky = true;
6679 sticky_position.is_anchored_bottom = true; 6674 sticky_position.is_anchored_bottom = true;
6680 sticky_position.bottom_offset = 10.0f; 6675 sticky_position.bottom_offset = 10.0f;
6681 sticky_position.parent_relative_sticky_box_offset = gfx::Point(0, 70);
6682 sticky_position.scroll_container_relative_sticky_box_rect = 6676 sticky_position.scroll_container_relative_sticky_box_rect =
6683 gfx::Rect(0, 70, 10, 10); 6677 gfx::Rect(0, 70, 10, 10);
6684 sticky_position.scroll_container_relative_containing_block_rect = 6678 sticky_position.scroll_container_relative_containing_block_rect =
6685 gfx::Rect(0, 60, 100, 100); 6679 gfx::Rect(0, 60, 100, 100);
6686 sticky_pos->SetStickyPositionConstraint(sticky_position); 6680 sticky_pos->SetStickyPositionConstraint(sticky_position);
6687 6681
6688 root->SetBounds(gfx::Size(100, 100)); 6682 root->SetBounds(gfx::Size(100, 100));
6689 scroller->SetBounds(gfx::Size(100, 1000)); 6683 scroller->SetBounds(gfx::Size(100, 1000));
6690 outer_clip->SetBounds(gfx::Size(100, 100)); 6684 outer_clip->SetBounds(gfx::Size(100, 100));
6691 sticky_pos->SetBounds(gfx::Size(10, 10)); 6685 sticky_pos->SetBounds(gfx::Size(10, 10));
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
6748 scroller->AddChild(sticky_pos); 6742 scroller->AddChild(sticky_pos);
6749 host()->SetRootLayer(root); 6743 host()->SetRootLayer(root);
6750 scroller->SetScrollClipLayerId(container->id()); 6744 scroller->SetScrollClipLayerId(container->id());
6751 6745
6752 LayerStickyPositionConstraint sticky_position; 6746 LayerStickyPositionConstraint sticky_position;
6753 sticky_position.is_sticky = true; 6747 sticky_position.is_sticky = true;
6754 sticky_position.is_anchored_left = true; 6748 sticky_position.is_anchored_left = true;
6755 sticky_position.is_anchored_right = true; 6749 sticky_position.is_anchored_right = true;
6756 sticky_position.left_offset = 10.f; 6750 sticky_position.left_offset = 10.f;
6757 sticky_position.right_offset = 10.f; 6751 sticky_position.right_offset = 10.f;
6758 sticky_position.parent_relative_sticky_box_offset = gfx::Point(145, 0);
6759 sticky_position.scroll_container_relative_sticky_box_rect = 6752 sticky_position.scroll_container_relative_sticky_box_rect =
6760 gfx::Rect(145, 0, 10, 10); 6753 gfx::Rect(145, 0, 10, 10);
6761 sticky_position.scroll_container_relative_containing_block_rect = 6754 sticky_position.scroll_container_relative_containing_block_rect =
6762 gfx::Rect(100, 0, 100, 100); 6755 gfx::Rect(100, 0, 100, 100);
6763 sticky_pos->SetStickyPositionConstraint(sticky_position); 6756 sticky_pos->SetStickyPositionConstraint(sticky_position);
6764 6757
6765 root->SetBounds(gfx::Size(100, 100)); 6758 root->SetBounds(gfx::Size(100, 100));
6766 container->SetBounds(gfx::Size(100, 100)); 6759 container->SetBounds(gfx::Size(100, 100));
6767 scroller->SetBounds(gfx::Size(1000, 1000)); 6760 scroller->SetBounds(gfx::Size(1000, 1000));
6768 sticky_pos->SetBounds(gfx::Size(10, 10)); 6761 sticky_pos->SetBounds(gfx::Size(10, 10));
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
6851 root->AddChild(container); 6844 root->AddChild(container);
6852 container->AddChild(scroller); 6845 container->AddChild(scroller);
6853 scroller->AddChild(sticky_pos); 6846 scroller->AddChild(sticky_pos);
6854 host()->SetRootLayer(root); 6847 host()->SetRootLayer(root);
6855 scroller->SetScrollClipLayerId(container->id()); 6848 scroller->SetScrollClipLayerId(container->id());
6856 6849
6857 LayerStickyPositionConstraint sticky_position; 6850 LayerStickyPositionConstraint sticky_position;
6858 sticky_position.is_sticky = true; 6851 sticky_position.is_sticky = true;
6859 sticky_position.is_anchored_top = true; 6852 sticky_position.is_anchored_top = true;
6860 sticky_position.top_offset = 10.0f; 6853 sticky_position.top_offset = 10.0f;
6861 sticky_position.parent_relative_sticky_box_offset = gfx::Point(10, 20);
6862 sticky_position.scroll_container_relative_sticky_box_rect = 6854 sticky_position.scroll_container_relative_sticky_box_rect =
6863 gfx::Rect(10, 20, 10, 10); 6855 gfx::Rect(10, 20, 10, 10);
6864 sticky_position.scroll_container_relative_containing_block_rect = 6856 sticky_position.scroll_container_relative_containing_block_rect =
6865 gfx::Rect(0, 0, 50, 50); 6857 gfx::Rect(0, 0, 50, 50);
6866 sticky_pos->SetStickyPositionConstraint(sticky_position); 6858 sticky_pos->SetStickyPositionConstraint(sticky_position);
6867 6859
6868 root->SetBounds(gfx::Size(100, 100)); 6860 root->SetBounds(gfx::Size(100, 100));
6869 container->SetBounds(gfx::Size(100, 100)); 6861 container->SetBounds(gfx::Size(100, 100));
6870 scroller->SetBounds(gfx::Size(1000, 1000)); 6862 scroller->SetBounds(gfx::Size(1000, 1000));
6871 sticky_pos->SetBounds(gfx::Size(10, 10)); 6863 sticky_pos->SetBounds(gfx::Size(10, 10));
(...skipping 25 matching lines...) Expand all
6897 // Scroll past the sticking point, the Y coordinate should now be clamped. 6889 // Scroll past the sticking point, the Y coordinate should now be clamped.
6898 SetScrollOffsetDelta(scroller_impl, gfx::Vector2dF(15.f, 15.f)); 6890 SetScrollOffsetDelta(scroller_impl, gfx::Vector2dF(15.f, 15.f));
6899 ExecuteCalculateDrawProperties(root_impl); 6891 ExecuteCalculateDrawProperties(root_impl);
6900 EXPECT_VECTOR2DF_EQ( 6892 EXPECT_VECTOR2DF_EQ(
6901 gfx::Vector2dF(-5.f, 10.f), 6893 gfx::Vector2dF(-5.f, 10.f),
6902 sticky_pos_impl->ScreenSpaceTransform().To2dTranslation()); 6894 sticky_pos_impl->ScreenSpaceTransform().To2dTranslation());
6903 6895
6904 // Now the main thread commits the new position of the sticky element. 6896 // Now the main thread commits the new position of the sticky element.
6905 scroller->SetScrollOffset(gfx::ScrollOffset(15, 15)); 6897 scroller->SetScrollOffset(gfx::ScrollOffset(15, 15));
6906 sticky_pos->SetPosition(gfx::PointF(10, 25)); 6898 sticky_pos->SetPosition(gfx::PointF(10, 25));
6899 sticky_pos->SetStickyMainThreadOffset(gfx::Size(0, 5));
6907 ExecuteCalculateDrawProperties(root.get()); 6900 ExecuteCalculateDrawProperties(root.get());
6908 host()->host_impl()->CreatePendingTree(); 6901 host()->host_impl()->CreatePendingTree();
6909 host()->CommitAndCreatePendingTree(); 6902 host()->CommitAndCreatePendingTree();
6910 host()->host_impl()->ActivateSyncTree(); 6903 host()->host_impl()->ActivateSyncTree();
6911 layer_tree_impl = host()->host_impl()->active_tree(); 6904 layer_tree_impl = host()->host_impl()->active_tree();
6912 root_impl = layer_tree_impl->LayerById(root->id()); 6905 root_impl = layer_tree_impl->LayerById(root->id());
6913 scroller_impl = layer_tree_impl->LayerById(scroller->id()); 6906 scroller_impl = layer_tree_impl->LayerById(scroller->id());
6914 sticky_pos_impl = layer_tree_impl->LayerById(sticky_pos->id()); 6907 sticky_pos_impl = layer_tree_impl->LayerById(sticky_pos->id());
6915 6908
6916 // The element should still be where it was before. We reset the delta to 6909 // The element should still be where it was before. We reset the delta to
(...skipping 26 matching lines...) Expand all
6943 container->AddChild(scroller); 6936 container->AddChild(scroller);
6944 scroller->AddChild(sticky_container); 6937 scroller->AddChild(sticky_container);
6945 sticky_container->AddChild(sticky_pos); 6938 sticky_container->AddChild(sticky_pos);
6946 host()->SetRootLayer(root); 6939 host()->SetRootLayer(root);
6947 scroller->SetScrollClipLayerId(container->id()); 6940 scroller->SetScrollClipLayerId(container->id());
6948 6941
6949 LayerStickyPositionConstraint sticky_position; 6942 LayerStickyPositionConstraint sticky_position;
6950 sticky_position.is_sticky = true; 6943 sticky_position.is_sticky = true;
6951 sticky_position.is_anchored_top = true; 6944 sticky_position.is_anchored_top = true;
6952 sticky_position.top_offset = 10.0f; 6945 sticky_position.top_offset = 10.0f;
6953 // The sticky position layer is only offset by (0, 10) from its parent
6954 // layer, this position is used to determine the offset applied by the main
6955 // thread.
6956 sticky_position.parent_relative_sticky_box_offset = gfx::Point(0, 10);
6957 sticky_position.scroll_container_relative_sticky_box_rect = 6946 sticky_position.scroll_container_relative_sticky_box_rect =
6958 gfx::Rect(20, 30, 10, 10); 6947 gfx::Rect(20, 30, 10, 10);
6959 sticky_position.scroll_container_relative_containing_block_rect = 6948 sticky_position.scroll_container_relative_containing_block_rect =
6960 gfx::Rect(20, 20, 30, 30); 6949 gfx::Rect(20, 20, 30, 30);
6961 sticky_pos->SetStickyPositionConstraint(sticky_position); 6950 sticky_pos->SetStickyPositionConstraint(sticky_position);
6962 6951
6963 root->SetBounds(gfx::Size(100, 100)); 6952 root->SetBounds(gfx::Size(100, 100));
6964 container->SetBounds(gfx::Size(100, 100)); 6953 container->SetBounds(gfx::Size(100, 100));
6965 scroller->SetBounds(gfx::Size(1000, 1000)); 6954 scroller->SetBounds(gfx::Size(1000, 1000));
6966 sticky_container->SetPosition(gfx::PointF(20, 20)); 6955 sticky_container->SetPosition(gfx::PointF(20, 20));
(...skipping 27 matching lines...) Expand all
6994 // Scroll past the sticking point, the Y coordinate should now be clamped. 6983 // Scroll past the sticking point, the Y coordinate should now be clamped.
6995 SetScrollOffsetDelta(scroller_impl, gfx::Vector2dF(0.f, 25.f)); 6984 SetScrollOffsetDelta(scroller_impl, gfx::Vector2dF(0.f, 25.f));
6996 ExecuteCalculateDrawProperties(root_impl); 6985 ExecuteCalculateDrawProperties(root_impl);
6997 EXPECT_VECTOR2DF_EQ( 6986 EXPECT_VECTOR2DF_EQ(
6998 gfx::Vector2dF(20.f, 10.f), 6987 gfx::Vector2dF(20.f, 10.f),
6999 sticky_pos_impl->ScreenSpaceTransform().To2dTranslation()); 6988 sticky_pos_impl->ScreenSpaceTransform().To2dTranslation());
7000 6989
7001 // Now the main thread commits the new position of the sticky element. 6990 // Now the main thread commits the new position of the sticky element.
7002 scroller->SetScrollOffset(gfx::ScrollOffset(0, 25)); 6991 scroller->SetScrollOffset(gfx::ScrollOffset(0, 25));
7003 sticky_pos->SetPosition(gfx::PointF(0, 15)); 6992 sticky_pos->SetPosition(gfx::PointF(0, 15));
6993 sticky_pos->SetStickyMainThreadOffset(gfx::Size(0, 5));
7004 ExecuteCalculateDrawProperties(root.get()); 6994 ExecuteCalculateDrawProperties(root.get());
7005 host()->host_impl()->CreatePendingTree(); 6995 host()->host_impl()->CreatePendingTree();
7006 host()->CommitAndCreatePendingTree(); 6996 host()->CommitAndCreatePendingTree();
7007 host()->host_impl()->ActivateSyncTree(); 6997 host()->host_impl()->ActivateSyncTree();
7008 layer_tree_impl = host()->host_impl()->active_tree(); 6998 layer_tree_impl = host()->host_impl()->active_tree();
7009 root_impl = layer_tree_impl->LayerById(root->id()); 6999 root_impl = layer_tree_impl->LayerById(root->id());
7010 scroller_impl = layer_tree_impl->LayerById(scroller->id()); 7000 scroller_impl = layer_tree_impl->LayerById(scroller->id());
7011 sticky_pos_impl = layer_tree_impl->LayerById(sticky_pos->id()); 7001 sticky_pos_impl = layer_tree_impl->LayerById(sticky_pos->id());
7012 7002
7013 // The element should still be where it was before. We reset the delta to 7003 // 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
7046 host()->SetRootLayer(root); 7036 host()->SetRootLayer(root);
7047 scroller->SetScrollClipLayerId(container->id()); 7037 scroller->SetScrollClipLayerId(container->id());
7048 gfx::Transform t; 7038 gfx::Transform t;
7049 t.Scale(2, 2); 7039 t.Scale(2, 2);
7050 sticky_pos->SetTransform(t); 7040 sticky_pos->SetTransform(t);
7051 7041
7052 LayerStickyPositionConstraint sticky_position; 7042 LayerStickyPositionConstraint sticky_position;
7053 sticky_position.is_sticky = true; 7043 sticky_position.is_sticky = true;
7054 sticky_position.is_anchored_top = true; 7044 sticky_position.is_anchored_top = true;
7055 sticky_position.top_offset = 0.0f; 7045 sticky_position.top_offset = 0.0f;
7056 sticky_position.parent_relative_sticky_box_offset = gfx::Point(0, 20);
7057 sticky_position.scroll_container_relative_sticky_box_rect = 7046 sticky_position.scroll_container_relative_sticky_box_rect =
7058 gfx::Rect(0, 20, 10, 10); 7047 gfx::Rect(0, 20, 10, 10);
7059 sticky_position.scroll_container_relative_containing_block_rect = 7048 sticky_position.scroll_container_relative_containing_block_rect =
7060 gfx::Rect(0, 0, 50, 50); 7049 gfx::Rect(0, 0, 50, 50);
7061 sticky_pos->SetStickyPositionConstraint(sticky_position); 7050 sticky_pos->SetStickyPositionConstraint(sticky_position);
7062 7051
7063 root->SetBounds(gfx::Size(100, 100)); 7052 root->SetBounds(gfx::Size(100, 100));
7064 container->SetBounds(gfx::Size(100, 100)); 7053 container->SetBounds(gfx::Size(100, 100));
7065 scroller->SetBounds(gfx::Size(1000, 1000)); 7054 scroller->SetBounds(gfx::Size(1000, 1000));
7066 sticky_pos->SetBounds(gfx::Size(10, 10)); 7055 sticky_pos->SetBounds(gfx::Size(10, 10));
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
7125 host()->SetRootLayer(root); 7114 host()->SetRootLayer(root);
7126 scroller->SetScrollClipLayerId(container->id()); 7115 scroller->SetScrollClipLayerId(container->id());
7127 gfx::Transform t; 7116 gfx::Transform t;
7128 t.Scale(2, 2); 7117 t.Scale(2, 2);
7129 sticky_container->SetTransform(t); 7118 sticky_container->SetTransform(t);
7130 7119
7131 LayerStickyPositionConstraint sticky_position; 7120 LayerStickyPositionConstraint sticky_position;
7132 sticky_position.is_sticky = true; 7121 sticky_position.is_sticky = true;
7133 sticky_position.is_anchored_top = true; 7122 sticky_position.is_anchored_top = true;
7134 sticky_position.top_offset = 0.0f; 7123 sticky_position.top_offset = 0.0f;
7135 sticky_position.parent_relative_sticky_box_offset = gfx::Point(0, 20);
7136 sticky_position.scroll_container_relative_sticky_box_rect = 7124 sticky_position.scroll_container_relative_sticky_box_rect =
7137 gfx::Rect(0, 20, 10, 10); 7125 gfx::Rect(0, 20, 10, 10);
7138 sticky_position.scroll_container_relative_containing_block_rect = 7126 sticky_position.scroll_container_relative_containing_block_rect =
7139 gfx::Rect(0, 0, 50, 50); 7127 gfx::Rect(0, 0, 50, 50);
7140 sticky_pos->SetStickyPositionConstraint(sticky_position); 7128 sticky_pos->SetStickyPositionConstraint(sticky_position);
7141 7129
7142 root->SetBounds(gfx::Size(100, 100)); 7130 root->SetBounds(gfx::Size(100, 100));
7143 container->SetBounds(gfx::Size(100, 100)); 7131 container->SetBounds(gfx::Size(100, 100));
7144 scroller->SetBounds(gfx::Size(1000, 1000)); 7132 scroller->SetBounds(gfx::Size(1000, 1000));
7145 sticky_container->SetBounds(gfx::Size(50, 50)); 7133 sticky_container->SetBounds(gfx::Size(50, 50));
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
7209 scroller->SetBounds(gfx::Size(100, 1000)); 7197 scroller->SetBounds(gfx::Size(100, 1000));
7210 outer_sticky->SetBounds(gfx::Size(10, 50)); 7198 outer_sticky->SetBounds(gfx::Size(10, 50));
7211 outer_sticky->SetPosition(gfx::PointF(0, 50)); 7199 outer_sticky->SetPosition(gfx::PointF(0, 50));
7212 inner_sticky->SetBounds(gfx::Size(10, 10)); 7200 inner_sticky->SetBounds(gfx::Size(10, 10));
7213 inner_sticky->SetPosition(gfx::PointF(0, 0)); 7201 inner_sticky->SetPosition(gfx::PointF(0, 0));
7214 7202
7215 LayerStickyPositionConstraint outer_sticky_pos; 7203 LayerStickyPositionConstraint outer_sticky_pos;
7216 outer_sticky_pos.is_sticky = true; 7204 outer_sticky_pos.is_sticky = true;
7217 outer_sticky_pos.is_anchored_top = true; 7205 outer_sticky_pos.is_anchored_top = true;
7218 outer_sticky_pos.top_offset = 10.0f; 7206 outer_sticky_pos.top_offset = 10.0f;
7219 outer_sticky_pos.parent_relative_sticky_box_offset = gfx::Point(0, 50);
7220 outer_sticky_pos.scroll_container_relative_sticky_box_rect = 7207 outer_sticky_pos.scroll_container_relative_sticky_box_rect =
7221 gfx::Rect(0, 50, 10, 50); 7208 gfx::Rect(0, 50, 10, 50);
7222 outer_sticky_pos.scroll_container_relative_containing_block_rect = 7209 outer_sticky_pos.scroll_container_relative_containing_block_rect =
7223 gfx::Rect(0, 0, 50, 400); 7210 gfx::Rect(0, 0, 50, 400);
7224 outer_sticky->SetStickyPositionConstraint(outer_sticky_pos); 7211 outer_sticky->SetStickyPositionConstraint(outer_sticky_pos);
7225 7212
7226 LayerStickyPositionConstraint inner_sticky_pos; 7213 LayerStickyPositionConstraint inner_sticky_pos;
7227 inner_sticky_pos.is_sticky = true; 7214 inner_sticky_pos.is_sticky = true;
7228 inner_sticky_pos.is_anchored_top = true; 7215 inner_sticky_pos.is_anchored_top = true;
7229 inner_sticky_pos.top_offset = 25.0f; 7216 inner_sticky_pos.top_offset = 25.0f;
7230 inner_sticky_pos.parent_relative_sticky_box_offset = gfx::Point(0, 0);
7231 inner_sticky_pos.scroll_container_relative_sticky_box_rect = 7217 inner_sticky_pos.scroll_container_relative_sticky_box_rect =
7232 gfx::Rect(0, 50, 10, 10); 7218 gfx::Rect(0, 50, 10, 10);
7233 inner_sticky_pos.scroll_container_relative_containing_block_rect = 7219 inner_sticky_pos.scroll_container_relative_containing_block_rect =
7234 gfx::Rect(0, 50, 10, 50); 7220 gfx::Rect(0, 50, 10, 50);
7235 inner_sticky_pos.nearest_layer_shifting_containing_block = outer_sticky->id(); 7221 inner_sticky_pos.nearest_layer_shifting_containing_block = outer_sticky->id();
7236 inner_sticky->SetStickyPositionConstraint(inner_sticky_pos); 7222 inner_sticky->SetStickyPositionConstraint(inner_sticky_pos);
7237 7223
7238 ExecuteCalculateDrawProperties(root.get()); 7224 ExecuteCalculateDrawProperties(root.get());
7239 host()->host_impl()->CreatePendingTree(); 7225 host()->host_impl()->CreatePendingTree();
7240 host()->CommitAndCreatePendingTree(); 7226 host()->CommitAndCreatePendingTree();
(...skipping 2968 matching lines...) Expand 10 before | Expand all | Expand 10 after
10209 10195
10210 // Check child layer draw properties. 10196 // Check child layer draw properties.
10211 EXPECT_EQ(gfx::Rect(10, 10), child->visible_layer_rect()); 10197 EXPECT_EQ(gfx::Rect(10, 10), child->visible_layer_rect());
10212 EXPECT_EQ(gfx::Transform(), child->DrawTransform()); 10198 EXPECT_EQ(gfx::Transform(), child->DrawTransform());
10213 EXPECT_EQ(gfx::Rect(10, 10), child->clip_rect()); 10199 EXPECT_EQ(gfx::Rect(10, 10), child->clip_rect());
10214 EXPECT_EQ(gfx::Rect(10, 10), child->drawable_content_rect()); 10200 EXPECT_EQ(gfx::Rect(10, 10), child->drawable_content_rect());
10215 } 10201 }
10216 10202
10217 } // namespace 10203 } // namespace
10218 } // namespace cc 10204 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698