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

Unified Diff: third_party/WebKit/Source/core/layout/LayoutBoxModelObjectTest.cpp

Issue 2383113003: Refactor ScrollableArea::setScrollPosition. (Closed)
Patch Set: nits and rebase Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/layout/LayoutBoxModelObjectTest.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutBoxModelObjectTest.cpp b/third_party/WebKit/Source/core/layout/LayoutBoxModelObjectTest.cpp
index d92b3d3f96ef384b9a9186c8989342ac004f3156..3ef9719f0918ead291cf54a18a7ebecbd9600e9d 100644
--- a/third_party/WebKit/Source/core/layout/LayoutBoxModelObjectTest.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutBoxModelObjectTest.cpp
@@ -41,16 +41,17 @@ TEST_F(LayoutBoxModelObjectTest, StickyPositionConstraints) {
"id='sticky'></div></div><div class='spacer'></div></div>");
LayoutBoxModelObject* scroller =
toLayoutBoxModelObject(getLayoutObjectByElementId("scroller"));
- scroller->getScrollableArea()->scrollToYOffset(50);
- ASSERT_EQ(50.0, scroller->getScrollableArea()->scrollYOffset());
+ PaintLayerScrollableArea* scrollableArea = scroller->getScrollableArea();
+ scrollableArea->scrollToOffset(
+ DoubleSize(scrollableArea->adjustedScrollOffset().width(), 50));
+ ASSERT_EQ(50.0, scrollableArea->adjustedScrollOffset().height());
LayoutBoxModelObject* sticky =
toLayoutBoxModelObject(getLayoutObjectByElementId("sticky"));
sticky->updateStickyPositionConstraints();
ASSERT_EQ(scroller->layer(), sticky->layer()->ancestorOverflowLayer());
const StickyPositionScrollingConstraints& constraints =
- scroller->getScrollableArea()->stickyConstraintsMap().get(
- sticky->layer());
+ scrollableArea->stickyConstraintsMap().get(sticky->layer());
ASSERT_EQ(0.f, constraints.topOffset());
// The coordinates of the constraint rects should all be with respect to the unscrolled scroller.
@@ -77,16 +78,17 @@ TEST_F(LayoutBoxModelObjectTest, StickyPositionTransforms) {
"id='sticky'></div></div><div class='spacer'></div></div>");
LayoutBoxModelObject* scroller =
toLayoutBoxModelObject(getLayoutObjectByElementId("scroller"));
- scroller->getScrollableArea()->scrollToYOffset(50);
- ASSERT_EQ(50.0, scroller->getScrollableArea()->scrollYOffset());
+ PaintLayerScrollableArea* scrollableArea = scroller->getScrollableArea();
+ scrollableArea->scrollToOffset(
+ DoubleSize(scrollableArea->adjustedScrollOffset().width(), 50));
+ ASSERT_EQ(50.0, scrollableArea->adjustedScrollOffset().height());
LayoutBoxModelObject* sticky =
toLayoutBoxModelObject(getLayoutObjectByElementId("sticky"));
sticky->updateStickyPositionConstraints();
ASSERT_EQ(scroller->layer(), sticky->layer()->ancestorOverflowLayer());
const StickyPositionScrollingConstraints& constraints =
- scroller->getScrollableArea()->stickyConstraintsMap().get(
- sticky->layer());
+ scrollableArea->stickyConstraintsMap().get(sticky->layer());
ASSERT_EQ(0.f, constraints.topOffset());
// The coordinates of the constraint rects should all be with respect to the unscrolled scroller.
@@ -112,16 +114,17 @@ TEST_F(LayoutBoxModelObjectTest, StickyPositionPercentageStyles) {
"id='sticky'></div></div><div class='spacer'></div></div>");
LayoutBoxModelObject* scroller =
toLayoutBoxModelObject(getLayoutObjectByElementId("scroller"));
- scroller->getScrollableArea()->scrollToYOffset(50);
- ASSERT_EQ(50.0, scroller->getScrollableArea()->scrollYOffset());
+ PaintLayerScrollableArea* scrollableArea = scroller->getScrollableArea();
+ scrollableArea->scrollToOffset(
+ DoubleSize(scrollableArea->adjustedScrollOffset().width(), 50));
+ ASSERT_EQ(50.0, scrollableArea->adjustedScrollOffset().height());
LayoutBoxModelObject* sticky =
toLayoutBoxModelObject(getLayoutObjectByElementId("sticky"));
sticky->updateStickyPositionConstraints();
ASSERT_EQ(scroller->layer(), sticky->layer()->ancestorOverflowLayer());
const StickyPositionScrollingConstraints& constraints =
- scroller->getScrollableArea()->stickyConstraintsMap().get(
- sticky->layer());
+ scrollableArea->stickyConstraintsMap().get(sticky->layer());
ASSERT_EQ(0.f, constraints.topOffset());
ASSERT_EQ(IntRect(25, 145, 200, 330),
@@ -145,16 +148,17 @@ TEST_F(LayoutBoxModelObjectTest, StickyPositionContainerIsScroller) {
"class='spacer'></div></div>");
LayoutBoxModelObject* scroller =
toLayoutBoxModelObject(getLayoutObjectByElementId("scroller"));
- scroller->getScrollableArea()->scrollToYOffset(50);
- ASSERT_EQ(50.0, scroller->getScrollableArea()->scrollYOffset());
+ PaintLayerScrollableArea* scrollableArea = scroller->getScrollableArea();
+ scrollableArea->scrollToOffset(
+ DoubleSize(scrollableArea->adjustedScrollOffset().width(), 50));
+ ASSERT_EQ(50.0, scrollableArea->adjustedScrollOffset().height());
LayoutBoxModelObject* sticky =
toLayoutBoxModelObject(getLayoutObjectByElementId("sticky"));
sticky->updateStickyPositionConstraints();
ASSERT_EQ(scroller->layer(), sticky->layer()->ancestorOverflowLayer());
const StickyPositionScrollingConstraints& constraints =
- scroller->getScrollableArea()->stickyConstraintsMap().get(
- sticky->layer());
+ scrollableArea->stickyConstraintsMap().get(sticky->layer());
ASSERT_EQ(IntRect(0, 0, 400, 1100),
enclosingIntRect(
getScrollContainerRelativeContainingBlockRect(constraints)));
@@ -179,16 +183,17 @@ TEST_F(LayoutBoxModelObjectTest, StickyPositionAnonymousContainer) {
"id='sticky'></div></div><div class='spacer'></div></div>");
LayoutBoxModelObject* scroller =
toLayoutBoxModelObject(getLayoutObjectByElementId("scroller"));
- scroller->getScrollableArea()->scrollToYOffset(50);
- ASSERT_EQ(50.0, scroller->getScrollableArea()->scrollYOffset());
+ PaintLayerScrollableArea* scrollableArea = scroller->getScrollableArea();
+ scrollableArea->scrollToOffset(
+ DoubleSize(scrollableArea->adjustedScrollOffset().width(), 50));
+ ASSERT_EQ(50.0, scrollableArea->adjustedScrollOffset().height());
LayoutBoxModelObject* sticky =
toLayoutBoxModelObject(getLayoutObjectByElementId("sticky"));
sticky->updateStickyPositionConstraints();
ASSERT_EQ(scroller->layer(), sticky->layer()->ancestorOverflowLayer());
const StickyPositionScrollingConstraints& constraints =
- scroller->getScrollableArea()->stickyConstraintsMap().get(
- sticky->layer());
+ scrollableArea->stickyConstraintsMap().get(sticky->layer());
ASSERT_EQ(IntRect(15, 115, 170, 370),
enclosingIntRect(
getScrollContainerRelativeContainingBlockRect(constraints)));
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutBox.cpp ('k') | third_party/WebKit/Source/core/layout/ScrollEnums.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698