| OLD | NEW |
| 1 #include "core/frame/FrameView.h" | 1 #include "core/frame/FrameView.h" |
| 2 #include "core/loader/DocumentLoader.h" | 2 #include "core/loader/DocumentLoader.h" |
| 3 #include "core/loader/FrameLoader.h" | 3 #include "core/loader/FrameLoader.h" |
| 4 #include "platform/testing/URLTestHelpers.h" | 4 #include "platform/testing/URLTestHelpers.h" |
| 5 #include "public/platform/Platform.h" | 5 #include "public/platform/Platform.h" |
| 6 #include "public/platform/WebURLLoaderMockFactory.h" | 6 #include "public/platform/WebURLLoaderMockFactory.h" |
| 7 #include "public/web/WebCache.h" | 7 #include "public/web/WebCache.h" |
| 8 #include "public/web/WebFrame.h" | 8 #include "public/web/WebFrame.h" |
| 9 #include "public/web/WebFrameClient.h" | 9 #include "public/web/WebFrameClient.h" |
| 10 #include "public/web/WebHistoryItem.h" | 10 #include "public/web/WebHistoryItem.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 webView->updateAllLifecyclePhases(); | 49 webView->updateAllLifecyclePhases(); |
| 50 | 50 |
| 51 WebViewImpl* webViewImpl = toWebViewImpl(webView); | 51 WebViewImpl* webViewImpl = toWebViewImpl(webView); |
| 52 FrameLoader& loader = webViewImpl->mainFrameImpl()->frame()->loader(); | 52 FrameLoader& loader = webViewImpl->mainFrameImpl()->frame()->loader(); |
| 53 loader.setLoadType(FrameLoadTypeBackForward); | 53 loader.setLoadType(FrameLoadTypeBackForward); |
| 54 | 54 |
| 55 webViewImpl->setPageScaleFactor(3.0f); | 55 webViewImpl->setPageScaleFactor(3.0f); |
| 56 webViewImpl->mainFrame()->setScrollOffset(WebSize(0, 500)); | 56 webViewImpl->mainFrame()->setScrollOffset(WebSize(0, 500)); |
| 57 loader.documentLoader()->initialScrollState().wasScrolledByUser = false; | 57 loader.documentLoader()->initialScrollState().wasScrolledByUser = false; |
| 58 loader.currentItem()->setPageScaleFactor(2); | 58 loader.currentItem()->setPageScaleFactor(2); |
| 59 loader.currentItem()->setScrollPoint(WebPoint(0, 200)); | 59 loader.currentItem()->setScrollOffset(ScrollOffset(0, 200)); |
| 60 | 60 |
| 61 // Flip back the wasScrolledByUser flag which was set to true by | 61 // Flip back the wasScrolledByUser flag which was set to true by |
| 62 // setPageScaleFactor because otherwise | 62 // setPageScaleFactor because otherwise |
| 63 // FrameLoader::restoreScrollPositionAndViewState does nothing. | 63 // FrameLoader::restoreScrollPositionAndViewState does nothing. |
| 64 loader.documentLoader()->initialScrollState().wasScrolledByUser = false; | 64 loader.documentLoader()->initialScrollState().wasScrolledByUser = false; |
| 65 loader.restoreScrollPositionAndViewState(); | 65 loader.restoreScrollPositionAndViewState(); |
| 66 | 66 |
| 67 // Expect that both scroll and scale were restored. | 67 // Expect that both scroll and scale were restored. |
| 68 EXPECT_EQ(2.0f, webViewImpl->pageScaleFactor()); | 68 EXPECT_EQ(2.0f, webViewImpl->pageScaleFactor()); |
| 69 EXPECT_EQ(200, webViewImpl->mainFrameImpl()->scrollOffset().height); | 69 EXPECT_EQ(200, webViewImpl->mainFrameImpl()->scrollOffset().height); |
| 70 } | 70 } |
| 71 | 71 |
| 72 TEST_F(ProgrammaticScrollTest, RestoreScrollPositionAndViewStateWithoutScale) { | 72 TEST_F(ProgrammaticScrollTest, RestoreScrollPositionAndViewStateWithoutScale) { |
| 73 registerMockedHttpURLLoad("long_scroll.html"); | 73 registerMockedHttpURLLoad("long_scroll.html"); |
| 74 | 74 |
| 75 FrameTestHelpers::WebViewHelper webViewHelper; | 75 FrameTestHelpers::WebViewHelper webViewHelper; |
| 76 WebView* webView = webViewHelper.initializeAndLoad( | 76 WebView* webView = webViewHelper.initializeAndLoad( |
| 77 m_baseURL + "long_scroll.html", true, 0, 0); | 77 m_baseURL + "long_scroll.html", true, 0, 0); |
| 78 webView->resize(WebSize(1000, 1000)); | 78 webView->resize(WebSize(1000, 1000)); |
| 79 webView->updateAllLifecyclePhases(); | 79 webView->updateAllLifecyclePhases(); |
| 80 | 80 |
| 81 WebViewImpl* webViewImpl = toWebViewImpl(webView); | 81 WebViewImpl* webViewImpl = toWebViewImpl(webView); |
| 82 FrameLoader& loader = webViewImpl->mainFrameImpl()->frame()->loader(); | 82 FrameLoader& loader = webViewImpl->mainFrameImpl()->frame()->loader(); |
| 83 loader.setLoadType(FrameLoadTypeBackForward); | 83 loader.setLoadType(FrameLoadTypeBackForward); |
| 84 | 84 |
| 85 webViewImpl->setPageScaleFactor(3.0f); | 85 webViewImpl->setPageScaleFactor(3.0f); |
| 86 webViewImpl->mainFrame()->setScrollOffset(WebSize(0, 500)); | 86 webViewImpl->mainFrame()->setScrollOffset(WebSize(0, 500)); |
| 87 loader.documentLoader()->initialScrollState().wasScrolledByUser = false; | 87 loader.documentLoader()->initialScrollState().wasScrolledByUser = false; |
| 88 loader.currentItem()->setPageScaleFactor(0); | 88 loader.currentItem()->setPageScaleFactor(0); |
| 89 loader.currentItem()->setScrollPoint(WebPoint(0, 400)); | 89 loader.currentItem()->setScrollOffset(ScrollOffset(0, 400)); |
| 90 | 90 |
| 91 // FrameLoader::restoreScrollPositionAndViewState flows differently if scale | 91 // FrameLoader::restoreScrollPositionAndViewState flows differently if scale |
| 92 // is zero. | 92 // is zero. |
| 93 loader.restoreScrollPositionAndViewState(); | 93 loader.restoreScrollPositionAndViewState(); |
| 94 | 94 |
| 95 // Expect that only the scroll position was restored. | 95 // Expect that only the scroll position was restored. |
| 96 EXPECT_EQ(3.0f, webViewImpl->pageScaleFactor()); | 96 EXPECT_EQ(3.0f, webViewImpl->pageScaleFactor()); |
| 97 EXPECT_EQ(400, webViewImpl->mainFrameImpl()->scrollOffset().height); | 97 EXPECT_EQ(400, webViewImpl->mainFrameImpl()->scrollOffset().height); |
| 98 } | 98 } |
| 99 | 99 |
| 100 } // namespace blink | 100 } // namespace blink |
| OLD | NEW |