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

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

Issue 2506473004: Fixed rotation anchoring while using a document.rootScroller. (Closed)
Patch Set: Rebase Created 4 years, 1 month 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/dom/ClientRect.h"
5 #include "core/frame/BrowserControls.h" 6 #include "core/frame/BrowserControls.h"
6 #include "core/frame/FrameHost.h" 7 #include "core/frame/FrameHost.h"
7 #include "core/frame/FrameView.h" 8 #include "core/frame/FrameView.h"
8 #include "core/frame/RootFrameViewport.h" 9 #include "core/frame/RootFrameViewport.h"
10 #include "core/frame/VisualViewport.h"
9 #include "core/html/HTMLFrameOwnerElement.h" 11 #include "core/html/HTMLFrameOwnerElement.h"
10 #include "core/layout/LayoutBox.h" 12 #include "core/layout/LayoutBox.h"
11 #include "core/layout/api/LayoutViewItem.h" 13 #include "core/layout/api/LayoutViewItem.h"
12 #include "core/layout/compositing/PaintLayerCompositor.h" 14 #include "core/layout/compositing/PaintLayerCompositor.h"
13 #include "core/page/Page.h" 15 #include "core/page/Page.h"
14 #include "core/page/scrolling/RootScrollerController.h" 16 #include "core/page/scrolling/RootScrollerController.h"
15 #include "core/page/scrolling/TopDocumentRootScrollerController.h" 17 #include "core/page/scrolling/TopDocumentRootScrollerController.h"
16 #include "core/paint/PaintLayerScrollableArea.h" 18 #include "core/paint/PaintLayerScrollableArea.h"
17 #include "platform/testing/URLTestHelpers.h" 19 #include "platform/testing/URLTestHelpers.h"
18 #include "platform/testing/UnitTestHelpers.h" 20 #include "platform/testing/UnitTestHelpers.h"
(...skipping 15 matching lines...) Expand all
34 36
35 namespace blink { 37 namespace blink {
36 38
37 namespace { 39 namespace {
38 40
39 class RootScrollerTest : public ::testing::Test { 41 class RootScrollerTest : public ::testing::Test {
40 public: 42 public:
41 RootScrollerTest() : m_baseURL("http://www.test.com/") { 43 RootScrollerTest() : m_baseURL("http://www.test.com/") {
42 registerMockedHttpURLLoad("overflow-scrolling.html"); 44 registerMockedHttpURLLoad("overflow-scrolling.html");
43 registerMockedHttpURLLoad("root-scroller.html"); 45 registerMockedHttpURLLoad("root-scroller.html");
46 registerMockedHttpURLLoad("root-scroller-rotation.html");
44 registerMockedHttpURLLoad("root-scroller-iframe.html"); 47 registerMockedHttpURLLoad("root-scroller-iframe.html");
45 registerMockedHttpURLLoad("root-scroller-child.html"); 48 registerMockedHttpURLLoad("root-scroller-child.html");
46 } 49 }
47 50
48 ~RootScrollerTest() override { 51 ~RootScrollerTest() override {
49 m_featuresBackup.restore(); 52 m_featuresBackup.restore();
50 Platform::current()->getURLLoaderMockFactory()->unregisterAllURLs(); 53 Platform::current()->getURLLoaderMockFactory()->unregisterAllURLs();
51 WebCache::clear(); 54 WebCache::clear();
52 } 55 }
53 56
(...skipping 926 matching lines...) Expand 10 before | Expand all | Expand 10 after
980 mainFrameView()->updateAllLifecyclePhases(); 983 mainFrameView()->updateAllLifecyclePhases();
981 984
982 ScrollableArea* containerScroller = childFrame->view(); 985 ScrollableArea* containerScroller = childFrame->view();
983 986
984 EXPECT_FALSE(containerScroller->horizontalScrollbar()); 987 EXPECT_FALSE(containerScroller->horizontalScrollbar());
985 EXPECT_FALSE(containerScroller->verticalScrollbar()); 988 EXPECT_FALSE(containerScroller->verticalScrollbar());
986 EXPECT_GT(containerScroller->maximumScrollOffset().width(), 0); 989 EXPECT_GT(containerScroller->maximumScrollOffset().width(), 0);
987 EXPECT_GT(containerScroller->maximumScrollOffset().height(), 0); 990 EXPECT_GT(containerScroller->maximumScrollOffset().height(), 0);
988 } 991 }
989 992
993 TEST_F(RootScrollerTest, RotationAnchoring) {
994 initialize("root-scroller-rotation.html");
995
996 ScrollableArea* containerScroller;
997
998 {
999 webViewImpl()->resizeWithBrowserControls(IntSize(250, 1000), 0, true);
1000 mainFrameView()->updateAllLifecyclePhases();
1001
1002 Element* container = mainFrame()->document()->getElementById("container");
1003 NonThrowableExceptionState nonThrow;
1004 mainFrame()->document()->setRootScroller(container, nonThrow);
1005 mainFrameView()->updateAllLifecyclePhases();
1006
1007 containerScroller = static_cast<PaintInvalidationCapableScrollableArea*>(
1008 toLayoutBox(container->layoutObject())->getScrollableArea());
1009 }
1010
1011 Element* target = mainFrame()->document()->getElementById("target");
1012
1013 // Zoom in and scroll the viewport so that the target is fully in the
1014 // viewport and the visual viewport is fully scrolled within the layout
1015 // viepwort.
1016 {
1017 int scrollX = 250 * 4;
1018 int scrollY = 1000 * 4;
1019
1020 webViewImpl()->setPageScaleFactor(2);
1021 webViewImpl()->handleInputEvent(
1022 generateTouchGestureEvent(WebInputEvent::GestureScrollBegin));
1023 webViewImpl()->handleInputEvent(generateTouchGestureEvent(
1024 WebInputEvent::GestureScrollUpdate, -scrollX, -scrollY));
1025 webViewImpl()->handleInputEvent(
1026 generateTouchGestureEvent(WebInputEvent::GestureScrollEnd));
1027
1028 // The visual viewport should be 1.5 screens scrolled so that the target
1029 // occupies the bottom quadrant of the layout viewport.
1030 ASSERT_EQ((250 * 3) / 2, containerScroller->scrollOffset().width());
1031 ASSERT_EQ((1000 * 3) / 2, containerScroller->scrollOffset().height());
1032
1033 // The visual viewport should have scrolled the last half layout viewport.
1034 ASSERT_EQ((250) / 2, visualViewport().scrollOffset().width());
1035 ASSERT_EQ((1000) / 2, visualViewport().scrollOffset().height());
1036 }
1037
1038 // Now do a rotation resize.
1039 webViewImpl()->resizeWithBrowserControls(IntSize(1000, 250), 50, false);
1040 mainFrameView()->updateAllLifecyclePhases();
1041
1042 // The visual viewport should remain fully filled by the target.
1043 ClientRect* rect = target->getBoundingClientRect();
1044 EXPECT_EQ(rect->left(), visualViewport().scrollOffset().width());
1045 EXPECT_EQ(rect->top(), visualViewport().scrollOffset().height());
1046 }
1047
990 } // namespace 1048 } // namespace
991 1049
992 } // namespace blink 1050 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698