| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 6730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6741 // is called from LocalFrame::createView (before the frame is associated | 6741 // is called from LocalFrame::createView (before the frame is associated |
| 6742 // with the the view). | 6742 // with the the view). |
| 6743 if (view) | 6743 if (view) |
| 6744 m_didScrollFrame = true; | 6744 m_didScrollFrame = true; |
| 6745 } | 6745 } |
| 6746 | 6746 |
| 6747 private: | 6747 private: |
| 6748 bool m_didScrollFrame; | 6748 bool m_didScrollFrame; |
| 6749 }; | 6749 }; |
| 6750 | 6750 |
| 6751 TEST_F(WebFrameTest, CompositorScrollIsUserScrollLongPage) { | 6751 // TODO(pdr): Merge WebFrameTestForSpv1AndSpv2 and ParameterizedWebFrameTest so |
| 6752 // more tests run with both (and neither) slimming paint v2 and root layer |
| 6753 // scrolling. |
| 6754 typedef bool TestParamSlimmingPaintV2; |
| 6755 class WebFrameTestForSpv1AndSpv2 |
| 6756 : public ::testing::WithParamInterface<TestParamSlimmingPaintV2>, |
| 6757 private ScopedSlimmingPaintV2ForTest, |
| 6758 public WebFrameTest { |
| 6759 public: |
| 6760 WebFrameTestForSpv1AndSpv2() : ScopedSlimmingPaintV2ForTest(GetParam()) {} |
| 6761 }; |
| 6762 |
| 6763 INSTANTIATE_TEST_CASE_P(All, WebFrameTestForSpv1AndSpv2, ::testing::Bool()); |
| 6764 |
| 6765 TEST_P(WebFrameTestForSpv1AndSpv2, CompositorScrollIsUserScrollLongPage) { |
| 6752 registerMockedHttpURLLoad("long_scroll.html"); | 6766 registerMockedHttpURLLoad("long_scroll.html"); |
| 6753 TestScrolledFrameClient client; | 6767 TestScrolledFrameClient client; |
| 6754 | 6768 |
| 6755 // Make sure we initialize to minimum scale, even if the window size | 6769 // Make sure we initialize to minimum scale, even if the window size |
| 6756 // only becomes available after the load begins. | 6770 // only becomes available after the load begins. |
| 6757 FrameTestHelpers::WebViewHelper webViewHelper; | 6771 FrameTestHelpers::WebViewHelper webViewHelper; |
| 6758 webViewHelper.initializeAndLoad(m_baseURL + "long_scroll.html", true, | 6772 webViewHelper.initializeAndLoad(m_baseURL + "long_scroll.html", true, |
| 6759 &client); | 6773 &client); |
| 6760 webViewHelper.resize(WebSize(1000, 1000)); | 6774 webViewHelper.resize(WebSize(1000, 1000)); |
| 6761 | 6775 |
| 6762 WebLocalFrameImpl* frameImpl = webViewHelper.webView()->mainFrameImpl(); | 6776 WebLocalFrameImpl* frameImpl = webViewHelper.webView()->mainFrameImpl(); |
| 6763 DocumentLoader::InitialScrollState& initialScrollState = | 6777 DocumentLoader::InitialScrollState& initialScrollState = |
| 6764 frameImpl->frame()->loader().documentLoader()->initialScrollState(); | 6778 frameImpl->frame()->loader().documentLoader()->initialScrollState(); |
| 6765 GraphicsLayer* frameViewLayer = frameImpl->frameView()->layerForScrolling(); | 6779 GraphicsLayer* frameViewLayer = frameImpl->frameView()->layerForScrolling(); |
| 6766 | 6780 |
| 6767 EXPECT_FALSE(client.wasFrameScrolled()); | 6781 EXPECT_FALSE(client.wasFrameScrolled()); |
| 6768 EXPECT_FALSE(initialScrollState.wasScrolledByUser); | 6782 EXPECT_FALSE(initialScrollState.wasScrolledByUser); |
| 6769 | 6783 |
| 6770 // Do a compositor scroll, verify that this is counted as a user scroll. | 6784 // Do a compositor scroll, verify that this is counted as a user scroll. |
| 6771 frameViewLayer->platformLayer()->setScrollPositionDouble( | 6785 frameViewLayer->platformLayer()->setScrollPositionDouble( |
| 6772 WebDoublePoint(0, 1)); | 6786 WebDoublePoint(0, 1)); |
| 6773 frameViewLayer->didScroll(); | 6787 auto* scrollableArea = frameImpl->frameView()->layoutViewportScrollableArea(); |
| 6788 scrollableArea->didScroll(gfx::ScrollOffset(0, 1)); |
| 6774 webViewHelper.webView()->applyViewportDeltas(WebFloatSize(), WebFloatSize(), | 6789 webViewHelper.webView()->applyViewportDeltas(WebFloatSize(), WebFloatSize(), |
| 6775 WebFloatSize(), 1.7f, 0); | 6790 WebFloatSize(), 1.7f, 0); |
| 6776 EXPECT_TRUE(client.wasFrameScrolled()); | 6791 EXPECT_TRUE(client.wasFrameScrolled()); |
| 6777 EXPECT_TRUE(initialScrollState.wasScrolledByUser); | 6792 EXPECT_TRUE(initialScrollState.wasScrolledByUser); |
| 6778 | 6793 |
| 6779 client.reset(); | 6794 client.reset(); |
| 6780 initialScrollState.wasScrolledByUser = false; | 6795 initialScrollState.wasScrolledByUser = false; |
| 6781 | 6796 |
| 6782 // The page scale 1.0f and scroll. | 6797 // The page scale 1.0f and scroll. |
| 6783 frameViewLayer->platformLayer()->setScrollPositionDouble( | 6798 frameViewLayer->platformLayer()->setScrollPositionDouble( |
| 6784 WebDoublePoint(0, 2)); | 6799 WebDoublePoint(0, 2)); |
| 6785 frameViewLayer->didScroll(); | 6800 scrollableArea->didScroll(gfx::ScrollOffset(0, 2)); |
| 6786 webViewHelper.webView()->applyViewportDeltas(WebFloatSize(), WebFloatSize(), | 6801 webViewHelper.webView()->applyViewportDeltas(WebFloatSize(), WebFloatSize(), |
| 6787 WebFloatSize(), 1.0f, 0); | 6802 WebFloatSize(), 1.0f, 0); |
| 6788 EXPECT_TRUE(client.wasFrameScrolled()); | 6803 EXPECT_TRUE(client.wasFrameScrolled()); |
| 6789 EXPECT_TRUE(initialScrollState.wasScrolledByUser); | 6804 EXPECT_TRUE(initialScrollState.wasScrolledByUser); |
| 6790 client.reset(); | 6805 client.reset(); |
| 6791 initialScrollState.wasScrolledByUser = false; | 6806 initialScrollState.wasScrolledByUser = false; |
| 6792 | 6807 |
| 6793 // No scroll event if there is no scroll delta. | 6808 // No scroll event if there is no scroll delta. |
| 6794 frameViewLayer->didScroll(); | 6809 scrollableArea->didScroll(gfx::ScrollOffset(0, 2)); |
| 6795 webViewHelper.webView()->applyViewportDeltas(WebFloatSize(), WebFloatSize(), | 6810 webViewHelper.webView()->applyViewportDeltas(WebFloatSize(), WebFloatSize(), |
| 6796 WebFloatSize(), 1.0f, 0); | 6811 WebFloatSize(), 1.0f, 0); |
| 6797 EXPECT_FALSE(client.wasFrameScrolled()); | 6812 EXPECT_FALSE(client.wasFrameScrolled()); |
| 6798 EXPECT_FALSE(initialScrollState.wasScrolledByUser); | 6813 EXPECT_FALSE(initialScrollState.wasScrolledByUser); |
| 6799 client.reset(); | 6814 client.reset(); |
| 6800 | 6815 |
| 6801 // Non zero page scale and scroll. | 6816 // Non zero page scale and scroll. |
| 6802 frameViewLayer->platformLayer()->setScrollPositionDouble( | 6817 frameViewLayer->platformLayer()->setScrollPositionDouble( |
| 6803 WebDoublePoint(9, 15)); | 6818 WebDoublePoint(9, 15)); |
| 6804 frameViewLayer->didScroll(); | 6819 scrollableArea->didScroll(gfx::ScrollOffset(9, 15)); |
| 6805 webViewHelper.webView()->applyViewportDeltas(WebFloatSize(), WebFloatSize(), | 6820 webViewHelper.webView()->applyViewportDeltas(WebFloatSize(), WebFloatSize(), |
| 6806 WebFloatSize(), 0.6f, 0); | 6821 WebFloatSize(), 0.6f, 0); |
| 6807 EXPECT_TRUE(client.wasFrameScrolled()); | 6822 EXPECT_TRUE(client.wasFrameScrolled()); |
| 6808 EXPECT_TRUE(initialScrollState.wasScrolledByUser); | 6823 EXPECT_TRUE(initialScrollState.wasScrolledByUser); |
| 6809 client.reset(); | 6824 client.reset(); |
| 6810 initialScrollState.wasScrolledByUser = false; | 6825 initialScrollState.wasScrolledByUser = false; |
| 6811 | 6826 |
| 6812 // Programmatic scroll. | 6827 // Programmatic scroll. |
| 6813 frameImpl->executeScript(WebScriptSource("window.scrollTo(0, 20);")); | 6828 frameImpl->executeScript(WebScriptSource("window.scrollTo(0, 20);")); |
| 6814 EXPECT_TRUE(client.wasFrameScrolled()); | 6829 EXPECT_TRUE(client.wasFrameScrolled()); |
| (...skipping 4442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11257 | 11272 |
| 11258 EXPECT_TRUE(mainFrameClient.childClient().didCallFrameDetached()); | 11273 EXPECT_TRUE(mainFrameClient.childClient().didCallFrameDetached()); |
| 11259 EXPECT_TRUE(mainFrameClient.childClient().didCallDidStopLoading()); | 11274 EXPECT_TRUE(mainFrameClient.childClient().didCallDidStopLoading()); |
| 11260 EXPECT_TRUE(mainFrameClient.childClient().didCallDidFinishDocumentLoad()); | 11275 EXPECT_TRUE(mainFrameClient.childClient().didCallDidFinishDocumentLoad()); |
| 11261 EXPECT_TRUE(mainFrameClient.childClient().didCallDidHandleOnloadEvents()); | 11276 EXPECT_TRUE(mainFrameClient.childClient().didCallDidHandleOnloadEvents()); |
| 11262 | 11277 |
| 11263 webViewHelper.reset(); | 11278 webViewHelper.reset(); |
| 11264 } | 11279 } |
| 11265 | 11280 |
| 11266 } // namespace blink | 11281 } // namespace blink |
| OLD | NEW |