| Index: third_party/WebKit/Source/web/tests/VisualViewportTest.cpp
|
| diff --git a/third_party/WebKit/Source/web/tests/VisualViewportTest.cpp b/third_party/WebKit/Source/web/tests/VisualViewportTest.cpp
|
| index 0786203f890b72cc32a7da82725408b2b5e8f78a..82515c716672f07aaea0c76c2c4698333dd58d6a 100644
|
| --- a/third_party/WebKit/Source/web/tests/VisualViewportTest.cpp
|
| +++ b/third_party/WebKit/Source/web/tests/VisualViewportTest.cpp
|
| @@ -46,6 +46,12 @@
|
| ASSERT_EQ((expected).y(), (actual).y()); \
|
| } while (false)
|
|
|
| +#define ASSERT_SIZE_EQ(expected, actual) \
|
| + do { \
|
| + ASSERT_EQ((expected).width(), (actual).width()); \
|
| + ASSERT_EQ((expected).height(), (actual).height()); \
|
| + } while (false)
|
| +
|
| #define EXPECT_POINT_EQ(expected, actual) \
|
| do { \
|
| EXPECT_EQ((expected).x(), (actual).x()); \
|
| @@ -240,18 +246,17 @@ TEST_P(ParameterizedVisualViewportTest,
|
| visualViewport.setScale(2);
|
|
|
| // Fully scroll both viewports.
|
| - frameView.layoutViewportScrollableArea()->setScrollPosition(
|
| - DoublePoint(10000, 10000), ProgrammaticScroll);
|
| + frameView.layoutViewportScrollableArea()->setScrollOffset(
|
| + ScrollOffset(10000, 10000), ProgrammaticScroll);
|
| visualViewport.move(FloatSize(10000, 10000));
|
|
|
| // Sanity check.
|
| ASSERT_POINT_EQ(FloatPoint(400, 300), visualViewport.location());
|
| - ASSERT_POINT_EQ(
|
| - DoublePoint(200, 1400),
|
| - frameView.layoutViewportScrollableArea()->scrollPositionDouble());
|
| + ASSERT_SIZE_EQ(ScrollOffset(200, 1400),
|
| + frameView.layoutViewportScrollableArea()->scrollOffset());
|
|
|
| - DoublePoint expectedLocation =
|
| - frameView.getScrollableArea()->visibleContentRectDouble().location();
|
| + IntPoint expectedLocation =
|
| + frameView.getScrollableArea()->visibleContentRect().location();
|
|
|
| // Shrink the WebView, this should cause both viewports to shrink and
|
| // WebView should do whatever it needs to do to preserve the visible
|
| @@ -260,13 +265,13 @@ TEST_P(ParameterizedVisualViewportTest,
|
|
|
| EXPECT_POINT_EQ(
|
| expectedLocation,
|
| - frameView.getScrollableArea()->visibleContentRectDouble().location());
|
| + frameView.getScrollableArea()->visibleContentRect().location());
|
|
|
| webViewImpl()->resize(IntSize(800, 600));
|
|
|
| EXPECT_POINT_EQ(
|
| expectedLocation,
|
| - frameView.getScrollableArea()->visibleContentRectDouble().location());
|
| + frameView.getScrollableArea()->visibleContentRect().location());
|
| }
|
|
|
| // Test that the VisualViewport works as expected in case of a scaled
|
| @@ -312,9 +317,9 @@ TEST_P(ParameterizedVisualViewportTest, TestResizeAfterVerticalScroll) {
|
|
|
| // Scroll main frame to the bottom of the document
|
| webViewImpl()->mainFrame()->setScrollOffset(WebSize(0, 400));
|
| - EXPECT_POINT_EQ(
|
| - IntPoint(0, 400),
|
| - frame()->view()->layoutViewportScrollableArea()->scrollPosition());
|
| + EXPECT_SIZE_EQ(
|
| + ScrollOffset(0, 400),
|
| + frame()->view()->layoutViewportScrollableArea()->scrollOffset());
|
|
|
| webViewImpl()->setPageScaleFactor(2.0);
|
|
|
| @@ -333,9 +338,9 @@ TEST_P(ParameterizedVisualViewportTest, TestResizeAfterVerticalScroll) {
|
| // After resizing the scale changes 2.0 -> 4.0
|
| EXPECT_FLOAT_SIZE_EQ(FloatSize(50, 25), visualViewport.visibleRect().size());
|
|
|
| - EXPECT_POINT_EQ(
|
| - IntPoint(0, 625),
|
| - frame()->view()->layoutViewportScrollableArea()->scrollPosition());
|
| + EXPECT_SIZE_EQ(
|
| + ScrollOffset(0, 625),
|
| + frame()->view()->layoutViewportScrollableArea()->scrollOffset());
|
| EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 75), visualViewport.location());
|
| }
|
|
|
| @@ -400,7 +405,7 @@ TEST_P(ParameterizedVisualViewportTest, TestResizeAfterHorizontalScroll) {
|
| // After resizing the scale changes 2.0 -> 4.0
|
| EXPECT_FLOAT_SIZE_EQ(FloatSize(50, 25), visualViewport.visibleRect().size());
|
|
|
| - EXPECT_POINT_EQ(IntPoint(0, 0), frame()->view()->scrollPosition());
|
| + EXPECT_SIZE_EQ(ScrollOffset(0, 0), frame()->view()->scrollOffset());
|
| EXPECT_FLOAT_POINT_EQ(FloatPoint(150, 0), visualViewport.location());
|
| }
|
|
|
| @@ -500,8 +505,8 @@ TEST_P(ParameterizedVisualViewportTest, TestVisibleRectInDocument) {
|
|
|
| // Scroll the layout viewport. Ensure its offset is reflected in visibleRectInDocument().
|
| FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView();
|
| - frameView.layoutViewportScrollableArea()->setScrollPosition(
|
| - DoublePoint(40, 100), ProgrammaticScroll);
|
| + frameView.layoutViewportScrollableArea()->setScrollOffset(
|
| + ScrollOffset(40, 100), ProgrammaticScroll);
|
| EXPECT_FLOAT_RECT_EQ(FloatRect(50, 115, 50, 200),
|
| visualViewport.visibleRectInDocument());
|
| }
|
| @@ -519,14 +524,13 @@ TEST_P(ParameterizedVisualViewportTest,
|
| navigateTo(m_baseURL + "200-by-800-viewport.html");
|
|
|
| FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView();
|
| - frameView.layoutViewportScrollableArea()->setScrollPosition(
|
| - DoublePoint(0, 10.5), ProgrammaticScroll);
|
| - frameView.layoutViewportScrollableArea()->ScrollableArea::setScrollPosition(
|
| - DoublePoint(10, 30.5), CompositorScroll);
|
| + frameView.layoutViewportScrollableArea()->setScrollOffset(
|
| + ScrollOffset(0, 10.5), ProgrammaticScroll);
|
| + frameView.layoutViewportScrollableArea()->ScrollableArea::setScrollOffset(
|
| + ScrollOffset(10, 30.5), CompositorScroll);
|
|
|
| - EXPECT_EQ(
|
| - 30.5,
|
| - frameView.layoutViewportScrollableArea()->scrollPositionDouble().y());
|
| + EXPECT_EQ(30.5,
|
| + frameView.layoutViewportScrollableArea()->scrollOffset().height());
|
|
|
| RuntimeEnabledFeatures::setFractionalScrollOffsetsEnabled(
|
| origFractionalOffsetsEnabled);
|
| @@ -757,7 +761,7 @@ TEST_P(ParameterizedVisualViewportTest,
|
| VisualViewport& visualViewport =
|
| frame()->page()->frameHost().visualViewport();
|
| visualViewport.setScale(2);
|
| - visualViewport.move(FloatPoint(50, 60));
|
| + visualViewport.move(ScrollOffset(50, 60));
|
|
|
| // Move and scale the viewport to make sure it gets reset in the navigation.
|
| EXPECT_POINT_EQ(FloatPoint(50, 60), visualViewport.location());
|
| @@ -855,11 +859,11 @@ TEST_P(ParameterizedVisualViewportTest, TestSavedToHistoryItem) {
|
| registerMockedHttpURLLoad("200-by-300.html");
|
| navigateTo(m_baseURL + "200-by-300.html");
|
|
|
| - EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0),
|
| - toLocalFrame(webViewImpl()->page()->mainFrame())
|
| - ->loader()
|
| - .currentItem()
|
| - ->visualViewportScrollPoint());
|
| + EXPECT_SIZE_EQ(ScrollOffset(0, 0),
|
| + toLocalFrame(webViewImpl()->page()->mainFrame())
|
| + ->loader()
|
| + .currentItem()
|
| + ->visualViewportScrollOffset());
|
|
|
| VisualViewport& visualViewport =
|
| frame()->page()->frameHost().visualViewport();
|
| @@ -872,11 +876,11 @@ TEST_P(ParameterizedVisualViewportTest, TestSavedToHistoryItem) {
|
|
|
| visualViewport.setLocation(FloatPoint(10, 20));
|
|
|
| - EXPECT_FLOAT_POINT_EQ(FloatPoint(10, 20),
|
| - toLocalFrame(webViewImpl()->page()->mainFrame())
|
| - ->loader()
|
| - .currentItem()
|
| - ->visualViewportScrollPoint());
|
| + EXPECT_SIZE_EQ(ScrollOffset(10, 20),
|
| + toLocalFrame(webViewImpl()->page()->mainFrame())
|
| + ->loader()
|
| + .currentItem()
|
| + ->visualViewportScrollOffset());
|
| }
|
|
|
| // Test restoring a HistoryItem properly restores the visual viewport's state.
|
| @@ -931,7 +935,7 @@ TEST_F(VisualViewportTest, TestRestoredFromLegacyHistoryItem) {
|
| VisualViewport& visualViewport =
|
| frame()->page()->frameHost().visualViewport();
|
| EXPECT_EQ(2, visualViewport.scale());
|
| - EXPECT_POINT_EQ(IntPoint(100, 150), frame()->view()->scrollPosition());
|
| + EXPECT_SIZE_EQ(ScrollOffset(100, 150), frame()->view()->scrollOffset());
|
| EXPECT_FLOAT_POINT_EQ(FloatPoint(20, 30),
|
| visualViewport.visibleRect().location());
|
| }
|
| @@ -948,8 +952,8 @@ TEST_P(ParameterizedVisualViewportTest,
|
| navigateTo(m_baseURL + "content-width-1000.html");
|
|
|
| FrameView* frameView = webViewImpl()->mainFrameImpl()->frameView();
|
| - frameView->layoutViewportScrollableArea()->setScrollPosition(
|
| - IntPoint(0, 1000), ProgrammaticScroll);
|
| + frameView->layoutViewportScrollableArea()->setScrollOffset(
|
| + ScrollOffset(0, 1000), ProgrammaticScroll);
|
|
|
| EXPECT_SIZE_EQ(IntSize(1000, 1000), frameView->frameRect().size());
|
|
|
| @@ -960,7 +964,7 @@ TEST_P(ParameterizedVisualViewportTest,
|
|
|
| Persistent<HistoryItem> firstItem =
|
| webViewImpl()->mainFrameImpl()->frame()->loader().currentItem();
|
| - EXPECT_POINT_EQ(IntPoint(0, 1000), firstItem->scrollPoint());
|
| + EXPECT_SIZE_EQ(ScrollOffset(0, 1000), firstItem->scrollOffset());
|
|
|
| // Now navigate to a page which causes a smaller frameView. Make sure that
|
| // navigating doesn't cause the history item to set a new scroll offset
|
| @@ -971,7 +975,7 @@ TEST_P(ParameterizedVisualViewportTest,
|
| EXPECT_NE(firstItem,
|
| webViewImpl()->mainFrameImpl()->frame()->loader().currentItem());
|
| EXPECT_LT(frameView->frameRect().size().width(), 1000);
|
| - EXPECT_POINT_EQ(IntPoint(0, 1000), firstItem->scrollPoint());
|
| + EXPECT_SIZE_EQ(ScrollOffset(0, 1000), firstItem->scrollOffset());
|
| }
|
|
|
| // Test that the coordinates sent into moveRangeSelection are offset by the
|
| @@ -1005,7 +1009,7 @@ TEST_P(ParameterizedVisualViewportTest,
|
| // the right and down one line.
|
| VisualViewport& visualViewport =
|
| frame()->page()->frameHost().visualViewport();
|
| - visualViewport.move(FloatPoint(60, 25));
|
| + visualViewport.move(ScrollOffset(60, 25));
|
| mainFrame->toWebLocalFrame()->moveRangeSelection(initialPoint, endPoint);
|
| EXPECT_EQ("t ", mainFrame->toWebLocalFrame()->selectionAsText().utf8());
|
| }
|
| @@ -1026,20 +1030,22 @@ TEST_P(ParameterizedVisualViewportTest,
|
| visualViewport.setLocation(FloatPoint());
|
| webViewImpl()->scrollFocusedEditableElementIntoRect(IntRect(0, 0, 500, 200));
|
|
|
| - EXPECT_POINT_EQ(IntPoint(0, frame()->view()->maximumScrollPosition().y()),
|
| - frame()->view()->scrollPosition());
|
| + EXPECT_SIZE_EQ(
|
| + ScrollOffset(0, frame()->view()->maximumScrollOffset().height()),
|
| + frame()->view()->scrollOffset());
|
| EXPECT_FLOAT_POINT_EQ(FloatPoint(150, 200),
|
| visualViewport.visibleRect().location());
|
|
|
| // Try it again but with the page zoomed in
|
| - frame()->view()->setScrollPosition(IntPoint(0, 0), ProgrammaticScroll);
|
| + frame()->view()->setScrollOffset(ScrollOffset(0, 0), ProgrammaticScroll);
|
| webViewImpl()->resizeVisualViewport(IntSize(500, 300));
|
| visualViewport.setLocation(FloatPoint(0, 0));
|
|
|
| webViewImpl()->setPageScaleFactor(2);
|
| webViewImpl()->scrollFocusedEditableElementIntoRect(IntRect(0, 0, 500, 200));
|
| - EXPECT_POINT_EQ(IntPoint(0, frame()->view()->maximumScrollPosition().y()),
|
| - frame()->view()->scrollPosition());
|
| + EXPECT_SIZE_EQ(
|
| + ScrollOffset(0, frame()->view()->maximumScrollOffset().height()),
|
| + frame()->view()->scrollOffset());
|
| EXPECT_FLOAT_POINT_EQ(FloatPoint(125, 150),
|
| visualViewport.visibleRect().location());
|
|
|
| @@ -1048,14 +1054,14 @@ TEST_P(ParameterizedVisualViewportTest,
|
| navigateTo(m_baseURL + "pinch-viewport-input-field-long-and-wide.html");
|
| webViewImpl()->setInitialFocus(false);
|
| visualViewport.setLocation(FloatPoint());
|
| - frame()->view()->setScrollPosition(IntPoint(0, 0), ProgrammaticScroll);
|
| + frame()->view()->setScrollOffset(ScrollOffset(0, 0), ProgrammaticScroll);
|
| webViewImpl()->resizeVisualViewport(IntSize(500, 300));
|
| visualViewport.setLocation(FloatPoint(30, 50));
|
|
|
| webViewImpl()->setPageScaleFactor(2);
|
| webViewImpl()->scrollFocusedEditableElementIntoRect(IntRect(0, 0, 500, 200));
|
| - EXPECT_POINT_EQ(IntPoint(200 - 30 - 75, 600 - 50 - 65),
|
| - frame()->view()->scrollPosition());
|
| + EXPECT_SIZE_EQ(ScrollOffset(200 - 30 - 75, 600 - 50 - 65),
|
| + frame()->view()->scrollOffset());
|
| EXPECT_FLOAT_POINT_EQ(FloatPoint(30, 50),
|
| visualViewport.visibleRect().location());
|
| }
|
| @@ -1207,59 +1213,60 @@ TEST_P(ParameterizedVisualViewportTest, ScrollIntoViewFractionalOffset) {
|
| // The element is already in the view so the scrollIntoView shouldn't move
|
| // the viewport at all.
|
| webViewImpl()->setVisualViewportOffset(WebFloatPoint(250.25f, 100.25f));
|
| - layoutViewportScrollableArea->setScrollPosition(DoublePoint(0, 900.75),
|
| - ProgrammaticScroll);
|
| + layoutViewportScrollableArea->setScrollOffset(ScrollOffset(0, 900.75),
|
| + ProgrammaticScroll);
|
| inputBox->scrollIntoViewIfNeeded(false);
|
|
|
| - EXPECT_POINT_EQ(DoublePoint(0, 900),
|
| - layoutViewportScrollableArea->scrollPositionDouble());
|
| + EXPECT_SIZE_EQ(ScrollOffset(0, 900),
|
| + layoutViewportScrollableArea->scrollOffset());
|
| EXPECT_POINT_EQ(FloatPoint(250.25f, 100.25f), visualViewport.location());
|
|
|
| // Change the fractional part of the frameview to one that would round down.
|
| - layoutViewportScrollableArea->setScrollPosition(DoublePoint(0, 900.125),
|
| - ProgrammaticScroll);
|
| + layoutViewportScrollableArea->setScrollOffset(ScrollOffset(0, 900.125),
|
| + ProgrammaticScroll);
|
| inputBox->scrollIntoViewIfNeeded(false);
|
|
|
| - EXPECT_POINT_EQ(DoublePoint(0, 900),
|
| - layoutViewportScrollableArea->scrollPositionDouble());
|
| + EXPECT_SIZE_EQ(ScrollOffset(0, 900),
|
| + layoutViewportScrollableArea->scrollOffset());
|
| EXPECT_POINT_EQ(FloatPoint(250.25f, 100.25f), visualViewport.location());
|
|
|
| // Repeat both tests above with the visual viewport at a high fractional.
|
| webViewImpl()->setVisualViewportOffset(WebFloatPoint(250.875f, 100.875f));
|
| - layoutViewportScrollableArea->setScrollPosition(DoublePoint(0, 900.75),
|
| - ProgrammaticScroll);
|
| + layoutViewportScrollableArea->setScrollOffset(ScrollOffset(0, 900.75),
|
| + ProgrammaticScroll);
|
| inputBox->scrollIntoViewIfNeeded(false);
|
|
|
| - EXPECT_POINT_EQ(DoublePoint(0, 900),
|
| - layoutViewportScrollableArea->scrollPositionDouble());
|
| + EXPECT_SIZE_EQ(ScrollOffset(0, 900),
|
| + layoutViewportScrollableArea->scrollOffset());
|
| EXPECT_POINT_EQ(FloatPoint(250.875f, 100.875f), visualViewport.location());
|
|
|
| // Change the fractional part of the frameview to one that would round down.
|
| - layoutViewportScrollableArea->setScrollPosition(DoublePoint(0, 900.125),
|
| - ProgrammaticScroll);
|
| + layoutViewportScrollableArea->setScrollOffset(ScrollOffset(0, 900.125),
|
| + ProgrammaticScroll);
|
| inputBox->scrollIntoViewIfNeeded(false);
|
|
|
| - EXPECT_POINT_EQ(DoublePoint(0, 900),
|
| - layoutViewportScrollableArea->scrollPositionDouble());
|
| + EXPECT_SIZE_EQ(ScrollOffset(0, 900),
|
| + layoutViewportScrollableArea->scrollOffset());
|
| EXPECT_POINT_EQ(FloatPoint(250.875f, 100.875f), visualViewport.location());
|
|
|
| // Both viewports with a 0.5 fraction.
|
| webViewImpl()->setVisualViewportOffset(WebFloatPoint(250.5f, 100.5f));
|
| - layoutViewportScrollableArea->setScrollPosition(DoublePoint(0, 900.5),
|
| - ProgrammaticScroll);
|
| + layoutViewportScrollableArea->setScrollOffset(ScrollOffset(0, 900.5),
|
| + ProgrammaticScroll);
|
| inputBox->scrollIntoViewIfNeeded(false);
|
|
|
| - EXPECT_POINT_EQ(DoublePoint(0, 900),
|
| - layoutViewportScrollableArea->scrollPositionDouble());
|
| + EXPECT_SIZE_EQ(ScrollOffset(0, 900),
|
| + layoutViewportScrollableArea->scrollOffset());
|
| EXPECT_POINT_EQ(FloatPoint(250.5f, 100.5f), visualViewport.location());
|
| }
|
|
|
| -static IntPoint expectedMaxFrameViewScrollOffset(VisualViewport& visualViewport,
|
| - FrameView& frameView) {
|
| +static ScrollOffset expectedMaxFrameViewScrollOffset(
|
| + VisualViewport& visualViewport,
|
| + FrameView& frameView) {
|
| float aspectRatio = visualViewport.visibleRect().width() /
|
| visualViewport.visibleRect().height();
|
| float newHeight = frameView.frameRect().width() / aspectRatio;
|
| - return IntPoint(
|
| + return ScrollOffset(
|
| frameView.contentsSize().width() - frameView.frameRect().width(),
|
| frameView.contentsSize().height() - newHeight);
|
| }
|
| @@ -1287,13 +1294,13 @@ TEST_F(VisualViewportTest, TestTopControlsAdjustment) {
|
| // Test that the scroll bounds are adjusted appropriately: the visual viewport
|
| // should be shrunk by 20px to 430px. The outer viewport was shrunk to maintain the
|
| // aspect ratio so it's height is 860px.
|
| - visualViewport.move(FloatPoint(10000, 10000));
|
| + visualViewport.move(ScrollOffset(10000, 10000));
|
| EXPECT_POINT_EQ(FloatPoint(500, 860 - 430), visualViewport.location());
|
|
|
| // The outer viewport (FrameView) should be affected as well.
|
| - frameView.scrollBy(IntSize(10000, 10000), UserScroll);
|
| - EXPECT_POINT_EQ(expectedMaxFrameViewScrollOffset(visualViewport, frameView),
|
| - frameView.scrollPosition());
|
| + frameView.scrollBy(ScrollOffset(10000, 10000), UserScroll);
|
| + EXPECT_SIZE_EQ(expectedMaxFrameViewScrollOffset(visualViewport, frameView),
|
| + frameView.scrollOffset());
|
|
|
| // Simulate bringing up the top controls by 10.5px.
|
| webViewImpl()->applyViewportDeltas(WebFloatSize(), WebFloatSize(),
|
| @@ -1302,13 +1309,13 @@ TEST_F(VisualViewportTest, TestTopControlsAdjustment) {
|
| visualViewport.visibleRect().size());
|
|
|
| // maximumScrollPosition |ceil|s the top controls adjustment.
|
| - visualViewport.move(FloatPoint(10000, 10000));
|
| + visualViewport.move(ScrollOffset(10000, 10000));
|
| EXPECT_FLOAT_POINT_EQ(FloatPoint(500, 881 - 441), visualViewport.location());
|
|
|
| // The outer viewport (FrameView) should be affected as well.
|
| - frameView.scrollBy(IntSize(10000, 10000), UserScroll);
|
| - EXPECT_POINT_EQ(expectedMaxFrameViewScrollOffset(visualViewport, frameView),
|
| - frameView.scrollPosition());
|
| + frameView.scrollBy(ScrollOffset(10000, 10000), UserScroll);
|
| + EXPECT_SIZE_EQ(expectedMaxFrameViewScrollOffset(visualViewport, frameView),
|
| + frameView.scrollOffset());
|
| }
|
|
|
| TEST_F(VisualViewportTest, TestTopControlsAdjustmentWithScale) {
|
| @@ -1334,26 +1341,26 @@ TEST_F(VisualViewportTest, TestTopControlsAdjustmentWithScale) {
|
| EXPECT_SIZE_EQ(IntSize(250, 215), visualViewport.visibleRect().size());
|
|
|
| // Test that the scroll bounds are adjusted appropriately.
|
| - visualViewport.move(FloatPoint(10000, 10000));
|
| + visualViewport.move(ScrollOffset(10000, 10000));
|
| EXPECT_POINT_EQ(FloatPoint(750, 860 - 215), visualViewport.location());
|
|
|
| // The outer viewport (FrameView) should be affected as well.
|
| - frameView.scrollBy(IntSize(10000, 10000), UserScroll);
|
| - IntPoint expected =
|
| + frameView.scrollBy(ScrollOffset(10000, 10000), UserScroll);
|
| + ScrollOffset expected =
|
| expectedMaxFrameViewScrollOffset(visualViewport, frameView);
|
| - EXPECT_POINT_EQ(expected, frameView.scrollPosition());
|
| + EXPECT_SIZE_EQ(expected, frameView.scrollOffset());
|
|
|
| // Scale back out, FrameView max scroll shouldn't have changed. Visual
|
| // viewport should be moved up to accomodate larger view.
|
| webViewImpl()->applyViewportDeltas(WebFloatSize(), WebFloatSize(),
|
| WebFloatSize(), 0.5f, 0);
|
| EXPECT_EQ(1, visualViewport.scale());
|
| - EXPECT_POINT_EQ(expected, frameView.scrollPosition());
|
| - frameView.scrollBy(IntSize(10000, 10000), UserScroll);
|
| - EXPECT_POINT_EQ(expected, frameView.scrollPosition());
|
| + EXPECT_SIZE_EQ(expected, frameView.scrollOffset());
|
| + frameView.scrollBy(ScrollOffset(10000, 10000), UserScroll);
|
| + EXPECT_SIZE_EQ(expected, frameView.scrollOffset());
|
|
|
| EXPECT_POINT_EQ(FloatPoint(500, 860 - 430), visualViewport.location());
|
| - visualViewport.move(FloatPoint(10000, 10000));
|
| + visualViewport.move(ScrollOffset(10000, 10000));
|
| EXPECT_POINT_EQ(FloatPoint(500, 860 - 430), visualViewport.location());
|
|
|
| // Scale out, use a scale that causes fractional rects.
|
| @@ -1367,13 +1374,13 @@ TEST_F(VisualViewportTest, TestTopControlsAdjustmentWithScale) {
|
| EXPECT_SIZE_EQ(FloatSize(625, 548.75), visualViewport.visibleRect().size());
|
|
|
| // Ensure max scroll offsets are updated properly.
|
| - visualViewport.move(FloatPoint(10000, 10000));
|
| + visualViewport.move(ScrollOffset(10000, 10000));
|
| EXPECT_FLOAT_POINT_EQ(FloatPoint(375, 877.5 - 548.75),
|
| visualViewport.location());
|
|
|
| - frameView.scrollBy(IntSize(10000, 10000), UserScroll);
|
| - EXPECT_POINT_EQ(expectedMaxFrameViewScrollOffset(visualViewport, frameView),
|
| - frameView.scrollPosition());
|
| + frameView.scrollBy(ScrollOffset(10000, 10000), UserScroll);
|
| + EXPECT_SIZE_EQ(expectedMaxFrameViewScrollOffset(visualViewport, frameView),
|
| + frameView.scrollOffset());
|
| }
|
|
|
| // Tests that a scroll all the way to the bottom of the page, while hiding the
|
| @@ -1411,20 +1418,20 @@ TEST_F(VisualViewportTest, TestTopControlsAdjustmentAndResize) {
|
| visualViewport.size());
|
|
|
| // Scroll all the way to the bottom, hiding the top controls in the process.
|
| - visualViewport.move(FloatPoint(10000, 10000));
|
| - frameView.scrollBy(IntSize(10000, 10000), UserScroll);
|
| + visualViewport.move(ScrollOffset(10000, 10000));
|
| + frameView.scrollBy(ScrollOffset(10000, 10000), UserScroll);
|
| webViewImpl()->topControls().setShownRatio(0);
|
|
|
| EXPECT_SIZE_EQ(IntSize(250, visualViewportHeight / pageScale),
|
| visualViewport.visibleRect().size());
|
|
|
| - IntPoint frameViewExpected =
|
| + ScrollOffset frameViewExpected =
|
| expectedMaxFrameViewScrollOffset(visualViewport, frameView);
|
| FloatPoint visualViewportExpected =
|
| FloatPoint(750, layoutViewportHeight - visualViewportHeight / pageScale);
|
|
|
| EXPECT_POINT_EQ(visualViewportExpected, visualViewport.location());
|
| - EXPECT_POINT_EQ(frameViewExpected, frameView.scrollPosition());
|
| + EXPECT_SIZE_EQ(frameViewExpected, frameView.scrollOffset());
|
|
|
| FloatPoint totalExpected = visualViewportExpected + frameViewExpected;
|
|
|
| @@ -1440,7 +1447,7 @@ TEST_F(VisualViewportTest, TestTopControlsAdjustmentAndResize) {
|
| EXPECT_SIZE_EQ(IntSize(1000, layoutViewportHeight),
|
| frameView.frameRect().size());
|
| EXPECT_POINT_EQ(totalExpected,
|
| - frameView.scrollPosition() + visualViewport.location());
|
| + visualViewport.location() + frameView.scrollOffset());
|
| }
|
|
|
| // Tests that a scroll all the way to the bottom while showing the top controls
|
| @@ -1479,14 +1486,14 @@ TEST_F(VisualViewportTest, TestTopControlsShrinkAdjustmentAndResize) {
|
| // process. (This could happen via window.scrollTo during a scroll, for
|
| // example).
|
| webViewImpl()->topControls().setShownRatio(1);
|
| - visualViewport.move(FloatPoint(10000, 10000));
|
| - frameView.scrollBy(IntSize(10000, 10000), UserScroll);
|
| + visualViewport.move(ScrollOffset(10000, 10000));
|
| + frameView.scrollBy(ScrollOffset(10000, 10000), UserScroll);
|
|
|
| EXPECT_SIZE_EQ(
|
| IntSize(250, (visualViewportHeight - topControlsHeight) / pageScale),
|
| visualViewport.visibleRect().size());
|
|
|
| - IntPoint frameViewExpected = IntPoint(
|
| + ScrollOffset frameViewExpected(
|
| 0, contentHeight -
|
| (layoutViewportHeight - topControlsHeight / minPageScale));
|
| FloatPoint visualViewportExpected =
|
| @@ -1494,7 +1501,7 @@ TEST_F(VisualViewportTest, TestTopControlsShrinkAdjustmentAndResize) {
|
| visualViewport.visibleRect().height()));
|
|
|
| EXPECT_POINT_EQ(visualViewportExpected, visualViewport.location());
|
| - EXPECT_POINT_EQ(frameViewExpected, frameView.scrollPosition());
|
| + EXPECT_SIZE_EQ(frameViewExpected, frameView.scrollOffset());
|
|
|
| FloatPoint totalExpected = visualViewportExpected + frameViewExpected;
|
|
|
| @@ -1513,7 +1520,7 @@ TEST_F(VisualViewportTest, TestTopControlsShrinkAdjustmentAndResize) {
|
| IntSize(1000, layoutViewportHeight - topControlsHeight / minPageScale),
|
| frameView.frameRect().size());
|
| EXPECT_POINT_EQ(totalExpected,
|
| - frameView.scrollPosition() + visualViewport.location());
|
| + visualViewport.location() + frameView.scrollOffset());
|
| }
|
|
|
| // Tests that a resize due to top controls hiding doesn't incorrectly clamp the
|
| @@ -1534,12 +1541,12 @@ TEST_F(VisualViewportTest, TestTopControlHidingResizeDoesntClampMainFrame) {
|
| webViewImpl()->applyViewportDeltas(WebFloatSize(), WebFloatSize(),
|
| WebFloatSize(), 1, -1);
|
| FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView();
|
| - frameView.setScrollPosition(IntPoint(0, 10000), ProgrammaticScroll);
|
| - EXPECT_EQ(500, frameView.scrollPositionDouble().y());
|
| + frameView.setScrollOffset(ScrollOffset(0, 10000), ProgrammaticScroll);
|
| + EXPECT_EQ(500, frameView.scrollOffset().height());
|
|
|
| // Now send the resize, make sure the scroll offset doesn't change.
|
| webViewImpl()->resizeWithTopControls(WebSize(1000, 1500), 500, false);
|
| - EXPECT_EQ(500, frameView.scrollPositionDouble().y());
|
| + EXPECT_EQ(500, frameView.scrollOffset().height());
|
| }
|
|
|
| static void configureHiddenScrollbarsSettings(WebSettings* settings) {
|
| @@ -1611,7 +1618,7 @@ TEST_P(ParameterizedVisualViewportTest,
|
|
|
| VisualViewport& visualViewport =
|
| frame()->page()->frameHost().visualViewport();
|
| - visualViewport.move(FloatPoint(0, 100));
|
| + visualViewport.move(ScrollOffset(0, 100));
|
|
|
| EXPECT_EQ(100, visualViewport.location().y());
|
|
|
| @@ -1779,12 +1786,11 @@ TEST_P(ParameterizedVisualViewportTest, FractionalMaxScrollOffset) {
|
| ScrollableArea* scrollableArea = &visualViewport;
|
|
|
| webViewImpl()->setPageScaleFactor(1.0);
|
| - EXPECT_FLOAT_POINT_EQ(DoublePoint(),
|
| - scrollableArea->maximumScrollPositionDouble());
|
| + EXPECT_SIZE_EQ(ScrollOffset(), scrollableArea->maximumScrollOffset());
|
|
|
| webViewImpl()->setPageScaleFactor(2);
|
| - EXPECT_FLOAT_POINT_EQ(DoublePoint(101. / 2., 201. / 2.),
|
| - scrollableArea->maximumScrollPositionDouble());
|
| + EXPECT_SIZE_EQ(ScrollOffset(101. / 2., 201. / 2.),
|
| + scrollableArea->maximumScrollOffset());
|
| }
|
|
|
| // Tests that the slow scrolling after an impl scroll on the visual viewport
|
| @@ -1838,8 +1844,8 @@ TEST_P(ParameterizedVisualViewportTest, AccessibilityHitTestWhileZoomedIn) {
|
|
|
| webViewImpl()->setPageScaleFactor(2);
|
| webViewImpl()->setVisualViewportOffset(WebFloatPoint(200, 230));
|
| - frameView.layoutViewportScrollableArea()->setScrollPosition(
|
| - DoublePoint(400, 1100), ProgrammaticScroll);
|
| + frameView.layoutViewportScrollableArea()->setScrollOffset(
|
| + ScrollOffset(400, 1100), ProgrammaticScroll);
|
|
|
| // FIXME(504057): PaintLayerScrollableArea dirties the compositing state.
|
| forceFullCompositingUpdate();
|
| @@ -1896,8 +1902,8 @@ TEST_P(ParameterizedVisualViewportTest, TestCoordinateTransforms) {
|
| visualViewport.rootFrameToViewport(FloatPoint(50.5, 62.4)));
|
|
|
| // Scrolling the main frame should have no effect.
|
| - frameView.layoutViewportScrollableArea()->setScrollPosition(
|
| - DoublePoint(100, 120), ProgrammaticScroll);
|
| + frameView.layoutViewportScrollableArea()->setScrollOffset(
|
| + ScrollOffset(100, 120), ProgrammaticScroll);
|
| EXPECT_FLOAT_POINT_EQ(FloatPoint(50, 62), visualViewport.viewportToRootFrame(
|
| FloatPoint(80, 100)));
|
| EXPECT_FLOAT_POINT_EQ(FloatPoint(80, 100),
|
| @@ -1959,7 +1965,7 @@ TEST_P(ParameterizedVisualViewportTest,
|
| FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView();
|
|
|
| EXPECT_FLOAT_POINT_EQ(FloatPoint(50, 50), visualViewport.location());
|
| - EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), frameView.scrollPositionDouble());
|
| + EXPECT_SIZE_EQ(ScrollOffset(0, 0), frameView.scrollOffset());
|
| }
|
|
|
| TEST_P(ParameterizedVisualViewportTest, ResizeWithScrollAnchoring) {
|
| @@ -1974,13 +1980,12 @@ TEST_P(ParameterizedVisualViewportTest, ResizeWithScrollAnchoring) {
|
| navigateTo(m_baseURL + "icb-relative-content.html");
|
|
|
| FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView();
|
| - frameView.layoutViewportScrollableArea()->setScrollPosition(
|
| - DoublePoint(700, 500), ProgrammaticScroll);
|
| + frameView.layoutViewportScrollableArea()->setScrollOffset(
|
| + ScrollOffset(700, 500), ProgrammaticScroll);
|
|
|
| webViewImpl()->resize(IntSize(800, 300));
|
| - EXPECT_POINT_EQ(
|
| - DoublePoint(700, 200),
|
| - frameView.layoutViewportScrollableArea()->scrollPositionDouble());
|
| + EXPECT_SIZE_EQ(ScrollOffset(700, 200),
|
| + frameView.layoutViewportScrollableArea()->scrollOffset());
|
|
|
| RuntimeEnabledFeatures::setScrollAnchoringEnabled(wasScrollAnchoringEnabled);
|
| }
|
| @@ -2005,18 +2010,17 @@ TEST_P(ParameterizedVisualViewportTest, ResizeAnchoringWithRootScroller) {
|
| frame()->document()->setRootScroller(scroller, nonThrow);
|
|
|
| webViewImpl()->setPageScaleFactor(3.f);
|
| - frameView.getScrollableArea()->setScrollPosition(DoublePoint(0, 400),
|
| - ProgrammaticScroll);
|
| + frameView.getScrollableArea()->setScrollOffset(ScrollOffset(0, 400),
|
| + ProgrammaticScroll);
|
|
|
| VisualViewport& visualViewport =
|
| webViewImpl()->page()->frameHost().visualViewport();
|
| - visualViewport.setScrollPosition(DoublePoint(0, 400), ProgrammaticScroll);
|
| + visualViewport.setScrollOffset(ScrollOffset(0, 400), ProgrammaticScroll);
|
|
|
| webViewImpl()->resize(IntSize(800, 500));
|
|
|
| - EXPECT_POINT_EQ(
|
| - DoublePoint(),
|
| - frameView.layoutViewportScrollableArea()->scrollPositionDouble());
|
| + EXPECT_SIZE_EQ(ScrollOffset(),
|
| + frameView.layoutViewportScrollableArea()->scrollOffset());
|
|
|
| RuntimeEnabledFeatures::setSetRootScrollerEnabled(wasRootScrollerEnabled);
|
| }
|
| @@ -2045,9 +2049,8 @@ TEST_P(ParameterizedVisualViewportTest, RotationAnchoringWithRootScroller) {
|
|
|
| webViewImpl()->resize(IntSize(600, 800));
|
|
|
| - EXPECT_POINT_EQ(
|
| - DoublePoint(),
|
| - frameView.layoutViewportScrollableArea()->scrollPositionDouble());
|
| + EXPECT_SIZE_EQ(ScrollOffset(),
|
| + frameView.layoutViewportScrollableArea()->scrollOffset());
|
| EXPECT_EQ(600, scroller->scrollTop());
|
|
|
| RuntimeEnabledFeatures::setSetRootScrollerEnabled(wasRootScrollerEnabled);
|
|
|