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 944 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
955 mouseDownEvent.button = WebMouseEvent::ButtonRight; | 955 mouseDownEvent.button = WebMouseEvent::ButtonRight; |
956 webViewImpl()->handleInputEvent(mouseDownEvent); | 956 webViewImpl()->handleInputEvent(mouseDownEvent); |
957 webViewImpl()->handleInputEvent(mouseUpEvent); | 957 webViewImpl()->handleInputEvent(mouseUpEvent); |
958 | 958 |
959 // Reset the old client so destruction can occur naturally. | 959 // Reset the old client so destruction can occur naturally. |
960 webViewImpl()->mainFrameImpl()->setClient(oldClient); | 960 webViewImpl()->mainFrameImpl()->setClient(oldClient); |
961 } | 961 } |
962 | 962 |
963 // Test that the scrollIntoView correctly scrolls the main frame | 963 // Test that the scrollIntoView correctly scrolls the main frame |
964 // and pinch viewports such that the given rect is centered in the viewport. | 964 // and pinch viewports such that the given rect is centered in the viewport. |
965 TEST_F(PinchViewportTest, DISABLED_TestScrollingDocumentRegionIntoView) | 965 TEST_F(PinchViewportTest, TestScrollingDocumentRegionIntoView) |
966 { | 966 { |
967 initializeWithDesktopSettings(); | 967 initializeWithDesktopSettings(); |
968 webViewImpl()->resize(IntSize(100, 150)); | 968 webViewImpl()->resize(IntSize(100, 150)); |
969 | 969 |
970 registerMockedHttpURLLoad("200-by-300-viewport.html"); | 970 registerMockedHttpURLLoad("200-by-300-viewport.html"); |
971 navigateTo(m_baseURL + "200-by-300-viewport.html"); | 971 navigateTo(m_baseURL + "200-by-300-viewport.html"); |
972 | 972 |
973 PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport(); | 973 PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport(); |
974 | 974 |
975 // Test that the pinch viewport is scrolled if the viewport has been | 975 // Test that the pinch viewport is scrolled if the viewport has been |
976 // resized (as is the case when the ChromeOS keyboard comes up) but not | 976 // resized (as is the case when the ChromeOS keyboard comes up) but not |
977 // scaled. | 977 // scaled. |
978 webViewImpl()->resizePinchViewport(WebSize(100, 100)); | 978 webViewImpl()->resizePinchViewport(WebSize(100, 100)); |
979 pinchViewport.scrollIntoView(FloatRect(100, 250, 50, 50)); | 979 pinchViewport.scrollIntoView(LayoutRect(100, 250, 50, 50)); |
980 EXPECT_POINT_EQ(IntPoint(75, 150), frame()->view()->scrollPosition()); | 980 EXPECT_POINT_EQ(IntPoint(75, 150), frame()->view()->scrollPosition()); |
981 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 50), pinchViewport.visibleRect().locatio
n()); | 981 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 50), pinchViewport.visibleRect().locatio
n()); |
982 | 982 |
983 pinchViewport.scrollIntoView(FloatRect(25, 75, 50, 50)); | 983 pinchViewport.scrollIntoView(LayoutRect(25, 75, 50, 50)); |
984 EXPECT_POINT_EQ(IntPoint(0, 0), frame()->view()->scrollPosition()); | 984 EXPECT_POINT_EQ(IntPoint(0, 0), frame()->view()->scrollPosition()); |
985 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 50), pinchViewport.visibleRect().locatio
n()); | 985 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 50), pinchViewport.visibleRect().locatio
n()); |
986 | 986 |
987 // Reset the pinch viewport's size, scale the page and repeat the test | 987 // Reset the pinch viewport's size, scale the page and repeat the test |
988 webViewImpl()->resizePinchViewport(IntSize(100, 150)); | 988 webViewImpl()->resizePinchViewport(IntSize(100, 150)); |
989 webViewImpl()->setPageScaleFactor(2); | 989 webViewImpl()->setPageScaleFactor(2); |
990 pinchViewport.setLocation(FloatPoint()); | 990 pinchViewport.setLocation(FloatPoint()); |
991 | 991 |
992 pinchViewport.scrollIntoView(FloatRect(50, 75, 50, 75)); | 992 pinchViewport.scrollIntoView(LayoutRect(50, 75, 50, 75)); |
993 EXPECT_POINT_EQ(IntPoint(50, 75), frame()->view()->scrollPosition()); | 993 EXPECT_POINT_EQ(IntPoint(50, 75), frame()->view()->scrollPosition()); |
994 EXPECT_FLOAT_POINT_EQ(FloatPoint(), pinchViewport.visibleRect().location()); | 994 EXPECT_FLOAT_POINT_EQ(FloatPoint(), pinchViewport.visibleRect().location()); |
995 | 995 |
996 pinchViewport.scrollIntoView(FloatRect(190, 290, 10, 10)); | 996 pinchViewport.scrollIntoView(LayoutRect(190, 290, 10, 10)); |
997 EXPECT_POINT_EQ(IntPoint(100, 150), frame()->view()->scrollPosition()); | 997 EXPECT_POINT_EQ(IntPoint(100, 150), frame()->view()->scrollPosition()); |
998 EXPECT_FLOAT_POINT_EQ(FloatPoint(50, 75), pinchViewport.visibleRect().locati
on()); | 998 EXPECT_FLOAT_POINT_EQ(FloatPoint(50, 75), pinchViewport.visibleRect().locati
on()); |
| 999 |
| 1000 // Scrolling into view the viewport rect itself should be a no-op. |
| 1001 webViewImpl()->resizePinchViewport(IntSize(100, 100)); |
| 1002 webViewImpl()->setPageScaleFactor(1.5f); |
| 1003 frame()->view()->scrollTo(IntPoint(50, 50)); |
| 1004 pinchViewport.setLocation(FloatPoint(0, 10)); |
| 1005 |
| 1006 pinchViewport.scrollIntoView(LayoutRect(pinchViewport.visibleRectInDocument(
))); |
| 1007 EXPECT_POINT_EQ(IntPoint(50, 50), frame()->view()->scrollPosition()); |
| 1008 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 10), pinchViewport.visibleRect().locatio
n()); |
999 } | 1009 } |
1000 | 1010 |
1001 static IntPoint expectedMaxFrameViewScrollOffset(PinchViewport& pinchViewport, F
rameView& frameView) | 1011 static IntPoint expectedMaxFrameViewScrollOffset(PinchViewport& pinchViewport, F
rameView& frameView) |
1002 { | 1012 { |
1003 float aspectRatio = pinchViewport.visibleRect().width() / pinchViewport.visi
bleRect().height(); | 1013 float aspectRatio = pinchViewport.visibleRect().width() / pinchViewport.visi
bleRect().height(); |
1004 float newHeight = frameView.frameRect().width() / aspectRatio; | 1014 float newHeight = frameView.frameRect().width() / aspectRatio; |
1005 return IntPoint( | 1015 return IntPoint( |
1006 frameView.contentsSize().width() - frameView.frameRect().width(), | 1016 frameView.contentsSize().width() - frameView.frameRect().width(), |
1007 frameView.contentsSize().height() - newHeight); | 1017 frameView.contentsSize().height() - newHeight); |
1008 } | 1018 } |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1194 EXPECT_EQ(500, frameView.scrollPositionDouble().y()); | 1204 EXPECT_EQ(500, frameView.scrollPositionDouble().y()); |
1195 | 1205 |
1196 // Now send the resize, make sure the scroll offset doesn't change. | 1206 // Now send the resize, make sure the scroll offset doesn't change. |
1197 webViewImpl()->setTopControlsLayoutHeight(0); | 1207 webViewImpl()->setTopControlsLayoutHeight(0); |
1198 webViewImpl()->resize(IntSize(1000, 1500)); | 1208 webViewImpl()->resize(IntSize(1000, 1500)); |
1199 EXPECT_EQ(500, frameView.scrollPositionDouble().y()); | 1209 EXPECT_EQ(500, frameView.scrollPositionDouble().y()); |
1200 } | 1210 } |
1201 | 1211 |
1202 | 1212 |
1203 } // namespace | 1213 } // namespace |
OLD | NEW |