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/FrameTestHelpers.h" | 9 #include "core/frame/FrameTestHelpers.h" |
10 #include "core/frame/LocalFrame.h" | 10 #include "core/frame/LocalFrame.h" |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 WebViewImpl()->SetDefaultPageScaleLimits(0.25f, 5); | 129 WebViewImpl()->SetDefaultPageScaleLimits(0.25f, 5); |
130 } | 130 } |
131 | 131 |
132 ~VisualViewportTest() override { | 132 ~VisualViewportTest() override { |
133 Platform::Current() | 133 Platform::Current() |
134 ->GetURLLoaderMockFactory() | 134 ->GetURLLoaderMockFactory() |
135 ->UnregisterAllURLsAndClearMemoryCache(); | 135 ->UnregisterAllURLsAndClearMemoryCache(); |
136 } | 136 } |
137 | 137 |
138 void NavigateTo(const std::string& url) { | 138 void NavigateTo(const std::string& url) { |
139 FrameTestHelpers::LoadFrame(WebViewImpl()->MainFrame(), url); | 139 FrameTestHelpers::LoadFrame(WebViewImpl()->MainFrameImpl(), url); |
140 } | 140 } |
141 | 141 |
142 void ForceFullCompositingUpdate() { | 142 void ForceFullCompositingUpdate() { |
143 WebViewImpl()->UpdateAllLifecyclePhases(); | 143 WebViewImpl()->UpdateAllLifecyclePhases(); |
144 } | 144 } |
145 | 145 |
146 void RegisterMockedHttpURLLoad(const std::string& fileName) { | 146 void RegisterMockedHttpURLLoad(const std::string& fileName) { |
147 URLTestHelpers::RegisterMockedURLLoadFromBase( | 147 URLTestHelpers::RegisterMockedURLLoadFromBase( |
148 WebString::FromUTF8(base_url_), blink::testing::WebTestDataPath(), | 148 WebString::FromUTF8(base_url_), blink::testing::WebTestDataPath(), |
149 WebString::FromUTF8(fileName)); | 149 WebString::FromUTF8(fileName)); |
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
902 | 902 |
903 RegisterMockedHttpURLLoad("200-by-300.html"); | 903 RegisterMockedHttpURLLoad("200-by-300.html"); |
904 | 904 |
905 WebHistoryItem item; | 905 WebHistoryItem item; |
906 item.Initialize(); | 906 item.Initialize(); |
907 WebURL destination_url(URLTestHelpers::ToKURL(base_url_ + "200-by-300.html")); | 907 WebURL destination_url(URLTestHelpers::ToKURL(base_url_ + "200-by-300.html")); |
908 item.SetURLString(destination_url.GetString()); | 908 item.SetURLString(destination_url.GetString()); |
909 item.SetVisualViewportScrollOffset(WebFloatPoint(100, 120)); | 909 item.SetVisualViewportScrollOffset(WebFloatPoint(100, 120)); |
910 item.SetPageScaleFactor(2); | 910 item.SetPageScaleFactor(2); |
911 | 911 |
912 FrameTestHelpers::LoadHistoryItem(WebViewImpl()->MainFrame(), item, | 912 FrameTestHelpers::LoadHistoryItem(WebViewImpl()->MainFrameImpl(), item, |
913 kWebHistoryDifferentDocumentLoad, | 913 kWebHistoryDifferentDocumentLoad, |
914 WebCachePolicy::kUseProtocolCachePolicy); | 914 WebCachePolicy::kUseProtocolCachePolicy); |
915 | 915 |
916 VisualViewport& visual_viewport = GetFrame()->GetPage()->GetVisualViewport(); | 916 VisualViewport& visual_viewport = GetFrame()->GetPage()->GetVisualViewport(); |
917 EXPECT_EQ(2, visual_viewport.Scale()); | 917 EXPECT_EQ(2, visual_viewport.Scale()); |
918 | 918 |
919 EXPECT_FLOAT_POINT_EQ(FloatPoint(100, 120), | 919 EXPECT_FLOAT_POINT_EQ(FloatPoint(100, 120), |
920 visual_viewport.VisibleRect().Location()); | 920 visual_viewport.VisibleRect().Location()); |
921 } | 921 } |
922 | 922 |
(...skipping 10 matching lines...) Expand all Loading... |
933 item.Initialize(); | 933 item.Initialize(); |
934 WebURL destination_url( | 934 WebURL destination_url( |
935 URLTestHelpers::ToKURL(base_url_ + "200-by-300-viewport.html")); | 935 URLTestHelpers::ToKURL(base_url_ + "200-by-300-viewport.html")); |
936 item.SetURLString(destination_url.GetString()); | 936 item.SetURLString(destination_url.GetString()); |
937 // (-1, -1) will be used if the HistoryItem is an older version prior to | 937 // (-1, -1) will be used if the HistoryItem is an older version prior to |
938 // having visual viewport scroll offset. | 938 // having visual viewport scroll offset. |
939 item.SetVisualViewportScrollOffset(WebFloatPoint(-1, -1)); | 939 item.SetVisualViewportScrollOffset(WebFloatPoint(-1, -1)); |
940 item.SetScrollOffset(WebPoint(120, 180)); | 940 item.SetScrollOffset(WebPoint(120, 180)); |
941 item.SetPageScaleFactor(2); | 941 item.SetPageScaleFactor(2); |
942 | 942 |
943 FrameTestHelpers::LoadHistoryItem(WebViewImpl()->MainFrame(), item, | 943 FrameTestHelpers::LoadHistoryItem(WebViewImpl()->MainFrameImpl(), item, |
944 kWebHistoryDifferentDocumentLoad, | 944 kWebHistoryDifferentDocumentLoad, |
945 WebCachePolicy::kUseProtocolCachePolicy); | 945 WebCachePolicy::kUseProtocolCachePolicy); |
946 | 946 |
947 VisualViewport& visual_viewport = GetFrame()->GetPage()->GetVisualViewport(); | 947 VisualViewport& visual_viewport = GetFrame()->GetPage()->GetVisualViewport(); |
948 EXPECT_EQ(2, visual_viewport.Scale()); | 948 EXPECT_EQ(2, visual_viewport.Scale()); |
949 EXPECT_SIZE_EQ( | 949 EXPECT_SIZE_EQ( |
950 ScrollOffset(100, 150), | 950 ScrollOffset(100, 150), |
951 GetFrame()->View()->LayoutViewportScrollableArea()->GetScrollOffset()); | 951 GetFrame()->View()->LayoutViewportScrollableArea()->GetScrollOffset()); |
952 EXPECT_FLOAT_POINT_EQ(FloatPoint(20, 30), | 952 EXPECT_FLOAT_POINT_EQ(FloatPoint(20, 30), |
953 visual_viewport.VisibleRect().Location()); | 953 visual_viewport.VisibleRect().Location()); |
(...skipping 1412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2366 nullptr, nullptr, nullptr, &configureAndroidCompositing); | 2366 nullptr, nullptr, nullptr, &configureAndroidCompositing); |
2367 | 2367 |
2368 int page_width = 320; | 2368 int page_width = 320; |
2369 int page_height = 590; | 2369 int page_height = 590; |
2370 float browser_controls_height = 50.0f; | 2370 float browser_controls_height = 50.0f; |
2371 int largest_height = page_height + browser_controls_height; | 2371 int largest_height = page_height + browser_controls_height; |
2372 | 2372 |
2373 web_view_impl->ResizeWithBrowserControls(WebSize(page_width, page_height), | 2373 web_view_impl->ResizeWithBrowserControls(WebSize(page_width, page_height), |
2374 browser_controls_height, true); | 2374 browser_controls_height, true); |
2375 | 2375 |
2376 FrameTestHelpers::LoadFrame(web_view_impl->MainFrame(), "about:blank"); | 2376 FrameTestHelpers::LoadFrame(web_view_impl->MainFrameImpl(), "about:blank"); |
2377 web_view_impl->UpdateAllLifecyclePhases(); | 2377 web_view_impl->UpdateAllLifecyclePhases(); |
2378 | 2378 |
2379 Document* document = | 2379 Document* document = |
2380 ToLocalFrame(web_view_impl->GetPage()->MainFrame())->GetDocument(); | 2380 ToLocalFrame(web_view_impl->GetPage()->MainFrame())->GetDocument(); |
2381 | 2381 |
2382 // Do a resize to check for invalidations. | 2382 // Do a resize to check for invalidations. |
2383 document->View()->SetTracksPaintInvalidations(true); | 2383 document->View()->SetTracksPaintInvalidations(true); |
2384 web_view_impl->ResizeWithBrowserControls(WebSize(page_width, largest_height), | 2384 web_view_impl->ResizeWithBrowserControls(WebSize(page_width, largest_height), |
2385 browser_controls_height, false); | 2385 browser_controls_height, false); |
2386 | 2386 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2420 " margin: 0px;" | 2420 " margin: 0px;" |
2421 " }" | 2421 " }" |
2422 " div { height:110vh; width: 110vw; }" | 2422 " div { height:110vh; width: 110vw; }" |
2423 "</style>" | 2423 "</style>" |
2424 "<div></div>", | 2424 "<div></div>", |
2425 base_url); | 2425 base_url); |
2426 } | 2426 } |
2427 | 2427 |
2428 } // namespace | 2428 } // namespace |
2429 } // namespace blink | 2429 } // namespace blink |
OLD | NEW |