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

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

Issue 2501723003: Disable scrollbars on the root scroller when using visual viewport scrollbars. (Closed)
Patch Set: Fix (?) Graphics2D test 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
« no previous file with comments | « third_party/WebKit/Source/platform/scroll/ScrollableArea.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/frame/BrowserControls.h" 5 #include "core/frame/BrowserControls.h"
6 #include "core/frame/FrameHost.h" 6 #include "core/frame/FrameHost.h"
7 #include "core/frame/FrameView.h" 7 #include "core/frame/FrameView.h"
8 #include "core/frame/RootFrameViewport.h" 8 #include "core/frame/RootFrameViewport.h"
9 #include "core/html/HTMLFrameOwnerElement.h" 9 #include "core/html/HTMLFrameOwnerElement.h"
10 #include "core/layout/LayoutBox.h" 10 #include "core/layout/LayoutBox.h"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 settings->setMainFrameResizesAreOrientationChanges(true); 82 settings->setMainFrameResizesAreOrientationChanges(true);
83 } 83 }
84 84
85 void registerMockedHttpURLLoad(const std::string& fileName) { 85 void registerMockedHttpURLLoad(const std::string& fileName) {
86 URLTestHelpers::registerMockedURLFromBaseURL( 86 URLTestHelpers::registerMockedURLFromBaseURL(
87 WebString::fromUTF8(m_baseURL.c_str()), 87 WebString::fromUTF8(m_baseURL.c_str()),
88 WebString::fromUTF8(fileName.c_str())); 88 WebString::fromUTF8(fileName.c_str()));
89 } 89 }
90 90
91 void executeScript(const WebString& code) { 91 void executeScript(const WebString& code) {
92 mainWebFrame()->executeScript(WebScriptSource(code)); 92 executeScript(code, *mainWebFrame());
93 mainWebFrame()->view()->updateAllLifecyclePhases(); 93 mainWebFrame()->view()->updateAllLifecyclePhases();
94 }
95
96 void executeScript(const WebString& code, WebLocalFrame& frame) {
97 frame.executeScript(WebScriptSource(code));
98 frame.view()->updateAllLifecyclePhases();
94 runPendingTasks(); 99 runPendingTasks();
95 } 100 }
96 101
97 WebViewImpl* webViewImpl() const { return m_helper.webView(); } 102 WebViewImpl* webViewImpl() const { return m_helper.webView(); }
98 103
99 FrameHost& frameHost() const { 104 FrameHost& frameHost() const {
100 return m_helper.webView()->page()->frameHost(); 105 return m_helper.webView()->page()->frameHost();
101 } 106 }
102 107
103 LocalFrame* mainFrame() const { 108 LocalFrame* mainFrame() const {
(...skipping 820 matching lines...) Expand 10 before | Expand all | Expand 10 after
924 const TopDocumentRootScrollerController& globalController = 929 const TopDocumentRootScrollerController& globalController =
925 mainFrame()->document()->frameHost()->globalRootScrollerController(); 930 mainFrame()->document()->frameHost()->globalRootScrollerController();
926 931
927 EXPECT_EQ(mainFrame()->document()->documentElement(), 932 EXPECT_EQ(mainFrame()->document()->documentElement(),
928 globalController.globalRootScroller()); 933 globalController.globalRootScroller());
929 EXPECT_EQ( 934 EXPECT_EQ(
930 mainFrameView()->layoutViewportScrollableArea()->layerForScrolling(), 935 mainFrameView()->layoutViewportScrollableArea()->layerForScrolling(),
931 globalController.rootScrollerLayer()); 936 globalController.rootScrollerLayer());
932 } 937 }
933 938
939 // On Android, the main scrollbars are owned by the visual viewport and the
940 // FrameView's disabled. This functionality should extend to a rootScroller
941 // that isn't the main FrameView.
942 TEST_F(RootScrollerTest, UseVisualViewportScrollbars) {
943 initialize("root-scroller.html");
944
945 Element* container = mainFrame()->document()->getElementById("container");
946 NonThrowableExceptionState nonThrow;
947 mainFrame()->document()->setRootScroller(container, nonThrow);
948 mainFrameView()->updateAllLifecyclePhases();
949
950 ScrollableArea* containerScroller =
951 static_cast<PaintInvalidationCapableScrollableArea*>(
952 toLayoutBox(container->layoutObject())->getScrollableArea());
953
954 EXPECT_FALSE(containerScroller->horizontalScrollbar());
955 EXPECT_FALSE(containerScroller->verticalScrollbar());
956 EXPECT_GT(containerScroller->maximumScrollOffset().width(), 0);
957 EXPECT_GT(containerScroller->maximumScrollOffset().height(), 0);
958 }
959
960 // On Android, the main scrollbars are owned by the visual viewport and the
961 // FrameView's disabled. This functionality should extend to a rootScroller
962 // that's a nested iframe.
963 TEST_F(RootScrollerTest, UseVisualViewportScrollbarsIframe) {
964 initialize("root-scroller-iframe.html");
965
966 Element* iframe = mainFrame()->document()->getElementById("iframe");
967 LocalFrame* childFrame =
968 toLocalFrame(toHTMLFrameOwnerElement(iframe)->contentFrame());
969
970 NonThrowableExceptionState nonThrow;
971 mainFrame()->document()->setRootScroller(iframe, nonThrow);
972
973 WebLocalFrame* childWebFrame =
974 mainWebFrame()->firstChild()->toWebLocalFrame();
975 executeScript(
976 "document.getElementById('container').style.width = '200%';"
977 "document.getElementById('container').style.height = '200%';",
978 *childWebFrame);
979
980 mainFrameView()->updateAllLifecyclePhases();
981
982 ScrollableArea* containerScroller = childFrame->view();
983
984 EXPECT_FALSE(containerScroller->horizontalScrollbar());
985 EXPECT_FALSE(containerScroller->verticalScrollbar());
986 EXPECT_GT(containerScroller->maximumScrollOffset().width(), 0);
987 EXPECT_GT(containerScroller->maximumScrollOffset().height(), 0);
988 }
989
934 } // namespace 990 } // namespace
935 991
936 } // namespace blink 992 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/scroll/ScrollableArea.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698