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

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutBoxModelObjectTest.cpp

Issue 2387883002: Use float for scroll offset. (Closed)
Patch Set: Fix README.md 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "core/layout/LayoutBoxModelObject.h" 5 #include "core/layout/LayoutBoxModelObject.h"
6 6
7 #include "core/html/HTMLElement.h" 7 #include "core/html/HTMLElement.h"
8 #include "core/layout/ImageQualityController.h" 8 #include "core/layout/ImageQualityController.h"
9 #include "core/layout/LayoutTestHelper.h" 9 #include "core/layout/LayoutTestHelper.h"
10 #include "core/page/scrolling/StickyPositionScrollingConstraints.h" 10 #include "core/page/scrolling/StickyPositionScrollingConstraints.h"
(...skipping 24 matching lines...) Expand all
35 "#container { box-sizing: border-box; position: relative; top: 100px; " 35 "#container { box-sizing: border-box; position: relative; top: 100px; "
36 "height: 400px; width: 200px; padding: 10px; border: 5px solid black; }" 36 "height: 400px; width: 200px; padding: 10px; border: 5px solid black; }"
37 "#scroller { height: 100px; overflow: auto; position: relative; top: " 37 "#scroller { height: 100px; overflow: auto; position: relative; top: "
38 "200px; }" 38 "200px; }"
39 ".spacer { height: 1000px; }</style>" 39 ".spacer { height: 1000px; }</style>"
40 "<div id='scroller'><div id='container'><div " 40 "<div id='scroller'><div id='container'><div "
41 "id='sticky'></div></div><div class='spacer'></div></div>"); 41 "id='sticky'></div></div><div class='spacer'></div></div>");
42 LayoutBoxModelObject* scroller = 42 LayoutBoxModelObject* scroller =
43 toLayoutBoxModelObject(getLayoutObjectByElementId("scroller")); 43 toLayoutBoxModelObject(getLayoutObjectByElementId("scroller"));
44 PaintLayerScrollableArea* scrollableArea = scroller->getScrollableArea(); 44 PaintLayerScrollableArea* scrollableArea = scroller->getScrollableArea();
45 scrollableArea->scrollToOffset( 45 scrollableArea->scrollToAbsolutePosition(
46 DoubleSize(scrollableArea->adjustedScrollOffset().width(), 50)); 46 FloatPoint(scrollableArea->scrollOffsetInt().width(), 50));
47 ASSERT_EQ(50.0, scrollableArea->adjustedScrollOffset().height()); 47 ASSERT_EQ(50.0, scrollableArea->scrollPosition().y());
48 LayoutBoxModelObject* sticky = 48 LayoutBoxModelObject* sticky =
49 toLayoutBoxModelObject(getLayoutObjectByElementId("sticky")); 49 toLayoutBoxModelObject(getLayoutObjectByElementId("sticky"));
50 sticky->updateStickyPositionConstraints(); 50 sticky->updateStickyPositionConstraints();
51 ASSERT_EQ(scroller->layer(), sticky->layer()->ancestorOverflowLayer()); 51 ASSERT_EQ(scroller->layer(), sticky->layer()->ancestorOverflowLayer());
52 52
53 const StickyPositionScrollingConstraints& constraints = 53 const StickyPositionScrollingConstraints& constraints =
54 scrollableArea->stickyConstraintsMap().get(sticky->layer()); 54 scrollableArea->stickyConstraintsMap().get(sticky->layer());
55 ASSERT_EQ(0.f, constraints.topOffset()); 55 ASSERT_EQ(0.f, constraints.topOffset());
56 56
57 // The coordinates of the constraint rects should all be with respect to the u nscrolled scroller. 57 // The coordinates of the constraint rects should all be with respect to the u nscrolled scroller.
(...skipping 14 matching lines...) Expand all
72 "height: 400px; width: 200px; padding: 10px; border: 5px solid black; " 72 "height: 400px; width: 200px; padding: 10px; border: 5px solid black; "
73 "transform: scale(2); transform-origin: top left; }" 73 "transform: scale(2); transform-origin: top left; }"
74 "#scroller { height: 100px; overflow: auto; position: relative; top: " 74 "#scroller { height: 100px; overflow: auto; position: relative; top: "
75 "200px; }" 75 "200px; }"
76 ".spacer { height: 1000px; }</style>" 76 ".spacer { height: 1000px; }</style>"
77 "<div id='scroller'><div id='container'><div " 77 "<div id='scroller'><div id='container'><div "
78 "id='sticky'></div></div><div class='spacer'></div></div>"); 78 "id='sticky'></div></div><div class='spacer'></div></div>");
79 LayoutBoxModelObject* scroller = 79 LayoutBoxModelObject* scroller =
80 toLayoutBoxModelObject(getLayoutObjectByElementId("scroller")); 80 toLayoutBoxModelObject(getLayoutObjectByElementId("scroller"));
81 PaintLayerScrollableArea* scrollableArea = scroller->getScrollableArea(); 81 PaintLayerScrollableArea* scrollableArea = scroller->getScrollableArea();
82 scrollableArea->scrollToOffset( 82 scrollableArea->scrollToAbsolutePosition(
83 DoubleSize(scrollableArea->adjustedScrollOffset().width(), 50)); 83 FloatPoint(scrollableArea->scrollOffsetInt().width(), 50));
84 ASSERT_EQ(50.0, scrollableArea->adjustedScrollOffset().height()); 84 ASSERT_EQ(50.0, scrollableArea->scrollPosition().y());
85 LayoutBoxModelObject* sticky = 85 LayoutBoxModelObject* sticky =
86 toLayoutBoxModelObject(getLayoutObjectByElementId("sticky")); 86 toLayoutBoxModelObject(getLayoutObjectByElementId("sticky"));
87 sticky->updateStickyPositionConstraints(); 87 sticky->updateStickyPositionConstraints();
88 ASSERT_EQ(scroller->layer(), sticky->layer()->ancestorOverflowLayer()); 88 ASSERT_EQ(scroller->layer(), sticky->layer()->ancestorOverflowLayer());
89 89
90 const StickyPositionScrollingConstraints& constraints = 90 const StickyPositionScrollingConstraints& constraints =
91 scrollableArea->stickyConstraintsMap().get(sticky->layer()); 91 scrollableArea->stickyConstraintsMap().get(sticky->layer());
92 ASSERT_EQ(0.f, constraints.topOffset()); 92 ASSERT_EQ(0.f, constraints.topOffset());
93 93
94 // The coordinates of the constraint rects should all be with respect to the u nscrolled scroller. 94 // The coordinates of the constraint rects should all be with respect to the u nscrolled scroller.
(...skipping 13 matching lines...) Expand all
108 "#container { box-sizing: border-box; position: relative; top: 100px; " 108 "#container { box-sizing: border-box; position: relative; top: 100px; "
109 "height: 400px; width: 250px; padding: 5%; border: 5px solid black; }" 109 "height: 400px; width: 250px; padding: 5%; border: 5px solid black; }"
110 "#scroller { width: 400px; height: 100px; overflow: auto; position: " 110 "#scroller { width: 400px; height: 100px; overflow: auto; position: "
111 "relative; top: 200px; }" 111 "relative; top: 200px; }"
112 ".spacer { height: 1000px; }</style>" 112 ".spacer { height: 1000px; }</style>"
113 "<div id='scroller'><div id='container'><div " 113 "<div id='scroller'><div id='container'><div "
114 "id='sticky'></div></div><div class='spacer'></div></div>"); 114 "id='sticky'></div></div><div class='spacer'></div></div>");
115 LayoutBoxModelObject* scroller = 115 LayoutBoxModelObject* scroller =
116 toLayoutBoxModelObject(getLayoutObjectByElementId("scroller")); 116 toLayoutBoxModelObject(getLayoutObjectByElementId("scroller"));
117 PaintLayerScrollableArea* scrollableArea = scroller->getScrollableArea(); 117 PaintLayerScrollableArea* scrollableArea = scroller->getScrollableArea();
118 scrollableArea->scrollToOffset( 118 scrollableArea->scrollToAbsolutePosition(
119 DoubleSize(scrollableArea->adjustedScrollOffset().width(), 50)); 119 FloatPoint(scrollableArea->scrollPosition().x(), 50));
120 ASSERT_EQ(50.0, scrollableArea->adjustedScrollOffset().height()); 120 ASSERT_EQ(50.0, scrollableArea->scrollPosition().y());
121 LayoutBoxModelObject* sticky = 121 LayoutBoxModelObject* sticky =
122 toLayoutBoxModelObject(getLayoutObjectByElementId("sticky")); 122 toLayoutBoxModelObject(getLayoutObjectByElementId("sticky"));
123 sticky->updateStickyPositionConstraints(); 123 sticky->updateStickyPositionConstraints();
124 ASSERT_EQ(scroller->layer(), sticky->layer()->ancestorOverflowLayer()); 124 ASSERT_EQ(scroller->layer(), sticky->layer()->ancestorOverflowLayer());
125 125
126 const StickyPositionScrollingConstraints& constraints = 126 const StickyPositionScrollingConstraints& constraints =
127 scrollableArea->stickyConstraintsMap().get(sticky->layer()); 127 scrollableArea->stickyConstraintsMap().get(sticky->layer());
128 ASSERT_EQ(0.f, constraints.topOffset()); 128 ASSERT_EQ(0.f, constraints.topOffset());
129 129
130 ASSERT_EQ(IntRect(25, 145, 200, 330), 130 ASSERT_EQ(IntRect(25, 145, 200, 330),
(...skipping 11 matching lines...) Expand all
142 "<style>#sticky { position: sticky; top: 0; width: 100px; height: 100px; " 142 "<style>#sticky { position: sticky; top: 0; width: 100px; height: 100px; "
143 "}" 143 "}"
144 "#scroller { height: 100px; width: 400px; overflow: auto; position: " 144 "#scroller { height: 100px; width: 400px; overflow: auto; position: "
145 "relative; top: 200px; }" 145 "relative; top: 200px; }"
146 ".spacer { height: 1000px; }</style>" 146 ".spacer { height: 1000px; }</style>"
147 "<div id='scroller'><div id='sticky'></div><div " 147 "<div id='scroller'><div id='sticky'></div><div "
148 "class='spacer'></div></div>"); 148 "class='spacer'></div></div>");
149 LayoutBoxModelObject* scroller = 149 LayoutBoxModelObject* scroller =
150 toLayoutBoxModelObject(getLayoutObjectByElementId("scroller")); 150 toLayoutBoxModelObject(getLayoutObjectByElementId("scroller"));
151 PaintLayerScrollableArea* scrollableArea = scroller->getScrollableArea(); 151 PaintLayerScrollableArea* scrollableArea = scroller->getScrollableArea();
152 scrollableArea->scrollToOffset( 152 scrollableArea->scrollToAbsolutePosition(
153 DoubleSize(scrollableArea->adjustedScrollOffset().width(), 50)); 153 FloatPoint(scrollableArea->scrollPosition().x(), 50));
154 ASSERT_EQ(50.0, scrollableArea->adjustedScrollOffset().height()); 154 ASSERT_EQ(50.0, scrollableArea->scrollPosition().y());
155 LayoutBoxModelObject* sticky = 155 LayoutBoxModelObject* sticky =
156 toLayoutBoxModelObject(getLayoutObjectByElementId("sticky")); 156 toLayoutBoxModelObject(getLayoutObjectByElementId("sticky"));
157 sticky->updateStickyPositionConstraints(); 157 sticky->updateStickyPositionConstraints();
158 ASSERT_EQ(scroller->layer(), sticky->layer()->ancestorOverflowLayer()); 158 ASSERT_EQ(scroller->layer(), sticky->layer()->ancestorOverflowLayer());
159 159
160 const StickyPositionScrollingConstraints& constraints = 160 const StickyPositionScrollingConstraints& constraints =
161 scrollableArea->stickyConstraintsMap().get(sticky->layer()); 161 scrollableArea->stickyConstraintsMap().get(sticky->layer());
162 ASSERT_EQ(IntRect(0, 0, 400, 1100), 162 ASSERT_EQ(IntRect(0, 0, 400, 1100),
163 enclosingIntRect( 163 enclosingIntRect(
164 getScrollContainerRelativeContainingBlockRect(constraints))); 164 getScrollContainerRelativeContainingBlockRect(constraints)));
(...skipping 12 matching lines...) Expand all
177 "height: 400px; width: 200px; padding: 10px; border: 5px solid black; }" 177 "height: 400px; width: 200px; padding: 10px; border: 5px solid black; }"
178 "#scroller { height: 100px; overflow: auto; position: relative; top: " 178 "#scroller { height: 100px; overflow: auto; position: relative; top: "
179 "200px; }" 179 "200px; }"
180 ".header { height: 50px; }" 180 ".header { height: 50px; }"
181 ".spacer { height: 1000px; }</style>" 181 ".spacer { height: 1000px; }</style>"
182 "<div id='scroller'><div id='container'><div class='header'></div><div " 182 "<div id='scroller'><div id='container'><div class='header'></div><div "
183 "id='sticky'></div></div><div class='spacer'></div></div>"); 183 "id='sticky'></div></div><div class='spacer'></div></div>");
184 LayoutBoxModelObject* scroller = 184 LayoutBoxModelObject* scroller =
185 toLayoutBoxModelObject(getLayoutObjectByElementId("scroller")); 185 toLayoutBoxModelObject(getLayoutObjectByElementId("scroller"));
186 PaintLayerScrollableArea* scrollableArea = scroller->getScrollableArea(); 186 PaintLayerScrollableArea* scrollableArea = scroller->getScrollableArea();
187 scrollableArea->scrollToOffset( 187 scrollableArea->scrollToAbsolutePosition(
188 DoubleSize(scrollableArea->adjustedScrollOffset().width(), 50)); 188 FloatPoint(scrollableArea->scrollPosition().x(), 50));
189 ASSERT_EQ(50.0, scrollableArea->adjustedScrollOffset().height()); 189 ASSERT_EQ(50.0, scrollableArea->scrollPosition().y());
190 LayoutBoxModelObject* sticky = 190 LayoutBoxModelObject* sticky =
191 toLayoutBoxModelObject(getLayoutObjectByElementId("sticky")); 191 toLayoutBoxModelObject(getLayoutObjectByElementId("sticky"));
192 sticky->updateStickyPositionConstraints(); 192 sticky->updateStickyPositionConstraints();
193 ASSERT_EQ(scroller->layer(), sticky->layer()->ancestorOverflowLayer()); 193 ASSERT_EQ(scroller->layer(), sticky->layer()->ancestorOverflowLayer());
194 194
195 const StickyPositionScrollingConstraints& constraints = 195 const StickyPositionScrollingConstraints& constraints =
196 scrollableArea->stickyConstraintsMap().get(sticky->layer()); 196 scrollableArea->stickyConstraintsMap().get(sticky->layer());
197 ASSERT_EQ(IntRect(15, 115, 170, 370), 197 ASSERT_EQ(IntRect(15, 115, 170, 370),
198 enclosingIntRect( 198 enclosingIntRect(
199 getScrollContainerRelativeContainingBlockRect(constraints))); 199 getScrollContainerRelativeContainingBlockRect(constraints)));
200 ASSERT_EQ( 200 ASSERT_EQ(
201 IntRect(15, 165, 100, 100), 201 IntRect(15, 165, 100, 100),
202 enclosingIntRect(getScrollContainerRelativeStickyBoxRect(constraints))); 202 enclosingIntRect(getScrollContainerRelativeStickyBoxRect(constraints)));
203 } 203 }
204 } // namespace blink 204 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698