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

Side by Side Diff: third_party/WebKit/Source/web/tests/VisualViewportTest.cpp

Issue 2005193005: Disable fractional scroll feature by default (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@layout-test-fix
Patch Set: Fix tests Created 4 years, 6 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
« no previous file with comments | « third_party/WebKit/Source/web/tests/ScrollingCoordinatorTest.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/VisualViewport.h" 5 #include "core/frame/VisualViewport.h"
6 6
7 #include "core/dom/Document.h" 7 #include "core/dom/Document.h"
8 #include "core/frame/FrameHost.h" 8 #include "core/frame/FrameHost.h"
9 #include "core/frame/FrameView.h" 9 #include "core/frame/FrameView.h"
10 #include "core/frame/LocalFrame.h" 10 #include "core/frame/LocalFrame.h"
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 EXPECT_FLOAT_RECT_EQ(FloatRect(10, 15, 50, 200), visualViewport.visibleRectI nDocument()); 505 EXPECT_FLOAT_RECT_EQ(FloatRect(10, 15, 50, 200), visualViewport.visibleRectI nDocument());
506 506
507 // Scroll the layout viewport. Ensure its offset is reflected in visibleRect InDocument(). 507 // Scroll the layout viewport. Ensure its offset is reflected in visibleRect InDocument().
508 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); 508 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView();
509 frameView.layoutViewportScrollableArea()->setScrollPosition(DoublePoint(40, 100), ProgrammaticScroll); 509 frameView.layoutViewportScrollableArea()->setScrollPosition(DoublePoint(40, 100), ProgrammaticScroll);
510 EXPECT_FLOAT_RECT_EQ(FloatRect(50, 115, 50, 200), visualViewport.visibleRect InDocument()); 510 EXPECT_FLOAT_RECT_EQ(FloatRect(50, 115, 50, 200), visualViewport.visibleRect InDocument());
511 } 511 }
512 512
513 TEST_P(ParameterizedVisualViewportTest, TestFractionalScrollOffsetIsNotOverwritt en) 513 TEST_P(ParameterizedVisualViewportTest, TestFractionalScrollOffsetIsNotOverwritt en)
514 { 514 {
515 bool origFractionalOffsetsEnabled = RuntimeEnabledFeatures::fractionalScroll OffsetsEnabled();
516 RuntimeEnabledFeatures::setFractionalScrollOffsetsEnabled(true);
517
515 initializeWithAndroidSettings(); 518 initializeWithAndroidSettings();
516 webViewImpl()->resize(IntSize(200, 250)); 519 webViewImpl()->resize(IntSize(200, 250));
517 520
518 registerMockedHttpURLLoad("200-by-800-viewport.html"); 521 registerMockedHttpURLLoad("200-by-800-viewport.html");
519 navigateTo(m_baseURL + "200-by-800-viewport.html"); 522 navigateTo(m_baseURL + "200-by-800-viewport.html");
520 523
521 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); 524 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView();
522 frameView.layoutViewportScrollableArea()->setScrollPosition(DoublePoint(0, 1 0.5), ProgrammaticScroll); 525 frameView.layoutViewportScrollableArea()->setScrollPosition(DoublePoint(0, 1 0.5), ProgrammaticScroll);
523 webViewImpl()->applyViewportDeltas(WebFloatSize(), WebFloatSize(10, 20), Web FloatSize(), 1, 0); 526 webViewImpl()->applyViewportDeltas(WebFloatSize(), WebFloatSize(10, 20), Web FloatSize(), 1, 0);
524 527
525 EXPECT_EQ(30.5, frameView.layoutViewportScrollableArea()->scrollPositionDoub le().y()); 528 EXPECT_EQ(30.5, frameView.layoutViewportScrollableArea()->scrollPositionDoub le().y());
529
530 RuntimeEnabledFeatures::setFractionalScrollOffsetsEnabled(origFractionalOffs etsEnabled);
526 } 531 }
527 532
528 // Test that the viewport's scroll offset is always appropriately bounded such t hat the 533 // Test that the viewport's scroll offset is always appropriately bounded such t hat the
529 // visual viewport always stays within the bounds of the main frame. 534 // visual viewport always stays within the bounds of the main frame.
530 TEST_P(ParameterizedVisualViewportTest, TestOffsetClamping) 535 TEST_P(ParameterizedVisualViewportTest, TestOffsetClamping)
531 { 536 {
532 initializeWithDesktopSettings(); 537 initializeWithDesktopSettings();
533 webViewImpl()->resize(IntSize(320, 240)); 538 webViewImpl()->resize(IntSize(320, 240));
534 539
535 navigateTo("about:blank"); 540 navigateTo("about:blank");
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after
1105 Mock::VerifyAndClearExpectations(&mockWebFrameClient); 1110 Mock::VerifyAndClearExpectations(&mockWebFrameClient);
1106 1111
1107 // Scroll horizontally. 1112 // Scroll horizontally.
1108 EXPECT_CALL(mockWebFrameClient, didChangeScrollOffset(_)); 1113 EXPECT_CALL(mockWebFrameClient, didChangeScrollOffset(_));
1109 visualViewport.setLocation(FloatPoint(70, 90)); 1114 visualViewport.setLocation(FloatPoint(70, 90));
1110 1115
1111 // Reset the old client so destruction can occur naturally. 1116 // Reset the old client so destruction can occur naturally.
1112 webViewImpl()->mainFrameImpl()->setClient(oldClient); 1117 webViewImpl()->mainFrameImpl()->setClient(oldClient);
1113 } 1118 }
1114 1119
1115 // Tests that calling scroll into view on a visible element doesn cause 1120 // Tests that calling scroll into view on a visible element doesn't cause
1116 // a scroll due to a fractional offset. Bug crbug.com/463356. 1121 // a scroll due to a fractional offset. Bug crbug.com/463356.
1117 TEST_P(ParameterizedVisualViewportTest, ScrollIntoViewFractionalOffset) 1122 TEST_P(ParameterizedVisualViewportTest, ScrollIntoViewFractionalOffset)
1118 { 1123 {
1119 initializeWithAndroidSettings(); 1124 initializeWithAndroidSettings();
1120 1125
1121 webViewImpl()->resize(IntSize(1000, 1000)); 1126 webViewImpl()->resize(IntSize(1000, 1000));
1122 1127
1123 registerMockedHttpURLLoad("scroll-into-view.html"); 1128 registerMockedHttpURLLoad("scroll-into-view.html");
1124 navigateTo(m_baseURL + "scroll-into-view.html"); 1129 navigateTo(m_baseURL + "scroll-into-view.html");
1125 1130
1126 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); 1131 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView();
1127 ScrollableArea* layoutViewportScrollableArea = frameView.layoutViewportScrol lableArea(); 1132 ScrollableArea* layoutViewportScrollableArea = frameView.layoutViewportScrol lableArea();
1128 VisualViewport& visualViewport = frame()->page()->frameHost().visualViewport (); 1133 VisualViewport& visualViewport = frame()->page()->frameHost().visualViewport ();
1129 Element* inputBox = frame()->document()->getElementById("box"); 1134 Element* inputBox = frame()->document()->getElementById("box");
1130 1135
1131 webViewImpl()->setPageScaleFactor(2); 1136 webViewImpl()->setPageScaleFactor(2);
1132 1137
1133 // The element is already in the view so the scrollIntoView shouldn't move 1138 // The element is already in the view so the scrollIntoView shouldn't move
1134 // the viewport at all. 1139 // the viewport at all.
1135 webViewImpl()->setVisualViewportOffset(WebFloatPoint(250.25f, 100.25f)); 1140 webViewImpl()->setVisualViewportOffset(WebFloatPoint(250.25f, 100.25f));
1136 layoutViewportScrollableArea->setScrollPosition(DoublePoint(0, 900.75), Prog rammaticScroll); 1141 layoutViewportScrollableArea->setScrollPosition(DoublePoint(0, 900.75), Prog rammaticScroll);
1137 inputBox->scrollIntoViewIfNeeded(false); 1142 inputBox->scrollIntoViewIfNeeded(false);
1138 1143
1139 EXPECT_POINT_EQ(DoublePoint(0, 900.75), layoutViewportScrollableArea->scroll PositionDouble()); 1144 EXPECT_POINT_EQ(DoublePoint(0, 900), layoutViewportScrollableArea->scrollPos itionDouble());
1140 EXPECT_POINT_EQ(FloatPoint(250.25f, 100.25f), visualViewport.location()); 1145 EXPECT_POINT_EQ(FloatPoint(250.25f, 100.25f), visualViewport.location());
1141 1146
1142 // Change the fractional part of the frameview to one that would round down. 1147 // Change the fractional part of the frameview to one that would round down.
1143 layoutViewportScrollableArea->setScrollPosition(DoublePoint(0, 900.125), Pro grammaticScroll); 1148 layoutViewportScrollableArea->setScrollPosition(DoublePoint(0, 900.125), Pro grammaticScroll);
1144 inputBox->scrollIntoViewIfNeeded(false); 1149 inputBox->scrollIntoViewIfNeeded(false);
1145 1150
1146 EXPECT_POINT_EQ(DoublePoint(0, 900.125), layoutViewportScrollableArea->scrol lPositionDouble()); 1151 EXPECT_POINT_EQ(DoublePoint(0, 900), layoutViewportScrollableArea->scrollPos itionDouble());
1147 EXPECT_POINT_EQ(FloatPoint(250.25f, 100.25f), visualViewport.location()); 1152 EXPECT_POINT_EQ(FloatPoint(250.25f, 100.25f), visualViewport.location());
1148 1153
1149 // Repeat both tests above with the visual viewport at a high fractional. 1154 // Repeat both tests above with the visual viewport at a high fractional.
1150 webViewImpl()->setVisualViewportOffset(WebFloatPoint(250.875f, 100.875f)); 1155 webViewImpl()->setVisualViewportOffset(WebFloatPoint(250.875f, 100.875f));
1151 layoutViewportScrollableArea->setScrollPosition(DoublePoint(0, 900.75), Prog rammaticScroll); 1156 layoutViewportScrollableArea->setScrollPosition(DoublePoint(0, 900.75), Prog rammaticScroll);
1152 inputBox->scrollIntoViewIfNeeded(false); 1157 inputBox->scrollIntoViewIfNeeded(false);
1153 1158
1154 EXPECT_POINT_EQ(DoublePoint(0, 900.75), layoutViewportScrollableArea->scroll PositionDouble()); 1159 EXPECT_POINT_EQ(DoublePoint(0, 900), layoutViewportScrollableArea->scrollPos itionDouble());
1155 EXPECT_POINT_EQ(FloatPoint(250.875f, 100.875f), visualViewport.location()); 1160 EXPECT_POINT_EQ(FloatPoint(250.875f, 100.875f), visualViewport.location());
1156 1161
1157 // Change the fractional part of the frameview to one that would round down. 1162 // Change the fractional part of the frameview to one that would round down.
1158 layoutViewportScrollableArea->setScrollPosition(DoublePoint(0, 900.125), Pro grammaticScroll); 1163 layoutViewportScrollableArea->setScrollPosition(DoublePoint(0, 900.125), Pro grammaticScroll);
1159 inputBox->scrollIntoViewIfNeeded(false); 1164 inputBox->scrollIntoViewIfNeeded(false);
1160 1165
1161 EXPECT_POINT_EQ(DoublePoint(0, 900.125), layoutViewportScrollableArea->scrol lPositionDouble()); 1166 EXPECT_POINT_EQ(DoublePoint(0, 900), layoutViewportScrollableArea->scrollPos itionDouble());
1162 EXPECT_POINT_EQ(FloatPoint(250.875f, 100.875f), visualViewport.location()); 1167 EXPECT_POINT_EQ(FloatPoint(250.875f, 100.875f), visualViewport.location());
1163 1168
1164 // Both viewports with a 0.5 fraction. 1169 // Both viewports with a 0.5 fraction.
1165 webViewImpl()->setVisualViewportOffset(WebFloatPoint(250.5f, 100.5f)); 1170 webViewImpl()->setVisualViewportOffset(WebFloatPoint(250.5f, 100.5f));
1166 layoutViewportScrollableArea->setScrollPosition(DoublePoint(0, 900.5), Progr ammaticScroll); 1171 layoutViewportScrollableArea->setScrollPosition(DoublePoint(0, 900.5), Progr ammaticScroll);
1167 inputBox->scrollIntoViewIfNeeded(false); 1172 inputBox->scrollIntoViewIfNeeded(false);
1168 1173
1169 EXPECT_POINT_EQ(DoublePoint(0, 900.5), layoutViewportScrollableArea->scrollP ositionDouble()); 1174 EXPECT_POINT_EQ(DoublePoint(0, 900), layoutViewportScrollableArea->scrollPos itionDouble());
1170 EXPECT_POINT_EQ(FloatPoint(250.5f, 100.5f), visualViewport.location()); 1175 EXPECT_POINT_EQ(FloatPoint(250.5f, 100.5f), visualViewport.location());
1171 } 1176 }
1172 1177
1173 // Top controls can make an unscrollable page temporarily scrollable, causing 1178 // Top controls can make an unscrollable page temporarily scrollable, causing
1174 // a scroll clamp when the page is resized. Make sure this bug is fixed. 1179 // a scroll clamp when the page is resized. Make sure this bug is fixed.
1175 // crbug.com/437620 1180 // crbug.com/437620
1176 TEST_F(VisualViewportTest, TestResizeDoesntChangeScrollOffset) 1181 TEST_F(VisualViewportTest, TestResizeDoesntChangeScrollOffset)
1177 { 1182 {
1178 RuntimeEnabledFeatures::setInertTopControlsEnabled(false); 1183 RuntimeEnabledFeatures::setInertTopControlsEnabled(false);
1179 initializeWithAndroidSettings(); 1184 initializeWithAndroidSettings();
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after
1853 webViewImpl()->handleInputEvent(pinchUpdate); 1858 webViewImpl()->handleInputEvent(pinchUpdate);
1854 1859
1855 VisualViewport& visualViewport = webViewImpl()->page()->frameHost().visualVi ewport(); 1860 VisualViewport& visualViewport = webViewImpl()->page()->frameHost().visualVi ewport();
1856 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); 1861 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView();
1857 1862
1858 EXPECT_FLOAT_POINT_EQ(FloatPoint(50, 50), visualViewport.location()); 1863 EXPECT_FLOAT_POINT_EQ(FloatPoint(50, 50), visualViewport.location());
1859 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), frameView.scrollPositionDouble()); 1864 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), frameView.scrollPositionDouble());
1860 } 1865 }
1861 1866
1862 } // namespace 1867 } // namespace
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/tests/ScrollingCoordinatorTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698