| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2011, 2012 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 1734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1745 // Scroll the page down. | 1745 // Scroll the page down. |
| 1746 webViewImpl->mainFrame()->setScrollOffset(WebSize(0, 2000)); | 1746 webViewImpl->mainFrame()->setScrollOffset(WebSize(0, 2000)); |
| 1747 ASSERT_EQ(2000, webViewImpl->mainFrame()->getScrollOffset().height); | 1747 ASSERT_EQ(2000, webViewImpl->mainFrame()->getScrollOffset().height); |
| 1748 | 1748 |
| 1749 // Enter fullscreen. | 1749 // Enter fullscreen. |
| 1750 Document* document = webViewImpl->mainFrameImpl()->frame()->document(); | 1750 Document* document = webViewImpl->mainFrameImpl()->frame()->document(); |
| 1751 Element* element = document->getElementById("fullscreenElement"); | 1751 Element* element = document->getElementById("fullscreenElement"); |
| 1752 UserGestureIndicator gesture(DocumentUserGestureToken::create(document)); | 1752 UserGestureIndicator gesture(DocumentUserGestureToken::create(document)); |
| 1753 Fullscreen::requestFullscreen(*element); | 1753 Fullscreen::requestFullscreen(*element); |
| 1754 webViewImpl->didEnterFullscreen(); | 1754 webViewImpl->didEnterFullscreen(); |
| 1755 webViewImpl->beginFrame(WTF::monotonicallyIncreasingTime()); | |
| 1756 webViewImpl->updateAllLifecyclePhases(); | 1755 webViewImpl->updateAllLifecyclePhases(); |
| 1757 | 1756 |
| 1758 // Sanity-check. There should be no scrolling possible. | 1757 // Sanity-check. There should be no scrolling possible. |
| 1759 ASSERT_EQ(0, webViewImpl->mainFrame()->getScrollOffset().height); | 1758 ASSERT_EQ(0, webViewImpl->mainFrame()->getScrollOffset().height); |
| 1760 ASSERT_EQ(0, webViewImpl->mainFrameImpl() | 1759 ASSERT_EQ(0, webViewImpl->mainFrameImpl() |
| 1761 ->frameView() | 1760 ->frameView() |
| 1762 ->maximumScrollOffset() | 1761 ->maximumScrollOffset() |
| 1763 .height()); | 1762 .height()); |
| 1764 | 1763 |
| 1765 // Confirm that after exiting and doing a layout, the scroll and scale | 1764 // Confirm that after exiting and doing a layout, the scroll and scale |
| 1766 // parameters are reset. The page sets display: none on overflowing elements | 1765 // parameters are reset. The page sets display: none on overflowing elements |
| 1767 // while in fullscreen so if we try to restore before the style and layout | 1766 // while in fullscreen so if we try to restore before the style and layout |
| 1768 // is applied the offsets will be clamped. | 1767 // is applied the offsets will be clamped. |
| 1769 EXPECT_FALSE(webViewImpl->mainFrameImpl()->frameView()->needsLayout()); | |
| 1770 webViewImpl->didExitFullscreen(); | 1768 webViewImpl->didExitFullscreen(); |
| 1771 EXPECT_TRUE(webViewImpl->mainFrameImpl()->frameView()->needsLayout()); | 1769 EXPECT_TRUE(webViewImpl->mainFrameImpl()->frameView()->needsLayout()); |
| 1772 webViewImpl->beginFrame(WTF::monotonicallyIncreasingTime()); | |
| 1773 EXPECT_EQ(0, webViewImpl->mainFrame()->getScrollOffset().height); | |
| 1774 webViewImpl->updateAllLifecyclePhases(); | 1770 webViewImpl->updateAllLifecyclePhases(); |
| 1771 |
| 1775 EXPECT_EQ(2000, webViewImpl->mainFrame()->getScrollOffset().height); | 1772 EXPECT_EQ(2000, webViewImpl->mainFrame()->getScrollOffset().height); |
| 1776 } | 1773 } |
| 1777 | 1774 |
| 1778 // Tests that exiting and immediately reentering fullscreen doesn't cause the | 1775 // Tests that exiting and immediately reentering fullscreen doesn't cause the |
| 1779 // scroll and scale restoration to occur when we enter fullscreen again. | 1776 // scroll and scale restoration to occur when we enter fullscreen again. |
| 1780 TEST_P(WebViewTest, FullscreenResetScrollAndScaleExitAndReenter) { | 1777 TEST_P(WebViewTest, FullscreenResetScrollAndScaleExitAndReenter) { |
| 1781 URLTestHelpers::registerMockedURLFromBaseURL( | 1778 URLTestHelpers::registerMockedURLFromBaseURL( |
| 1782 WebString::fromUTF8(m_baseURL.c_str()), | 1779 WebString::fromUTF8(m_baseURL.c_str()), |
| 1783 WebString::fromUTF8("fullscreen_style.html")); | 1780 WebString::fromUTF8("fullscreen_style.html")); |
| 1784 WebViewImpl* webViewImpl = | 1781 WebViewImpl* webViewImpl = |
| 1785 m_webViewHelper.initializeAndLoad(m_baseURL + "fullscreen_style.html"); | 1782 m_webViewHelper.initializeAndLoad(m_baseURL + "fullscreen_style.html"); |
| 1786 webViewImpl->resize(WebSize(800, 600)); | 1783 webViewImpl->resize(WebSize(800, 600)); |
| 1787 webViewImpl->updateAllLifecyclePhases(); | 1784 webViewImpl->updateAllLifecyclePhases(); |
| 1788 | 1785 |
| 1789 // Scroll the page down. | 1786 // Scroll the page down. |
| 1790 webViewImpl->mainFrame()->setScrollOffset(WebSize(0, 2000)); | 1787 webViewImpl->mainFrame()->setScrollOffset(WebSize(0, 2000)); |
| 1791 ASSERT_EQ(2000, webViewImpl->mainFrame()->getScrollOffset().height); | 1788 ASSERT_EQ(2000, webViewImpl->mainFrame()->getScrollOffset().height); |
| 1792 | 1789 |
| 1793 // Enter fullscreen. | 1790 // Enter fullscreen. |
| 1794 Document* document = webViewImpl->mainFrameImpl()->frame()->document(); | 1791 Document* document = webViewImpl->mainFrameImpl()->frame()->document(); |
| 1795 Element* element = document->getElementById("fullscreenElement"); | 1792 Element* element = document->getElementById("fullscreenElement"); |
| 1796 UserGestureIndicator gesture(DocumentUserGestureToken::create(document)); | 1793 UserGestureIndicator gesture(DocumentUserGestureToken::create(document)); |
| 1797 Fullscreen::requestFullscreen(*element); | 1794 Fullscreen::requestFullscreen(*element); |
| 1798 webViewImpl->didEnterFullscreen(); | 1795 webViewImpl->didEnterFullscreen(); |
| 1799 webViewImpl->beginFrame(WTF::monotonicallyIncreasingTime()); | |
| 1800 webViewImpl->updateAllLifecyclePhases(); | 1796 webViewImpl->updateAllLifecyclePhases(); |
| 1801 | 1797 |
| 1802 // Sanity-check. There should be no scrolling possible. | 1798 // Sanity-check. There should be no scrolling possible. |
| 1803 ASSERT_EQ(0, webViewImpl->mainFrame()->getScrollOffset().height); | 1799 ASSERT_EQ(0, webViewImpl->mainFrame()->getScrollOffset().height); |
| 1804 ASSERT_EQ(0, webViewImpl->mainFrameImpl() | 1800 ASSERT_EQ(0, webViewImpl->mainFrameImpl() |
| 1805 ->frameView() | 1801 ->frameView() |
| 1806 ->maximumScrollOffset() | 1802 ->maximumScrollOffset() |
| 1807 .height()); | 1803 .height()); |
| 1808 | 1804 |
| 1809 // Exit and, without performing a layout, reenter fullscreen again. We | 1805 // Exit and, without performing a layout, reenter fullscreen again. We |
| 1810 // shouldn't try to restore the scroll and scale values when we layout to | 1806 // shouldn't try to restore the scroll and scale values when we layout to |
| 1811 // enter fullscreen. | 1807 // enter fullscreen. |
| 1812 webViewImpl->didExitFullscreen(); | 1808 webViewImpl->didExitFullscreen(); |
| 1813 Fullscreen::requestFullscreen(*element); | 1809 Fullscreen::requestFullscreen(*element); |
| 1814 webViewImpl->didEnterFullscreen(); | 1810 webViewImpl->didEnterFullscreen(); |
| 1815 webViewImpl->beginFrame(WTF::monotonicallyIncreasingTime()); | |
| 1816 webViewImpl->updateAllLifecyclePhases(); | 1811 webViewImpl->updateAllLifecyclePhases(); |
| 1817 | 1812 |
| 1818 // Sanity-check. There should be no scrolling possible. | 1813 // Sanity-check. There should be no scrolling possible. |
| 1819 ASSERT_EQ(0, webViewImpl->mainFrame()->getScrollOffset().height); | 1814 ASSERT_EQ(0, webViewImpl->mainFrame()->getScrollOffset().height); |
| 1820 ASSERT_EQ(0, webViewImpl->mainFrameImpl() | 1815 ASSERT_EQ(0, webViewImpl->mainFrameImpl() |
| 1821 ->frameView() | 1816 ->frameView() |
| 1822 ->maximumScrollOffset() | 1817 ->maximumScrollOffset() |
| 1823 .height()); | 1818 .height()); |
| 1824 | 1819 |
| 1825 // When we exit now, we should restore the original scroll value. | 1820 // When we exit now, we should restore the original scroll value. |
| 1826 webViewImpl->didExitFullscreen(); | 1821 webViewImpl->didExitFullscreen(); |
| 1827 webViewImpl->beginFrame(WTF::monotonicallyIncreasingTime()); | |
| 1828 webViewImpl->updateAllLifecyclePhases(); | 1822 webViewImpl->updateAllLifecyclePhases(); |
| 1829 | 1823 |
| 1830 EXPECT_EQ(2000, webViewImpl->mainFrame()->getScrollOffset().height); | 1824 EXPECT_EQ(2000, webViewImpl->mainFrame()->getScrollOffset().height); |
| 1831 } | 1825 } |
| 1832 | 1826 |
| 1833 TEST_P(WebViewTest, EnterFullscreenResetScrollAndScaleState) { | 1827 TEST_P(WebViewTest, EnterFullscreenResetScrollAndScaleState) { |
| 1834 URLTestHelpers::registerMockedURLFromBaseURL( | 1828 URLTestHelpers::registerMockedURLFromBaseURL( |
| 1835 WebString::fromUTF8(m_baseURL.c_str()), | 1829 WebString::fromUTF8(m_baseURL.c_str()), |
| 1836 WebString::fromUTF8("200-by-300.html")); | 1830 WebString::fromUTF8("200-by-300.html")); |
| 1837 WebViewImpl* webViewImpl = | 1831 WebViewImpl* webViewImpl = |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1849 EXPECT_EQ(94, webViewImpl->mainFrame()->getScrollOffset().width); | 1843 EXPECT_EQ(94, webViewImpl->mainFrame()->getScrollOffset().width); |
| 1850 EXPECT_EQ(111, webViewImpl->mainFrame()->getScrollOffset().height); | 1844 EXPECT_EQ(111, webViewImpl->mainFrame()->getScrollOffset().height); |
| 1851 EXPECT_EQ(12, webViewImpl->visualViewportOffset().x); | 1845 EXPECT_EQ(12, webViewImpl->visualViewportOffset().x); |
| 1852 EXPECT_EQ(20, webViewImpl->visualViewportOffset().y); | 1846 EXPECT_EQ(20, webViewImpl->visualViewportOffset().y); |
| 1853 | 1847 |
| 1854 Document* document = webViewImpl->mainFrameImpl()->frame()->document(); | 1848 Document* document = webViewImpl->mainFrameImpl()->frame()->document(); |
| 1855 Element* element = document->body(); | 1849 Element* element = document->body(); |
| 1856 UserGestureIndicator gesture(DocumentUserGestureToken::create(document)); | 1850 UserGestureIndicator gesture(DocumentUserGestureToken::create(document)); |
| 1857 Fullscreen::requestFullscreen(*element); | 1851 Fullscreen::requestFullscreen(*element); |
| 1858 webViewImpl->didEnterFullscreen(); | 1852 webViewImpl->didEnterFullscreen(); |
| 1859 webViewImpl->beginFrame(WTF::monotonicallyIncreasingTime()); | |
| 1860 webViewImpl->updateAllLifecyclePhases(); | |
| 1861 | 1853 |
| 1862 // Page scale factor must be 1.0 during fullscreen for elements to be sized | 1854 // Page scale factor must be 1.0 during fullscreen for elements to be sized |
| 1863 // properly. | 1855 // properly. |
| 1864 EXPECT_EQ(1.0f, webViewImpl->pageScaleFactor()); | 1856 EXPECT_EQ(1.0f, webViewImpl->pageScaleFactor()); |
| 1865 | 1857 |
| 1866 // Make sure fullscreen nesting doesn't disrupt scroll/scale saving. | 1858 // Make sure fullscreen nesting doesn't disrupt scroll/scale saving. |
| 1867 Element* otherElement = document->getElementById("content"); | 1859 Element* otherElement = document->getElementById("content"); |
| 1868 Fullscreen::requestFullscreen(*otherElement); | 1860 Fullscreen::requestFullscreen(*otherElement); |
| 1869 | 1861 |
| 1870 // Confirm that exiting fullscreen restores the parameters. | 1862 // Confirm that exiting fullscreen restores the parameters. |
| 1871 webViewImpl->didExitFullscreen(); | 1863 webViewImpl->didExitFullscreen(); |
| 1872 webViewImpl->beginFrame(WTF::monotonicallyIncreasingTime()); | |
| 1873 webViewImpl->updateAllLifecyclePhases(); | 1864 webViewImpl->updateAllLifecyclePhases(); |
| 1874 | 1865 |
| 1875 EXPECT_EQ(2.0f, webViewImpl->pageScaleFactor()); | 1866 EXPECT_EQ(2.0f, webViewImpl->pageScaleFactor()); |
| 1876 EXPECT_EQ(94, webViewImpl->mainFrame()->getScrollOffset().width); | 1867 EXPECT_EQ(94, webViewImpl->mainFrame()->getScrollOffset().width); |
| 1877 EXPECT_EQ(111, webViewImpl->mainFrame()->getScrollOffset().height); | 1868 EXPECT_EQ(111, webViewImpl->mainFrame()->getScrollOffset().height); |
| 1878 EXPECT_EQ(12, webViewImpl->visualViewportOffset().x); | 1869 EXPECT_EQ(12, webViewImpl->visualViewportOffset().x); |
| 1879 EXPECT_EQ(20, webViewImpl->visualViewportOffset().y); | 1870 EXPECT_EQ(20, webViewImpl->visualViewportOffset().y); |
| 1880 } | 1871 } |
| 1881 | 1872 |
| 1882 class PrintWebViewClient : public FrameTestHelpers::TestWebViewClient { | 1873 class PrintWebViewClient : public FrameTestHelpers::TestWebViewClient { |
| (...skipping 2492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4375 EXPECT_EQ(expectedWidth, vwElement->offsetWidth()); | 4366 EXPECT_EQ(expectedWidth, vwElement->offsetWidth()); |
| 4376 EXPECT_EQ(expectedHeight, vwElement->offsetHeight()); | 4367 EXPECT_EQ(expectedHeight, vwElement->offsetHeight()); |
| 4377 | 4368 |
| 4378 webView->resize(WebSize(800, 600)); | 4369 webView->resize(WebSize(800, 600)); |
| 4379 frame->printEnd(); | 4370 frame->printEnd(); |
| 4380 | 4371 |
| 4381 EXPECT_EQ(800, vwElement->offsetWidth()); | 4372 EXPECT_EQ(800, vwElement->offsetWidth()); |
| 4382 } | 4373 } |
| 4383 | 4374 |
| 4384 } // namespace blink | 4375 } // namespace blink |
| OLD | NEW |