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

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

Issue 2128553002: Make rootScroller the layout viewport. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@viewportScrollCallbackInterface
Patch Set: Rebase + comment fix in test Created 4 years, 5 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 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 434
435 rootFrameViewport->setScrollPosition(DoublePoint(40, 40), UserScroll); 435 rootFrameViewport->setScrollPosition(DoublePoint(40, 40), UserScroll);
436 EXPECT_POINT_EQ(DoublePoint(40, 40), visualViewport->scrollPositionDouble()) ; 436 EXPECT_POINT_EQ(DoublePoint(40, 40), visualViewport->scrollPositionDouble()) ;
437 EXPECT_POINT_EQ(DoublePoint(0, 0), layoutViewport->scrollPositionDouble()); 437 EXPECT_POINT_EQ(DoublePoint(0, 0), layoutViewport->scrollPositionDouble());
438 438
439 rootFrameViewport->setScrollPosition(DoublePoint(60, 60), ProgrammaticScroll ); 439 rootFrameViewport->setScrollPosition(DoublePoint(60, 60), ProgrammaticScroll );
440 EXPECT_POINT_EQ(DoublePoint(50, 50), visualViewport->scrollPositionDouble()) ; 440 EXPECT_POINT_EQ(DoublePoint(50, 50), visualViewport->scrollPositionDouble()) ;
441 EXPECT_POINT_EQ(DoublePoint(10, 10), layoutViewport->scrollPositionDouble()) ; 441 EXPECT_POINT_EQ(DoublePoint(10, 10), layoutViewport->scrollPositionDouble()) ;
442 } 442 }
443 443
444 // Tests that setting an alternate layout viewport scrolls the alternate
445 // instead of the original.
446 TEST_F(RootFrameViewportTest, SetAlternateLayoutViewport)
447 {
448 IntSize viewportSize(100, 100);
449 RootFrameViewStub* layoutViewport = RootFrameViewStub::create(viewportSize, IntSize(200, 300));
450 VisualViewportStub* visualViewport = VisualViewportStub::create(viewportSize , viewportSize);
451
452 RootFrameViewStub* alternateScroller = RootFrameViewStub::create(viewportSiz e, IntSize(600, 500));
453
454 RootFrameViewport* rootFrameViewport =
455 RootFrameViewport::create(*visualViewport, *layoutViewport);
456
457 visualViewport->setScale(2);
458
459 rootFrameViewport->setScrollPosition(DoublePoint(100, 100), UserScroll);
460 EXPECT_POINT_EQ(DoublePoint(50, 50), visualViewport->scrollPositionDouble()) ;
461 EXPECT_POINT_EQ(DoublePoint(50, 50), layoutViewport->scrollPositionDouble()) ;
462 EXPECT_POINT_EQ(DoublePoint(100, 100), rootFrameViewport->scrollPositionDoub le());
463
464 rootFrameViewport->setLayoutViewport(*alternateScroller);
465 EXPECT_POINT_EQ(DoublePoint(50, 50), visualViewport->scrollPositionDouble()) ;
466 EXPECT_POINT_EQ(DoublePoint(0, 0), alternateScroller->scrollPositionDouble() );
467 EXPECT_POINT_EQ(DoublePoint(50, 50), rootFrameViewport->scrollPositionDouble ());
468
469 rootFrameViewport->setScrollPosition(DoublePoint(200, 200), UserScroll);
470 EXPECT_POINT_EQ(DoublePoint(50, 50), visualViewport->scrollPositionDouble()) ;
471 EXPECT_POINT_EQ(DoublePoint(150, 150), alternateScroller->scrollPositionDoub le());
472 EXPECT_POINT_EQ(DoublePoint(200, 200), rootFrameViewport->scrollPositionDoub le());
473 EXPECT_POINT_EQ(DoublePoint(50, 50), layoutViewport->scrollPositionDouble()) ;
474
475 EXPECT_POINT_EQ(DoublePoint(550, 450), rootFrameViewport->maximumScrollPosit ionDouble());
476 }
477
444 } // namespace blink 478 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698