| 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 1311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1322 EXPECT_EQ(-1, info.composition_start); | 1322 EXPECT_EQ(-1, info.composition_start); |
| 1323 EXPECT_EQ(-1, info.composition_end); | 1323 EXPECT_EQ(-1, info.composition_end); |
| 1324 } | 1324 } |
| 1325 | 1325 |
| 1326 TEST_P(WebViewTest, FinishCompositionDoesNotRevealSelection) { | 1326 TEST_P(WebViewTest, FinishCompositionDoesNotRevealSelection) { |
| 1327 RegisterMockedHttpURLLoad("form_with_input.html"); | 1327 RegisterMockedHttpURLLoad("form_with_input.html"); |
| 1328 WebViewBase* web_view = | 1328 WebViewBase* web_view = |
| 1329 web_view_helper_.InitializeAndLoad(base_url_ + "form_with_input.html"); | 1329 web_view_helper_.InitializeAndLoad(base_url_ + "form_with_input.html"); |
| 1330 web_view->Resize(WebSize(800, 600)); | 1330 web_view->Resize(WebSize(800, 600)); |
| 1331 web_view->SetInitialFocus(false); | 1331 web_view->SetInitialFocus(false); |
| 1332 EXPECT_EQ(0, web_view->MainFrame()->GetScrollOffset().width); | 1332 EXPECT_EQ(0, web_view->MainFrameImpl()->GetScrollOffset().width); |
| 1333 EXPECT_EQ(0, web_view->MainFrame()->GetScrollOffset().height); | 1333 EXPECT_EQ(0, web_view->MainFrameImpl()->GetScrollOffset().height); |
| 1334 | 1334 |
| 1335 // Set up a composition from existing text that needs to be committed. | 1335 // Set up a composition from existing text that needs to be committed. |
| 1336 Vector<CompositionUnderline> empty_underlines; | 1336 Vector<CompositionUnderline> empty_underlines; |
| 1337 WebLocalFrameBase* frame = web_view->MainFrameImpl(); | 1337 WebLocalFrameBase* frame = web_view->MainFrameImpl(); |
| 1338 frame->GetFrame()->GetInputMethodController().SetCompositionFromExistingText( | 1338 frame->GetFrame()->GetInputMethodController().SetCompositionFromExistingText( |
| 1339 empty_underlines, 0, 3); | 1339 empty_underlines, 0, 3); |
| 1340 | 1340 |
| 1341 // Scroll the input field out of the viewport. | 1341 // Scroll the input field out of the viewport. |
| 1342 Element* element = static_cast<Element*>( | 1342 Element* element = static_cast<Element*>( |
| 1343 web_view->MainFrame()->GetDocument().GetElementById("btn")); | 1343 web_view->MainFrame()->GetDocument().GetElementById("btn")); |
| 1344 element->scrollIntoView(); | 1344 element->scrollIntoView(); |
| 1345 float offset_height = web_view->MainFrame()->GetScrollOffset().height; | 1345 float offset_height = web_view->MainFrameImpl()->GetScrollOffset().height; |
| 1346 EXPECT_EQ(0, web_view->MainFrame()->GetScrollOffset().width); | 1346 EXPECT_EQ(0, web_view->MainFrameImpl()->GetScrollOffset().width); |
| 1347 EXPECT_LT(0, offset_height); | 1347 EXPECT_LT(0, offset_height); |
| 1348 | 1348 |
| 1349 WebTextInputInfo info = frame->GetInputMethodController()->TextInputInfo(); | 1349 WebTextInputInfo info = frame->GetInputMethodController()->TextInputInfo(); |
| 1350 EXPECT_EQ("hello", std::string(info.value.Utf8().data())); | 1350 EXPECT_EQ("hello", std::string(info.value.Utf8().data())); |
| 1351 | 1351 |
| 1352 // Verify that the input field is not scrolled back into the viewport. | 1352 // Verify that the input field is not scrolled back into the viewport. |
| 1353 frame->FrameWidget() | 1353 frame->FrameWidget() |
| 1354 ->GetActiveWebInputMethodController() | 1354 ->GetActiveWebInputMethodController() |
| 1355 ->FinishComposingText(WebInputMethodController::kDoNotKeepSelection); | 1355 ->FinishComposingText(WebInputMethodController::kDoNotKeepSelection); |
| 1356 EXPECT_EQ(0, web_view->MainFrame()->GetScrollOffset().width); | 1356 EXPECT_EQ(0, web_view->MainFrameImpl()->GetScrollOffset().width); |
| 1357 EXPECT_EQ(offset_height, web_view->MainFrame()->GetScrollOffset().height); | 1357 EXPECT_EQ(offset_height, web_view->MainFrameImpl()->GetScrollOffset().height); |
| 1358 } | 1358 } |
| 1359 | 1359 |
| 1360 TEST_P(WebViewTest, InsertNewLinePlacementAfterFinishComposingText) { | 1360 TEST_P(WebViewTest, InsertNewLinePlacementAfterFinishComposingText) { |
| 1361 RegisterMockedHttpURLLoad("text_area_populated.html"); | 1361 RegisterMockedHttpURLLoad("text_area_populated.html"); |
| 1362 WebViewBase* web_view = web_view_helper_.InitializeAndLoad( | 1362 WebViewBase* web_view = web_view_helper_.InitializeAndLoad( |
| 1363 base_url_ + "text_area_populated.html"); | 1363 base_url_ + "text_area_populated.html"); |
| 1364 web_view->SetInitialFocus(false); | 1364 web_view->SetInitialFocus(false); |
| 1365 | 1365 |
| 1366 WebVector<WebCompositionUnderline> empty_underlines; | 1366 WebVector<WebCompositionUnderline> empty_underlines; |
| 1367 | 1367 |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1655 | 1655 |
| 1656 EXPECT_EQ(page_scale_expected, web_view_impl->PageScaleFactor()); | 1656 EXPECT_EQ(page_scale_expected, web_view_impl->PageScaleFactor()); |
| 1657 } | 1657 } |
| 1658 | 1658 |
| 1659 TEST_P(WebViewTest, HistoryResetScrollAndScaleState) { | 1659 TEST_P(WebViewTest, HistoryResetScrollAndScaleState) { |
| 1660 RegisterMockedHttpURLLoad("200-by-300.html"); | 1660 RegisterMockedHttpURLLoad("200-by-300.html"); |
| 1661 WebViewBase* web_view_impl = | 1661 WebViewBase* web_view_impl = |
| 1662 web_view_helper_.InitializeAndLoad(base_url_ + "200-by-300.html"); | 1662 web_view_helper_.InitializeAndLoad(base_url_ + "200-by-300.html"); |
| 1663 web_view_impl->Resize(WebSize(100, 150)); | 1663 web_view_impl->Resize(WebSize(100, 150)); |
| 1664 web_view_impl->UpdateAllLifecyclePhases(); | 1664 web_view_impl->UpdateAllLifecyclePhases(); |
| 1665 EXPECT_EQ(0, web_view_impl->MainFrame()->GetScrollOffset().width); | 1665 EXPECT_EQ(0, web_view_impl->MainFrameImpl()->GetScrollOffset().width); |
| 1666 EXPECT_EQ(0, web_view_impl->MainFrame()->GetScrollOffset().height); | 1666 EXPECT_EQ(0, web_view_impl->MainFrameImpl()->GetScrollOffset().height); |
| 1667 | 1667 |
| 1668 // Make the page scale and scroll with the given paremeters. | 1668 // Make the page scale and scroll with the given paremeters. |
| 1669 web_view_impl->SetPageScaleFactor(2.0f); | 1669 web_view_impl->SetPageScaleFactor(2.0f); |
| 1670 web_view_impl->MainFrame()->SetScrollOffset(WebSize(94, 111)); | 1670 web_view_impl->MainFrameImpl()->SetScrollOffset(WebSize(94, 111)); |
| 1671 EXPECT_EQ(2.0f, web_view_impl->PageScaleFactor()); | 1671 EXPECT_EQ(2.0f, web_view_impl->PageScaleFactor()); |
| 1672 EXPECT_EQ(94, web_view_impl->MainFrame()->GetScrollOffset().width); | 1672 EXPECT_EQ(94, web_view_impl->MainFrameImpl()->GetScrollOffset().width); |
| 1673 EXPECT_EQ(111, web_view_impl->MainFrame()->GetScrollOffset().height); | 1673 EXPECT_EQ(111, web_view_impl->MainFrameImpl()->GetScrollOffset().height); |
| 1674 LocalFrame* main_frame_local = | 1674 LocalFrame* main_frame_local = |
| 1675 ToLocalFrame(web_view_impl->GetPage()->MainFrame()); | 1675 ToLocalFrame(web_view_impl->GetPage()->MainFrame()); |
| 1676 main_frame_local->Loader().SaveScrollState(); | 1676 main_frame_local->Loader().SaveScrollState(); |
| 1677 EXPECT_EQ(2.0f, main_frame_local->Loader() | 1677 EXPECT_EQ(2.0f, main_frame_local->Loader() |
| 1678 .GetDocumentLoader() | 1678 .GetDocumentLoader() |
| 1679 ->GetHistoryItem() | 1679 ->GetHistoryItem() |
| 1680 ->PageScaleFactor()); | 1680 ->PageScaleFactor()); |
| 1681 EXPECT_EQ(94, main_frame_local->Loader() | 1681 EXPECT_EQ(94, main_frame_local->Loader() |
| 1682 .GetDocumentLoader() | 1682 .GetDocumentLoader() |
| 1683 ->GetHistoryItem() | 1683 ->GetHistoryItem() |
| 1684 ->GetScrollOffset() | 1684 ->GetScrollOffset() |
| 1685 .Width()); | 1685 .Width()); |
| 1686 EXPECT_EQ(111, main_frame_local->Loader() | 1686 EXPECT_EQ(111, main_frame_local->Loader() |
| 1687 .GetDocumentLoader() | 1687 .GetDocumentLoader() |
| 1688 ->GetHistoryItem() | 1688 ->GetHistoryItem() |
| 1689 ->GetScrollOffset() | 1689 ->GetScrollOffset() |
| 1690 .Height()); | 1690 .Height()); |
| 1691 | 1691 |
| 1692 // Confirm that resetting the page state resets the saved scroll position. | 1692 // Confirm that resetting the page state resets the saved scroll position. |
| 1693 web_view_impl->ResetScrollAndScaleState(); | 1693 web_view_impl->ResetScrollAndScaleState(); |
| 1694 EXPECT_EQ(1.0f, web_view_impl->PageScaleFactor()); | 1694 EXPECT_EQ(1.0f, web_view_impl->PageScaleFactor()); |
| 1695 EXPECT_EQ(0, web_view_impl->MainFrame()->GetScrollOffset().width); | 1695 EXPECT_EQ(0, web_view_impl->MainFrameImpl()->GetScrollOffset().width); |
| 1696 EXPECT_EQ(0, web_view_impl->MainFrame()->GetScrollOffset().height); | 1696 EXPECT_EQ(0, web_view_impl->MainFrameImpl()->GetScrollOffset().height); |
| 1697 EXPECT_EQ(1.0f, main_frame_local->Loader() | 1697 EXPECT_EQ(1.0f, main_frame_local->Loader() |
| 1698 .GetDocumentLoader() | 1698 .GetDocumentLoader() |
| 1699 ->GetHistoryItem() | 1699 ->GetHistoryItem() |
| 1700 ->PageScaleFactor()); | 1700 ->PageScaleFactor()); |
| 1701 EXPECT_EQ(0, main_frame_local->Loader() | 1701 EXPECT_EQ(0, main_frame_local->Loader() |
| 1702 .GetDocumentLoader() | 1702 .GetDocumentLoader() |
| 1703 ->GetHistoryItem() | 1703 ->GetHistoryItem() |
| 1704 ->GetScrollOffset() | 1704 ->GetScrollOffset() |
| 1705 .Width()); | 1705 .Width()); |
| 1706 EXPECT_EQ(0, main_frame_local->Loader() | 1706 EXPECT_EQ(0, main_frame_local->Loader() |
| 1707 .GetDocumentLoader() | 1707 .GetDocumentLoader() |
| 1708 ->GetHistoryItem() | 1708 ->GetHistoryItem() |
| 1709 ->GetScrollOffset() | 1709 ->GetScrollOffset() |
| 1710 .Height()); | 1710 .Height()); |
| 1711 } | 1711 } |
| 1712 | 1712 |
| 1713 TEST_P(WebViewTest, BackForwardRestoreScroll) { | 1713 TEST_P(WebViewTest, BackForwardRestoreScroll) { |
| 1714 RegisterMockedHttpURLLoad("back_forward_restore_scroll.html"); | 1714 RegisterMockedHttpURLLoad("back_forward_restore_scroll.html"); |
| 1715 WebViewBase* web_view_impl = web_view_helper_.InitializeAndLoad( | 1715 WebViewBase* web_view_impl = web_view_helper_.InitializeAndLoad( |
| 1716 base_url_ + "back_forward_restore_scroll.html"); | 1716 base_url_ + "back_forward_restore_scroll.html"); |
| 1717 web_view_impl->Resize(WebSize(640, 480)); | 1717 web_view_impl->Resize(WebSize(640, 480)); |
| 1718 web_view_impl->UpdateAllLifecyclePhases(); | 1718 web_view_impl->UpdateAllLifecyclePhases(); |
| 1719 | 1719 |
| 1720 // Emulate a user scroll | 1720 // Emulate a user scroll |
| 1721 web_view_impl->MainFrame()->SetScrollOffset(WebSize(0, 900)); | 1721 web_view_impl->MainFrameImpl()->SetScrollOffset(WebSize(0, 900)); |
| 1722 LocalFrame* main_frame_local = | 1722 LocalFrame* main_frame_local = |
| 1723 ToLocalFrame(web_view_impl->GetPage()->MainFrame()); | 1723 ToLocalFrame(web_view_impl->GetPage()->MainFrame()); |
| 1724 Persistent<HistoryItem> item1 = | 1724 Persistent<HistoryItem> item1 = |
| 1725 main_frame_local->Loader().GetDocumentLoader()->GetHistoryItem(); | 1725 main_frame_local->Loader().GetDocumentLoader()->GetHistoryItem(); |
| 1726 | 1726 |
| 1727 // Click an anchor | 1727 // Click an anchor |
| 1728 main_frame_local->Loader().Load(FrameLoadRequest( | 1728 main_frame_local->Loader().Load(FrameLoadRequest( |
| 1729 main_frame_local->GetDocument(), | 1729 main_frame_local->GetDocument(), |
| 1730 ResourceRequest(main_frame_local->GetDocument()->CompleteURL("#a")))); | 1730 ResourceRequest(main_frame_local->GetDocument()->CompleteURL("#a")))); |
| 1731 Persistent<HistoryItem> item2 = | 1731 Persistent<HistoryItem> item2 = |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1755 // Go back, then forward. The scroll position should be properly set on the | 1755 // Go back, then forward. The scroll position should be properly set on the |
| 1756 // forward navigation. | 1756 // forward navigation. |
| 1757 main_frame_local->Loader().Load( | 1757 main_frame_local->Loader().Load( |
| 1758 FrameLoadRequest(nullptr, item1->GenerateResourceRequest( | 1758 FrameLoadRequest(nullptr, item1->GenerateResourceRequest( |
| 1759 WebCachePolicy::kUseProtocolCachePolicy)), | 1759 WebCachePolicy::kUseProtocolCachePolicy)), |
| 1760 kFrameLoadTypeBackForward, item1.Get(), kHistorySameDocumentLoad); | 1760 kFrameLoadTypeBackForward, item1.Get(), kHistorySameDocumentLoad); |
| 1761 main_frame_local->Loader().Load( | 1761 main_frame_local->Loader().Load( |
| 1762 FrameLoadRequest(nullptr, item3->GenerateResourceRequest( | 1762 FrameLoadRequest(nullptr, item3->GenerateResourceRequest( |
| 1763 WebCachePolicy::kUseProtocolCachePolicy)), | 1763 WebCachePolicy::kUseProtocolCachePolicy)), |
| 1764 kFrameLoadTypeBackForward, item3.Get(), kHistorySameDocumentLoad); | 1764 kFrameLoadTypeBackForward, item3.Get(), kHistorySameDocumentLoad); |
| 1765 EXPECT_EQ(0, web_view_impl->MainFrame()->GetScrollOffset().width); | 1765 EXPECT_EQ(0, web_view_impl->MainFrameImpl()->GetScrollOffset().width); |
| 1766 EXPECT_GT(web_view_impl->MainFrame()->GetScrollOffset().height, 2000); | 1766 EXPECT_GT(web_view_impl->MainFrameImpl()->GetScrollOffset().height, 2000); |
| 1767 } | 1767 } |
| 1768 | 1768 |
| 1769 // Tests that we restore scroll and scale *after* the fullscreen styles are | 1769 // Tests that we restore scroll and scale *after* the fullscreen styles are |
| 1770 // removed and the page is laid out. http://crbug.com/625683. | 1770 // removed and the page is laid out. http://crbug.com/625683. |
| 1771 TEST_P(WebViewTest, FullscreenResetScrollAndScaleFullscreenStyles) { | 1771 TEST_P(WebViewTest, FullscreenResetScrollAndScaleFullscreenStyles) { |
| 1772 RegisterMockedHttpURLLoad("fullscreen_style.html"); | 1772 RegisterMockedHttpURLLoad("fullscreen_style.html"); |
| 1773 WebViewBase* web_view_impl = | 1773 WebViewBase* web_view_impl = |
| 1774 web_view_helper_.InitializeAndLoad(base_url_ + "fullscreen_style.html"); | 1774 web_view_helper_.InitializeAndLoad(base_url_ + "fullscreen_style.html"); |
| 1775 web_view_impl->Resize(WebSize(800, 600)); | 1775 web_view_impl->Resize(WebSize(800, 600)); |
| 1776 web_view_impl->UpdateAllLifecyclePhases(); | 1776 web_view_impl->UpdateAllLifecyclePhases(); |
| 1777 | 1777 |
| 1778 // Scroll the page down. | 1778 // Scroll the page down. |
| 1779 web_view_impl->MainFrame()->SetScrollOffset(WebSize(0, 2000)); | 1779 web_view_impl->MainFrameImpl()->SetScrollOffset(WebSize(0, 2000)); |
| 1780 ASSERT_EQ(2000, web_view_impl->MainFrame()->GetScrollOffset().height); | 1780 ASSERT_EQ(2000, web_view_impl->MainFrameImpl()->GetScrollOffset().height); |
| 1781 | 1781 |
| 1782 // Enter fullscreen. | 1782 // Enter fullscreen. |
| 1783 Document* document = | 1783 Document* document = |
| 1784 web_view_impl->MainFrameImpl()->GetFrame()->GetDocument(); | 1784 web_view_impl->MainFrameImpl()->GetFrame()->GetDocument(); |
| 1785 Element* element = document->getElementById("fullscreenElement"); | 1785 Element* element = document->getElementById("fullscreenElement"); |
| 1786 UserGestureIndicator gesture(UserGestureToken::Create(document)); | 1786 UserGestureIndicator gesture(UserGestureToken::Create(document)); |
| 1787 Fullscreen::RequestFullscreen(*element); | 1787 Fullscreen::RequestFullscreen(*element); |
| 1788 web_view_impl->DidEnterFullscreen(); | 1788 web_view_impl->DidEnterFullscreen(); |
| 1789 web_view_impl->UpdateAllLifecyclePhases(); | 1789 web_view_impl->UpdateAllLifecyclePhases(); |
| 1790 | 1790 |
| 1791 // Sanity-check. There should be no scrolling possible. | 1791 // Sanity-check. There should be no scrolling possible. |
| 1792 ASSERT_EQ(0, web_view_impl->MainFrame()->GetScrollOffset().height); | 1792 ASSERT_EQ(0, web_view_impl->MainFrameImpl()->GetScrollOffset().height); |
| 1793 ASSERT_EQ(0, web_view_impl->MainFrameImpl() | 1793 ASSERT_EQ(0, web_view_impl->MainFrameImpl() |
| 1794 ->GetFrameView() | 1794 ->GetFrameView() |
| 1795 ->MaximumScrollOffset() | 1795 ->MaximumScrollOffset() |
| 1796 .Height()); | 1796 .Height()); |
| 1797 | 1797 |
| 1798 // Confirm that after exiting and doing a layout, the scroll and scale | 1798 // Confirm that after exiting and doing a layout, the scroll and scale |
| 1799 // parameters are reset. The page sets display: none on overflowing elements | 1799 // parameters are reset. The page sets display: none on overflowing elements |
| 1800 // while in fullscreen so if we try to restore before the style and layout | 1800 // while in fullscreen so if we try to restore before the style and layout |
| 1801 // is applied the offsets will be clamped. | 1801 // is applied the offsets will be clamped. |
| 1802 web_view_impl->DidExitFullscreen(); | 1802 web_view_impl->DidExitFullscreen(); |
| 1803 EXPECT_TRUE(web_view_impl->MainFrameImpl()->GetFrameView()->NeedsLayout()); | 1803 EXPECT_TRUE(web_view_impl->MainFrameImpl()->GetFrameView()->NeedsLayout()); |
| 1804 web_view_impl->UpdateAllLifecyclePhases(); | 1804 web_view_impl->UpdateAllLifecyclePhases(); |
| 1805 | 1805 |
| 1806 EXPECT_EQ(2000, web_view_impl->MainFrame()->GetScrollOffset().height); | 1806 EXPECT_EQ(2000, web_view_impl->MainFrameImpl()->GetScrollOffset().height); |
| 1807 } | 1807 } |
| 1808 | 1808 |
| 1809 // Tests that exiting and immediately reentering fullscreen doesn't cause the | 1809 // Tests that exiting and immediately reentering fullscreen doesn't cause the |
| 1810 // scroll and scale restoration to occur when we enter fullscreen again. | 1810 // scroll and scale restoration to occur when we enter fullscreen again. |
| 1811 TEST_P(WebViewTest, FullscreenResetScrollAndScaleExitAndReenter) { | 1811 TEST_P(WebViewTest, FullscreenResetScrollAndScaleExitAndReenter) { |
| 1812 RegisterMockedHttpURLLoad("fullscreen_style.html"); | 1812 RegisterMockedHttpURLLoad("fullscreen_style.html"); |
| 1813 WebViewBase* web_view_impl = | 1813 WebViewBase* web_view_impl = |
| 1814 web_view_helper_.InitializeAndLoad(base_url_ + "fullscreen_style.html"); | 1814 web_view_helper_.InitializeAndLoad(base_url_ + "fullscreen_style.html"); |
| 1815 web_view_impl->Resize(WebSize(800, 600)); | 1815 web_view_impl->Resize(WebSize(800, 600)); |
| 1816 web_view_impl->UpdateAllLifecyclePhases(); | 1816 web_view_impl->UpdateAllLifecyclePhases(); |
| 1817 | 1817 |
| 1818 // Scroll the page down. | 1818 // Scroll the page down. |
| 1819 web_view_impl->MainFrame()->SetScrollOffset(WebSize(0, 2000)); | 1819 web_view_impl->MainFrameImpl()->SetScrollOffset(WebSize(0, 2000)); |
| 1820 ASSERT_EQ(2000, web_view_impl->MainFrame()->GetScrollOffset().height); | 1820 ASSERT_EQ(2000, web_view_impl->MainFrameImpl()->GetScrollOffset().height); |
| 1821 | 1821 |
| 1822 // Enter fullscreen. | 1822 // Enter fullscreen. |
| 1823 Document* document = | 1823 Document* document = |
| 1824 web_view_impl->MainFrameImpl()->GetFrame()->GetDocument(); | 1824 web_view_impl->MainFrameImpl()->GetFrame()->GetDocument(); |
| 1825 Element* element = document->getElementById("fullscreenElement"); | 1825 Element* element = document->getElementById("fullscreenElement"); |
| 1826 UserGestureIndicator gesture(UserGestureToken::Create(document)); | 1826 UserGestureIndicator gesture(UserGestureToken::Create(document)); |
| 1827 Fullscreen::RequestFullscreen(*element); | 1827 Fullscreen::RequestFullscreen(*element); |
| 1828 web_view_impl->DidEnterFullscreen(); | 1828 web_view_impl->DidEnterFullscreen(); |
| 1829 web_view_impl->UpdateAllLifecyclePhases(); | 1829 web_view_impl->UpdateAllLifecyclePhases(); |
| 1830 | 1830 |
| 1831 // Sanity-check. There should be no scrolling possible. | 1831 // Sanity-check. There should be no scrolling possible. |
| 1832 ASSERT_EQ(0, web_view_impl->MainFrame()->GetScrollOffset().height); | 1832 ASSERT_EQ(0, web_view_impl->MainFrameImpl()->GetScrollOffset().height); |
| 1833 ASSERT_EQ(0, web_view_impl->MainFrameImpl() | 1833 ASSERT_EQ(0, web_view_impl->MainFrameImpl() |
| 1834 ->GetFrameView() | 1834 ->GetFrameView() |
| 1835 ->MaximumScrollOffset() | 1835 ->MaximumScrollOffset() |
| 1836 .Height()); | 1836 .Height()); |
| 1837 | 1837 |
| 1838 // Exit and, without performing a layout, reenter fullscreen again. We | 1838 // Exit and, without performing a layout, reenter fullscreen again. We |
| 1839 // shouldn't try to restore the scroll and scale values when we layout to | 1839 // shouldn't try to restore the scroll and scale values when we layout to |
| 1840 // enter fullscreen. | 1840 // enter fullscreen. |
| 1841 web_view_impl->DidExitFullscreen(); | 1841 web_view_impl->DidExitFullscreen(); |
| 1842 Fullscreen::RequestFullscreen(*element); | 1842 Fullscreen::RequestFullscreen(*element); |
| 1843 web_view_impl->DidEnterFullscreen(); | 1843 web_view_impl->DidEnterFullscreen(); |
| 1844 web_view_impl->UpdateAllLifecyclePhases(); | 1844 web_view_impl->UpdateAllLifecyclePhases(); |
| 1845 | 1845 |
| 1846 // Sanity-check. There should be no scrolling possible. | 1846 // Sanity-check. There should be no scrolling possible. |
| 1847 ASSERT_EQ(0, web_view_impl->MainFrame()->GetScrollOffset().height); | 1847 ASSERT_EQ(0, web_view_impl->MainFrameImpl()->GetScrollOffset().height); |
| 1848 ASSERT_EQ(0, web_view_impl->MainFrameImpl() | 1848 ASSERT_EQ(0, web_view_impl->MainFrameImpl() |
| 1849 ->GetFrameView() | 1849 ->GetFrameView() |
| 1850 ->MaximumScrollOffset() | 1850 ->MaximumScrollOffset() |
| 1851 .Height()); | 1851 .Height()); |
| 1852 | 1852 |
| 1853 // When we exit now, we should restore the original scroll value. | 1853 // When we exit now, we should restore the original scroll value. |
| 1854 web_view_impl->DidExitFullscreen(); | 1854 web_view_impl->DidExitFullscreen(); |
| 1855 web_view_impl->UpdateAllLifecyclePhases(); | 1855 web_view_impl->UpdateAllLifecyclePhases(); |
| 1856 | 1856 |
| 1857 EXPECT_EQ(2000, web_view_impl->MainFrame()->GetScrollOffset().height); | 1857 EXPECT_EQ(2000, web_view_impl->MainFrameImpl()->GetScrollOffset().height); |
| 1858 } | 1858 } |
| 1859 | 1859 |
| 1860 TEST_P(WebViewTest, EnterFullscreenResetScrollAndScaleState) { | 1860 TEST_P(WebViewTest, EnterFullscreenResetScrollAndScaleState) { |
| 1861 RegisterMockedHttpURLLoad("200-by-300.html"); | 1861 RegisterMockedHttpURLLoad("200-by-300.html"); |
| 1862 WebViewBase* web_view_impl = | 1862 WebViewBase* web_view_impl = |
| 1863 web_view_helper_.InitializeAndLoad(base_url_ + "200-by-300.html"); | 1863 web_view_helper_.InitializeAndLoad(base_url_ + "200-by-300.html"); |
| 1864 web_view_impl->Resize(WebSize(100, 150)); | 1864 web_view_impl->Resize(WebSize(100, 150)); |
| 1865 web_view_impl->UpdateAllLifecyclePhases(); | 1865 web_view_impl->UpdateAllLifecyclePhases(); |
| 1866 EXPECT_EQ(0, web_view_impl->MainFrame()->GetScrollOffset().width); | 1866 EXPECT_EQ(0, web_view_impl->MainFrameImpl()->GetScrollOffset().width); |
| 1867 EXPECT_EQ(0, web_view_impl->MainFrame()->GetScrollOffset().height); | 1867 EXPECT_EQ(0, web_view_impl->MainFrameImpl()->GetScrollOffset().height); |
| 1868 | 1868 |
| 1869 // Make the page scale and scroll with the given paremeters. | 1869 // Make the page scale and scroll with the given paremeters. |
| 1870 web_view_impl->SetPageScaleFactor(2.0f); | 1870 web_view_impl->SetPageScaleFactor(2.0f); |
| 1871 web_view_impl->MainFrame()->SetScrollOffset(WebSize(94, 111)); | 1871 web_view_impl->MainFrameImpl()->SetScrollOffset(WebSize(94, 111)); |
| 1872 web_view_impl->SetVisualViewportOffset(WebFloatPoint(12, 20)); | 1872 web_view_impl->SetVisualViewportOffset(WebFloatPoint(12, 20)); |
| 1873 EXPECT_EQ(2.0f, web_view_impl->PageScaleFactor()); | 1873 EXPECT_EQ(2.0f, web_view_impl->PageScaleFactor()); |
| 1874 EXPECT_EQ(94, web_view_impl->MainFrame()->GetScrollOffset().width); | 1874 EXPECT_EQ(94, web_view_impl->MainFrameImpl()->GetScrollOffset().width); |
| 1875 EXPECT_EQ(111, web_view_impl->MainFrame()->GetScrollOffset().height); | 1875 EXPECT_EQ(111, web_view_impl->MainFrameImpl()->GetScrollOffset().height); |
| 1876 EXPECT_EQ(12, web_view_impl->VisualViewportOffset().x); | 1876 EXPECT_EQ(12, web_view_impl->VisualViewportOffset().x); |
| 1877 EXPECT_EQ(20, web_view_impl->VisualViewportOffset().y); | 1877 EXPECT_EQ(20, web_view_impl->VisualViewportOffset().y); |
| 1878 | 1878 |
| 1879 Document* document = | 1879 Document* document = |
| 1880 web_view_impl->MainFrameImpl()->GetFrame()->GetDocument(); | 1880 web_view_impl->MainFrameImpl()->GetFrame()->GetDocument(); |
| 1881 Element* element = document->body(); | 1881 Element* element = document->body(); |
| 1882 UserGestureIndicator gesture(UserGestureToken::Create(document)); | 1882 UserGestureIndicator gesture(UserGestureToken::Create(document)); |
| 1883 Fullscreen::RequestFullscreen(*element); | 1883 Fullscreen::RequestFullscreen(*element); |
| 1884 web_view_impl->DidEnterFullscreen(); | 1884 web_view_impl->DidEnterFullscreen(); |
| 1885 | 1885 |
| 1886 // Page scale factor must be 1.0 during fullscreen for elements to be sized | 1886 // Page scale factor must be 1.0 during fullscreen for elements to be sized |
| 1887 // properly. | 1887 // properly. |
| 1888 EXPECT_EQ(1.0f, web_view_impl->PageScaleFactor()); | 1888 EXPECT_EQ(1.0f, web_view_impl->PageScaleFactor()); |
| 1889 | 1889 |
| 1890 // Make sure fullscreen nesting doesn't disrupt scroll/scale saving. | 1890 // Make sure fullscreen nesting doesn't disrupt scroll/scale saving. |
| 1891 Element* other_element = document->getElementById("content"); | 1891 Element* other_element = document->getElementById("content"); |
| 1892 Fullscreen::RequestFullscreen(*other_element); | 1892 Fullscreen::RequestFullscreen(*other_element); |
| 1893 | 1893 |
| 1894 // Confirm that exiting fullscreen restores the parameters. | 1894 // Confirm that exiting fullscreen restores the parameters. |
| 1895 web_view_impl->DidExitFullscreen(); | 1895 web_view_impl->DidExitFullscreen(); |
| 1896 web_view_impl->UpdateAllLifecyclePhases(); | 1896 web_view_impl->UpdateAllLifecyclePhases(); |
| 1897 | 1897 |
| 1898 EXPECT_EQ(2.0f, web_view_impl->PageScaleFactor()); | 1898 EXPECT_EQ(2.0f, web_view_impl->PageScaleFactor()); |
| 1899 EXPECT_EQ(94, web_view_impl->MainFrame()->GetScrollOffset().width); | 1899 EXPECT_EQ(94, web_view_impl->MainFrameImpl()->GetScrollOffset().width); |
| 1900 EXPECT_EQ(111, web_view_impl->MainFrame()->GetScrollOffset().height); | 1900 EXPECT_EQ(111, web_view_impl->MainFrameImpl()->GetScrollOffset().height); |
| 1901 EXPECT_EQ(12, web_view_impl->VisualViewportOffset().x); | 1901 EXPECT_EQ(12, web_view_impl->VisualViewportOffset().x); |
| 1902 EXPECT_EQ(20, web_view_impl->VisualViewportOffset().y); | 1902 EXPECT_EQ(20, web_view_impl->VisualViewportOffset().y); |
| 1903 } | 1903 } |
| 1904 | 1904 |
| 1905 class PrintWebViewClient : public FrameTestHelpers::TestWebViewClient { | 1905 class PrintWebViewClient : public FrameTestHelpers::TestWebViewClient { |
| 1906 public: | 1906 public: |
| 1907 PrintWebViewClient() : print_called_(false) {} | 1907 PrintWebViewClient() : print_called_(false) {} |
| 1908 | 1908 |
| 1909 // WebViewClient methods | 1909 // WebViewClient methods |
| 1910 void PrintPage(WebLocalFrame*) override { print_called_ = true; } | 1910 void PrintPage(WebLocalFrame*) override { print_called_ = true; } |
| (...skipping 2426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4337 EXPECT_FALSE(frame_view->VisualViewportSuppliesScrollbars()); | 4337 EXPECT_FALSE(frame_view->VisualViewportSuppliesScrollbars()); |
| 4338 if (RuntimeEnabledFeatures::RootLayerScrollingEnabled()) { | 4338 if (RuntimeEnabledFeatures::RootLayerScrollingEnabled()) { |
| 4339 EXPECT_NE(nullptr, | 4339 EXPECT_NE(nullptr, |
| 4340 frame_view->LayoutViewportScrollableArea()->VerticalScrollbar()); | 4340 frame_view->LayoutViewportScrollableArea()->VerticalScrollbar()); |
| 4341 } else { | 4341 } else { |
| 4342 EXPECT_NE(nullptr, frame_view->VerticalScrollbar()); | 4342 EXPECT_NE(nullptr, frame_view->VerticalScrollbar()); |
| 4343 } | 4343 } |
| 4344 } | 4344 } |
| 4345 | 4345 |
| 4346 } // namespace blink | 4346 } // namespace blink |
| OLD | NEW |