| 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 1424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2378 &configureAndroidCompositing); | 2378 &configureAndroidCompositing); |
| 2379 | 2379 |
| 2380 int page_width = 320; | 2380 int page_width = 320; |
| 2381 int page_height = 590; | 2381 int page_height = 590; |
| 2382 float browser_controls_height = 50.0f; | 2382 float browser_controls_height = 50.0f; |
| 2383 int largest_height = page_height + browser_controls_height; | 2383 int largest_height = page_height + browser_controls_height; |
| 2384 | 2384 |
| 2385 web_view_impl->ResizeWithBrowserControls(WebSize(page_width, page_height), | 2385 web_view_impl->ResizeWithBrowserControls(WebSize(page_width, page_height), |
| 2386 browser_controls_height, true); | 2386 browser_controls_height, true); |
| 2387 | 2387 |
| 2388 FrameTestHelpers::LoadFrame(web_view_impl->MainFrame(), "about:blank"); | 2388 FrameTestHelpers::LoadFrame(web_view_impl->MainFrameImpl(), "about:blank"); |
| 2389 web_view_impl->UpdateAllLifecyclePhases(); | 2389 web_view_impl->UpdateAllLifecyclePhases(); |
| 2390 | 2390 |
| 2391 Document* document = | 2391 Document* document = |
| 2392 ToLocalFrame(web_view_impl->GetPage()->MainFrame())->GetDocument(); | 2392 ToLocalFrame(web_view_impl->GetPage()->MainFrame())->GetDocument(); |
| 2393 | 2393 |
| 2394 // Do a resize to check for invalidations. | 2394 // Do a resize to check for invalidations. |
| 2395 document->View()->SetTracksPaintInvalidations(true); | 2395 document->View()->SetTracksPaintInvalidations(true); |
| 2396 web_view_impl->ResizeWithBrowserControls(WebSize(page_width, largest_height), | 2396 web_view_impl->ResizeWithBrowserControls(WebSize(page_width, largest_height), |
| 2397 browser_controls_height, false); | 2397 browser_controls_height, false); |
| 2398 | 2398 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2432 " margin: 0px;" | 2432 " margin: 0px;" |
| 2433 " }" | 2433 " }" |
| 2434 " div { height:110vh; width: 110vw; }" | 2434 " div { height:110vh; width: 110vw; }" |
| 2435 "</style>" | 2435 "</style>" |
| 2436 "<div></div>", | 2436 "<div></div>", |
| 2437 base_url); | 2437 base_url); |
| 2438 } | 2438 } |
| 2439 | 2439 |
| 2440 } // namespace | 2440 } // namespace |
| 2441 } // namespace blink | 2441 } // namespace blink |
| OLD | NEW |