| 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/BrowserControls.h" | 8 #include "core/frame/BrowserControls.h" |
| 9 #include "core/frame/LocalFrame.h" | 9 #include "core/frame/LocalFrame.h" |
| 10 #include "core/frame/LocalFrameView.h" | 10 #include "core/frame/LocalFrameView.h" |
| (...skipping 994 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1005 InitializeWithDesktopSettings(); | 1005 InitializeWithDesktopSettings(); |
| 1006 WebViewImpl()->GetSettings()->SetDefaultFontSize(12); | 1006 WebViewImpl()->GetSettings()->SetDefaultFontSize(12); |
| 1007 WebViewImpl()->Resize(WebSize(640, 480)); | 1007 WebViewImpl()->Resize(WebSize(640, 480)); |
| 1008 RegisterMockedHttpURLLoad("move_range.html"); | 1008 RegisterMockedHttpURLLoad("move_range.html"); |
| 1009 NavigateTo(base_url_ + "move_range.html"); | 1009 NavigateTo(base_url_ + "move_range.html"); |
| 1010 | 1010 |
| 1011 WebRect base_rect; | 1011 WebRect base_rect; |
| 1012 WebRect extent_rect; | 1012 WebRect extent_rect; |
| 1013 | 1013 |
| 1014 WebViewImpl()->SetPageScaleFactor(2); | 1014 WebViewImpl()->SetPageScaleFactor(2); |
| 1015 WebFrame* mainFrame = WebViewImpl()->MainFrame(); | 1015 WebLocalFrame* mainFrame = WebViewImpl()->MainFrameImpl(); |
| 1016 | 1016 |
| 1017 // Select some text and get the base and extent rects (that's the start of | 1017 // Select some text and get the base and extent rects (that's the start of |
| 1018 // the range and its end). Do a sanity check that the expected text is | 1018 // the range and its end). Do a sanity check that the expected text is |
| 1019 // selected | 1019 // selected |
| 1020 mainFrame->ExecuteScript(WebScriptSource("selectRange();")); | 1020 mainFrame->ExecuteScript(WebScriptSource("selectRange();")); |
| 1021 EXPECT_EQ("ir", mainFrame->ToWebLocalFrame()->SelectionAsText().Utf8()); | 1021 EXPECT_EQ("ir", mainFrame->SelectionAsText().Utf8()); |
| 1022 | 1022 |
| 1023 WebViewImpl()->SelectionBounds(base_rect, extent_rect); | 1023 WebViewImpl()->SelectionBounds(base_rect, extent_rect); |
| 1024 WebPoint initialPoint(base_rect.x, base_rect.y); | 1024 WebPoint initialPoint(base_rect.x, base_rect.y); |
| 1025 WebPoint endPoint(extent_rect.x, extent_rect.y); | 1025 WebPoint endPoint(extent_rect.x, extent_rect.y); |
| 1026 | 1026 |
| 1027 // Move the visual viewport over and make the selection in the same | 1027 // Move the visual viewport over and make the selection in the same |
| 1028 // screen-space location. The selection should change to two characters to the | 1028 // screen-space location. The selection should change to two characters to the |
| 1029 // right and down one line. | 1029 // right and down one line. |
| 1030 VisualViewport& visual_viewport = GetFrame()->GetPage()->GetVisualViewport(); | 1030 VisualViewport& visual_viewport = GetFrame()->GetPage()->GetVisualViewport(); |
| 1031 visual_viewport.Move(ScrollOffset(60, 25)); | 1031 visual_viewport.Move(ScrollOffset(60, 25)); |
| 1032 mainFrame->ToWebLocalFrame()->MoveRangeSelection(initialPoint, endPoint); | 1032 mainFrame->MoveRangeSelection(initialPoint, endPoint); |
| 1033 EXPECT_EQ("t ", mainFrame->ToWebLocalFrame()->SelectionAsText().Utf8()); | 1033 EXPECT_EQ("t ", mainFrame->SelectionAsText().Utf8()); |
| 1034 } | 1034 } |
| 1035 | 1035 |
| 1036 // Test that the scrollFocusedEditableElementIntoRect method works with the | 1036 // Test that the scrollFocusedEditableElementIntoRect method works with the |
| 1037 // visual viewport. | 1037 // visual viewport. |
| 1038 TEST_P(VisualViewportTest, DISABLED_TestScrollFocusedEditableElementIntoRect) { | 1038 TEST_P(VisualViewportTest, DISABLED_TestScrollFocusedEditableElementIntoRect) { |
| 1039 InitializeWithDesktopSettings(); | 1039 InitializeWithDesktopSettings(); |
| 1040 WebViewImpl()->Resize(IntSize(500, 300)); | 1040 WebViewImpl()->Resize(IntSize(500, 300)); |
| 1041 | 1041 |
| 1042 RegisterMockedHttpURLLoad("pinch-viewport-input-field.html"); | 1042 RegisterMockedHttpURLLoad("pinch-viewport-input-field.html"); |
| 1043 NavigateTo(base_url_ + "pinch-viewport-input-field.html"); | 1043 NavigateTo(base_url_ + "pinch-viewport-input-field.html"); |
| (...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1628 // compositing change update. crbug.com/423188. | 1628 // compositing change update. crbug.com/423188. |
| 1629 TEST_P(VisualViewportTest, TestChangingContentSizeAffectsScrollBounds) { | 1629 TEST_P(VisualViewportTest, TestChangingContentSizeAffectsScrollBounds) { |
| 1630 InitializeWithAndroidSettings(); | 1630 InitializeWithAndroidSettings(); |
| 1631 WebViewImpl()->Resize(IntSize(100, 150)); | 1631 WebViewImpl()->Resize(IntSize(100, 150)); |
| 1632 | 1632 |
| 1633 RegisterMockedHttpURLLoad("content-width-1000.html"); | 1633 RegisterMockedHttpURLLoad("content-width-1000.html"); |
| 1634 NavigateTo(base_url_ + "content-width-1000.html"); | 1634 NavigateTo(base_url_ + "content-width-1000.html"); |
| 1635 | 1635 |
| 1636 LocalFrameView& frame_view = *WebViewImpl()->MainFrameImpl()->GetFrameView(); | 1636 LocalFrameView& frame_view = *WebViewImpl()->MainFrameImpl()->GetFrameView(); |
| 1637 | 1637 |
| 1638 WebViewImpl()->MainFrame()->ExecuteScript( | 1638 WebViewImpl()->MainFrameImpl()->ExecuteScript( |
| 1639 WebScriptSource("var content = document.getElementById(\"content\");" | 1639 WebScriptSource("var content = document.getElementById(\"content\");" |
| 1640 "content.style.width = \"1500px\";" | 1640 "content.style.width = \"1500px\";" |
| 1641 "content.style.height = \"2400px\";")); | 1641 "content.style.height = \"2400px\";")); |
| 1642 frame_view.UpdateAllLifecyclePhases(); | 1642 frame_view.UpdateAllLifecyclePhases(); |
| 1643 WebLayer* scrollLayer = frame_view.LayoutViewportScrollableArea() | 1643 WebLayer* scrollLayer = frame_view.LayoutViewportScrollableArea() |
| 1644 ->LayerForScrolling() | 1644 ->LayerForScrolling() |
| 1645 ->PlatformLayer(); | 1645 ->PlatformLayer(); |
| 1646 | 1646 |
| 1647 EXPECT_SIZE_EQ(IntSize(1500, 2400), IntSize(scrollLayer->Bounds())); | 1647 EXPECT_SIZE_EQ(IntSize(1500, 2400), IntSize(scrollLayer->Bounds())); |
| 1648 } | 1648 } |
| (...skipping 804 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2453 " margin: 0px;" | 2453 " margin: 0px;" |
| 2454 " }" | 2454 " }" |
| 2455 " div { height:110vh; width: 110vw; }" | 2455 " div { height:110vh; width: 110vw; }" |
| 2456 "</style>" | 2456 "</style>" |
| 2457 "<div></div>", | 2457 "<div></div>", |
| 2458 base_url); | 2458 base_url); |
| 2459 } | 2459 } |
| 2460 | 2460 |
| 2461 } // namespace | 2461 } // namespace |
| 2462 } // namespace blink | 2462 } // namespace blink |
| OLD | NEW |