OLD | NEW |
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/frame/FrameHost.h" | 9 #include "core/frame/FrameHost.h" |
10 #include "core/frame/LocalFrame.h" | 10 #include "core/frame/LocalFrame.h" |
(...skipping 1039 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1050 webViewImpl()->resizePinchViewport(IntSize(100, 100)); | 1050 webViewImpl()->resizePinchViewport(IntSize(100, 100)); |
1051 webViewImpl()->setPageScaleFactor(1.5f); | 1051 webViewImpl()->setPageScaleFactor(1.5f); |
1052 frame()->view()->scrollTo(IntPoint(50, 50)); | 1052 frame()->view()->scrollTo(IntPoint(50, 50)); |
1053 pinchViewport.setLocation(FloatPoint(0, 10)); | 1053 pinchViewport.setLocation(FloatPoint(0, 10)); |
1054 | 1054 |
1055 pinchViewport.scrollIntoView(LayoutRect(pinchViewport.visibleRectInDocument(
))); | 1055 pinchViewport.scrollIntoView(LayoutRect(pinchViewport.visibleRectInDocument(
))); |
1056 EXPECT_POINT_EQ(IntPoint(50, 50), frame()->view()->scrollPosition()); | 1056 EXPECT_POINT_EQ(IntPoint(50, 50), frame()->view()->scrollPosition()); |
1057 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 10), pinchViewport.visibleRect().locatio
n()); | 1057 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 10), pinchViewport.visibleRect().locatio
n()); |
1058 } | 1058 } |
1059 | 1059 |
1060 #if OS(ANDROID) | |
1061 | |
1062 // Top controls can make an unscrollable page temporarily scrollable, causing | 1060 // Top controls can make an unscrollable page temporarily scrollable, causing |
1063 // a scroll clamp when the page is resized. Make sure this bug is fixed. | 1061 // a scroll clamp when the page is resized. Make sure this bug is fixed. |
1064 // crbug.com/437620 | 1062 // crbug.com/437620 |
1065 TEST_F(PinchViewportTest, TestResizeDoesntChangeScrollOffset) | 1063 TEST_F(PinchViewportTest, TestResizeDoesntChangeScrollOffset) |
1066 { | 1064 { |
1067 initializeWithAndroidSettings(); | 1065 initializeWithAndroidSettings(); |
1068 webViewImpl()->resize(IntSize(980, 650)); | 1066 webViewImpl()->resize(IntSize(980, 650)); |
1069 | 1067 |
1070 navigateTo("about:blank"); | 1068 navigateTo("about:blank"); |
1071 | 1069 |
1072 PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport(); | 1070 PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport(); |
1073 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); | 1071 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); |
1074 | 1072 |
| 1073 webViewImpl()->setTopControlsHeight(20, false); |
| 1074 |
1075 // Outer viewport isn't scrollable | 1075 // Outer viewport isn't scrollable |
1076 EXPECT_SIZE_EQ(IntSize(980, 650), frameView.visibleContentRect().size()); | 1076 EXPECT_SIZE_EQ(IntSize(980, 650), frameView.visibleContentRect().size()); |
1077 | 1077 |
1078 pinchViewport.setScale(2); | 1078 pinchViewport.setScale(2); |
1079 pinchViewport.move(FloatPoint(0, 40)); | 1079 pinchViewport.move(FloatPoint(0, 40)); |
1080 | 1080 |
1081 // Simulate bringing down the top controls by 20px but counterscrolling the
outer viewport. | 1081 // Simulate bringing down the top controls by 20px but counterscrolling the
outer viewport. |
1082 webViewImpl()->applyViewportDeltas(WebSize(), WebSize(0, 20), WebFloatSize()
, 1, 20); | 1082 webViewImpl()->applyViewportDeltas(WebSize(), WebSize(0, 20), WebFloatSize()
, 1, 1); |
1083 | 1083 |
1084 EXPECT_EQ(20, frameView.scrollPosition().y()); | 1084 EXPECT_EQ(20, frameView.scrollPosition().y()); |
1085 | 1085 |
1086 webViewImpl()->setTopControlsLayoutHeight(20); | 1086 webViewImpl()->setTopControlsHeight(20, true); |
1087 webViewImpl()->resize(WebSize(980, 630)); | 1087 webViewImpl()->resize(WebSize(980, 630)); |
1088 | 1088 |
1089 EXPECT_EQ(0, frameView.scrollPosition().y()); | 1089 EXPECT_EQ(0, frameView.scrollPosition().y()); |
1090 EXPECT_EQ(60, pinchViewport.location().y()); | 1090 EXPECT_EQ(60, pinchViewport.location().y()); |
1091 } | 1091 } |
1092 | 1092 |
1093 static IntPoint expectedMaxFrameViewScrollOffset(PinchViewport& pinchViewport, F
rameView& frameView) | 1093 static IntPoint expectedMaxFrameViewScrollOffset(PinchViewport& pinchViewport, F
rameView& frameView) |
1094 { | 1094 { |
1095 float aspectRatio = pinchViewport.visibleRect().width() / pinchViewport.visi
bleRect().height(); | 1095 float aspectRatio = pinchViewport.visibleRect().width() / pinchViewport.visi
bleRect().height(); |
1096 float newHeight = frameView.frameRect().width() / aspectRatio; | 1096 float newHeight = frameView.frameRect().width() / aspectRatio; |
1097 return IntPoint( | 1097 return IntPoint( |
1098 frameView.contentsSize().width() - frameView.frameRect().width(), | 1098 frameView.contentsSize().width() - frameView.frameRect().width(), |
1099 frameView.contentsSize().height() - newHeight); | 1099 frameView.contentsSize().height() - newHeight); |
1100 } | 1100 } |
1101 | 1101 |
1102 TEST_F(PinchViewportTest, TestTopControlsAdjustment) | 1102 TEST_F(PinchViewportTest, TestTopControlsAdjustment) |
1103 { | 1103 { |
1104 initializeWithAndroidSettings(); | 1104 initializeWithAndroidSettings(); |
1105 webViewImpl()->resize(IntSize(500, 450)); | 1105 webViewImpl()->resize(IntSize(500, 450)); |
1106 | 1106 |
1107 registerMockedHttpURLLoad("content-width-1000.html"); | 1107 registerMockedHttpURLLoad("content-width-1000.html"); |
1108 navigateTo(m_baseURL + "content-width-1000.html"); | 1108 navigateTo(m_baseURL + "content-width-1000.html"); |
1109 | 1109 |
1110 PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport(); | 1110 PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport(); |
1111 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); | 1111 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); |
1112 | 1112 |
| 1113 webViewImpl()->setTopControlsHeight(20, false); |
| 1114 |
1113 pinchViewport.setScale(1); | 1115 pinchViewport.setScale(1); |
1114 EXPECT_SIZE_EQ(IntSize(500, 450), pinchViewport.visibleRect().size()); | 1116 EXPECT_SIZE_EQ(IntSize(500, 450), pinchViewport.visibleRect().size()); |
1115 EXPECT_SIZE_EQ(IntSize(1000, 900), frameView.frameRect().size()); | 1117 EXPECT_SIZE_EQ(IntSize(1000, 900), frameView.frameRect().size()); |
1116 | 1118 |
1117 // Simulate bringing down the top controls by 20px. | 1119 // Simulate bringing down the top controls by 20px. |
1118 webViewImpl()->applyViewportDeltas(WebSize(), WebSize(), WebFloatSize(), 1,
20); | 1120 webViewImpl()->applyViewportDeltas(WebSize(), WebSize(), WebFloatSize(), 1,
1); |
1119 EXPECT_SIZE_EQ(IntSize(500, 430), pinchViewport.visibleRect().size()); | 1121 EXPECT_SIZE_EQ(IntSize(500, 430), pinchViewport.visibleRect().size()); |
1120 | 1122 |
1121 // Test that the scroll bounds are adjusted appropriately: the pinch viewpor
t | 1123 // Test that the scroll bounds are adjusted appropriately: the pinch viewpor
t |
1122 // should be shrunk by 20px to 430px. The outer viewport was shrunk to maint
ain the | 1124 // should be shrunk by 20px to 430px. The outer viewport was shrunk to maint
ain the |
1123 // aspect ratio so it's height is 860px. | 1125 // aspect ratio so it's height is 860px. |
1124 pinchViewport.move(FloatPoint(10000, 10000)); | 1126 pinchViewport.move(FloatPoint(10000, 10000)); |
1125 EXPECT_POINT_EQ(FloatPoint(500, 860 - 430), pinchViewport.location()); | 1127 EXPECT_POINT_EQ(FloatPoint(500, 860 - 430), pinchViewport.location()); |
1126 | 1128 |
1127 // The outer viewport (FrameView) should be affected as well. | 1129 // The outer viewport (FrameView) should be affected as well. |
1128 frameView.scrollBy(IntSize(10000, 10000)); | 1130 frameView.scrollBy(IntSize(10000, 10000)); |
1129 EXPECT_POINT_EQ( | 1131 EXPECT_POINT_EQ( |
1130 expectedMaxFrameViewScrollOffset(pinchViewport, frameView), | 1132 expectedMaxFrameViewScrollOffset(pinchViewport, frameView), |
1131 frameView.scrollPosition()); | 1133 frameView.scrollPosition()); |
1132 | 1134 |
1133 // Simulate bringing up the top controls by 10.5px. | 1135 // Simulate bringing up the top controls by 10.5px. |
1134 webViewImpl()->applyViewportDeltas(WebSize(), WebSize(), WebFloatSize(), 1,
-10.5f); | 1136 webViewImpl()->applyViewportDeltas(WebSize(), WebSize(), WebFloatSize(), 1,
-10.5f / 20); |
1135 EXPECT_SIZE_EQ(FloatSize(500, 440.5f), pinchViewport.visibleRect().size()); | 1137 EXPECT_SIZE_EQ(FloatSize(500, 440.5f), pinchViewport.visibleRect().size()); |
1136 | 1138 |
1137 // maximumScrollPosition floors the final values. | 1139 // maximumScrollPosition floors the final values. |
1138 pinchViewport.move(FloatPoint(10000, 10000)); | 1140 pinchViewport.move(FloatPoint(10000, 10000)); |
1139 EXPECT_POINT_EQ(FloatPoint(500, floor(881 - 440.5f)), pinchViewport.location
()); | 1141 EXPECT_POINT_EQ(FloatPoint(500, floor(881 - 440.5f)), pinchViewport.location
()); |
1140 | 1142 |
1141 // The outer viewport (FrameView) should be affected as well. | 1143 // The outer viewport (FrameView) should be affected as well. |
1142 frameView.scrollBy(IntSize(10000, 10000)); | 1144 frameView.scrollBy(IntSize(10000, 10000)); |
1143 EXPECT_POINT_EQ( | 1145 EXPECT_POINT_EQ( |
1144 expectedMaxFrameViewScrollOffset(pinchViewport, frameView), | 1146 expectedMaxFrameViewScrollOffset(pinchViewport, frameView), |
1145 frameView.scrollPosition()); | 1147 frameView.scrollPosition()); |
1146 } | 1148 } |
1147 | 1149 |
1148 TEST_F(PinchViewportTest, TestTopControlsAdjustmentWithScale) | 1150 TEST_F(PinchViewportTest, TestTopControlsAdjustmentWithScale) |
1149 { | 1151 { |
1150 initializeWithAndroidSettings(); | 1152 initializeWithAndroidSettings(); |
1151 webViewImpl()->resize(IntSize(500, 450)); | 1153 webViewImpl()->resize(IntSize(500, 450)); |
1152 | 1154 |
1153 registerMockedHttpURLLoad("content-width-1000.html"); | 1155 registerMockedHttpURLLoad("content-width-1000.html"); |
1154 navigateTo(m_baseURL + "content-width-1000.html"); | 1156 navigateTo(m_baseURL + "content-width-1000.html"); |
1155 | 1157 |
1156 PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport(); | 1158 PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport(); |
1157 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); | 1159 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); |
1158 | 1160 |
| 1161 webViewImpl()->setTopControlsHeight(20, false); |
| 1162 |
1159 pinchViewport.setScale(2); | 1163 pinchViewport.setScale(2); |
1160 EXPECT_SIZE_EQ(IntSize(250, 225), pinchViewport.visibleRect().size()); | 1164 EXPECT_SIZE_EQ(IntSize(250, 225), pinchViewport.visibleRect().size()); |
1161 EXPECT_SIZE_EQ(IntSize(1000, 900), frameView.frameRect().size()); | 1165 EXPECT_SIZE_EQ(IntSize(1000, 900), frameView.frameRect().size()); |
1162 | 1166 |
1163 // Simulate bringing down the top controls by 20px. Since we're zoomed in, | 1167 // Simulate bringing down the top controls by 20px. Since we're zoomed in, |
1164 // the top controls take up half as much space (in document-space) than | 1168 // the top controls take up half as much space (in document-space) than |
1165 // they do at an unzoomed level. | 1169 // they do at an unzoomed level. |
1166 webViewImpl()->applyViewportDeltas(WebSize(), WebSize(), WebFloatSize(), 1,
20); | 1170 webViewImpl()->applyViewportDeltas(WebSize(), WebSize(), WebFloatSize(), 1,
1); |
1167 EXPECT_SIZE_EQ(IntSize(250, 215), pinchViewport.visibleRect().size()); | 1171 EXPECT_SIZE_EQ(IntSize(250, 215), pinchViewport.visibleRect().size()); |
1168 | 1172 |
1169 // Test that the scroll bounds are adjusted appropriately. | 1173 // Test that the scroll bounds are adjusted appropriately. |
1170 pinchViewport.move(FloatPoint(10000, 10000)); | 1174 pinchViewport.move(FloatPoint(10000, 10000)); |
1171 EXPECT_POINT_EQ(FloatPoint(750, 860 - 215), pinchViewport.location()); | 1175 EXPECT_POINT_EQ(FloatPoint(750, 860 - 215), pinchViewport.location()); |
1172 | 1176 |
1173 // The outer viewport (FrameView) should be affected as well. | 1177 // The outer viewport (FrameView) should be affected as well. |
1174 frameView.scrollBy(IntSize(10000, 10000)); | 1178 frameView.scrollBy(IntSize(10000, 10000)); |
1175 IntPoint expected = expectedMaxFrameViewScrollOffset(pinchViewport, frameVie
w); | 1179 IntPoint expected = expectedMaxFrameViewScrollOffset(pinchViewport, frameVie
w); |
1176 EXPECT_POINT_EQ(expected, frameView.scrollPosition()); | 1180 EXPECT_POINT_EQ(expected, frameView.scrollPosition()); |
1177 | 1181 |
1178 // Scale back out, FrameView max scroll shouldn't have changed. Pinch | 1182 // Scale back out, FrameView max scroll shouldn't have changed. Pinch |
1179 // viewport should be moved up to accomodate larger view. | 1183 // viewport should be moved up to accomodate larger view. |
1180 webViewImpl()->applyViewportDeltas(WebSize(), WebSize(), WebFloatSize(), 0.5
f, 0); | 1184 webViewImpl()->applyViewportDeltas(WebSize(), WebSize(), WebFloatSize(), 0.5
f, 0); |
1181 EXPECT_EQ(1, pinchViewport.scale()); | 1185 EXPECT_EQ(1, pinchViewport.scale()); |
1182 EXPECT_POINT_EQ(expected, frameView.scrollPosition()); | 1186 EXPECT_POINT_EQ(expected, frameView.scrollPosition()); |
1183 frameView.scrollBy(IntSize(10000, 10000)); | 1187 frameView.scrollBy(IntSize(10000, 10000)); |
1184 EXPECT_POINT_EQ(expected, frameView.scrollPosition()); | 1188 EXPECT_POINT_EQ(expected, frameView.scrollPosition()); |
1185 | 1189 |
1186 EXPECT_POINT_EQ(FloatPoint(500, 860 - 430), pinchViewport.location()); | 1190 EXPECT_POINT_EQ(FloatPoint(500, 860 - 430), pinchViewport.location()); |
1187 pinchViewport.move(FloatPoint(10000, 10000)); | 1191 pinchViewport.move(FloatPoint(10000, 10000)); |
1188 EXPECT_POINT_EQ(FloatPoint(500, 860 - 430), pinchViewport.location()); | 1192 EXPECT_POINT_EQ(FloatPoint(500, 860 - 430), pinchViewport.location()); |
1189 | 1193 |
1190 // Scale out, use a scale that causes fractional rects. | 1194 // Scale out, use a scale that causes fractional rects. |
1191 webViewImpl()->applyViewportDeltas(WebSize(), WebSize(), WebFloatSize(), 0.8
f, -20); | 1195 webViewImpl()->applyViewportDeltas(WebSize(), WebSize(), WebFloatSize(), 0.8
f, -1); |
1192 EXPECT_SIZE_EQ(FloatSize(625, 562.5), pinchViewport.visibleRect().size()); | 1196 EXPECT_SIZE_EQ(FloatSize(625, 562.5), pinchViewport.visibleRect().size()); |
1193 | 1197 |
1194 // Bring out the top controls by 11 | 1198 // Bring out the top controls by 11 |
1195 webViewImpl()->applyViewportDeltas(WebSize(), WebSize(), WebFloatSize(), 1,
11); | 1199 webViewImpl()->applyViewportDeltas(WebSize(), WebSize(), WebFloatSize(), 1,
11 / 20.f); |
1196 EXPECT_SIZE_EQ(FloatSize(625, 548.75), pinchViewport.visibleRect().size()); | 1200 EXPECT_SIZE_EQ(FloatSize(625, 548.75), pinchViewport.visibleRect().size()); |
1197 | 1201 |
1198 // Ensure max scroll offsets are updated properly. | 1202 // Ensure max scroll offsets are updated properly. |
1199 pinchViewport.move(FloatPoint(10000, 10000)); | 1203 pinchViewport.move(FloatPoint(10000, 10000)); |
1200 EXPECT_POINT_EQ(FloatPoint(375, floor(877 - 548.75)), pinchViewport.location
()); | 1204 EXPECT_POINT_EQ(FloatPoint(375, floor(877 - 548.75)), pinchViewport.location
()); |
1201 | 1205 |
1202 frameView.scrollBy(IntSize(10000, 10000)); | 1206 frameView.scrollBy(IntSize(10000, 10000)); |
1203 EXPECT_POINT_EQ( | 1207 EXPECT_POINT_EQ( |
1204 expectedMaxFrameViewScrollOffset(pinchViewport, frameView), | 1208 expectedMaxFrameViewScrollOffset(pinchViewport, frameView), |
1205 frameView.scrollPosition()); | 1209 frameView.scrollPosition()); |
1206 | 1210 |
1207 } | 1211 } |
1208 | 1212 |
1209 TEST_F(PinchViewportTest, TestTopControlsAdjustmentAndResize) | 1213 TEST_F(PinchViewportTest, TestTopControlsAdjustmentAndResize) |
1210 { | 1214 { |
1211 initializeWithAndroidSettings(); | 1215 initializeWithAndroidSettings(); |
1212 webViewImpl()->resize(IntSize(500, 450)); | 1216 webViewImpl()->resize(IntSize(500, 450)); |
1213 | 1217 |
1214 registerMockedHttpURLLoad("content-width-1000.html"); | 1218 registerMockedHttpURLLoad("content-width-1000.html"); |
1215 navigateTo(m_baseURL + "content-width-1000.html"); | 1219 navigateTo(m_baseURL + "content-width-1000.html"); |
1216 | 1220 |
1217 PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport(); | 1221 PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport(); |
1218 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); | 1222 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); |
1219 | 1223 |
1220 pinchViewport.setScale(2); | 1224 pinchViewport.setScale(2); |
1221 EXPECT_SIZE_EQ(IntSize(250, 225), pinchViewport.visibleRect().size()); | 1225 EXPECT_SIZE_EQ(IntSize(250, 225), pinchViewport.visibleRect().size()); |
1222 EXPECT_SIZE_EQ(IntSize(1000, 900), frameView.frameRect().size()); | 1226 EXPECT_SIZE_EQ(IntSize(1000, 900), frameView.frameRect().size()); |
1223 | 1227 |
1224 webViewImpl()->applyViewportDeltas(WebSize(), WebSize(), WebFloatSize(), 1,
20); | 1228 webViewImpl()->setTopControlsHeight(20, false); |
| 1229 |
| 1230 webViewImpl()->applyViewportDeltas(WebSize(), WebSize(), WebFloatSize(), 1,
1); |
1225 EXPECT_SIZE_EQ(IntSize(500, 450), pinchViewport.size()); | 1231 EXPECT_SIZE_EQ(IntSize(500, 450), pinchViewport.size()); |
1226 EXPECT_SIZE_EQ(IntSize(250, 215), pinchViewport.visibleRect().size()); | 1232 EXPECT_SIZE_EQ(IntSize(250, 215), pinchViewport.visibleRect().size()); |
1227 | 1233 |
1228 // Scroll all the way to the bottom. | 1234 // Scroll all the way to the bottom. |
1229 pinchViewport.move(FloatPoint(10000, 10000)); | 1235 pinchViewport.move(FloatPoint(10000, 10000)); |
1230 frameView.scrollBy(IntSize(10000, 10000)); | 1236 frameView.scrollBy(IntSize(10000, 10000)); |
1231 IntPoint frameViewExpected = expectedMaxFrameViewScrollOffset(pinchViewport,
frameView); | 1237 IntPoint frameViewExpected = expectedMaxFrameViewScrollOffset(pinchViewport,
frameView); |
1232 FloatPoint pinchViewportExpected = FloatPoint(750, 860 - 215); | 1238 FloatPoint pinchViewportExpected = FloatPoint(750, 860 - 215); |
1233 EXPECT_POINT_EQ(pinchViewportExpected, pinchViewport.location()); | 1239 EXPECT_POINT_EQ(pinchViewportExpected, pinchViewport.location()); |
1234 EXPECT_POINT_EQ(frameViewExpected, frameView.scrollPosition()); | 1240 EXPECT_POINT_EQ(frameViewExpected, frameView.scrollPosition()); |
1235 | 1241 |
1236 // Resize the widget to match the top controls adjustment. Ensure that scrol
l | 1242 // Resize the widget to match the top controls adjustment. Ensure that scrol
l |
1237 // offsets don't get clamped in the the process. | 1243 // offsets don't get clamped in the the process. |
1238 webViewImpl()->setTopControlsLayoutHeight(20); | 1244 webViewImpl()->setTopControlsHeight(20, true); |
1239 webViewImpl()->resize(WebSize(500, 430)); | 1245 webViewImpl()->resize(WebSize(500, 430)); |
1240 | 1246 |
1241 EXPECT_SIZE_EQ(IntSize(500, 430), pinchViewport.size()); | 1247 EXPECT_SIZE_EQ(IntSize(500, 430), pinchViewport.size()); |
1242 EXPECT_SIZE_EQ(IntSize(250, 215), pinchViewport.visibleRect().size()); | 1248 EXPECT_SIZE_EQ(IntSize(250, 215), pinchViewport.visibleRect().size()); |
1243 EXPECT_SIZE_EQ(IntSize(1000, 860), frameView.frameRect().size()); | 1249 EXPECT_SIZE_EQ(IntSize(1000, 860), frameView.frameRect().size()); |
1244 | 1250 |
1245 EXPECT_POINT_EQ(frameViewExpected, frameView.scrollPosition()); | 1251 EXPECT_POINT_EQ(frameViewExpected, frameView.scrollPosition()); |
1246 EXPECT_POINT_EQ(pinchViewportExpected, pinchViewport.location()); | 1252 EXPECT_POINT_EQ(pinchViewportExpected, pinchViewport.location()); |
1247 } | 1253 } |
1248 | 1254 |
1249 // Tests that a resize due to top controls hiding doesn't incorrectly clamp the | 1255 // Tests that a resize due to top controls hiding doesn't incorrectly clamp the |
1250 // main frame's scroll offset. crbug.com/428193. | 1256 // main frame's scroll offset. crbug.com/428193. |
1251 TEST_F(PinchViewportTest, TestTopControlHidingResizeDoesntClampMainFrame) | 1257 TEST_F(PinchViewportTest, TestTopControlHidingResizeDoesntClampMainFrame) |
1252 { | 1258 { |
1253 initializeWithAndroidSettings(); | 1259 initializeWithAndroidSettings(); |
1254 webViewImpl()->applyViewportDeltas(WebSize(), WebSize(), WebFloatSize(), 1,
500); | 1260 webViewImpl()->setTopControlsHeight(500, false); |
1255 webViewImpl()->setTopControlsLayoutHeight(500); | 1261 webViewImpl()->applyViewportDeltas(WebSize(), WebSize(), WebFloatSize(), 1,
1); |
| 1262 webViewImpl()->setTopControlsHeight(500, true); |
1256 webViewImpl()->resize(IntSize(1000, 1000)); | 1263 webViewImpl()->resize(IntSize(1000, 1000)); |
1257 | 1264 |
1258 registerMockedHttpURLLoad("content-width-1000.html"); | 1265 registerMockedHttpURLLoad("content-width-1000.html"); |
1259 navigateTo(m_baseURL + "content-width-1000.html"); | 1266 navigateTo(m_baseURL + "content-width-1000.html"); |
1260 | 1267 |
1261 // Scroll the FrameView to the bottom of the page but "hide" the top | 1268 // Scroll the FrameView to the bottom of the page but "hide" the top |
1262 // controls on the compositor side so the max scroll position should account | 1269 // controls on the compositor side so the max scroll position should account |
1263 // for the full viewport height. | 1270 // for the full viewport height. |
1264 webViewImpl()->applyViewportDeltas(WebSize(), WebSize(), WebFloatSize(), 1,
-500); | 1271 webViewImpl()->applyViewportDeltas(WebSize(), WebSize(), WebFloatSize(), 1,
-1); |
1265 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); | 1272 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); |
1266 frameView.setScrollPosition(IntPoint(0, 10000)); | 1273 frameView.setScrollPosition(IntPoint(0, 10000)); |
1267 EXPECT_EQ(500, frameView.scrollPositionDouble().y()); | 1274 EXPECT_EQ(500, frameView.scrollPositionDouble().y()); |
1268 | 1275 |
1269 // Now send the resize, make sure the scroll offset doesn't change. | 1276 // Now send the resize, make sure the scroll offset doesn't change. |
1270 webViewImpl()->setTopControlsLayoutHeight(0); | 1277 webViewImpl()->setTopControlsHeight(500, false); |
1271 webViewImpl()->resize(IntSize(1000, 1500)); | 1278 webViewImpl()->resize(IntSize(1000, 1500)); |
1272 EXPECT_EQ(500, frameView.scrollPositionDouble().y()); | 1279 EXPECT_EQ(500, frameView.scrollPositionDouble().y()); |
1273 } | 1280 } |
1274 #endif | |
1275 | 1281 |
1276 // Tests that the layout viewport's scroll layer bounds are updated in a composi
ting | 1282 // Tests that the layout viewport's scroll layer bounds are updated in a composi
ting |
1277 // change update. crbug.com/423188. | 1283 // change update. crbug.com/423188. |
1278 TEST_F(PinchViewportTest, TestChangingContentSizeAffectsScrollBounds) | 1284 TEST_F(PinchViewportTest, TestChangingContentSizeAffectsScrollBounds) |
1279 { | 1285 { |
1280 initializeWithAndroidSettings(); | 1286 initializeWithAndroidSettings(); |
1281 webViewImpl()->resize(IntSize(100, 150)); | 1287 webViewImpl()->resize(IntSize(100, 150)); |
1282 | 1288 |
1283 registerMockedHttpURLLoad("content-width-1000.html"); | 1289 registerMockedHttpURLLoad("content-width-1000.html"); |
1284 navigateTo(m_baseURL + "content-width-1000.html"); | 1290 navigateTo(m_baseURL + "content-width-1000.html"); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1355 navigateTo(m_baseURL + "content-width-1000-min-scale.html"); | 1361 navigateTo(m_baseURL + "content-width-1000-min-scale.html"); |
1356 | 1362 |
1357 WebLocalFrameImpl* localFrame = webViewImpl()->mainFrameImpl(); | 1363 WebLocalFrameImpl* localFrame = webViewImpl()->mainFrameImpl(); |
1358 localFrame->createFrameView(); | 1364 localFrame->createFrameView(); |
1359 | 1365 |
1360 FrameView& frameView = *localFrame->frameView(); | 1366 FrameView& frameView = *localFrame->frameView(); |
1361 EXPECT_SIZE_EQ(IntSize(200, 400), frameView.frameRect().size()); | 1367 EXPECT_SIZE_EQ(IntSize(200, 400), frameView.frameRect().size()); |
1362 } | 1368 } |
1363 | 1369 |
1364 } // namespace | 1370 } // namespace |
OLD | NEW |