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

Side by Side Diff: Source/web/tests/PinchViewportTest.cpp

Issue 1158673006: Replace various ScrollableArea scroll methods with setScrollPosition (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Build fix Created 5 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 | « Source/web/WebViewImpl.cpp ('k') | Source/web/tests/ScrollAnimatorNoneTest.cpp » ('j') | 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 "config.h" 5 #include "config.h"
6 6
7 #include "core/frame/PinchViewport.h" 7 #include "core/frame/PinchViewport.h"
8 8
9 #include "core/dom/Document.h" 9 #include "core/dom/Document.h"
10 #include "core/frame/FrameHost.h" 10 #include "core/frame/FrameHost.h"
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 227
228 registerMockedHttpURLLoad("content-width-1000.html"); 228 registerMockedHttpURLLoad("content-width-1000.html");
229 navigateTo(m_baseURL + "content-width-1000.html"); 229 navigateTo(m_baseURL + "content-width-1000.html");
230 230
231 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); 231 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView();
232 PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport(); 232 PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport();
233 233
234 pinchViewport.setScale(2); 234 pinchViewport.setScale(2);
235 235
236 // Fully scroll both viewports. 236 // Fully scroll both viewports.
237 frameView.setScrollPosition(DoublePoint(10000, 10000)); 237 frameView.setScrollPosition(DoublePoint(10000, 10000), ProgrammaticScroll);
238 pinchViewport.move(FloatSize(10000, 10000)); 238 pinchViewport.move(FloatSize(10000, 10000));
239 239
240 // Sanity check. 240 // Sanity check.
241 ASSERT_POINT_EQ(FloatPoint(400, 300), pinchViewport.location()); 241 ASSERT_POINT_EQ(FloatPoint(400, 300), pinchViewport.location());
242 ASSERT_POINT_EQ(DoublePoint(200, 1400), frameView.scrollPositionDouble()); 242 ASSERT_POINT_EQ(DoublePoint(200, 1400), frameView.scrollPositionDouble());
243 243
244 DoublePoint expectedLocation = frameView.scrollableArea()->visibleContentRec tDouble().location(); 244 DoublePoint expectedLocation = frameView.scrollableArea()->visibleContentRec tDouble().location();
245 245
246 // Shrink the WebView, this should cause both viewports to shrink and 246 // Shrink the WebView, this should cause both viewports to shrink and
247 // WebView should do whatever it needs to do to preserve the visible 247 // WebView should do whatever it needs to do to preserve the visible
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 TEST_F(PinchViewportTest, TestNavigateToSmallerFrameViewHistoryItemClobberBug) 836 TEST_F(PinchViewportTest, TestNavigateToSmallerFrameViewHistoryItemClobberBug)
837 { 837 {
838 initializeWithAndroidSettings(); 838 initializeWithAndroidSettings();
839 webViewImpl()->resize(IntSize(400, 400)); 839 webViewImpl()->resize(IntSize(400, 400));
840 webViewImpl()->layout(); 840 webViewImpl()->layout();
841 841
842 registerMockedHttpURLLoad("content-width-1000.html"); 842 registerMockedHttpURLLoad("content-width-1000.html");
843 navigateTo(m_baseURL + "content-width-1000.html"); 843 navigateTo(m_baseURL + "content-width-1000.html");
844 844
845 FrameView* frameView = webViewImpl()->mainFrameImpl()->frameView(); 845 FrameView* frameView = webViewImpl()->mainFrameImpl()->frameView();
846 frameView->setScrollOffset(IntPoint(0, 1000)); 846 frameView->setScrollPosition(IntPoint(0, 1000), ProgrammaticScroll);
847 847
848 EXPECT_SIZE_EQ(IntSize(1000, 1000), frameView->frameRect().size()); 848 EXPECT_SIZE_EQ(IntSize(1000, 1000), frameView->frameRect().size());
849 849
850 PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport(); 850 PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport();
851 pinchViewport.setScale(2); 851 pinchViewport.setScale(2);
852 pinchViewport.setLocation(FloatPoint(350, 350)); 852 pinchViewport.setLocation(FloatPoint(350, 350));
853 853
854 RefPtrWillBePersistent<HistoryItem> firstItem = webViewImpl()->mainFrameImpl ()->frame()->loader().currentItem(); 854 RefPtrWillBePersistent<HistoryItem> firstItem = webViewImpl()->mainFrameImpl ()->frame()->loader().currentItem();
855 EXPECT_POINT_EQ(IntPoint(0, 1000), firstItem->scrollPoint()); 855 EXPECT_POINT_EQ(IntPoint(0, 1000), firstItem->scrollPoint());
856 856
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
928 webViewImpl()->scrollFocusedNodeIntoRect(IntRect(0, 0, 500, 200)); 928 webViewImpl()->scrollFocusedNodeIntoRect(IntRect(0, 0, 500, 200));
929 EXPECT_POINT_EQ(IntPoint(0, frame()->view()->maximumScrollPosition().y()), 929 EXPECT_POINT_EQ(IntPoint(0, frame()->view()->maximumScrollPosition().y()),
930 frame()->view()->scrollPosition()); 930 frame()->view()->scrollPosition());
931 EXPECT_FLOAT_POINT_EQ(FloatPoint(125, 150), pinchViewport.visibleRect().loca tion()); 931 EXPECT_FLOAT_POINT_EQ(FloatPoint(125, 150), pinchViewport.visibleRect().loca tion());
932 932
933 // Once more but make sure that we don't move the pinch viewport unless nece ssary. 933 // Once more but make sure that we don't move the pinch viewport unless nece ssary.
934 registerMockedHttpURLLoad("pinch-viewport-input-field-long-and-wide.html"); 934 registerMockedHttpURLLoad("pinch-viewport-input-field-long-and-wide.html");
935 navigateTo(m_baseURL + "pinch-viewport-input-field-long-and-wide.html"); 935 navigateTo(m_baseURL + "pinch-viewport-input-field-long-and-wide.html");
936 webViewImpl()->setInitialFocus(false); 936 webViewImpl()->setInitialFocus(false);
937 pinchViewport.setLocation(FloatPoint()); 937 pinchViewport.setLocation(FloatPoint());
938 frame()->view()->notifyScrollPositionChanged(IntPoint(0, 0)); 938 frame()->view()->setScrollPosition(IntPoint(0, 0), ProgrammaticScroll);
939 webViewImpl()->resizePinchViewport(IntSize(500, 300)); 939 webViewImpl()->resizePinchViewport(IntSize(500, 300));
940 pinchViewport.setLocation(FloatPoint(30, 50)); 940 pinchViewport.setLocation(FloatPoint(30, 50));
941 941
942 webViewImpl()->setPageScaleFactor(2); 942 webViewImpl()->setPageScaleFactor(2);
943 webViewImpl()->scrollFocusedNodeIntoRect(IntRect(0, 0, 500, 200)); 943 webViewImpl()->scrollFocusedNodeIntoRect(IntRect(0, 0, 500, 200));
944 EXPECT_POINT_EQ(IntPoint(200-30-75, 600-50-65), frame()->view()->scrollPosit ion()); 944 EXPECT_POINT_EQ(IntPoint(200-30-75, 600-50-65), frame()->view()->scrollPosit ion());
945 EXPECT_FLOAT_POINT_EQ(FloatPoint(30, 50), pinchViewport.visibleRect().locati on()); 945 EXPECT_FLOAT_POINT_EQ(FloatPoint(30, 50), pinchViewport.visibleRect().locati on());
946 } 946 }
947 947
948 // Test that resizing the WebView causes ViewportConstrained objects to relayout . 948 // Test that resizing the WebView causes ViewportConstrained objects to relayout .
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
1077 1077
1078 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); 1078 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView();
1079 PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport(); 1079 PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport();
1080 Element* inputBox = frame()->document()->getElementById("box"); 1080 Element* inputBox = frame()->document()->getElementById("box");
1081 1081
1082 webViewImpl()->setPageScaleFactor(2); 1082 webViewImpl()->setPageScaleFactor(2);
1083 1083
1084 // The element is already in the view so the scrollIntoView shouldn't move 1084 // The element is already in the view so the scrollIntoView shouldn't move
1085 // the viewport at all. 1085 // the viewport at all.
1086 webViewImpl()->setPinchViewportOffset(WebFloatPoint(250.25f, 100.25f)); 1086 webViewImpl()->setPinchViewportOffset(WebFloatPoint(250.25f, 100.25f));
1087 frameView.setScrollPosition(DoublePoint(0, 900.75)); 1087 frameView.setScrollPosition(DoublePoint(0, 900.75), ProgrammaticScroll);
1088 inputBox->scrollIntoViewIfNeeded(false); 1088 inputBox->scrollIntoViewIfNeeded(false);
1089 1089
1090 EXPECT_POINT_EQ(DoublePoint(0, 900.75), frameView.scrollPositionDouble()); 1090 EXPECT_POINT_EQ(DoublePoint(0, 900.75), frameView.scrollPositionDouble());
1091 EXPECT_POINT_EQ(FloatPoint(250.25f, 100.25f), pinchViewport.location()); 1091 EXPECT_POINT_EQ(FloatPoint(250.25f, 100.25f), pinchViewport.location());
1092 1092
1093 // Change the fractional part of the frameview to one that would round down. 1093 // Change the fractional part of the frameview to one that would round down.
1094 frameView.setScrollPosition(DoublePoint(0, 900.125)); 1094 frameView.setScrollPosition(DoublePoint(0, 900.125), ProgrammaticScroll);
1095 inputBox->scrollIntoViewIfNeeded(false); 1095 inputBox->scrollIntoViewIfNeeded(false);
1096 1096
1097 EXPECT_POINT_EQ(DoublePoint(0, 900.125), frameView.scrollPositionDouble()); 1097 EXPECT_POINT_EQ(DoublePoint(0, 900.125), frameView.scrollPositionDouble());
1098 EXPECT_POINT_EQ(FloatPoint(250.25f, 100.25f), pinchViewport.location()); 1098 EXPECT_POINT_EQ(FloatPoint(250.25f, 100.25f), pinchViewport.location());
1099 1099
1100 // Repeat both tests above with the pinch viewport at a high fractional. 1100 // Repeat both tests above with the pinch viewport at a high fractional.
1101 webViewImpl()->setPinchViewportOffset(WebFloatPoint(250.875f, 100.875f)); 1101 webViewImpl()->setPinchViewportOffset(WebFloatPoint(250.875f, 100.875f));
1102 frameView.setScrollPosition(DoublePoint(0, 900.75)); 1102 frameView.setScrollPosition(DoublePoint(0, 900.75), ProgrammaticScroll);
1103 inputBox->scrollIntoViewIfNeeded(false); 1103 inputBox->scrollIntoViewIfNeeded(false);
1104 1104
1105 EXPECT_POINT_EQ(DoublePoint(0, 900.75), frameView.scrollPositionDouble()); 1105 EXPECT_POINT_EQ(DoublePoint(0, 900.75), frameView.scrollPositionDouble());
1106 EXPECT_POINT_EQ(FloatPoint(250.875f, 100.875f), pinchViewport.location()); 1106 EXPECT_POINT_EQ(FloatPoint(250.875f, 100.875f), pinchViewport.location());
1107 1107
1108 // Change the fractional part of the frameview to one that would round down. 1108 // Change the fractional part of the frameview to one that would round down.
1109 frameView.setScrollPosition(DoublePoint(0, 900.125)); 1109 frameView.setScrollPosition(DoublePoint(0, 900.125), ProgrammaticScroll);
1110 inputBox->scrollIntoViewIfNeeded(false); 1110 inputBox->scrollIntoViewIfNeeded(false);
1111 1111
1112 EXPECT_POINT_EQ(DoublePoint(0, 900.125), frameView.scrollPositionDouble()); 1112 EXPECT_POINT_EQ(DoublePoint(0, 900.125), frameView.scrollPositionDouble());
1113 EXPECT_POINT_EQ(FloatPoint(250.875f, 100.875f), pinchViewport.location()); 1113 EXPECT_POINT_EQ(FloatPoint(250.875f, 100.875f), pinchViewport.location());
1114 1114
1115 // Both viewports with a 0.5 fraction. 1115 // Both viewports with a 0.5 fraction.
1116 webViewImpl()->setPinchViewportOffset(WebFloatPoint(250.5f, 100.5f)); 1116 webViewImpl()->setPinchViewportOffset(WebFloatPoint(250.5f, 100.5f));
1117 frameView.setScrollPosition(DoublePoint(0, 900.5)); 1117 frameView.setScrollPosition(DoublePoint(0, 900.5), ProgrammaticScroll);
1118 inputBox->scrollIntoViewIfNeeded(false); 1118 inputBox->scrollIntoViewIfNeeded(false);
1119 1119
1120 EXPECT_POINT_EQ(DoublePoint(0, 900.5), frameView.scrollPositionDouble()); 1120 EXPECT_POINT_EQ(DoublePoint(0, 900.5), frameView.scrollPositionDouble());
1121 EXPECT_POINT_EQ(FloatPoint(250.5f, 100.5f), pinchViewport.location()); 1121 EXPECT_POINT_EQ(FloatPoint(250.5f, 100.5f), pinchViewport.location());
1122 } 1122 }
1123 1123
1124 // Top controls can make an unscrollable page temporarily scrollable, causing 1124 // Top controls can make an unscrollable page temporarily scrollable, causing
1125 // a scroll clamp when the page is resized. Make sure this bug is fixed. 1125 // a scroll clamp when the page is resized. Make sure this bug is fixed.
1126 // crbug.com/437620 1126 // crbug.com/437620
1127 TEST_F(PinchViewportTest, TestResizeDoesntChangeScrollOffset) 1127 TEST_F(PinchViewportTest, TestResizeDoesntChangeScrollOffset)
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1184 webViewImpl()->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatS ize(), 1, 1); 1184 webViewImpl()->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatS ize(), 1, 1);
1185 EXPECT_SIZE_EQ(IntSize(500, 430), pinchViewport.visibleRect().size()); 1185 EXPECT_SIZE_EQ(IntSize(500, 430), pinchViewport.visibleRect().size());
1186 1186
1187 // Test that the scroll bounds are adjusted appropriately: the pinch viewpor t 1187 // Test that the scroll bounds are adjusted appropriately: the pinch viewpor t
1188 // should be shrunk by 20px to 430px. The outer viewport was shrunk to maint ain the 1188 // should be shrunk by 20px to 430px. The outer viewport was shrunk to maint ain the
1189 // aspect ratio so it's height is 860px. 1189 // aspect ratio so it's height is 860px.
1190 pinchViewport.move(FloatPoint(10000, 10000)); 1190 pinchViewport.move(FloatPoint(10000, 10000));
1191 EXPECT_POINT_EQ(FloatPoint(500, 860 - 430), pinchViewport.location()); 1191 EXPECT_POINT_EQ(FloatPoint(500, 860 - 430), pinchViewport.location());
1192 1192
1193 // The outer viewport (FrameView) should be affected as well. 1193 // The outer viewport (FrameView) should be affected as well.
1194 frameView.scrollBy(IntSize(10000, 10000)); 1194 frameView.scrollBy(IntSize(10000, 10000), UserScroll);
1195 EXPECT_POINT_EQ( 1195 EXPECT_POINT_EQ(
1196 expectedMaxFrameViewScrollOffset(pinchViewport, frameView), 1196 expectedMaxFrameViewScrollOffset(pinchViewport, frameView),
1197 frameView.scrollPosition()); 1197 frameView.scrollPosition());
1198 1198
1199 // Simulate bringing up the top controls by 10.5px. 1199 // Simulate bringing up the top controls by 10.5px.
1200 webViewImpl()->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatS ize(), 1, -10.5f / 20); 1200 webViewImpl()->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatS ize(), 1, -10.5f / 20);
1201 EXPECT_FLOAT_SIZE_EQ(FloatSize(500, 440.5f), pinchViewport.visibleRect().siz e()); 1201 EXPECT_FLOAT_SIZE_EQ(FloatSize(500, 440.5f), pinchViewport.visibleRect().siz e());
1202 1202
1203 // maximumScrollPosition floors the final values. 1203 // maximumScrollPosition floors the final values.
1204 pinchViewport.move(FloatPoint(10000, 10000)); 1204 pinchViewport.move(FloatPoint(10000, 10000));
1205 EXPECT_FLOAT_POINT_EQ(FloatPoint(500, 881 - 440.5f), pinchViewport.location( )); 1205 EXPECT_FLOAT_POINT_EQ(FloatPoint(500, 881 - 440.5f), pinchViewport.location( ));
1206 1206
1207 // The outer viewport (FrameView) should be affected as well. 1207 // The outer viewport (FrameView) should be affected as well.
1208 frameView.scrollBy(IntSize(10000, 10000)); 1208 frameView.scrollBy(IntSize(10000, 10000), UserScroll);
1209 EXPECT_POINT_EQ( 1209 EXPECT_POINT_EQ(
1210 expectedMaxFrameViewScrollOffset(pinchViewport, frameView), 1210 expectedMaxFrameViewScrollOffset(pinchViewport, frameView),
1211 frameView.scrollPosition()); 1211 frameView.scrollPosition());
1212 } 1212 }
1213 1213
1214 TEST_F(PinchViewportTest, TestTopControlsAdjustmentWithScale) 1214 TEST_F(PinchViewportTest, TestTopControlsAdjustmentWithScale)
1215 { 1215 {
1216 initializeWithAndroidSettings(); 1216 initializeWithAndroidSettings();
1217 webViewImpl()->resize(IntSize(500, 450)); 1217 webViewImpl()->resize(IntSize(500, 450));
1218 1218
(...skipping 13 matching lines...) Expand all
1232 // the top controls take up half as much space (in document-space) than 1232 // the top controls take up half as much space (in document-space) than
1233 // they do at an unzoomed level. 1233 // they do at an unzoomed level.
1234 webViewImpl()->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatS ize(), 1, 1); 1234 webViewImpl()->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatS ize(), 1, 1);
1235 EXPECT_SIZE_EQ(IntSize(250, 215), pinchViewport.visibleRect().size()); 1235 EXPECT_SIZE_EQ(IntSize(250, 215), pinchViewport.visibleRect().size());
1236 1236
1237 // Test that the scroll bounds are adjusted appropriately. 1237 // Test that the scroll bounds are adjusted appropriately.
1238 pinchViewport.move(FloatPoint(10000, 10000)); 1238 pinchViewport.move(FloatPoint(10000, 10000));
1239 EXPECT_POINT_EQ(FloatPoint(750, 860 - 215), pinchViewport.location()); 1239 EXPECT_POINT_EQ(FloatPoint(750, 860 - 215), pinchViewport.location());
1240 1240
1241 // The outer viewport (FrameView) should be affected as well. 1241 // The outer viewport (FrameView) should be affected as well.
1242 frameView.scrollBy(IntSize(10000, 10000)); 1242 frameView.scrollBy(IntSize(10000, 10000), UserScroll);
1243 IntPoint expected = expectedMaxFrameViewScrollOffset(pinchViewport, frameVie w); 1243 IntPoint expected = expectedMaxFrameViewScrollOffset(pinchViewport, frameVie w);
1244 EXPECT_POINT_EQ(expected, frameView.scrollPosition()); 1244 EXPECT_POINT_EQ(expected, frameView.scrollPosition());
1245 1245
1246 // Scale back out, FrameView max scroll shouldn't have changed. Pinch 1246 // Scale back out, FrameView max scroll shouldn't have changed. Pinch
1247 // viewport should be moved up to accomodate larger view. 1247 // viewport should be moved up to accomodate larger view.
1248 webViewImpl()->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatS ize(), 0.5f, 0); 1248 webViewImpl()->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatS ize(), 0.5f, 0);
1249 EXPECT_EQ(1, pinchViewport.scale()); 1249 EXPECT_EQ(1, pinchViewport.scale());
1250 EXPECT_POINT_EQ(expected, frameView.scrollPosition()); 1250 EXPECT_POINT_EQ(expected, frameView.scrollPosition());
1251 frameView.scrollBy(IntSize(10000, 10000)); 1251 frameView.scrollBy(IntSize(10000, 10000), UserScroll);
1252 EXPECT_POINT_EQ(expected, frameView.scrollPosition()); 1252 EXPECT_POINT_EQ(expected, frameView.scrollPosition());
1253 1253
1254 EXPECT_POINT_EQ(FloatPoint(500, 860 - 430), pinchViewport.location()); 1254 EXPECT_POINT_EQ(FloatPoint(500, 860 - 430), pinchViewport.location());
1255 pinchViewport.move(FloatPoint(10000, 10000)); 1255 pinchViewport.move(FloatPoint(10000, 10000));
1256 EXPECT_POINT_EQ(FloatPoint(500, 860 - 430), pinchViewport.location()); 1256 EXPECT_POINT_EQ(FloatPoint(500, 860 - 430), pinchViewport.location());
1257 1257
1258 // Scale out, use a scale that causes fractional rects. 1258 // Scale out, use a scale that causes fractional rects.
1259 webViewImpl()->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatS ize(), 0.8f, -1); 1259 webViewImpl()->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatS ize(), 0.8f, -1);
1260 EXPECT_SIZE_EQ(FloatSize(625, 562.5), pinchViewport.visibleRect().size()); 1260 EXPECT_SIZE_EQ(FloatSize(625, 562.5), pinchViewport.visibleRect().size());
1261 1261
1262 // Bring out the top controls by 11 1262 // Bring out the top controls by 11
1263 webViewImpl()->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatS ize(), 1, 11 / 20.f); 1263 webViewImpl()->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatS ize(), 1, 11 / 20.f);
1264 EXPECT_SIZE_EQ(FloatSize(625, 548.75), pinchViewport.visibleRect().size()); 1264 EXPECT_SIZE_EQ(FloatSize(625, 548.75), pinchViewport.visibleRect().size());
1265 1265
1266 // Ensure max scroll offsets are updated properly. 1266 // Ensure max scroll offsets are updated properly.
1267 pinchViewport.move(FloatPoint(10000, 10000)); 1267 pinchViewport.move(FloatPoint(10000, 10000));
1268 EXPECT_FLOAT_POINT_EQ(FloatPoint(375, 877.5 - 548.75), pinchViewport.locatio n()); 1268 EXPECT_FLOAT_POINT_EQ(FloatPoint(375, 877.5 - 548.75), pinchViewport.locatio n());
1269 1269
1270 frameView.scrollBy(IntSize(10000, 10000)); 1270 frameView.scrollBy(IntSize(10000, 10000), UserScroll);
1271 EXPECT_POINT_EQ( 1271 EXPECT_POINT_EQ(
1272 expectedMaxFrameViewScrollOffset(pinchViewport, frameView), 1272 expectedMaxFrameViewScrollOffset(pinchViewport, frameView),
1273 frameView.scrollPosition()); 1273 frameView.scrollPosition());
1274 1274
1275 } 1275 }
1276 1276
1277 TEST_F(PinchViewportTest, TestTopControlsAdjustmentAndResize) 1277 TEST_F(PinchViewportTest, TestTopControlsAdjustmentAndResize)
1278 { 1278 {
1279 initializeWithAndroidSettings(); 1279 initializeWithAndroidSettings();
1280 webViewImpl()->resize(IntSize(500, 450)); 1280 webViewImpl()->resize(IntSize(500, 450));
1281 1281
1282 registerMockedHttpURLLoad("content-width-1000.html"); 1282 registerMockedHttpURLLoad("content-width-1000.html");
1283 navigateTo(m_baseURL + "content-width-1000.html"); 1283 navigateTo(m_baseURL + "content-width-1000.html");
1284 1284
1285 PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport(); 1285 PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport();
1286 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); 1286 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView();
1287 1287
1288 pinchViewport.setScale(2); 1288 pinchViewport.setScale(2);
1289 EXPECT_SIZE_EQ(IntSize(250, 225), pinchViewport.visibleRect().size()); 1289 EXPECT_SIZE_EQ(IntSize(250, 225), pinchViewport.visibleRect().size());
1290 EXPECT_SIZE_EQ(IntSize(1000, 900), frameView.frameRect().size()); 1290 EXPECT_SIZE_EQ(IntSize(1000, 900), frameView.frameRect().size());
1291 1291
1292 webViewImpl()->setTopControlsHeight(20, false); 1292 webViewImpl()->setTopControlsHeight(20, false);
1293 1293
1294 webViewImpl()->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatS ize(), 1, 1); 1294 webViewImpl()->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatS ize(), 1, 1);
1295 EXPECT_SIZE_EQ(IntSize(500, 450), pinchViewport.size()); 1295 EXPECT_SIZE_EQ(IntSize(500, 450), pinchViewport.size());
1296 EXPECT_SIZE_EQ(IntSize(250, 215), pinchViewport.visibleRect().size()); 1296 EXPECT_SIZE_EQ(IntSize(250, 215), pinchViewport.visibleRect().size());
1297 1297
1298 // Scroll all the way to the bottom. 1298 // Scroll all the way to the bottom.
1299 pinchViewport.move(FloatPoint(10000, 10000)); 1299 pinchViewport.move(FloatPoint(10000, 10000));
1300 frameView.scrollBy(IntSize(10000, 10000)); 1300 frameView.scrollBy(IntSize(10000, 10000), UserScroll);
1301 IntPoint frameViewExpected = expectedMaxFrameViewScrollOffset(pinchViewport, frameView); 1301 IntPoint frameViewExpected = expectedMaxFrameViewScrollOffset(pinchViewport, frameView);
1302 FloatPoint pinchViewportExpected = FloatPoint(750, 860 - 215); 1302 FloatPoint pinchViewportExpected = FloatPoint(750, 860 - 215);
1303 EXPECT_POINT_EQ(pinchViewportExpected, pinchViewport.location()); 1303 EXPECT_POINT_EQ(pinchViewportExpected, pinchViewport.location());
1304 EXPECT_POINT_EQ(frameViewExpected, frameView.scrollPosition()); 1304 EXPECT_POINT_EQ(frameViewExpected, frameView.scrollPosition());
1305 1305
1306 // Resize the widget to match the top controls adjustment. Ensure that scrol l 1306 // Resize the widget to match the top controls adjustment. Ensure that scrol l
1307 // offsets don't get clamped in the the process. 1307 // offsets don't get clamped in the the process.
1308 webViewImpl()->setTopControlsHeight(20, true); 1308 webViewImpl()->setTopControlsHeight(20, true);
1309 webViewImpl()->resize(WebSize(500, 430)); 1309 webViewImpl()->resize(WebSize(500, 430));
1310 1310
(...skipping 16 matching lines...) Expand all
1327 webViewImpl()->resize(IntSize(1000, 1000)); 1327 webViewImpl()->resize(IntSize(1000, 1000));
1328 1328
1329 registerMockedHttpURLLoad("content-width-1000.html"); 1329 registerMockedHttpURLLoad("content-width-1000.html");
1330 navigateTo(m_baseURL + "content-width-1000.html"); 1330 navigateTo(m_baseURL + "content-width-1000.html");
1331 1331
1332 // Scroll the FrameView to the bottom of the page but "hide" the top 1332 // Scroll the FrameView to the bottom of the page but "hide" the top
1333 // controls on the compositor side so the max scroll position should account 1333 // controls on the compositor side so the max scroll position should account
1334 // for the full viewport height. 1334 // for the full viewport height.
1335 webViewImpl()->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatS ize(), 1, -1); 1335 webViewImpl()->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatS ize(), 1, -1);
1336 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); 1336 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView();
1337 frameView.setScrollPosition(IntPoint(0, 10000)); 1337 frameView.setScrollPosition(IntPoint(0, 10000), ProgrammaticScroll);
1338 EXPECT_EQ(500, frameView.scrollPositionDouble().y()); 1338 EXPECT_EQ(500, frameView.scrollPositionDouble().y());
1339 1339
1340 // Now send the resize, make sure the scroll offset doesn't change. 1340 // Now send the resize, make sure the scroll offset doesn't change.
1341 webViewImpl()->setTopControlsHeight(500, false); 1341 webViewImpl()->setTopControlsHeight(500, false);
1342 webViewImpl()->resize(IntSize(1000, 1500)); 1342 webViewImpl()->resize(IntSize(1000, 1500));
1343 EXPECT_EQ(500, frameView.scrollPositionDouble().y()); 1343 EXPECT_EQ(500, frameView.scrollPositionDouble().y());
1344 } 1344 }
1345 1345
1346 // Tests that the layout viewport's scroll layer bounds are updated in a composi ting 1346 // Tests that the layout viewport's scroll layer bounds are updated in a composi ting
1347 // change update. crbug.com/423188. 1347 // change update. crbug.com/423188.
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
1580 navigateTo(m_baseURL + "hit-test.html"); 1580 navigateTo(m_baseURL + "hit-test.html");
1581 1581
1582 webViewImpl()->resize(IntSize(500, 500)); 1582 webViewImpl()->resize(IntSize(500, 500));
1583 webViewImpl()->layout(); 1583 webViewImpl()->layout();
1584 1584
1585 WebDocument webDoc = webViewImpl()->mainFrame()->document(); 1585 WebDocument webDoc = webViewImpl()->mainFrame()->document();
1586 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); 1586 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView();
1587 1587
1588 webViewImpl()->setPageScaleFactor(2); 1588 webViewImpl()->setPageScaleFactor(2);
1589 webViewImpl()->setPinchViewportOffset(WebFloatPoint(200, 230)); 1589 webViewImpl()->setPinchViewportOffset(WebFloatPoint(200, 230));
1590 frameView.setScrollPosition(DoublePoint(400, 1100)); 1590 frameView.setScrollPosition(DoublePoint(400, 1100), ProgrammaticScroll);
1591 1591
1592 // Because of where the pinch viewport is located, this should hit the botto m right 1592 // Because of where the pinch viewport is located, this should hit the botto m right
1593 // target (target 4). 1593 // target (target 4).
1594 WebAXObject hitNode = webDoc.accessibilityObject().hitTest(WebPoint(154, 165 )); 1594 WebAXObject hitNode = webDoc.accessibilityObject().hitTest(WebPoint(154, 165 ));
1595 EXPECT_EQ(std::string("Target4"), hitNode.title().utf8()); 1595 EXPECT_EQ(std::string("Target4"), hitNode.title().utf8());
1596 } 1596 }
1597 1597
1598 // Tests that the maximum scroll offset of the viewport can be fractional. 1598 // Tests that the maximum scroll offset of the viewport can be fractional.
1599 TEST_F(PinchViewportTest, TestCoordinateTransforms) 1599 TEST_F(PinchViewportTest, TestCoordinateTransforms)
1600 { 1600 {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1658 registerMockedHttpURLLoad("window_dimensions_wide_div.html"); 1658 registerMockedHttpURLLoad("window_dimensions_wide_div.html");
1659 webViewImpl()->resize(IntSize(800, 600)); 1659 webViewImpl()->resize(IntSize(800, 600));
1660 navigateTo(m_baseURL + "window_dimensions_wide_div.html"); 1660 navigateTo(m_baseURL + "window_dimensions_wide_div.html");
1661 1661
1662 Element* output = frame()->document()->getElementById("output"); 1662 Element* output = frame()->document()->getElementById("output");
1663 ASSERT(output); 1663 ASSERT(output);
1664 EXPECT_EQ(std::string("2000x1500"), std::string(output->innerHTML().ascii(). data())); 1664 EXPECT_EQ(std::string("2000x1500"), std::string(output->innerHTML().ascii(). data()));
1665 } 1665 }
1666 1666
1667 } // namespace 1667 } // namespace
OLDNEW
« no previous file with comments | « Source/web/WebViewImpl.cpp ('k') | Source/web/tests/ScrollAnimatorNoneTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698