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