| OLD | NEW |
| 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 Loading... |
| 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->scrollToOffsetFromOrigin( | 45 scrollableArea->scrollToAbsolutePosition( |
| 46 DoubleSize(scrollableArea->offsetFromOrigin().width(), 50)); | 46 FloatPoint(scrollableArea->scrollOffsetInt().width(), 50)); |
| 47 ASSERT_EQ(50.0, scrollableArea->offsetFromOrigin().height()); | 47 ASSERT_EQ(50.0, scrollableArea->absolutePosition().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 13 matching lines...) Expand all Loading... |
| 71 "#container { box-sizing: border-box; position: relative; top: 100px; " | 71 "#container { box-sizing: border-box; position: relative; top: 100px; " |
| 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 DoubleSize newOffset( | 81 PaintLayerScrollableArea* scrollableArea = scroller->getScrollableArea(); |
| 82 scroller->getScrollableArea()->offsetFromOrigin().width(), 50); | 82 scrollableArea->scrollToAbsolutePosition( |
| 83 scroller->getScrollableArea()->scrollToOffsetFromOrigin(newOffset); | 83 FloatPoint(scrollableArea->scrollOffsetInt().width(), 50)); |
| 84 ASSERT_EQ(50.0, scroller->getScrollableArea()->offsetFromOrigin().height()); | 84 ASSERT_EQ(50.0, scrollableArea->absolutePosition().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 scroller->getScrollableArea()->stickyConstraintsMap().get( | 91 scroller->getScrollableArea()->stickyConstraintsMap().get( |
| 92 sticky->layer()); | 92 sticky->layer()); |
| 93 ASSERT_EQ(0.f, constraints.topOffset()); | 93 ASSERT_EQ(0.f, constraints.topOffset()); |
| 94 | 94 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 109 "#container { box-sizing: border-box; position: relative; top: 100px; " | 109 "#container { box-sizing: border-box; position: relative; top: 100px; " |
| 110 "height: 400px; width: 250px; padding: 5%; border: 5px solid black; }" | 110 "height: 400px; width: 250px; padding: 5%; border: 5px solid black; }" |
| 111 "#scroller { width: 400px; height: 100px; overflow: auto; position: " | 111 "#scroller { width: 400px; height: 100px; overflow: auto; position: " |
| 112 "relative; top: 200px; }" | 112 "relative; top: 200px; }" |
| 113 ".spacer { height: 1000px; }</style>" | 113 ".spacer { height: 1000px; }</style>" |
| 114 "<div id='scroller'><div id='container'><div " | 114 "<div id='scroller'><div id='container'><div " |
| 115 "id='sticky'></div></div><div class='spacer'></div></div>"); | 115 "id='sticky'></div></div><div class='spacer'></div></div>"); |
| 116 LayoutBoxModelObject* scroller = | 116 LayoutBoxModelObject* scroller = |
| 117 toLayoutBoxModelObject(getLayoutObjectByElementId("scroller")); | 117 toLayoutBoxModelObject(getLayoutObjectByElementId("scroller")); |
| 118 PaintLayerScrollableArea* scrollableArea = scroller->getScrollableArea(); | 118 PaintLayerScrollableArea* scrollableArea = scroller->getScrollableArea(); |
| 119 scrollableArea->scrollToOffsetFromOrigin( | 119 scrollableArea->scrollToAbsolutePosition( |
| 120 DoubleSize(scrollableArea->offsetFromOrigin().width(), 50)); | 120 FloatPoint(scrollableArea->absolutePosition().x(), 50)); |
| 121 ASSERT_EQ(50.0, scrollableArea->offsetFromOrigin().height()); | 121 ASSERT_EQ(50.0, scrollableArea->absolutePosition().y()); |
| 122 LayoutBoxModelObject* sticky = | 122 LayoutBoxModelObject* sticky = |
| 123 toLayoutBoxModelObject(getLayoutObjectByElementId("sticky")); | 123 toLayoutBoxModelObject(getLayoutObjectByElementId("sticky")); |
| 124 sticky->updateStickyPositionConstraints(); | 124 sticky->updateStickyPositionConstraints(); |
| 125 ASSERT_EQ(scroller->layer(), sticky->layer()->ancestorOverflowLayer()); | 125 ASSERT_EQ(scroller->layer(), sticky->layer()->ancestorOverflowLayer()); |
| 126 | 126 |
| 127 const StickyPositionScrollingConstraints& constraints = | 127 const StickyPositionScrollingConstraints& constraints = |
| 128 scrollableArea->stickyConstraintsMap().get(sticky->layer()); | 128 scrollableArea->stickyConstraintsMap().get(sticky->layer()); |
| 129 ASSERT_EQ(0.f, constraints.topOffset()); | 129 ASSERT_EQ(0.f, constraints.topOffset()); |
| 130 | 130 |
| 131 ASSERT_EQ(IntRect(25, 145, 200, 330), | 131 ASSERT_EQ(IntRect(25, 145, 200, 330), |
| (...skipping 11 matching lines...) Expand all Loading... |
| 143 "<style>#sticky { position: sticky; top: 0; width: 100px; height: 100px; " | 143 "<style>#sticky { position: sticky; top: 0; width: 100px; height: 100px; " |
| 144 "}" | 144 "}" |
| 145 "#scroller { height: 100px; width: 400px; overflow: auto; position: " | 145 "#scroller { height: 100px; width: 400px; overflow: auto; position: " |
| 146 "relative; top: 200px; }" | 146 "relative; top: 200px; }" |
| 147 ".spacer { height: 1000px; }</style>" | 147 ".spacer { height: 1000px; }</style>" |
| 148 "<div id='scroller'><div id='sticky'></div><div " | 148 "<div id='scroller'><div id='sticky'></div><div " |
| 149 "class='spacer'></div></div>"); | 149 "class='spacer'></div></div>"); |
| 150 LayoutBoxModelObject* scroller = | 150 LayoutBoxModelObject* scroller = |
| 151 toLayoutBoxModelObject(getLayoutObjectByElementId("scroller")); | 151 toLayoutBoxModelObject(getLayoutObjectByElementId("scroller")); |
| 152 PaintLayerScrollableArea* scrollableArea = scroller->getScrollableArea(); | 152 PaintLayerScrollableArea* scrollableArea = scroller->getScrollableArea(); |
| 153 scrollableArea->scrollToOffsetFromOrigin( | 153 scrollableArea->scrollToAbsolutePosition( |
| 154 DoubleSize(scrollableArea->offsetFromOrigin().width(), 50)); | 154 FloatPoint(scrollableArea->absolutePosition().x(), 50)); |
| 155 ASSERT_EQ(50.0, scrollableArea->offsetFromOrigin().height()); | 155 ASSERT_EQ(50.0, scrollableArea->absolutePosition().y()); |
| 156 LayoutBoxModelObject* sticky = | 156 LayoutBoxModelObject* sticky = |
| 157 toLayoutBoxModelObject(getLayoutObjectByElementId("sticky")); | 157 toLayoutBoxModelObject(getLayoutObjectByElementId("sticky")); |
| 158 sticky->updateStickyPositionConstraints(); | 158 sticky->updateStickyPositionConstraints(); |
| 159 ASSERT_EQ(scroller->layer(), sticky->layer()->ancestorOverflowLayer()); | 159 ASSERT_EQ(scroller->layer(), sticky->layer()->ancestorOverflowLayer()); |
| 160 | 160 |
| 161 const StickyPositionScrollingConstraints& constraints = | 161 const StickyPositionScrollingConstraints& constraints = |
| 162 scrollableArea->stickyConstraintsMap().get(sticky->layer()); | 162 scrollableArea->stickyConstraintsMap().get(sticky->layer()); |
| 163 ASSERT_EQ(IntRect(0, 0, 400, 1100), | 163 ASSERT_EQ(IntRect(0, 0, 400, 1100), |
| 164 enclosingIntRect( | 164 enclosingIntRect( |
| 165 getScrollContainerRelativeContainingBlockRect(constraints))); | 165 getScrollContainerRelativeContainingBlockRect(constraints))); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 178 "height: 400px; width: 200px; padding: 10px; border: 5px solid black; }" | 178 "height: 400px; width: 200px; padding: 10px; border: 5px solid black; }" |
| 179 "#scroller { height: 100px; overflow: auto; position: relative; top: " | 179 "#scroller { height: 100px; overflow: auto; position: relative; top: " |
| 180 "200px; }" | 180 "200px; }" |
| 181 ".header { height: 50px; }" | 181 ".header { height: 50px; }" |
| 182 ".spacer { height: 1000px; }</style>" | 182 ".spacer { height: 1000px; }</style>" |
| 183 "<div id='scroller'><div id='container'><div class='header'></div><div " | 183 "<div id='scroller'><div id='container'><div class='header'></div><div " |
| 184 "id='sticky'></div></div><div class='spacer'></div></div>"); | 184 "id='sticky'></div></div><div class='spacer'></div></div>"); |
| 185 LayoutBoxModelObject* scroller = | 185 LayoutBoxModelObject* scroller = |
| 186 toLayoutBoxModelObject(getLayoutObjectByElementId("scroller")); | 186 toLayoutBoxModelObject(getLayoutObjectByElementId("scroller")); |
| 187 PaintLayerScrollableArea* scrollableArea = scroller->getScrollableArea(); | 187 PaintLayerScrollableArea* scrollableArea = scroller->getScrollableArea(); |
| 188 scrollableArea->scrollToOffsetFromOrigin( | 188 scrollableArea->scrollToAbsolutePosition( |
| 189 DoubleSize(scrollableArea->offsetFromOrigin().width(), 50)); | 189 FloatPoint(scrollableArea->absolutePosition().x(), 50)); |
| 190 ASSERT_EQ(50.0, scrollableArea->offsetFromOrigin().height()); | 190 ASSERT_EQ(50.0, scrollableArea->absolutePosition().y()); |
| 191 LayoutBoxModelObject* sticky = | 191 LayoutBoxModelObject* sticky = |
| 192 toLayoutBoxModelObject(getLayoutObjectByElementId("sticky")); | 192 toLayoutBoxModelObject(getLayoutObjectByElementId("sticky")); |
| 193 sticky->updateStickyPositionConstraints(); | 193 sticky->updateStickyPositionConstraints(); |
| 194 ASSERT_EQ(scroller->layer(), sticky->layer()->ancestorOverflowLayer()); | 194 ASSERT_EQ(scroller->layer(), sticky->layer()->ancestorOverflowLayer()); |
| 195 | 195 |
| 196 const StickyPositionScrollingConstraints& constraints = | 196 const StickyPositionScrollingConstraints& constraints = |
| 197 scrollableArea->stickyConstraintsMap().get(sticky->layer()); | 197 scrollableArea->stickyConstraintsMap().get(sticky->layer()); |
| 198 ASSERT_EQ(IntRect(15, 115, 170, 370), | 198 ASSERT_EQ(IntRect(15, 115, 170, 370), |
| 199 enclosingIntRect( | 199 enclosingIntRect( |
| 200 getScrollContainerRelativeContainingBlockRect(constraints))); | 200 getScrollContainerRelativeContainingBlockRect(constraints))); |
| 201 ASSERT_EQ( | 201 ASSERT_EQ( |
| 202 IntRect(15, 165, 100, 100), | 202 IntRect(15, 165, 100, 100), |
| 203 enclosingIntRect(getScrollContainerRelativeStickyBoxRect(constraints))); | 203 enclosingIntRect(getScrollContainerRelativeStickyBoxRect(constraints))); |
| 204 } | 204 } |
| 205 } // namespace blink | 205 } // namespace blink |
| OLD | NEW |