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

Side by Side Diff: third_party/WebKit/Source/core/frame/RootFrameViewportTest.cpp

Issue 2393313002: reflow comments in core/frame (Closed)
Patch Set: tweak 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 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 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 243
244 // Horizontal scrolling should be unaffected. 244 // Horizontal scrolling should be unaffected.
245 rootFrameViewport->userScroll(ScrollByPixel, FloatSize(300, 0)); 245 rootFrameViewport->userScroll(ScrollByPixel, FloatSize(300, 0));
246 EXPECT_POINT_EQ(DoublePoint(100, 0), layoutViewport->scrollPositionDouble()); 246 EXPECT_POINT_EQ(DoublePoint(100, 0), layoutViewport->scrollPositionDouble());
247 EXPECT_POINT_EQ(DoublePoint(50, 75), visualViewport->scrollPositionDouble()); 247 EXPECT_POINT_EQ(DoublePoint(50, 75), visualViewport->scrollPositionDouble());
248 EXPECT_POINT_EQ(DoublePoint(150, 75), 248 EXPECT_POINT_EQ(DoublePoint(150, 75),
249 rootFrameViewport->scrollPositionDouble()); 249 rootFrameViewport->scrollPositionDouble());
250 } 250 }
251 251
252 // Make sure scrolls using the scroll animator (scroll(), setScrollPosition()) 252 // Make sure scrolls using the scroll animator (scroll(), setScrollPosition())
253 // work correctly when one of the subviewports is explicitly scrolled without us ing the 253 // work correctly when one of the subviewports is explicitly scrolled without
254 // RootFrameViewport interface. 254 // using the RootFrameViewport interface.
255 TEST_F(RootFrameViewportTest, TestScrollAnimatorUpdatedBeforeScroll) { 255 TEST_F(RootFrameViewportTest, TestScrollAnimatorUpdatedBeforeScroll) {
256 IntSize viewportSize(100, 150); 256 IntSize viewportSize(100, 150);
257 RootFrameViewStub* layoutViewport = 257 RootFrameViewStub* layoutViewport =
258 RootFrameViewStub::create(viewportSize, IntSize(200, 300)); 258 RootFrameViewStub::create(viewportSize, IntSize(200, 300));
259 VisualViewportStub* visualViewport = 259 VisualViewportStub* visualViewport =
260 VisualViewportStub::create(viewportSize, viewportSize); 260 VisualViewportStub::create(viewportSize, viewportSize);
261 261
262 ScrollableArea* rootFrameViewport = 262 ScrollableArea* rootFrameViewport =
263 RootFrameViewport::create(*visualViewport, *layoutViewport); 263 RootFrameViewport::create(*visualViewport, *layoutViewport);
264 264
265 visualViewport->setScale(2); 265 visualViewport->setScale(2);
266 266
267 visualViewport->setScrollPosition(DoublePoint(50, 75), ProgrammaticScroll); 267 visualViewport->setScrollPosition(DoublePoint(50, 75), ProgrammaticScroll);
268 EXPECT_POINT_EQ(DoublePoint(50, 75), 268 EXPECT_POINT_EQ(DoublePoint(50, 75),
269 rootFrameViewport->scrollPositionDouble()); 269 rootFrameViewport->scrollPositionDouble());
270 270
271 // If the scroll animator doesn't update, it will still think it's at (0, 0) a nd so it 271 // If the scroll animator doesn't update, it will still think it's at (0, 0)
272 // may early exit. 272 // and so it may early exit.
273 rootFrameViewport->setScrollPosition(DoublePoint(0, 0), ProgrammaticScroll); 273 rootFrameViewport->setScrollPosition(DoublePoint(0, 0), ProgrammaticScroll);
274 EXPECT_POINT_EQ(DoublePoint(0, 0), rootFrameViewport->scrollPositionDouble()); 274 EXPECT_POINT_EQ(DoublePoint(0, 0), rootFrameViewport->scrollPositionDouble());
275 EXPECT_POINT_EQ(DoublePoint(0, 0), visualViewport->scrollPositionDouble()); 275 EXPECT_POINT_EQ(DoublePoint(0, 0), visualViewport->scrollPositionDouble());
276 276
277 // Try again for userScroll() 277 // Try again for userScroll()
278 visualViewport->setScrollPosition(DoublePoint(50, 75), ProgrammaticScroll); 278 visualViewport->setScrollPosition(DoublePoint(50, 75), ProgrammaticScroll);
279 EXPECT_POINT_EQ(DoublePoint(50, 75), 279 EXPECT_POINT_EQ(DoublePoint(50, 75),
280 rootFrameViewport->scrollPositionDouble()); 280 rootFrameViewport->scrollPositionDouble());
281 281
282 rootFrameViewport->userScroll(ScrollByPixel, FloatSize(-50, 0)); 282 rootFrameViewport->userScroll(ScrollByPixel, FloatSize(-50, 0));
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 386
387 visualViewport->setScale(2); 387 visualViewport->setScale(2);
388 388
389 // Ensure that the visual viewport scrolls first. 389 // Ensure that the visual viewport scrolls first.
390 rootFrameViewport->setScrollPosition(DoublePoint(100, 100), 390 rootFrameViewport->setScrollPosition(DoublePoint(100, 100),
391 ProgrammaticScroll); 391 ProgrammaticScroll);
392 EXPECT_POINT_EQ(DoublePoint(100, 100), 392 EXPECT_POINT_EQ(DoublePoint(100, 100),
393 visualViewport->scrollPositionDouble()); 393 visualViewport->scrollPositionDouble());
394 EXPECT_POINT_EQ(DoublePoint(0, 0), layoutViewport->scrollPositionDouble()); 394 EXPECT_POINT_EQ(DoublePoint(0, 0), layoutViewport->scrollPositionDouble());
395 395
396 // Scroll to the visual viewport's extent, the layout viewport should scroll t he 396 // Scroll to the visual viewport's extent, the layout viewport should scroll
397 // remainder. 397 // the remainder.
398 rootFrameViewport->setScrollPosition(DoublePoint(300, 400), 398 rootFrameViewport->setScrollPosition(DoublePoint(300, 400),
399 ProgrammaticScroll); 399 ProgrammaticScroll);
400 EXPECT_POINT_EQ(DoublePoint(250, 250), 400 EXPECT_POINT_EQ(DoublePoint(250, 250),
401 visualViewport->scrollPositionDouble()); 401 visualViewport->scrollPositionDouble());
402 EXPECT_POINT_EQ(DoublePoint(50, 150), layoutViewport->scrollPositionDouble()); 402 EXPECT_POINT_EQ(DoublePoint(50, 150), layoutViewport->scrollPositionDouble());
403 403
404 // Only the layout viewport should scroll further. Make sure it doesn't scroll 404 // Only the layout viewport should scroll further. Make sure it doesn't scroll
405 // out of bounds. 405 // out of bounds.
406 rootFrameViewport->setScrollPosition(DoublePoint(780, 1780), 406 rootFrameViewport->setScrollPosition(DoublePoint(780, 1780),
407 ProgrammaticScroll); 407 ProgrammaticScroll);
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 alternateScroller->scrollPositionDouble()); 510 alternateScroller->scrollPositionDouble());
511 EXPECT_POINT_EQ(DoublePoint(200, 200), 511 EXPECT_POINT_EQ(DoublePoint(200, 200),
512 rootFrameViewport->scrollPositionDouble()); 512 rootFrameViewport->scrollPositionDouble());
513 EXPECT_POINT_EQ(DoublePoint(50, 50), layoutViewport->scrollPositionDouble()); 513 EXPECT_POINT_EQ(DoublePoint(50, 50), layoutViewport->scrollPositionDouble());
514 514
515 EXPECT_POINT_EQ(DoublePoint(550, 450), 515 EXPECT_POINT_EQ(DoublePoint(550, 450),
516 rootFrameViewport->maximumScrollPositionDouble()); 516 rootFrameViewport->maximumScrollPositionDouble());
517 } 517 }
518 518
519 } // namespace blink 519 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/RootFrameViewport.cpp ('k') | third_party/WebKit/Source/core/frame/Settings.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698