Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: third_party/WebKit/Source/web/tests/VisualViewportTest.cpp

Issue 2710983003: Move HistoryItem handling to DocumentLoader (Closed)
Patch Set: Experiment to fix DCHECKing tests Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/frame/VisualViewport.h" 5 #include "core/frame/VisualViewport.h"
6 6
7 #include "core/dom/Document.h" 7 #include "core/dom/Document.h"
8 #include "core/frame/BrowserControls.h" 8 #include "core/frame/BrowserControls.h"
9 #include "core/frame/FrameHost.h" 9 #include "core/frame/FrameHost.h"
10 #include "core/frame/FrameView.h" 10 #include "core/frame/FrameView.h"
11 #include "core/frame/LocalFrame.h" 11 #include "core/frame/LocalFrame.h"
12 #include "core/html/HTMLBodyElement.h" 12 #include "core/html/HTMLBodyElement.h"
13 #include "core/html/HTMLElement.h" 13 #include "core/html/HTMLElement.h"
14 #include "core/input/EventHandler.h" 14 #include "core/input/EventHandler.h"
15 #include "core/layout/LayoutObject.h" 15 #include "core/layout/LayoutObject.h"
16 #include "core/layout/api/LayoutViewItem.h" 16 #include "core/layout/api/LayoutViewItem.h"
17 #include "core/layout/compositing/PaintLayerCompositor.h" 17 #include "core/layout/compositing/PaintLayerCompositor.h"
18 #include "core/loader/DocumentLoader.h"
18 #include "core/page/Page.h" 19 #include "core/page/Page.h"
19 #include "core/paint/PaintLayer.h" 20 #include "core/paint/PaintLayer.h"
20 #include "platform/geometry/DoublePoint.h" 21 #include "platform/geometry/DoublePoint.h"
21 #include "platform/geometry/DoubleRect.h" 22 #include "platform/geometry/DoubleRect.h"
22 #include "platform/graphics/CompositorElementId.h" 23 #include "platform/graphics/CompositorElementId.h"
23 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" 24 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h"
24 #include "platform/testing/URLTestHelpers.h" 25 #include "platform/testing/URLTestHelpers.h"
25 #include "platform/testing/UnitTestHelpers.h" 26 #include "platform/testing/UnitTestHelpers.h"
26 #include "public/platform/Platform.h" 27 #include "public/platform/Platform.h"
27 #include "public/platform/WebCachePolicy.h" 28 #include "public/platform/WebCachePolicy.h"
(...skipping 842 matching lines...) Expand 10 before | Expand all | Expand 10 after
870 initializeWithDesktopSettings(); 871 initializeWithDesktopSettings();
871 webViewImpl()->resize(IntSize(200, 300)); 872 webViewImpl()->resize(IntSize(200, 300));
872 webViewImpl()->updateAllLifecyclePhases(); 873 webViewImpl()->updateAllLifecyclePhases();
873 874
874 registerMockedHttpURLLoad("200-by-300.html"); 875 registerMockedHttpURLLoad("200-by-300.html");
875 navigateTo(m_baseURL + "200-by-300.html"); 876 navigateTo(m_baseURL + "200-by-300.html");
876 877
877 EXPECT_SIZE_EQ(ScrollOffset(0, 0), 878 EXPECT_SIZE_EQ(ScrollOffset(0, 0),
878 toLocalFrame(webViewImpl()->page()->mainFrame()) 879 toLocalFrame(webViewImpl()->page()->mainFrame())
879 ->loader() 880 ->loader()
880 .currentItem() 881 .documentLoader()
882 ->historyItem()
881 ->visualViewportScrollOffset()); 883 ->visualViewportScrollOffset());
882 884
883 VisualViewport& visualViewport = frame()->page()->visualViewport(); 885 VisualViewport& visualViewport = frame()->page()->visualViewport();
884 visualViewport.setScale(2); 886 visualViewport.setScale(2);
885 887
886 EXPECT_EQ(2, toLocalFrame(webViewImpl()->page()->mainFrame()) 888 EXPECT_EQ(2, toLocalFrame(webViewImpl()->page()->mainFrame())
887 ->loader() 889 ->loader()
888 .currentItem() 890 .documentLoader()
891 ->historyItem()
889 ->pageScaleFactor()); 892 ->pageScaleFactor());
890 893
891 visualViewport.setLocation(FloatPoint(10, 20)); 894 visualViewport.setLocation(FloatPoint(10, 20));
892 895
893 EXPECT_SIZE_EQ(ScrollOffset(10, 20), 896 EXPECT_SIZE_EQ(ScrollOffset(10, 20),
894 toLocalFrame(webViewImpl()->page()->mainFrame()) 897 toLocalFrame(webViewImpl()->page()->mainFrame())
895 ->loader() 898 ->loader()
896 .currentItem() 899 .documentLoader()
900 ->historyItem()
897 ->visualViewportScrollOffset()); 901 ->visualViewportScrollOffset());
898 } 902 }
899 903
900 // Test restoring a HistoryItem properly restores the visual viewport's state. 904 // Test restoring a HistoryItem properly restores the visual viewport's state.
901 TEST_P(VisualViewportTest, TestRestoredFromHistoryItem) { 905 TEST_P(VisualViewportTest, TestRestoredFromHistoryItem) {
902 initializeWithDesktopSettings(); 906 initializeWithDesktopSettings();
903 webViewImpl()->resize(IntSize(200, 300)); 907 webViewImpl()->resize(IntSize(200, 300));
904 908
905 registerMockedHttpURLLoad("200-by-300.html"); 909 registerMockedHttpURLLoad("200-by-300.html");
906 910
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
969 FrameView* frameView = webViewImpl()->mainFrameImpl()->frameView(); 973 FrameView* frameView = webViewImpl()->mainFrameImpl()->frameView();
970 frameView->layoutViewportScrollableArea()->setScrollOffset( 974 frameView->layoutViewportScrollableArea()->setScrollOffset(
971 ScrollOffset(0, 1000), ProgrammaticScroll); 975 ScrollOffset(0, 1000), ProgrammaticScroll);
972 976
973 EXPECT_SIZE_EQ(IntSize(1000, 1000), frameView->frameRect().size()); 977 EXPECT_SIZE_EQ(IntSize(1000, 1000), frameView->frameRect().size());
974 978
975 VisualViewport& visualViewport = frame()->page()->visualViewport(); 979 VisualViewport& visualViewport = frame()->page()->visualViewport();
976 visualViewport.setScale(2); 980 visualViewport.setScale(2);
977 visualViewport.setLocation(FloatPoint(350, 350)); 981 visualViewport.setLocation(FloatPoint(350, 350));
978 982
979 Persistent<HistoryItem> firstItem = 983 Persistent<HistoryItem> firstItem = webViewImpl()
980 webViewImpl()->mainFrameImpl()->frame()->loader().currentItem(); 984 ->mainFrameImpl()
985 ->frame()
986 ->loader()
987 .documentLoader()
988 ->historyItem();
981 EXPECT_SIZE_EQ(ScrollOffset(0, 1000), firstItem->getScrollOffset()); 989 EXPECT_SIZE_EQ(ScrollOffset(0, 1000), firstItem->getScrollOffset());
982 990
983 // Now navigate to a page which causes a smaller frameView. Make sure that 991 // Now navigate to a page which causes a smaller frameView. Make sure that
984 // navigating doesn't cause the history item to set a new scroll offset 992 // navigating doesn't cause the history item to set a new scroll offset
985 // before the item was replaced. 993 // before the item was replaced.
986 navigateTo("about:blank"); 994 navigateTo("about:blank");
987 frameView = webViewImpl()->mainFrameImpl()->frameView(); 995 frameView = webViewImpl()->mainFrameImpl()->frameView();
988 996
989 EXPECT_NE(firstItem, 997 EXPECT_NE(firstItem, webViewImpl()
990 webViewImpl()->mainFrameImpl()->frame()->loader().currentItem()); 998 ->mainFrameImpl()
999 ->frame()
1000 ->loader()
1001 .documentLoader()
1002 ->historyItem());
991 EXPECT_LT(frameView->frameRect().size().width(), 1000); 1003 EXPECT_LT(frameView->frameRect().size().width(), 1000);
992 EXPECT_SIZE_EQ(ScrollOffset(0, 1000), firstItem->getScrollOffset()); 1004 EXPECT_SIZE_EQ(ScrollOffset(0, 1000), firstItem->getScrollOffset());
993 } 1005 }
994 1006
995 // Test that the coordinates sent into moveRangeSelection are offset by the 1007 // Test that the coordinates sent into moveRangeSelection are offset by the
996 // visual viewport's location. 1008 // visual viewport's location.
997 TEST_P(VisualViewportTest, 1009 TEST_P(VisualViewportTest,
998 DISABLED_TestWebFrameRangeAccountsForVisualViewportScroll) { 1010 DISABLED_TestWebFrameRangeAccountsForVisualViewportScroll) {
999 initializeWithDesktopSettings(); 1011 initializeWithDesktopSettings();
1000 webViewImpl()->settings()->setDefaultFontSize(12); 1012 webViewImpl()->settings()->setDefaultFontSize(12);
(...skipping 1430 matching lines...) Expand 10 before | Expand all | Expand 10 after
2431 " body {" 2443 " body {"
2432 " margin: 0px;" 2444 " margin: 0px;"
2433 " }" 2445 " }"
2434 " div { height:110vh; width: 110vw; }" 2446 " div { height:110vh; width: 110vw; }"
2435 "</style>" 2447 "</style>"
2436 "<div></div>", 2448 "<div></div>",
2437 baseURL); 2449 baseURL);
2438 } 2450 }
2439 2451
2440 } // namespace 2452 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698