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