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 921 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
932 WebRect baseRect; | 932 WebRect baseRect; |
933 WebRect extentRect; | 933 WebRect extentRect; |
934 | 934 |
935 webViewImpl()->setPageScaleFactor(2); | 935 webViewImpl()->setPageScaleFactor(2); |
936 WebFrame* mainFrame = webViewImpl()->mainFrame(); | 936 WebFrame* mainFrame = webViewImpl()->mainFrame(); |
937 | 937 |
938 // Select some text and get the base and extent rects (that's the start of | 938 // Select some text and get the base and extent rects (that's the start of |
939 // the range and its end). Do a sanity check that the expected text is | 939 // the range and its end). Do a sanity check that the expected text is |
940 // selected | 940 // selected |
941 mainFrame->executeScript(WebScriptSource("selectRange();")); | 941 mainFrame->executeScript(WebScriptSource("selectRange();")); |
942 EXPECT_EQ("ir", mainFrame->selectionAsText().utf8()); | 942 EXPECT_EQ("ir", mainFrame->toWebLocalFrame()->selectionAsText().utf8()); |
943 | 943 |
944 webViewImpl()->selectionBounds(baseRect, extentRect); | 944 webViewImpl()->selectionBounds(baseRect, extentRect); |
945 WebPoint initialPoint(baseRect.x, baseRect.y); | 945 WebPoint initialPoint(baseRect.x, baseRect.y); |
946 WebPoint endPoint(extentRect.x, extentRect.y); | 946 WebPoint endPoint(extentRect.x, extentRect.y); |
947 | 947 |
948 // Move the visual viewport over and make the selection in the same | 948 // Move the visual viewport over and make the selection in the same |
949 // screen-space location. The selection should change to two characters to | 949 // screen-space location. The selection should change to two characters to |
950 // the right and down one line. | 950 // the right and down one line. |
951 VisualViewport& visualViewport = frame()->page()->frameHost().visualViewport
(); | 951 VisualViewport& visualViewport = frame()->page()->frameHost().visualViewport
(); |
952 visualViewport.move(FloatPoint(60, 25)); | 952 visualViewport.move(FloatPoint(60, 25)); |
953 mainFrame->moveRangeSelection(initialPoint, endPoint); | 953 mainFrame->toWebLocalFrame()->moveRangeSelection(initialPoint, endPoint); |
954 EXPECT_EQ("t ", mainFrame->selectionAsText().utf8()); | 954 EXPECT_EQ("t ", mainFrame->toWebLocalFrame()->selectionAsText().utf8()); |
955 } | 955 } |
956 | 956 |
957 // Test that the scrollFocusedEditableElementIntoRect method works with the visu
al viewport. | 957 // Test that the scrollFocusedEditableElementIntoRect method works with the visu
al viewport. |
958 TEST_P(ParameterizedVisualViewportTest, DISABLED_TestScrollFocusedEditableElemen
tIntoRect) | 958 TEST_P(ParameterizedVisualViewportTest, DISABLED_TestScrollFocusedEditableElemen
tIntoRect) |
959 { | 959 { |
960 initializeWithDesktopSettings(); | 960 initializeWithDesktopSettings(); |
961 webViewImpl()->resize(IntSize(500, 300)); | 961 webViewImpl()->resize(IntSize(500, 300)); |
962 | 962 |
963 registerMockedHttpURLLoad("pinch-viewport-input-field.html"); | 963 registerMockedHttpURLLoad("pinch-viewport-input-field.html"); |
964 navigateTo(m_baseURL + "pinch-viewport-input-field.html"); | 964 navigateTo(m_baseURL + "pinch-viewport-input-field.html"); |
(...skipping 894 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1859 webViewImpl()->handleInputEvent(pinchUpdate); | 1859 webViewImpl()->handleInputEvent(pinchUpdate); |
1860 | 1860 |
1861 VisualViewport& visualViewport = webViewImpl()->page()->frameHost().visualVi
ewport(); | 1861 VisualViewport& visualViewport = webViewImpl()->page()->frameHost().visualVi
ewport(); |
1862 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); | 1862 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); |
1863 | 1863 |
1864 EXPECT_FLOAT_POINT_EQ(FloatPoint(50, 50), visualViewport.location()); | 1864 EXPECT_FLOAT_POINT_EQ(FloatPoint(50, 50), visualViewport.location()); |
1865 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), frameView.scrollPositionDouble()); | 1865 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), frameView.scrollPositionDouble()); |
1866 } | 1866 } |
1867 | 1867 |
1868 } // namespace | 1868 } // namespace |
OLD | NEW |