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

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: 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/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 1039 matching lines...) Expand 10 before | Expand all | Expand 10 after
1050 const TopDocumentRootScrollerController& globalController = 1050 const TopDocumentRootScrollerController& globalController =
1051 mainFrame()->document()->frameHost()->globalRootScrollerController(); 1051 mainFrame()->document()->frameHost()->globalRootScrollerController();
1052 1052
1053 EXPECT_EQ(mainFrame()->document()->documentElement(), 1053 EXPECT_EQ(mainFrame()->document()->documentElement(),
1054 globalController.globalRootScroller()); 1054 globalController.globalRootScroller());
1055 EXPECT_EQ( 1055 EXPECT_EQ(
1056 mainFrameView()->layoutViewportScrollableArea()->layerForScrolling(), 1056 mainFrameView()->layoutViewportScrollableArea()->layerForScrolling(),
1057 globalController.rootScrollerLayer()); 1057 globalController.rootScrollerLayer());
1058 } 1058 }
1059 1059
1060 // On Android, the main scrollbars are owned by the visual viewport and the
1061 // FrameView's disabled. This functionality should extend to a rootScroller
1062 // that isn't the main FrameView.
1063 TEST_F(RootScrollerTest, UseVisualViewportScrollbars) {
1064 initialize("root-scroller.html");
1065
1066 Element* container = mainFrame()->document()->getElementById("container");
1067 NonThrowableExceptionState nonThrow;
1068 mainFrame()->document()->setRootScroller(container, nonThrow);
1069 mainFrameView()->updateAllLifecyclePhases();
1070
1071 ScrollableArea* containerScroller =
1072 static_cast<PaintInvalidationCapableScrollableArea*>(
1073 toLayoutBox(container->layoutObject())->getScrollableArea());
1074
1075 EXPECT_FALSE(containerScroller->horizontalScrollbar());
1076 EXPECT_FALSE(containerScroller->verticalScrollbar());
1077 EXPECT_GT(containerScroller->maximumScrollOffset().width(), 0);
1078 EXPECT_GT(containerScroller->maximumScrollOffset().height(), 0);
1079 }
1080
1081 // On Android, the main scrollbars are owned by the visual viewport and the
1082 // FrameView's disabled. This functionality should extend to a rootScroller
1083 // that's a nested iframe.
1084 TEST_F(RootScrollerTest, UseVisualViewportScrollbarsIframe) {
1085 initialize("root-scroller-iframe.html");
1086
1087 Element* iframe = mainFrame()->document()->getElementById("iframe");
1088 LocalFrame* childFrame =
1089 toLocalFrame(toHTMLFrameOwnerElement(iframe)->contentFrame());
1090
1091 NonThrowableExceptionState nonThrow;
1092 mainFrame()->document()->setRootScroller(iframe, nonThrow);
1093
1094 WebLocalFrame* childWebFrame =
1095 mainWebFrame()->firstChild()->toWebLocalFrame();
1096 executeScript(
1097 "document.getElementById('container').style.width = '200%';"
1098 "document.getElementById('container').style.height = '200%';",
1099 *childWebFrame);
1100
1101 mainFrameView()->updateAllLifecyclePhases();
1102
1103 ScrollableArea* containerScroller = childFrame->view();
1104
1105 EXPECT_FALSE(containerScroller->horizontalScrollbar());
1106 EXPECT_FALSE(containerScroller->verticalScrollbar());
1107 EXPECT_GT(containerScroller->maximumScrollOffset().width(), 0);
1108 EXPECT_GT(containerScroller->maximumScrollOffset().height(), 0);
1109 }
1110
1060 } // namespace 1111 } // namespace
1061 1112
1062 } // namespace blink 1113 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698