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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/frame/RootFrameViewportTest.cpp
diff --git a/third_party/WebKit/Source/core/frame/RootFrameViewportTest.cpp b/third_party/WebKit/Source/core/frame/RootFrameViewportTest.cpp
index e0edd0cc033ff31e0ca166c167c2076cdf7abb74..87ff48b999885042a61eb5abf73cd48ab8dd4414 100644
--- a/third_party/WebKit/Source/core/frame/RootFrameViewportTest.cpp
+++ b/third_party/WebKit/Source/core/frame/RootFrameViewportTest.cpp
@@ -441,4 +441,38 @@ TEST_F(RootFrameViewportTest, ViewportScrollOrder)
EXPECT_POINT_EQ(DoublePoint(10, 10), layoutViewport->scrollPositionDouble());
}
+// Tests that setting an alternate layout viewport scrolls the alternate
+// instead of the original.
+TEST_F(RootFrameViewportTest, SetAlternateLayoutViewport)
+{
+ IntSize viewportSize(100, 100);
+ RootFrameViewStub* layoutViewport = RootFrameViewStub::create(viewportSize, IntSize(200, 300));
+ VisualViewportStub* visualViewport = VisualViewportStub::create(viewportSize, viewportSize);
+
+ RootFrameViewStub* alternateScroller = RootFrameViewStub::create(viewportSize, IntSize(600, 500));
+
+ RootFrameViewport* rootFrameViewport =
+ RootFrameViewport::create(*visualViewport, *layoutViewport);
+
+ visualViewport->setScale(2);
+
+ rootFrameViewport->setScrollPosition(DoublePoint(100, 100), UserScroll);
+ EXPECT_POINT_EQ(DoublePoint(50, 50), visualViewport->scrollPositionDouble());
+ EXPECT_POINT_EQ(DoublePoint(50, 50), layoutViewport->scrollPositionDouble());
+ EXPECT_POINT_EQ(DoublePoint(100, 100), rootFrameViewport->scrollPositionDouble());
+
+ rootFrameViewport->setLayoutViewport(*alternateScroller);
+ EXPECT_POINT_EQ(DoublePoint(50, 50), visualViewport->scrollPositionDouble());
+ EXPECT_POINT_EQ(DoublePoint(0, 0), alternateScroller->scrollPositionDouble());
+ EXPECT_POINT_EQ(DoublePoint(50, 50), rootFrameViewport->scrollPositionDouble());
+
+ rootFrameViewport->setScrollPosition(DoublePoint(200, 200), UserScroll);
+ EXPECT_POINT_EQ(DoublePoint(50, 50), visualViewport->scrollPositionDouble());
+ EXPECT_POINT_EQ(DoublePoint(150, 150), alternateScroller->scrollPositionDouble());
+ EXPECT_POINT_EQ(DoublePoint(200, 200), rootFrameViewport->scrollPositionDouble());
+ EXPECT_POINT_EQ(DoublePoint(50, 50), layoutViewport->scrollPositionDouble());
+
+ EXPECT_POINT_EQ(DoublePoint(550, 450), rootFrameViewport->maximumScrollPositionDouble());
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698