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

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

Issue 1509783002: Revert of Remove invert viewport scroll order setting from Blink (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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 "config.h" 5 #include "config.h"
6 #include "core/frame/RootFrameViewport.h" 6 #include "core/frame/RootFrameViewport.h"
7 7
8 #include "core/layout/ScrollAlignment.h" 8 #include "core/layout/ScrollAlignment.h"
9 #include "platform/geometry/DoubleRect.h" 9 #include "platform/geometry/DoubleRect.h"
10 #include "platform/geometry/LayoutRect.h" 10 #include "platform/geometry/LayoutRect.h"
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 LayoutRect(100, 250, 50, 50), 353 LayoutRect(100, 250, 50, 50),
354 ScrollAlignment::alignToEdgeIfNeeded, 354 ScrollAlignment::alignToEdgeIfNeeded,
355 ScrollAlignment::alignToEdgeIfNeeded); 355 ScrollAlignment::alignToEdgeIfNeeded);
356 EXPECT_POINT_EQ(DoublePoint(50, 150), layoutViewport->scrollPositionDouble() ); 356 EXPECT_POINT_EQ(DoublePoint(50, 150), layoutViewport->scrollPositionDouble() );
357 EXPECT_POINT_EQ(DoublePoint(0, 50), visualViewport->scrollPositionDouble()); 357 EXPECT_POINT_EQ(DoublePoint(0, 50), visualViewport->scrollPositionDouble());
358 358
359 rootFrameViewport->scrollIntoView( 359 rootFrameViewport->scrollIntoView(
360 LayoutRect(25, 75, 50, 50), 360 LayoutRect(25, 75, 50, 50),
361 ScrollAlignment::alignToEdgeIfNeeded, 361 ScrollAlignment::alignToEdgeIfNeeded,
362 ScrollAlignment::alignToEdgeIfNeeded); 362 ScrollAlignment::alignToEdgeIfNeeded);
363 EXPECT_POINT_EQ(DoublePoint(25, 75), layoutViewport->scrollPositionDouble()) ; 363 EXPECT_POINT_EQ(DoublePoint(25, 25), layoutViewport->scrollPositionDouble()) ;
364 EXPECT_POINT_EQ(DoublePoint(0, 0), visualViewport->scrollPositionDouble()); 364 EXPECT_POINT_EQ(DoublePoint(0, 50), visualViewport->scrollPositionDouble());
365 365
366 // Reset the visual viewport's size, scale the page, and repeat the test 366 // Reset the visual viewport's size, scale the page and repeat the test
367 visualViewport->setViewportSize(IntSize(100, 150)); 367 visualViewport->setViewportSize(IntSize(100, 150));
368 visualViewport->setScale(2); 368 visualViewport->setScale(2);
369 rootFrameViewport->setScrollPosition(DoublePoint(), ProgrammaticScroll); 369 rootFrameViewport->setScrollPosition(DoublePoint(), ProgrammaticScroll);
370 370
371 rootFrameViewport->scrollIntoView( 371 rootFrameViewport->scrollIntoView(
372 LayoutRect(50, 75, 50, 75), 372 LayoutRect(50, 75, 50, 75),
373 ScrollAlignment::alignToEdgeIfNeeded, 373 ScrollAlignment::alignToEdgeIfNeeded,
374 ScrollAlignment::alignToEdgeIfNeeded); 374 ScrollAlignment::alignToEdgeIfNeeded);
375 EXPECT_POINT_EQ(DoublePoint(0, 0), layoutViewport->scrollPositionDouble()); 375 EXPECT_POINT_EQ(DoublePoint(50, 75), layoutViewport->scrollPositionDouble()) ;
376 EXPECT_POINT_EQ(DoublePoint(50, 75), visualViewport->scrollPositionDouble()) ; 376 EXPECT_POINT_EQ(DoublePoint(0, 0), visualViewport->scrollPositionDouble());
377 377
378 rootFrameViewport->scrollIntoView( 378 rootFrameViewport->scrollIntoView(
379 LayoutRect(190, 290, 10, 10), 379 LayoutRect(190, 290, 10, 10),
380 ScrollAlignment::alignToEdgeIfNeeded, 380 ScrollAlignment::alignToEdgeIfNeeded,
381 ScrollAlignment::alignToEdgeIfNeeded); 381 ScrollAlignment::alignToEdgeIfNeeded);
382 EXPECT_POINT_EQ(DoublePoint(100, 150), layoutViewport->scrollPositionDouble( )); 382 EXPECT_POINT_EQ(DoublePoint(100, 150), layoutViewport->scrollPositionDouble( ));
383 EXPECT_POINT_EQ(DoublePoint(50, 75), visualViewport->scrollPositionDouble()) ; 383 EXPECT_POINT_EQ(DoublePoint(50, 75), visualViewport->scrollPositionDouble()) ;
384 384
385 // Scrolling into view the viewport rect itself should be a no-op. 385 // Scrolling into view the viewport rect itself should be a no-op.
386 visualViewport->setViewportSize(IntSize(100, 100)); 386 visualViewport->setViewportSize(IntSize(100, 100));
(...skipping 28 matching lines...) Expand all
415 TEST_F(RootFrameViewportTest, SetScrollPosition) 415 TEST_F(RootFrameViewportTest, SetScrollPosition)
416 { 416 {
417 IntSize viewportSize(500, 500); 417 IntSize viewportSize(500, 500);
418 OwnPtrWillBeRawPtr<RootFrameViewStub> layoutViewport = RootFrameViewStub::cr eate(viewportSize, IntSize(1000, 2000)); 418 OwnPtrWillBeRawPtr<RootFrameViewStub> layoutViewport = RootFrameViewStub::cr eate(viewportSize, IntSize(1000, 2000));
419 OwnPtrWillBeRawPtr<VisualViewportStub> visualViewport = VisualViewportStub:: create(viewportSize, viewportSize); 419 OwnPtrWillBeRawPtr<VisualViewportStub> visualViewport = VisualViewportStub:: create(viewportSize, viewportSize);
420 420
421 OwnPtrWillBeRawPtr<ScrollableArea> rootFrameViewport = RootFrameViewport::cr eate(*visualViewport.get(), *layoutViewport.get()); 421 OwnPtrWillBeRawPtr<ScrollableArea> rootFrameViewport = RootFrameViewport::cr eate(*visualViewport.get(), *layoutViewport.get());
422 422
423 visualViewport->setScale(2); 423 visualViewport->setScale(2);
424 424
425 // Ensure that the visual viewport scrolls first. 425 // Ensure that the layout viewport scrolls first.
426 rootFrameViewport->setScrollPosition(DoublePoint(100, 100), ProgrammaticScro ll); 426 rootFrameViewport->setScrollPosition(DoublePoint(100, 100), ProgrammaticScro ll);
427 EXPECT_POINT_EQ(DoublePoint(100, 100), visualViewport->scrollPositionDouble( )); 427 EXPECT_POINT_EQ(DoublePoint(0, 0), visualViewport->scrollPositionDouble());
428 EXPECT_POINT_EQ(DoublePoint(0, 0), layoutViewport->scrollPositionDouble()); 428 EXPECT_POINT_EQ(DoublePoint(100, 100), layoutViewport->scrollPositionDouble( ));
429 429
430 // Scroll to the visual viewport's extent, the layout viewport should scroll the 430 // Scroll to the layout viewport's extent, the visual viewport should scroll the
431 // remainder. 431 // remainder.
432 rootFrameViewport->setScrollPosition(DoublePoint(300, 400), ProgrammaticScro ll); 432 rootFrameViewport->setScrollPosition(DoublePoint(700, 1700), ProgrammaticScr oll);
433 EXPECT_POINT_EQ(DoublePoint(250, 250), visualViewport->scrollPositionDouble( )); 433 EXPECT_POINT_EQ(DoublePoint(200, 200), visualViewport->scrollPositionDouble( ));
434 EXPECT_POINT_EQ(DoublePoint(50, 150), layoutViewport->scrollPositionDouble() ); 434 EXPECT_POINT_EQ(DoublePoint(500, 1500), layoutViewport->scrollPositionDouble ());
435 435
436 // Only the layout viewport should scroll further. Make sure it doesn't scro ll 436 // Only the visual viewport should scroll further. Make sure it doesn't scro ll
437 // out of bounds. 437 // out of bounds.
438 rootFrameViewport->setScrollPosition(DoublePoint(780, 1780), ProgrammaticScr oll); 438 rootFrameViewport->setScrollPosition(DoublePoint(780, 1780), ProgrammaticScr oll);
439 EXPECT_POINT_EQ(DoublePoint(250, 250), visualViewport->scrollPositionDouble( )); 439 EXPECT_POINT_EQ(DoublePoint(250, 250), visualViewport->scrollPositionDouble( ));
440 EXPECT_POINT_EQ(DoublePoint(500, 1500), layoutViewport->scrollPositionDouble ()); 440 EXPECT_POINT_EQ(DoublePoint(500, 1500), layoutViewport->scrollPositionDouble ());
441 441
442 // Scroll all the way back. 442 // Scroll all the way back.
443 rootFrameViewport->setScrollPosition(DoublePoint(0, 0), ProgrammaticScroll); 443 rootFrameViewport->setScrollPosition(DoublePoint(0, 0), ProgrammaticScroll);
444 EXPECT_POINT_EQ(DoublePoint(0, 0), visualViewport->scrollPositionDouble()); 444 EXPECT_POINT_EQ(DoublePoint(0, 0), visualViewport->scrollPositionDouble());
445 EXPECT_POINT_EQ(DoublePoint(0, 0), layoutViewport->scrollPositionDouble()); 445 EXPECT_POINT_EQ(DoublePoint(0, 0), layoutViewport->scrollPositionDouble());
446 } 446 }
(...skipping 16 matching lines...) Expand all
463 EXPECT_SIZE_EQ(DoubleSize(500, 401), rootFrameViewport->visibleContentRectDo uble().size()); 463 EXPECT_SIZE_EQ(DoubleSize(500, 401), rootFrameViewport->visibleContentRectDo uble().size());
464 464
465 visualViewport->setScale(2); 465 visualViewport->setScale(2);
466 466
467 EXPECT_POINT_EQ(DoublePoint(100, 75), rootFrameViewport->visibleContentRect( ).location()); 467 EXPECT_POINT_EQ(DoublePoint(100, 75), rootFrameViewport->visibleContentRect( ).location());
468 EXPECT_POINT_EQ(DoublePoint(100, 75), rootFrameViewport->visibleContentRectD ouble().location()); 468 EXPECT_POINT_EQ(DoublePoint(100, 75), rootFrameViewport->visibleContentRectD ouble().location());
469 EXPECT_SIZE_EQ(DoubleSize(250, 201), rootFrameViewport->visibleContentRect() .size()); 469 EXPECT_SIZE_EQ(DoubleSize(250, 201), rootFrameViewport->visibleContentRect() .size());
470 EXPECT_SIZE_EQ(DoubleSize(250, 200.5), rootFrameViewport->visibleContentRect Double().size()); 470 EXPECT_SIZE_EQ(DoubleSize(250, 200.5), rootFrameViewport->visibleContentRect Double().size());
471 } 471 }
472 472
473 // Tests that scrolls on the root frame scroll the visual viewport before 473 // Tests that the invert scroll order experiment scrolls the visual viewport
474 // trying to scroll the layout viewport. 474 // before trying to scroll the layout viewport.
475 TEST_F(RootFrameViewportTest, ViewportScrollOrder) 475 TEST_F(RootFrameViewportTest, ViewportScrollOrder)
476 { 476 {
477 IntSize viewportSize(100, 100); 477 IntSize viewportSize(100, 100);
478 OwnPtrWillBeRawPtr<RootFrameViewStub> layoutViewport = RootFrameViewStub::cr eate(viewportSize, IntSize(200, 300)); 478 OwnPtrWillBeRawPtr<RootFrameViewStub> layoutViewport = RootFrameViewStub::cr eate(viewportSize, IntSize(200, 300));
479 OwnPtrWillBeRawPtr<VisualViewportStub> visualViewport = VisualViewportStub:: create(viewportSize, viewportSize); 479 OwnPtrWillBeRawPtr<VisualViewportStub> visualViewport = VisualViewportStub:: create(viewportSize, viewportSize);
480 480
481 bool invertScrollOrder = true;
481 OwnPtrWillBeRawPtr<ScrollableArea> rootFrameViewport = 482 OwnPtrWillBeRawPtr<ScrollableArea> rootFrameViewport =
482 RootFrameViewport::create(*visualViewport.get(), *layoutViewport.get()); 483 RootFrameViewport::create(*visualViewport.get(), *layoutViewport.get(), invertScrollOrder);
483 484
484 visualViewport->setScale(2); 485 visualViewport->setScale(2);
485 486
486 rootFrameViewport->setScrollPosition(DoublePoint(40, 40), UserScroll); 487 rootFrameViewport->setScrollPosition(DoublePoint(40, 40), UserScroll);
487 EXPECT_POINT_EQ(DoublePoint(40, 40), visualViewport->scrollPositionDouble()) ; 488 EXPECT_POINT_EQ(DoublePoint(40, 40), visualViewport->scrollPositionDouble()) ;
488 EXPECT_POINT_EQ(DoublePoint(0, 0), layoutViewport->scrollPositionDouble()); 489 EXPECT_POINT_EQ(DoublePoint(0, 0), layoutViewport->scrollPositionDouble());
489 490
490 rootFrameViewport->setScrollPosition(DoublePoint(60, 60), ProgrammaticScroll ); 491 rootFrameViewport->setScrollPosition(DoublePoint(60, 60), ProgrammaticScroll );
491 EXPECT_POINT_EQ(DoublePoint(50, 50), visualViewport->scrollPositionDouble()) ; 492 EXPECT_POINT_EQ(DoublePoint(50, 50), visualViewport->scrollPositionDouble()) ;
492 EXPECT_POINT_EQ(DoublePoint(10, 10), layoutViewport->scrollPositionDouble()) ; 493 EXPECT_POINT_EQ(DoublePoint(10, 10), layoutViewport->scrollPositionDouble()) ;
493 } 494 }
494 495
495 } // namespace blink 496 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/RootFrameViewport.cpp ('k') | third_party/WebKit/Source/core/frame/Settings.in » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698