OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/frame/RootFrameViewport.h" | 5 #include "core/frame/RootFrameViewport.h" |
6 | 6 |
7 #include "core/layout/ScrollAlignment.h" | 7 #include "core/layout/ScrollAlignment.h" |
8 #include "platform/geometry/DoubleRect.h" | 8 #include "platform/geometry/DoubleRect.h" |
9 #include "platform/geometry/LayoutRect.h" | 9 #include "platform/geometry/LayoutRect.h" |
10 #include "platform/scroll/ScrollableArea.h" | 10 #include "platform/scroll/ScrollableArea.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 | 35 |
36 void setViewportSize(const IntSize& viewportSize) { | 36 void setViewportSize(const IntSize& viewportSize) { |
37 m_viewportSize = viewportSize; | 37 m_viewportSize = viewportSize; |
38 } | 38 } |
39 | 39 |
40 IntSize viewportSize() const { return m_viewportSize; } | 40 IntSize viewportSize() const { return m_viewportSize; } |
41 | 41 |
42 // ScrollableArea Impl | 42 // ScrollableArea Impl |
43 int scrollSize(ScrollbarOrientation orientation) const override { | 43 int scrollSize(ScrollbarOrientation orientation) const override { |
44 IntSize scrollDimensions = | 44 IntSize scrollDimensions = |
45 maximumScrollPosition() - minimumScrollPosition(); | 45 maximumScrollOffsetInt() - minimumScrollOffsetInt(); |
| 46 |
46 return (orientation == HorizontalScrollbar) ? scrollDimensions.width() | 47 return (orientation == HorizontalScrollbar) ? scrollDimensions.width() |
47 : scrollDimensions.height(); | 48 : scrollDimensions.height(); |
48 } | 49 } |
49 | 50 |
50 void setUserInputScrollable(bool x, bool y) { | 51 void setUserInputScrollable(bool x, bool y) { |
51 m_userInputScrollableX = x; | 52 m_userInputScrollableX = x; |
52 m_userInputScrollableY = y; | 53 m_userInputScrollableY = y; |
53 } | 54 } |
54 | 55 |
55 IntPoint scrollPosition() const override { | 56 IntSize scrollOffsetInt() const override { |
56 return flooredIntPoint(m_scrollPosition); | 57 return flooredIntSize(m_scrollOffset); |
57 } | 58 } |
58 DoublePoint scrollPositionDouble() const override { return m_scrollPosition; } | 59 ScrollOffset scrollOffset() const override { return m_scrollOffset; } |
59 IntPoint minimumScrollPosition() const override { return IntPoint(); } | 60 IntSize minimumScrollOffsetInt() const override { return IntSize(); } |
60 DoublePoint minimumScrollPositionDouble() const override { | 61 ScrollOffset minimumScrollOffset() const override { return ScrollOffset(); } |
61 return DoublePoint(); | 62 IntSize maximumScrollOffsetInt() const override { |
62 } | 63 return flooredIntSize(maximumScrollOffset()); |
63 IntPoint maximumScrollPosition() const override { | |
64 return flooredIntPoint(maximumScrollPositionDouble()); | |
65 } | 64 } |
66 | 65 |
67 IntSize contentsSize() const override { return m_contentsSize; } | 66 IntSize contentsSize() const override { return m_contentsSize; } |
68 void setContentSize(const IntSize& contentsSize) { | 67 void setContentSize(const IntSize& contentsSize) { |
69 m_contentsSize = contentsSize; | 68 m_contentsSize = contentsSize; |
70 } | 69 } |
71 | 70 |
72 DEFINE_INLINE_VIRTUAL_TRACE() { ScrollableArea::trace(visitor); } | 71 DEFINE_INLINE_VIRTUAL_TRACE() { ScrollableArea::trace(visitor); } |
73 | 72 |
74 protected: | 73 protected: |
75 ScrollableAreaStub(const IntSize& viewportSize, const IntSize& contentsSize) | 74 ScrollableAreaStub(const IntSize& viewportSize, const IntSize& contentsSize) |
76 : m_userInputScrollableX(true), | 75 : m_userInputScrollableX(true), |
77 m_userInputScrollableY(true), | 76 m_userInputScrollableY(true), |
78 m_viewportSize(viewportSize), | 77 m_viewportSize(viewportSize), |
79 m_contentsSize(contentsSize) {} | 78 m_contentsSize(contentsSize) {} |
80 | 79 |
81 void setScrollOffset(const DoublePoint& offset, ScrollType) override { | 80 void updateScrollOffset(const ScrollOffset& offset, ScrollType) override { |
82 m_scrollPosition = offset; | 81 m_scrollOffset = offset; |
83 } | 82 } |
84 bool shouldUseIntegerScrollOffset() const override { return true; } | 83 bool shouldUseIntegerScrollOffset() const override { return true; } |
85 LayoutRect visualRectForScrollbarParts() const override { | 84 LayoutRect visualRectForScrollbarParts() const override { |
86 ASSERT_NOT_REACHED(); | 85 ASSERT_NOT_REACHED(); |
87 return LayoutRect(); | 86 return LayoutRect(); |
88 } | 87 } |
89 bool isActive() const override { return true; } | 88 bool isActive() const override { return true; } |
90 bool isScrollCornerVisible() const override { return true; } | 89 bool isScrollCornerVisible() const override { return true; } |
91 IntRect scrollCornerRect() const override { return IntRect(); } | 90 IntRect scrollCornerRect() const override { return IntRect(); } |
92 bool scrollbarsCanBeActive() const override { return true; } | 91 bool scrollbarsCanBeActive() const override { return true; } |
93 IntRect scrollableAreaBoundingBox() const override { return IntRect(); } | 92 IntRect scrollableAreaBoundingBox() const override { return IntRect(); } |
94 bool shouldPlaceVerticalScrollbarOnLeft() const override { return true; } | 93 bool shouldPlaceVerticalScrollbarOnLeft() const override { return true; } |
95 void scrollControlWasSetNeedsPaintInvalidation() override {} | 94 void scrollControlWasSetNeedsPaintInvalidation() override {} |
96 GraphicsLayer* layerForContainer() const override { return nullptr; } | 95 GraphicsLayer* layerForContainer() const override { return nullptr; } |
97 GraphicsLayer* layerForScrolling() const override { return nullptr; } | 96 GraphicsLayer* layerForScrolling() const override { return nullptr; } |
98 GraphicsLayer* layerForHorizontalScrollbar() const override { | 97 GraphicsLayer* layerForHorizontalScrollbar() const override { |
99 return nullptr; | 98 return nullptr; |
100 } | 99 } |
101 GraphicsLayer* layerForVerticalScrollbar() const override { return nullptr; } | 100 GraphicsLayer* layerForVerticalScrollbar() const override { return nullptr; } |
102 bool userInputScrollable(ScrollbarOrientation orientation) const override { | 101 bool userInputScrollable(ScrollbarOrientation orientation) const override { |
103 return orientation == HorizontalScrollbar ? m_userInputScrollableX | 102 return orientation == HorizontalScrollbar ? m_userInputScrollableX |
104 : m_userInputScrollableY; | 103 : m_userInputScrollableY; |
105 } | 104 } |
106 | 105 |
107 DoublePoint clampedScrollOffset(const DoublePoint& offset) { | 106 ScrollOffset clampedScrollOffset(const ScrollOffset& offset) { |
108 DoublePoint clampedOffset(offset); | 107 ScrollOffset minOffset = minimumScrollOffset(); |
109 clampedOffset = | 108 ScrollOffset maxOffset = maximumScrollOffset(); |
110 clampedOffset.shrunkTo(FloatPoint(maximumScrollPositionDouble())); | 109 float width = std::min(std::max(offset.width(), minOffset.width()), |
111 clampedOffset = | 110 maxOffset.width()); |
112 clampedOffset.expandedTo(FloatPoint(minimumScrollPositionDouble())); | 111 float height = std::min(std::max(offset.height(), minOffset.height()), |
113 return clampedOffset; | 112 maxOffset.height()); |
| 113 return ScrollOffset(width, height); |
114 } | 114 } |
115 | 115 |
116 bool m_userInputScrollableX; | 116 bool m_userInputScrollableX; |
117 bool m_userInputScrollableY; | 117 bool m_userInputScrollableY; |
118 DoublePoint m_scrollPosition; | 118 ScrollOffset m_scrollOffset; |
119 IntSize m_viewportSize; | 119 IntSize m_viewportSize; |
120 IntSize m_contentsSize; | 120 IntSize m_contentsSize; |
121 }; | 121 }; |
122 | 122 |
123 class RootFrameViewStub : public ScrollableAreaStub { | 123 class RootFrameViewStub : public ScrollableAreaStub { |
124 public: | 124 public: |
125 static RootFrameViewStub* create(const IntSize& viewportSize, | 125 static RootFrameViewStub* create(const IntSize& viewportSize, |
126 const IntSize& contentsSize) { | 126 const IntSize& contentsSize) { |
127 return new RootFrameViewStub(viewportSize, contentsSize); | 127 return new RootFrameViewStub(viewportSize, contentsSize); |
128 } | 128 } |
129 | 129 |
130 DoublePoint maximumScrollPositionDouble() const override { | 130 ScrollOffset maximumScrollOffset() const override { |
131 return IntPoint(contentsSize() - viewportSize()); | 131 return ScrollOffset(contentsSize() - viewportSize()); |
132 } | 132 } |
133 | 133 |
134 private: | 134 private: |
135 RootFrameViewStub(const IntSize& viewportSize, const IntSize& contentsSize) | 135 RootFrameViewStub(const IntSize& viewportSize, const IntSize& contentsSize) |
136 : ScrollableAreaStub(viewportSize, contentsSize) {} | 136 : ScrollableAreaStub(viewportSize, contentsSize) {} |
137 | 137 |
138 int visibleWidth() const override { return m_viewportSize.width(); } | 138 int visibleWidth() const override { return m_viewportSize.width(); } |
139 int visibleHeight() const override { return m_viewportSize.height(); } | 139 int visibleHeight() const override { return m_viewportSize.height(); } |
140 }; | 140 }; |
141 | 141 |
142 class VisualViewportStub : public ScrollableAreaStub { | 142 class VisualViewportStub : public ScrollableAreaStub { |
143 public: | 143 public: |
144 static VisualViewportStub* create(const IntSize& viewportSize, | 144 static VisualViewportStub* create(const IntSize& viewportSize, |
145 const IntSize& contentsSize) { | 145 const IntSize& contentsSize) { |
146 return new VisualViewportStub(viewportSize, contentsSize); | 146 return new VisualViewportStub(viewportSize, contentsSize); |
147 } | 147 } |
148 | 148 |
149 DoublePoint maximumScrollPositionDouble() const override { | 149 ScrollOffset maximumScrollOffset() const override { |
150 DoubleSize visibleViewport = viewportSize(); | 150 ScrollOffset visibleViewport(viewportSize()); |
151 visibleViewport.scale(1 / m_scale); | 151 visibleViewport.scale(1 / m_scale); |
152 | 152 |
153 DoubleSize maxPosition = DoubleSize(contentsSize()) - visibleViewport; | 153 ScrollOffset maxOffset = ScrollOffset(contentsSize()) - visibleViewport; |
154 return DoublePoint(maxPosition); | 154 return ScrollOffset(maxOffset); |
155 } | 155 } |
156 | 156 |
157 void setScale(float scale) { m_scale = scale; } | 157 void setScale(float scale) { m_scale = scale; } |
158 | 158 |
159 private: | 159 private: |
160 VisualViewportStub(const IntSize& viewportSize, const IntSize& contentsSize) | 160 VisualViewportStub(const IntSize& viewportSize, const IntSize& contentsSize) |
161 : ScrollableAreaStub(viewportSize, contentsSize), m_scale(1) {} | 161 : ScrollableAreaStub(viewportSize, contentsSize), m_scale(1) {} |
162 | 162 |
163 int visibleWidth() const override { return m_viewportSize.width() / m_scale; } | 163 int visibleWidth() const override { return m_viewportSize.width() / m_scale; } |
164 int visibleHeight() const override { | 164 int visibleHeight() const override { |
165 return m_viewportSize.height() / m_scale; | 165 return m_viewportSize.height() / m_scale; |
166 } | 166 } |
167 DoubleRect visibleContentRectDouble(IncludeScrollbarsInRect) const override { | 167 IntRect visibleContentRect(IncludeScrollbarsInRect) const override { |
168 DoubleSize size = m_viewportSize; | 168 FloatSize size(m_viewportSize); |
169 size.scale(1 / m_scale); | 169 size.scale(1 / m_scale); |
170 DoubleRect rect(scrollPositionDouble(), size); | 170 return IntRect(IntPoint(flooredIntSize(scrollOffset())), |
171 return rect; | 171 expandedIntSize(size)); |
172 } | 172 } |
173 | 173 |
174 float m_scale; | 174 float m_scale; |
175 }; | 175 }; |
176 | 176 |
177 class RootFrameViewportTest : public ::testing::Test { | 177 class RootFrameViewportTest : public ::testing::Test { |
178 public: | 178 public: |
179 RootFrameViewportTest() {} | 179 RootFrameViewportTest() {} |
180 | 180 |
181 protected: | 181 protected: |
(...skipping 19 matching lines...) Expand all Loading... |
201 // RootFrameViewport should remain scrollable overall. | 201 // RootFrameViewport should remain scrollable overall. |
202 layoutViewport->setUserInputScrollable(false, true); | 202 layoutViewport->setUserInputScrollable(false, true); |
203 visualViewport->setUserInputScrollable(true, true); | 203 visualViewport->setUserInputScrollable(true, true); |
204 | 204 |
205 EXPECT_TRUE(rootFrameViewport->userInputScrollable(HorizontalScrollbar)); | 205 EXPECT_TRUE(rootFrameViewport->userInputScrollable(HorizontalScrollbar)); |
206 EXPECT_TRUE(rootFrameViewport->userInputScrollable(VerticalScrollbar)); | 206 EXPECT_TRUE(rootFrameViewport->userInputScrollable(VerticalScrollbar)); |
207 | 207 |
208 // Layout viewport shouldn't scroll since it's not horizontally scrollable, | 208 // Layout viewport shouldn't scroll since it's not horizontally scrollable, |
209 // but visual viewport should. | 209 // but visual viewport should. |
210 rootFrameViewport->userScroll(ScrollByPixel, FloatSize(300, 0)); | 210 rootFrameViewport->userScroll(ScrollByPixel, FloatSize(300, 0)); |
211 EXPECT_POINT_EQ(DoublePoint(0, 0), layoutViewport->scrollPositionDouble()); | 211 EXPECT_SIZE_EQ(ScrollOffset(0, 0), layoutViewport->scrollOffset()); |
212 EXPECT_POINT_EQ(DoublePoint(50, 0), visualViewport->scrollPositionDouble()); | 212 EXPECT_SIZE_EQ(ScrollOffset(50, 0), visualViewport->scrollOffset()); |
213 EXPECT_POINT_EQ(DoublePoint(50, 0), | 213 EXPECT_SIZE_EQ(ScrollOffset(50, 0), rootFrameViewport->scrollOffset()); |
214 rootFrameViewport->scrollPositionDouble()); | |
215 | 214 |
216 // Vertical scrolling should be unaffected. | 215 // Vertical scrolling should be unaffected. |
217 rootFrameViewport->userScroll(ScrollByPixel, FloatSize(0, 300)); | 216 rootFrameViewport->userScroll(ScrollByPixel, FloatSize(0, 300)); |
218 EXPECT_POINT_EQ(DoublePoint(0, 150), layoutViewport->scrollPositionDouble()); | 217 EXPECT_SIZE_EQ(ScrollOffset(0, 150), layoutViewport->scrollOffset()); |
219 EXPECT_POINT_EQ(DoublePoint(50, 75), visualViewport->scrollPositionDouble()); | 218 EXPECT_SIZE_EQ(ScrollOffset(50, 75), visualViewport->scrollOffset()); |
220 EXPECT_POINT_EQ(DoublePoint(50, 225), | 219 EXPECT_SIZE_EQ(ScrollOffset(50, 225), rootFrameViewport->scrollOffset()); |
221 rootFrameViewport->scrollPositionDouble()); | |
222 | 220 |
223 // Try the same checks as above but for the vertical direction. | 221 // Try the same checks as above but for the vertical direction. |
224 // =============================================== | 222 // =============================================== |
225 | 223 |
226 rootFrameViewport->setScrollPosition(DoublePoint(), ProgrammaticScroll); | 224 rootFrameViewport->setScrollOffset(ScrollOffset(), ProgrammaticScroll); |
227 | 225 |
228 // Disable just the layout viewport's vertical scrolling, the | 226 // Disable just the layout viewport's vertical scrolling, the |
229 // RootFrameViewport should remain scrollable overall. | 227 // RootFrameViewport should remain scrollable overall. |
230 layoutViewport->setUserInputScrollable(true, false); | 228 layoutViewport->setUserInputScrollable(true, false); |
231 visualViewport->setUserInputScrollable(true, true); | 229 visualViewport->setUserInputScrollable(true, true); |
232 | 230 |
233 EXPECT_TRUE(rootFrameViewport->userInputScrollable(HorizontalScrollbar)); | 231 EXPECT_TRUE(rootFrameViewport->userInputScrollable(HorizontalScrollbar)); |
234 EXPECT_TRUE(rootFrameViewport->userInputScrollable(VerticalScrollbar)); | 232 EXPECT_TRUE(rootFrameViewport->userInputScrollable(VerticalScrollbar)); |
235 | 233 |
236 // Layout viewport shouldn't scroll since it's not vertically scrollable, | 234 // Layout viewport shouldn't scroll since it's not vertically scrollable, |
237 // but visual viewport should. | 235 // but visual viewport should. |
238 rootFrameViewport->userScroll(ScrollByPixel, FloatSize(0, 300)); | 236 rootFrameViewport->userScroll(ScrollByPixel, FloatSize(0, 300)); |
239 EXPECT_POINT_EQ(DoublePoint(0, 0), layoutViewport->scrollPositionDouble()); | 237 EXPECT_SIZE_EQ(ScrollOffset(0, 0), layoutViewport->scrollOffset()); |
240 EXPECT_POINT_EQ(DoublePoint(0, 75), visualViewport->scrollPositionDouble()); | 238 EXPECT_SIZE_EQ(ScrollOffset(0, 75), visualViewport->scrollOffset()); |
241 EXPECT_POINT_EQ(DoublePoint(0, 75), | 239 EXPECT_SIZE_EQ(ScrollOffset(0, 75), rootFrameViewport->scrollOffset()); |
242 rootFrameViewport->scrollPositionDouble()); | |
243 | 240 |
244 // Horizontal scrolling should be unaffected. | 241 // Horizontal scrolling should be unaffected. |
245 rootFrameViewport->userScroll(ScrollByPixel, FloatSize(300, 0)); | 242 rootFrameViewport->userScroll(ScrollByPixel, FloatSize(300, 0)); |
246 EXPECT_POINT_EQ(DoublePoint(100, 0), layoutViewport->scrollPositionDouble()); | 243 EXPECT_SIZE_EQ(ScrollOffset(100, 0), layoutViewport->scrollOffset()); |
247 EXPECT_POINT_EQ(DoublePoint(50, 75), visualViewport->scrollPositionDouble()); | 244 EXPECT_SIZE_EQ(ScrollOffset(50, 75), visualViewport->scrollOffset()); |
248 EXPECT_POINT_EQ(DoublePoint(150, 75), | 245 EXPECT_SIZE_EQ(ScrollOffset(150, 75), rootFrameViewport->scrollOffset()); |
249 rootFrameViewport->scrollPositionDouble()); | |
250 } | 246 } |
251 | 247 |
252 // Make sure scrolls using the scroll animator (scroll(), setScrollPosition()) | 248 // Make sure scrolls using the scroll animator (scroll(), setScrollOffset()) |
253 // work correctly when one of the subviewports is explicitly scrolled without | 249 // work correctly when one of the subviewports is explicitly scrolled without |
254 // using the RootFrameViewport interface. | 250 // using the // RootFrameViewport interface. |
255 TEST_F(RootFrameViewportTest, TestScrollAnimatorUpdatedBeforeScroll) { | 251 TEST_F(RootFrameViewportTest, TestScrollAnimatorUpdatedBeforeScroll) { |
256 IntSize viewportSize(100, 150); | 252 IntSize viewportSize(100, 150); |
257 RootFrameViewStub* layoutViewport = | 253 RootFrameViewStub* layoutViewport = |
258 RootFrameViewStub::create(viewportSize, IntSize(200, 300)); | 254 RootFrameViewStub::create(viewportSize, IntSize(200, 300)); |
259 VisualViewportStub* visualViewport = | 255 VisualViewportStub* visualViewport = |
260 VisualViewportStub::create(viewportSize, viewportSize); | 256 VisualViewportStub::create(viewportSize, viewportSize); |
261 | 257 |
262 ScrollableArea* rootFrameViewport = | 258 ScrollableArea* rootFrameViewport = |
263 RootFrameViewport::create(*visualViewport, *layoutViewport); | 259 RootFrameViewport::create(*visualViewport, *layoutViewport); |
264 | 260 |
265 visualViewport->setScale(2); | 261 visualViewport->setScale(2); |
266 | 262 |
267 visualViewport->setScrollPosition(DoublePoint(50, 75), ProgrammaticScroll); | 263 visualViewport->setScrollOffset(ScrollOffset(50, 75), ProgrammaticScroll); |
268 EXPECT_POINT_EQ(DoublePoint(50, 75), | 264 EXPECT_SIZE_EQ(ScrollOffset(50, 75), rootFrameViewport->scrollOffset()); |
269 rootFrameViewport->scrollPositionDouble()); | |
270 | 265 |
271 // If the scroll animator doesn't update, it will still think it's at (0, 0) | 266 // If the scroll animator doesn't update, it will still think it's at (0, 0) |
272 // and so it may early exit. | 267 // and so it may early exit. |
273 rootFrameViewport->setScrollPosition(DoublePoint(0, 0), ProgrammaticScroll); | 268 rootFrameViewport->setScrollOffset(ScrollOffset(0, 0), ProgrammaticScroll); |
274 EXPECT_POINT_EQ(DoublePoint(0, 0), rootFrameViewport->scrollPositionDouble()); | 269 EXPECT_SIZE_EQ(ScrollOffset(0, 0), rootFrameViewport->scrollOffset()); |
275 EXPECT_POINT_EQ(DoublePoint(0, 0), visualViewport->scrollPositionDouble()); | 270 EXPECT_SIZE_EQ(ScrollOffset(0, 0), visualViewport->scrollOffset()); |
276 | 271 |
277 // Try again for userScroll() | 272 // Try again for userScroll() |
278 visualViewport->setScrollPosition(DoublePoint(50, 75), ProgrammaticScroll); | 273 visualViewport->setScrollOffset(ScrollOffset(50, 75), ProgrammaticScroll); |
279 EXPECT_POINT_EQ(DoublePoint(50, 75), | 274 EXPECT_SIZE_EQ(ScrollOffset(50, 75), rootFrameViewport->scrollOffset()); |
280 rootFrameViewport->scrollPositionDouble()); | |
281 | 275 |
282 rootFrameViewport->userScroll(ScrollByPixel, FloatSize(-50, 0)); | 276 rootFrameViewport->userScroll(ScrollByPixel, FloatSize(-50, 0)); |
283 EXPECT_POINT_EQ(DoublePoint(0, 75), | 277 EXPECT_SIZE_EQ(ScrollOffset(0, 75), rootFrameViewport->scrollOffset()); |
284 rootFrameViewport->scrollPositionDouble()); | 278 EXPECT_SIZE_EQ(ScrollOffset(0, 75), visualViewport->scrollOffset()); |
285 EXPECT_POINT_EQ(DoublePoint(0, 75), visualViewport->scrollPositionDouble()); | |
286 | 279 |
287 // Make sure the layout viewport is also accounted for. | 280 // Make sure the layout viewport is also accounted for. |
288 rootFrameViewport->setScrollPosition(DoublePoint(0, 0), ProgrammaticScroll); | 281 rootFrameViewport->setScrollOffset(ScrollOffset(0, 0), ProgrammaticScroll); |
289 layoutViewport->setScrollPosition(DoublePoint(100, 150), ProgrammaticScroll); | 282 layoutViewport->setScrollOffset(ScrollOffset(100, 150), ProgrammaticScroll); |
290 EXPECT_POINT_EQ(DoublePoint(100, 150), | 283 EXPECT_SIZE_EQ(ScrollOffset(100, 150), rootFrameViewport->scrollOffset()); |
291 rootFrameViewport->scrollPositionDouble()); | |
292 | 284 |
293 rootFrameViewport->userScroll(ScrollByPixel, FloatSize(-100, 0)); | 285 rootFrameViewport->userScroll(ScrollByPixel, FloatSize(-100, 0)); |
294 EXPECT_POINT_EQ(DoublePoint(0, 150), | 286 EXPECT_SIZE_EQ(ScrollOffset(0, 150), rootFrameViewport->scrollOffset()); |
295 rootFrameViewport->scrollPositionDouble()); | 287 EXPECT_SIZE_EQ(ScrollOffset(0, 150), layoutViewport->scrollOffset()); |
296 EXPECT_POINT_EQ(DoublePoint(0, 150), layoutViewport->scrollPositionDouble()); | |
297 } | 288 } |
298 | 289 |
299 // Test that the scrollIntoView correctly scrolls the main frame | 290 // Test that the scrollIntoView correctly scrolls the main frame |
300 // and visual viewport such that the given rect is centered in the viewport. | 291 // and visual viewport such that the given rect is centered in the viewport. |
301 TEST_F(RootFrameViewportTest, ScrollIntoView) { | 292 TEST_F(RootFrameViewportTest, ScrollIntoView) { |
302 IntSize viewportSize(100, 150); | 293 IntSize viewportSize(100, 150); |
303 RootFrameViewStub* layoutViewport = | 294 RootFrameViewStub* layoutViewport = |
304 RootFrameViewStub::create(viewportSize, IntSize(200, 300)); | 295 RootFrameViewStub::create(viewportSize, IntSize(200, 300)); |
305 VisualViewportStub* visualViewport = | 296 VisualViewportStub* visualViewport = |
306 VisualViewportStub::create(viewportSize, viewportSize); | 297 VisualViewportStub::create(viewportSize, viewportSize); |
307 | 298 |
308 ScrollableArea* rootFrameViewport = | 299 ScrollableArea* rootFrameViewport = |
309 RootFrameViewport::create(*visualViewport, *layoutViewport); | 300 RootFrameViewport::create(*visualViewport, *layoutViewport); |
310 | 301 |
311 // Test that the visual viewport is scrolled if the viewport has been | 302 // Test that the visual viewport is scrolled if the viewport has been |
312 // resized (as is the case when the ChromeOS keyboard comes up) but not | 303 // resized (as is the case when the ChromeOS keyboard comes up) but not |
313 // scaled. | 304 // scaled. |
314 visualViewport->setViewportSize(IntSize(100, 100)); | 305 visualViewport->setViewportSize(IntSize(100, 100)); |
315 rootFrameViewport->scrollIntoView(LayoutRect(100, 250, 50, 50), | 306 rootFrameViewport->scrollIntoView(LayoutRect(100, 250, 50, 50), |
316 ScrollAlignment::alignToEdgeIfNeeded, | 307 ScrollAlignment::alignToEdgeIfNeeded, |
317 ScrollAlignment::alignToEdgeIfNeeded); | 308 ScrollAlignment::alignToEdgeIfNeeded); |
318 EXPECT_POINT_EQ(DoublePoint(50, 150), layoutViewport->scrollPositionDouble()); | 309 EXPECT_SIZE_EQ(ScrollOffset(50, 150), layoutViewport->scrollOffset()); |
319 EXPECT_POINT_EQ(DoublePoint(0, 50), visualViewport->scrollPositionDouble()); | 310 EXPECT_SIZE_EQ(ScrollOffset(0, 50), visualViewport->scrollOffset()); |
320 | 311 |
321 rootFrameViewport->scrollIntoView(LayoutRect(25, 75, 50, 50), | 312 rootFrameViewport->scrollIntoView(LayoutRect(25, 75, 50, 50), |
322 ScrollAlignment::alignToEdgeIfNeeded, | 313 ScrollAlignment::alignToEdgeIfNeeded, |
323 ScrollAlignment::alignToEdgeIfNeeded); | 314 ScrollAlignment::alignToEdgeIfNeeded); |
324 EXPECT_POINT_EQ(DoublePoint(25, 75), layoutViewport->scrollPositionDouble()); | 315 EXPECT_SIZE_EQ(ScrollOffset(25, 75), layoutViewport->scrollOffset()); |
325 EXPECT_POINT_EQ(DoublePoint(0, 0), visualViewport->scrollPositionDouble()); | 316 EXPECT_SIZE_EQ(ScrollOffset(0, 0), visualViewport->scrollOffset()); |
326 | 317 |
327 // Reset the visual viewport's size, scale the page, and repeat the test | 318 // Reset the visual viewport's size, scale the page, and repeat the test |
328 visualViewport->setViewportSize(IntSize(100, 150)); | 319 visualViewport->setViewportSize(IntSize(100, 150)); |
329 visualViewport->setScale(2); | 320 visualViewport->setScale(2); |
330 rootFrameViewport->setScrollPosition(DoublePoint(), ProgrammaticScroll); | 321 rootFrameViewport->setScrollOffset(ScrollOffset(), ProgrammaticScroll); |
331 | 322 |
332 rootFrameViewport->scrollIntoView(LayoutRect(50, 75, 50, 75), | 323 rootFrameViewport->scrollIntoView(LayoutRect(50, 75, 50, 75), |
333 ScrollAlignment::alignToEdgeIfNeeded, | 324 ScrollAlignment::alignToEdgeIfNeeded, |
334 ScrollAlignment::alignToEdgeIfNeeded); | 325 ScrollAlignment::alignToEdgeIfNeeded); |
335 EXPECT_POINT_EQ(DoublePoint(0, 0), layoutViewport->scrollPositionDouble()); | 326 EXPECT_SIZE_EQ(ScrollOffset(0, 0), layoutViewport->scrollOffset()); |
336 EXPECT_POINT_EQ(DoublePoint(50, 75), visualViewport->scrollPositionDouble()); | 327 EXPECT_SIZE_EQ(ScrollOffset(50, 75), visualViewport->scrollOffset()); |
337 | 328 |
338 rootFrameViewport->scrollIntoView(LayoutRect(190, 290, 10, 10), | 329 rootFrameViewport->scrollIntoView(LayoutRect(190, 290, 10, 10), |
339 ScrollAlignment::alignToEdgeIfNeeded, | 330 ScrollAlignment::alignToEdgeIfNeeded, |
340 ScrollAlignment::alignToEdgeIfNeeded); | 331 ScrollAlignment::alignToEdgeIfNeeded); |
341 EXPECT_POINT_EQ(DoublePoint(100, 150), | 332 EXPECT_SIZE_EQ(ScrollOffset(100, 150), layoutViewport->scrollOffset()); |
342 layoutViewport->scrollPositionDouble()); | 333 EXPECT_SIZE_EQ(ScrollOffset(50, 75), visualViewport->scrollOffset()); |
343 EXPECT_POINT_EQ(DoublePoint(50, 75), visualViewport->scrollPositionDouble()); | |
344 | 334 |
345 // Scrolling into view the viewport rect itself should be a no-op. | 335 // Scrolling into view the viewport rect itself should be a no-op. |
346 visualViewport->setViewportSize(IntSize(100, 100)); | 336 visualViewport->setViewportSize(IntSize(100, 100)); |
347 visualViewport->setScale(1.5f); | 337 visualViewport->setScale(1.5f); |
348 visualViewport->setScrollPosition(DoublePoint(0, 10), ProgrammaticScroll); | 338 visualViewport->setScrollOffset(ScrollOffset(0, 10), ProgrammaticScroll); |
349 layoutViewport->setScrollPosition(DoublePoint(50, 50), ProgrammaticScroll); | 339 layoutViewport->setScrollOffset(ScrollOffset(50, 50), ProgrammaticScroll); |
350 rootFrameViewport->setScrollPosition( | 340 rootFrameViewport->setScrollOffset(rootFrameViewport->scrollOffset(), |
351 rootFrameViewport->scrollPositionDouble(), ProgrammaticScroll); | 341 ProgrammaticScroll); |
352 | 342 |
353 rootFrameViewport->scrollIntoView( | 343 rootFrameViewport->scrollIntoView( |
354 LayoutRect( | 344 LayoutRect(rootFrameViewport->visibleContentRect(ExcludeScrollbars)), |
355 rootFrameViewport->visibleContentRectDouble(ExcludeScrollbars)), | |
356 ScrollAlignment::alignToEdgeIfNeeded, | 345 ScrollAlignment::alignToEdgeIfNeeded, |
357 ScrollAlignment::alignToEdgeIfNeeded); | 346 ScrollAlignment::alignToEdgeIfNeeded); |
358 EXPECT_POINT_EQ(DoublePoint(50, 50), layoutViewport->scrollPositionDouble()); | 347 EXPECT_SIZE_EQ(ScrollOffset(50, 50), layoutViewport->scrollOffset()); |
359 EXPECT_POINT_EQ(DoublePoint(0, 10), visualViewport->scrollPositionDouble()); | 348 EXPECT_SIZE_EQ(ScrollOffset(0, 10), visualViewport->scrollOffset()); |
360 | 349 |
361 rootFrameViewport->scrollIntoView( | 350 rootFrameViewport->scrollIntoView( |
362 LayoutRect( | 351 LayoutRect(rootFrameViewport->visibleContentRect(ExcludeScrollbars)), |
363 rootFrameViewport->visibleContentRectDouble(ExcludeScrollbars)), | |
364 ScrollAlignment::alignCenterAlways, ScrollAlignment::alignCenterAlways); | 352 ScrollAlignment::alignCenterAlways, ScrollAlignment::alignCenterAlways); |
365 EXPECT_POINT_EQ(DoublePoint(50, 50), layoutViewport->scrollPositionDouble()); | 353 EXPECT_SIZE_EQ(ScrollOffset(50, 50), layoutViewport->scrollOffset()); |
366 EXPECT_POINT_EQ(DoublePoint(0, 10), visualViewport->scrollPositionDouble()); | 354 EXPECT_SIZE_EQ(ScrollOffset(0, 10), visualViewport->scrollOffset()); |
367 | 355 |
368 rootFrameViewport->scrollIntoView( | 356 rootFrameViewport->scrollIntoView( |
369 LayoutRect( | 357 LayoutRect(rootFrameViewport->visibleContentRect(ExcludeScrollbars)), |
370 rootFrameViewport->visibleContentRectDouble(ExcludeScrollbars)), | |
371 ScrollAlignment::alignTopAlways, ScrollAlignment::alignTopAlways); | 358 ScrollAlignment::alignTopAlways, ScrollAlignment::alignTopAlways); |
372 EXPECT_POINT_EQ(DoublePoint(50, 50), layoutViewport->scrollPositionDouble()); | 359 EXPECT_SIZE_EQ(ScrollOffset(50, 50), layoutViewport->scrollOffset()); |
373 EXPECT_POINT_EQ(DoublePoint(0, 10), visualViewport->scrollPositionDouble()); | 360 EXPECT_SIZE_EQ(ScrollOffset(0, 10), visualViewport->scrollOffset()); |
374 } | 361 } |
375 | 362 |
376 // Tests that the setScrollPosition method works correctly with both viewports. | 363 // Tests that the setScrollOffset method works correctly with both viewports. |
377 TEST_F(RootFrameViewportTest, SetScrollPosition) { | 364 TEST_F(RootFrameViewportTest, SetScrollOffset) { |
378 IntSize viewportSize(500, 500); | 365 IntSize viewportSize(500, 500); |
379 RootFrameViewStub* layoutViewport = | 366 RootFrameViewStub* layoutViewport = |
380 RootFrameViewStub::create(viewportSize, IntSize(1000, 2000)); | 367 RootFrameViewStub::create(viewportSize, IntSize(1000, 2000)); |
381 VisualViewportStub* visualViewport = | 368 VisualViewportStub* visualViewport = |
382 VisualViewportStub::create(viewportSize, viewportSize); | 369 VisualViewportStub::create(viewportSize, viewportSize); |
383 | 370 |
384 ScrollableArea* rootFrameViewport = | 371 ScrollableArea* rootFrameViewport = |
385 RootFrameViewport::create(*visualViewport, *layoutViewport); | 372 RootFrameViewport::create(*visualViewport, *layoutViewport); |
386 | 373 |
387 visualViewport->setScale(2); | 374 visualViewport->setScale(2); |
388 | 375 |
389 // Ensure that the visual viewport scrolls first. | 376 // Ensure that the visual viewport scrolls first. |
390 rootFrameViewport->setScrollPosition(DoublePoint(100, 100), | 377 rootFrameViewport->setScrollOffset(ScrollOffset(100, 100), |
391 ProgrammaticScroll); | 378 ProgrammaticScroll); |
392 EXPECT_POINT_EQ(DoublePoint(100, 100), | 379 EXPECT_SIZE_EQ(ScrollOffset(100, 100), visualViewport->scrollOffset()); |
393 visualViewport->scrollPositionDouble()); | 380 EXPECT_SIZE_EQ(ScrollOffset(0, 0), layoutViewport->scrollOffset()); |
394 EXPECT_POINT_EQ(DoublePoint(0, 0), layoutViewport->scrollPositionDouble()); | |
395 | 381 |
396 // Scroll to the visual viewport's extent, the layout viewport should scroll | 382 // Scroll to the visual viewport's extent, the layout viewport should scroll |
397 // the remainder. | 383 // the remainder. |
398 rootFrameViewport->setScrollPosition(DoublePoint(300, 400), | 384 rootFrameViewport->setScrollOffset(ScrollOffset(300, 400), |
399 ProgrammaticScroll); | 385 ProgrammaticScroll); |
400 EXPECT_POINT_EQ(DoublePoint(250, 250), | 386 EXPECT_SIZE_EQ(ScrollOffset(250, 250), visualViewport->scrollOffset()); |
401 visualViewport->scrollPositionDouble()); | 387 EXPECT_SIZE_EQ(ScrollOffset(50, 150), layoutViewport->scrollOffset()); |
402 EXPECT_POINT_EQ(DoublePoint(50, 150), layoutViewport->scrollPositionDouble()); | |
403 | 388 |
404 // Only the layout viewport should scroll further. Make sure it doesn't scroll | 389 // Only the layout viewport should scroll further. Make sure it doesn't scroll |
405 // out of bounds. | 390 // out of bounds. |
406 rootFrameViewport->setScrollPosition(DoublePoint(780, 1780), | 391 rootFrameViewport->setScrollOffset(ScrollOffset(780, 1780), |
407 ProgrammaticScroll); | 392 ProgrammaticScroll); |
408 EXPECT_POINT_EQ(DoublePoint(250, 250), | 393 EXPECT_SIZE_EQ(ScrollOffset(250, 250), visualViewport->scrollOffset()); |
409 visualViewport->scrollPositionDouble()); | 394 EXPECT_SIZE_EQ(ScrollOffset(500, 1500), layoutViewport->scrollOffset()); |
410 EXPECT_POINT_EQ(DoublePoint(500, 1500), | |
411 layoutViewport->scrollPositionDouble()); | |
412 | 395 |
413 // Scroll all the way back. | 396 // Scroll all the way back. |
414 rootFrameViewport->setScrollPosition(DoublePoint(0, 0), ProgrammaticScroll); | 397 rootFrameViewport->setScrollOffset(ScrollOffset(0, 0), ProgrammaticScroll); |
415 EXPECT_POINT_EQ(DoublePoint(0, 0), visualViewport->scrollPositionDouble()); | 398 EXPECT_SIZE_EQ(ScrollOffset(0, 0), visualViewport->scrollOffset()); |
416 EXPECT_POINT_EQ(DoublePoint(0, 0), layoutViewport->scrollPositionDouble()); | 399 EXPECT_SIZE_EQ(ScrollOffset(0, 0), layoutViewport->scrollOffset()); |
417 } | 400 } |
418 | 401 |
419 // Tests that the visible rect (i.e. visual viewport rect) is correctly | 402 // Tests that the visible rect (i.e. visual viewport rect) is correctly |
420 // calculated, taking into account both viewports and page scale. | 403 // calculated, taking into account both viewports and page scale. |
421 TEST_F(RootFrameViewportTest, VisibleContentRect) { | 404 TEST_F(RootFrameViewportTest, VisibleContentRect) { |
422 IntSize viewportSize(500, 401); | 405 IntSize viewportSize(500, 401); |
423 RootFrameViewStub* layoutViewport = | 406 RootFrameViewStub* layoutViewport = |
424 RootFrameViewStub::create(viewportSize, IntSize(1000, 2000)); | 407 RootFrameViewStub::create(viewportSize, IntSize(1000, 2000)); |
425 VisualViewportStub* visualViewport = | 408 VisualViewportStub* visualViewport = |
426 VisualViewportStub::create(viewportSize, viewportSize); | 409 VisualViewportStub::create(viewportSize, viewportSize); |
427 | 410 |
428 ScrollableArea* rootFrameViewport = | 411 ScrollableArea* rootFrameViewport = |
429 RootFrameViewport::create(*visualViewport, *layoutViewport); | 412 RootFrameViewport::create(*visualViewport, *layoutViewport); |
430 | 413 |
431 rootFrameViewport->setScrollPosition(DoublePoint(100, 75), | 414 rootFrameViewport->setScrollOffset(ScrollOffset(100, 75), ProgrammaticScroll); |
432 ProgrammaticScroll); | |
433 | 415 |
434 EXPECT_POINT_EQ(DoublePoint(100, 75), | 416 EXPECT_POINT_EQ(IntPoint(100, 75), |
435 rootFrameViewport->visibleContentRect().location()); | 417 rootFrameViewport->visibleContentRect().location()); |
436 EXPECT_POINT_EQ(DoublePoint(100, 75), | 418 EXPECT_SIZE_EQ(ScrollOffset(500, 401), |
437 rootFrameViewport->visibleContentRectDouble().location()); | |
438 EXPECT_SIZE_EQ(DoubleSize(500, 401), | |
439 rootFrameViewport->visibleContentRect().size()); | 419 rootFrameViewport->visibleContentRect().size()); |
440 EXPECT_SIZE_EQ(DoubleSize(500, 401), | |
441 rootFrameViewport->visibleContentRectDouble().size()); | |
442 | 420 |
443 visualViewport->setScale(2); | 421 visualViewport->setScale(2); |
444 | 422 |
445 EXPECT_POINT_EQ(DoublePoint(100, 75), | 423 EXPECT_POINT_EQ(IntPoint(100, 75), |
446 rootFrameViewport->visibleContentRect().location()); | 424 rootFrameViewport->visibleContentRect().location()); |
447 EXPECT_POINT_EQ(DoublePoint(100, 75), | 425 EXPECT_SIZE_EQ(ScrollOffset(250, 201), |
448 rootFrameViewport->visibleContentRectDouble().location()); | |
449 EXPECT_SIZE_EQ(DoubleSize(250, 201), | |
450 rootFrameViewport->visibleContentRect().size()); | 426 rootFrameViewport->visibleContentRect().size()); |
451 EXPECT_SIZE_EQ(DoubleSize(250, 200.5), | |
452 rootFrameViewport->visibleContentRectDouble().size()); | |
453 } | 427 } |
454 | 428 |
455 // Tests that scrolls on the root frame scroll the visual viewport before | 429 // Tests that scrolls on the root frame scroll the visual viewport before |
456 // trying to scroll the layout viewport. | 430 // trying to scroll the layout viewport. |
457 TEST_F(RootFrameViewportTest, ViewportScrollOrder) { | 431 TEST_F(RootFrameViewportTest, ViewportScrollOrder) { |
458 IntSize viewportSize(100, 100); | 432 IntSize viewportSize(100, 100); |
459 RootFrameViewStub* layoutViewport = | 433 RootFrameViewStub* layoutViewport = |
460 RootFrameViewStub::create(viewportSize, IntSize(200, 300)); | 434 RootFrameViewStub::create(viewportSize, IntSize(200, 300)); |
461 VisualViewportStub* visualViewport = | 435 VisualViewportStub* visualViewport = |
462 VisualViewportStub::create(viewportSize, viewportSize); | 436 VisualViewportStub::create(viewportSize, viewportSize); |
463 | 437 |
464 ScrollableArea* rootFrameViewport = | 438 ScrollableArea* rootFrameViewport = |
465 RootFrameViewport::create(*visualViewport, *layoutViewport); | 439 RootFrameViewport::create(*visualViewport, *layoutViewport); |
466 | 440 |
467 visualViewport->setScale(2); | 441 visualViewport->setScale(2); |
468 | 442 |
469 rootFrameViewport->setScrollPosition(DoublePoint(40, 40), UserScroll); | 443 rootFrameViewport->setScrollOffset(ScrollOffset(40, 40), UserScroll); |
470 EXPECT_POINT_EQ(DoublePoint(40, 40), visualViewport->scrollPositionDouble()); | 444 EXPECT_SIZE_EQ(ScrollOffset(40, 40), visualViewport->scrollOffset()); |
471 EXPECT_POINT_EQ(DoublePoint(0, 0), layoutViewport->scrollPositionDouble()); | 445 EXPECT_SIZE_EQ(ScrollOffset(0, 0), layoutViewport->scrollOffset()); |
472 | 446 |
473 rootFrameViewport->setScrollPosition(DoublePoint(60, 60), ProgrammaticScroll); | 447 rootFrameViewport->setScrollOffset(ScrollOffset(60, 60), ProgrammaticScroll); |
474 EXPECT_POINT_EQ(DoublePoint(50, 50), visualViewport->scrollPositionDouble()); | 448 EXPECT_SIZE_EQ(ScrollOffset(50, 50), visualViewport->scrollOffset()); |
475 EXPECT_POINT_EQ(DoublePoint(10, 10), layoutViewport->scrollPositionDouble()); | 449 EXPECT_SIZE_EQ(ScrollOffset(10, 10), layoutViewport->scrollOffset()); |
476 } | 450 } |
477 | 451 |
478 // Tests that setting an alternate layout viewport scrolls the alternate | 452 // Tests that setting an alternate layout viewport scrolls the alternate |
479 // instead of the original. | 453 // instead of the original. |
480 TEST_F(RootFrameViewportTest, SetAlternateLayoutViewport) { | 454 TEST_F(RootFrameViewportTest, SetAlternateLayoutViewport) { |
481 IntSize viewportSize(100, 100); | 455 IntSize viewportSize(100, 100); |
482 RootFrameViewStub* layoutViewport = | 456 RootFrameViewStub* layoutViewport = |
483 RootFrameViewStub::create(viewportSize, IntSize(200, 300)); | 457 RootFrameViewStub::create(viewportSize, IntSize(200, 300)); |
484 VisualViewportStub* visualViewport = | 458 VisualViewportStub* visualViewport = |
485 VisualViewportStub::create(viewportSize, viewportSize); | 459 VisualViewportStub::create(viewportSize, viewportSize); |
486 | 460 |
487 RootFrameViewStub* alternateScroller = | 461 RootFrameViewStub* alternateScroller = |
488 RootFrameViewStub::create(viewportSize, IntSize(600, 500)); | 462 RootFrameViewStub::create(viewportSize, IntSize(600, 500)); |
489 | 463 |
490 RootFrameViewport* rootFrameViewport = | 464 RootFrameViewport* rootFrameViewport = |
491 RootFrameViewport::create(*visualViewport, *layoutViewport); | 465 RootFrameViewport::create(*visualViewport, *layoutViewport); |
492 | 466 |
493 visualViewport->setScale(2); | 467 visualViewport->setScale(2); |
494 | 468 |
495 rootFrameViewport->setScrollPosition(DoublePoint(100, 100), UserScroll); | 469 rootFrameViewport->setScrollOffset(ScrollOffset(100, 100), UserScroll); |
496 EXPECT_POINT_EQ(DoublePoint(50, 50), visualViewport->scrollPositionDouble()); | 470 EXPECT_SIZE_EQ(ScrollOffset(50, 50), visualViewport->scrollOffset()); |
497 EXPECT_POINT_EQ(DoublePoint(50, 50), layoutViewport->scrollPositionDouble()); | 471 EXPECT_SIZE_EQ(ScrollOffset(50, 50), layoutViewport->scrollOffset()); |
498 EXPECT_POINT_EQ(DoublePoint(100, 100), | 472 EXPECT_SIZE_EQ(ScrollOffset(100, 100), rootFrameViewport->scrollOffset()); |
499 rootFrameViewport->scrollPositionDouble()); | |
500 | 473 |
501 rootFrameViewport->setLayoutViewport(*alternateScroller); | 474 rootFrameViewport->setLayoutViewport(*alternateScroller); |
502 EXPECT_POINT_EQ(DoublePoint(50, 50), visualViewport->scrollPositionDouble()); | 475 EXPECT_SIZE_EQ(ScrollOffset(50, 50), visualViewport->scrollOffset()); |
503 EXPECT_POINT_EQ(DoublePoint(0, 0), alternateScroller->scrollPositionDouble()); | 476 EXPECT_SIZE_EQ(ScrollOffset(0, 0), alternateScroller->scrollOffset()); |
504 EXPECT_POINT_EQ(DoublePoint(50, 50), | 477 EXPECT_SIZE_EQ(ScrollOffset(50, 50), rootFrameViewport->scrollOffset()); |
505 rootFrameViewport->scrollPositionDouble()); | |
506 | 478 |
507 rootFrameViewport->setScrollPosition(DoublePoint(200, 200), UserScroll); | 479 rootFrameViewport->setScrollOffset(ScrollOffset(200, 200), UserScroll); |
508 EXPECT_POINT_EQ(DoublePoint(50, 50), visualViewport->scrollPositionDouble()); | 480 EXPECT_SIZE_EQ(ScrollOffset(50, 50), visualViewport->scrollOffset()); |
509 EXPECT_POINT_EQ(DoublePoint(150, 150), | 481 EXPECT_SIZE_EQ(ScrollOffset(150, 150), alternateScroller->scrollOffset()); |
510 alternateScroller->scrollPositionDouble()); | 482 EXPECT_SIZE_EQ(ScrollOffset(200, 200), rootFrameViewport->scrollOffset()); |
511 EXPECT_POINT_EQ(DoublePoint(200, 200), | 483 EXPECT_SIZE_EQ(ScrollOffset(50, 50), layoutViewport->scrollOffset()); |
512 rootFrameViewport->scrollPositionDouble()); | |
513 EXPECT_POINT_EQ(DoublePoint(50, 50), layoutViewport->scrollPositionDouble()); | |
514 | 484 |
515 EXPECT_POINT_EQ(DoublePoint(550, 450), | 485 EXPECT_SIZE_EQ(ScrollOffset(550, 450), |
516 rootFrameViewport->maximumScrollPositionDouble()); | 486 rootFrameViewport->maximumScrollOffset()); |
517 } | 487 } |
518 | 488 |
519 } // namespace blink | 489 } // namespace blink |
OLD | NEW |