| 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 "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 930 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 941 | 941 |
| 942 // Move the visual viewport over and make the selection in the same | 942 // Move the visual viewport over and make the selection in the same |
| 943 // screen-space location. The selection should change to two characters to | 943 // screen-space location. The selection should change to two characters to |
| 944 // the right and down one line. | 944 // the right and down one line. |
| 945 VisualViewport& visualViewport = frame()->page()->frameHost().visualViewport
(); | 945 VisualViewport& visualViewport = frame()->page()->frameHost().visualViewport
(); |
| 946 visualViewport.move(FloatPoint(60, 25)); | 946 visualViewport.move(FloatPoint(60, 25)); |
| 947 mainFrame->moveRangeSelection(initialPoint, endPoint); | 947 mainFrame->moveRangeSelection(initialPoint, endPoint); |
| 948 EXPECT_EQ("t ", mainFrame->selectionAsText().utf8()); | 948 EXPECT_EQ("t ", mainFrame->selectionAsText().utf8()); |
| 949 } | 949 } |
| 950 | 950 |
| 951 // Test that the scrollFocusedNodeIntoRect method works with the visual viewport
. | 951 // Test that the scrollFocusedEditableElementIntoRect method works with the visu
al viewport. |
| 952 TEST_P(ParameterizedVisualViewportTest, DISABLED_TestScrollFocusedNodeIntoRect) | 952 TEST_P(ParameterizedVisualViewportTest, DISABLED_TestScrollFocusedEditableElemen
tIntoRect) |
| 953 { | 953 { |
| 954 bool willAnimate; |
| 954 initializeWithDesktopSettings(); | 955 initializeWithDesktopSettings(); |
| 955 webViewImpl()->resize(IntSize(500, 300)); | 956 webViewImpl()->resize(IntSize(500, 300)); |
| 956 | 957 |
| 957 registerMockedHttpURLLoad("pinch-viewport-input-field.html"); | 958 registerMockedHttpURLLoad("pinch-viewport-input-field.html"); |
| 958 navigateTo(m_baseURL + "pinch-viewport-input-field.html"); | 959 navigateTo(m_baseURL + "pinch-viewport-input-field.html"); |
| 959 | 960 |
| 960 VisualViewport& visualViewport = frame()->page()->frameHost().visualViewport
(); | 961 VisualViewport& visualViewport = frame()->page()->frameHost().visualViewport
(); |
| 961 webViewImpl()->resizeVisualViewport(IntSize(200, 100)); | 962 webViewImpl()->resizeVisualViewport(IntSize(200, 100)); |
| 962 webViewImpl()->setInitialFocus(false); | 963 webViewImpl()->setInitialFocus(false); |
| 963 visualViewport.setLocation(FloatPoint()); | 964 visualViewport.setLocation(FloatPoint()); |
| 964 webViewImpl()->scrollFocusedNodeIntoRect(IntRect(0, 0, 500, 200)); | 965 webViewImpl()->scrollFocusedEditableElementIntoRect(IntRect(0, 0, 500, 200),
willAnimate); |
| 965 | 966 |
| 966 EXPECT_POINT_EQ(IntPoint(0, frame()->view()->maximumScrollPosition().y()), | 967 EXPECT_POINT_EQ(IntPoint(0, frame()->view()->maximumScrollPosition().y()), |
| 967 frame()->view()->scrollPosition()); | 968 frame()->view()->scrollPosition()); |
| 968 EXPECT_FLOAT_POINT_EQ(FloatPoint(150, 200), visualViewport.visibleRect().loc
ation()); | 969 EXPECT_FLOAT_POINT_EQ(FloatPoint(150, 200), visualViewport.visibleRect().loc
ation()); |
| 969 | 970 |
| 970 // Try it again but with the page zoomed in | 971 // Try it again but with the page zoomed in |
| 971 frame()->view()->setScrollPosition(IntPoint(0, 0), ProgrammaticScroll); | 972 frame()->view()->setScrollPosition(IntPoint(0, 0), ProgrammaticScroll); |
| 972 webViewImpl()->resizeVisualViewport(IntSize(500, 300)); | 973 webViewImpl()->resizeVisualViewport(IntSize(500, 300)); |
| 973 visualViewport.setLocation(FloatPoint(0, 0)); | 974 visualViewport.setLocation(FloatPoint(0, 0)); |
| 974 | 975 |
| 975 webViewImpl()->setPageScaleFactor(2); | 976 webViewImpl()->setPageScaleFactor(2); |
| 976 webViewImpl()->scrollFocusedNodeIntoRect(IntRect(0, 0, 500, 200)); | 977 webViewImpl()->scrollFocusedEditableElementIntoRect(IntRect(0, 0, 500, 200),
willAnimate); |
| 977 EXPECT_POINT_EQ(IntPoint(0, frame()->view()->maximumScrollPosition().y()), | 978 EXPECT_POINT_EQ(IntPoint(0, frame()->view()->maximumScrollPosition().y()), |
| 978 frame()->view()->scrollPosition()); | 979 frame()->view()->scrollPosition()); |
| 979 EXPECT_FLOAT_POINT_EQ(FloatPoint(125, 150), visualViewport.visibleRect().loc
ation()); | 980 EXPECT_FLOAT_POINT_EQ(FloatPoint(125, 150), visualViewport.visibleRect().loc
ation()); |
| 980 | 981 |
| 981 // Once more but make sure that we don't move the visual viewport unless nec
essary. | 982 // Once more but make sure that we don't move the visual viewport unless nec
essary. |
| 982 registerMockedHttpURLLoad("pinch-viewport-input-field-long-and-wide.html"); | 983 registerMockedHttpURLLoad("pinch-viewport-input-field-long-and-wide.html"); |
| 983 navigateTo(m_baseURL + "pinch-viewport-input-field-long-and-wide.html"); | 984 navigateTo(m_baseURL + "pinch-viewport-input-field-long-and-wide.html"); |
| 984 webViewImpl()->setInitialFocus(false); | 985 webViewImpl()->setInitialFocus(false); |
| 985 visualViewport.setLocation(FloatPoint()); | 986 visualViewport.setLocation(FloatPoint()); |
| 986 frame()->view()->setScrollPosition(IntPoint(0, 0), ProgrammaticScroll); | 987 frame()->view()->setScrollPosition(IntPoint(0, 0), ProgrammaticScroll); |
| 987 webViewImpl()->resizeVisualViewport(IntSize(500, 300)); | 988 webViewImpl()->resizeVisualViewport(IntSize(500, 300)); |
| 988 visualViewport.setLocation(FloatPoint(30, 50)); | 989 visualViewport.setLocation(FloatPoint(30, 50)); |
| 989 | 990 |
| 990 webViewImpl()->setPageScaleFactor(2); | 991 webViewImpl()->setPageScaleFactor(2); |
| 991 webViewImpl()->scrollFocusedNodeIntoRect(IntRect(0, 0, 500, 200)); | 992 webViewImpl()->scrollFocusedEditableElementIntoRect(IntRect(0, 0, 500, 200),
willAnimate); |
| 992 EXPECT_POINT_EQ(IntPoint(200-30-75, 600-50-65), frame()->view()->scrollPosit
ion()); | 993 EXPECT_POINT_EQ(IntPoint(200-30-75, 600-50-65), frame()->view()->scrollPosit
ion()); |
| 993 EXPECT_FLOAT_POINT_EQ(FloatPoint(30, 50), visualViewport.visibleRect().locat
ion()); | 994 EXPECT_FLOAT_POINT_EQ(FloatPoint(30, 50), visualViewport.visibleRect().locat
ion()); |
| 994 } | 995 } |
| 995 | 996 |
| 996 // Test that resizing the WebView causes ViewportConstrained objects to relayout
. | 997 // Test that resizing the WebView causes ViewportConstrained objects to relayout
. |
| 997 TEST_P(ParameterizedVisualViewportTest, TestWebViewResizeCausesViewportConstrain
edLayout) | 998 TEST_P(ParameterizedVisualViewportTest, TestWebViewResizeCausesViewportConstrain
edLayout) |
| 998 { | 999 { |
| 999 initializeWithDesktopSettings(); | 1000 initializeWithDesktopSettings(); |
| 1000 webViewImpl()->resize(IntSize(500, 300)); | 1001 webViewImpl()->resize(IntSize(500, 300)); |
| 1001 | 1002 |
| (...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1853 webViewImpl()->handleInputEvent(pinchUpdate); | 1854 webViewImpl()->handleInputEvent(pinchUpdate); |
| 1854 | 1855 |
| 1855 VisualViewport& visualViewport = webViewImpl()->page()->frameHost().visualVi
ewport(); | 1856 VisualViewport& visualViewport = webViewImpl()->page()->frameHost().visualVi
ewport(); |
| 1856 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); | 1857 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); |
| 1857 | 1858 |
| 1858 EXPECT_FLOAT_POINT_EQ(FloatPoint(50, 50), visualViewport.location()); | 1859 EXPECT_FLOAT_POINT_EQ(FloatPoint(50, 50), visualViewport.location()); |
| 1859 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), frameView.scrollPositionDouble()); | 1860 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), frameView.scrollPositionDouble()); |
| 1860 } | 1861 } |
| 1861 | 1862 |
| 1862 } // namespace | 1863 } // namespace |
| OLD | NEW |