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

Unified Diff: third_party/WebKit/Source/web/tests/RootScrollerTest.cpp

Issue 2499853002: Fixed clip resize for document.rootScroller with inertTopControls (Closed)
Patch Set: Fixed typo 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/web/tests/RootScrollerTest.cpp
diff --git a/third_party/WebKit/Source/web/tests/RootScrollerTest.cpp b/third_party/WebKit/Source/web/tests/RootScrollerTest.cpp
index cdfaa2c31f21059d82ab43bda0afbd21b547f1fc..ae8b8d373a6abd6dd0422f4f1f9318fb52af32d0 100644
--- a/third_party/WebKit/Source/web/tests/RootScrollerTest.cpp
+++ b/third_party/WebKit/Source/web/tests/RootScrollerTest.cpp
@@ -11,10 +11,12 @@
#include "core/html/HTMLFrameOwnerElement.h"
#include "core/layout/LayoutBox.h"
#include "core/layout/api/LayoutViewItem.h"
+#include "core/layout/compositing/CompositedLayerMapping.h"
#include "core/layout/compositing/PaintLayerCompositor.h"
#include "core/page/Page.h"
#include "core/page/scrolling/RootScrollerController.h"
#include "core/page/scrolling/TopDocumentRootScrollerController.h"
+#include "core/paint/PaintLayer.h"
#include "core/paint/PaintLayerScrollableArea.h"
#include "platform/testing/URLTestHelpers.h"
#include "platform/testing/UnitTestHelpers.h"
@@ -93,7 +95,6 @@ class RootScrollerTest : public ::testing::Test {
void executeScript(const WebString& code) {
executeScript(code, *mainWebFrame());
- mainWebFrame()->view()->updateAllLifecyclePhases();
}
void executeScript(const WebString& code, WebLocalFrame& frame) {
@@ -887,6 +888,128 @@ TEST_F(RootScrollerTest, RemoveClippingOnCompositorLayers) {
}
}
+// Tests that the clipping layer is resized on the root scroller element even
+// if the layout height doesn't change.
+TEST_F(RootScrollerTest, BrowserControlsResizeClippingLayer) {
+ bool oldInertTopControls = RuntimeEnabledFeatures::inertTopControlsEnabled();
+ RuntimeEnabledFeatures::setInertTopControlsEnabled(true);
+
+ initialize("root-scroller.html");
+ Element* container = mainFrame()->document()->getElementById("container");
+
+ {
+ NonThrowableExceptionState exceptionState;
+ mainFrame()->document()->setRootScroller(container, exceptionState);
+
+ mainFrameView()->updateAllLifecyclePhases();
+ ASSERT_EQ(toLayoutBox(container->layoutObject())->clientHeight(), 400);
+
+ GraphicsLayer* clipLayer = toLayoutBox(container->layoutObject())
+ ->layer()
+ ->compositedLayerMapping()
+ ->scrollingLayer();
+ ASSERT_EQ(clipLayer->size().height(), 400);
+ }
+
+ {
+ webViewImpl()->handleInputEvent(
+ generateTouchGestureEvent(WebInputEvent::GestureScrollBegin));
+
+ // Scrolling over the #container DIV should cause the browser controls to
+ // hide.
+ EXPECT_FLOAT_EQ(1, browserControls().shownRatio());
+ webViewImpl()->handleInputEvent(generateTouchGestureEvent(
+ WebInputEvent::GestureScrollUpdate, 0, -browserControls().height()));
+ EXPECT_FLOAT_EQ(0, browserControls().shownRatio());
+
+ webViewImpl()->handleInputEvent(
+ generateTouchGestureEvent(WebInputEvent::GestureScrollEnd));
+
+ webViewImpl()->resizeWithBrowserControls(IntSize(400, 450), 50, false);
+
+ EXPECT_FALSE(container->layoutObject()->needsLayout());
+
+ mainFrameView()->updateAllLifecyclePhases();
+
+ // Since inert top controls are enabled, the container should not have
+ // resized, however, the clip layer should.
+ EXPECT_EQ(toLayoutBox(container->layoutObject())->clientHeight(), 400);
+ GraphicsLayer* clipLayer = toLayoutBox(container->layoutObject())
+ ->layer()
+ ->compositedLayerMapping()
+ ->scrollingLayer();
+ EXPECT_EQ(clipLayer->size().height(), 450);
+ }
+
+ RuntimeEnabledFeatures::setInertTopControlsEnabled(oldInertTopControls);
+}
+
+// Tests that the clipping layer is resized on the root scroller element when
+// it's an iframe and even if the layout height doesn't change.
+TEST_F(RootScrollerTest, BrowserControlsResizeClippingLayerIFrame) {
+ bool oldInertTopControls = RuntimeEnabledFeatures::inertTopControlsEnabled();
+ RuntimeEnabledFeatures::setInertTopControlsEnabled(true);
+
+ initialize("root-scroller-iframe.html");
+
+ Element* iframe = mainFrame()->document()->getElementById("iframe");
+ LocalFrame* childFrame =
+ toLocalFrame(toHTMLFrameOwnerElement(iframe)->contentFrame());
+
+ PaintLayerCompositor* childPLC =
+ childFrame->view()->layoutViewItem().compositor();
+
+ // Give the iframe itself scrollable content and make it the root scroller.
+ {
+ NonThrowableExceptionState nonThrow;
+ mainFrame()->document()->setRootScroller(iframe, nonThrow);
+
+ WebLocalFrame* childWebFrame =
+ mainWebFrame()->firstChild()->toWebLocalFrame();
+ executeScript(
+ "document.getElementById('container').style.width = '300%';"
+ "document.getElementById('container').style.height = '300%';",
+ *childWebFrame);
+
+ mainFrameView()->updateAllLifecyclePhases();
+
+ // Some sanity checks to make sure the test is setup correctly.
+ ASSERT_EQ(childFrame->view()->visibleContentSize().height(), 400);
+ ASSERT_EQ(childPLC->containerLayer()->size().height(), 400);
+ ASSERT_EQ(childPLC->rootGraphicsLayer()->size().height(), 400);
+ }
+
+ {
+ webViewImpl()->handleInputEvent(
+ generateTouchGestureEvent(WebInputEvent::GestureScrollBegin));
+
+ // Scrolling over the #container DIV should cause the browser controls to
+ // hide.
+ EXPECT_FLOAT_EQ(1, browserControls().shownRatio());
+ webViewImpl()->handleInputEvent(generateTouchGestureEvent(
+ WebInputEvent::GestureScrollUpdate, 0, -browserControls().height()));
+ EXPECT_FLOAT_EQ(0, browserControls().shownRatio());
+
+ webViewImpl()->handleInputEvent(
+ generateTouchGestureEvent(WebInputEvent::GestureScrollEnd));
+
+ webViewImpl()->resizeWithBrowserControls(IntSize(400, 450), 50, false);
+
+ EXPECT_FALSE(childFrame->view()->needsLayout());
+
+ mainFrameView()->updateAllLifecyclePhases();
+
+ // Since inert top controls are enabled, the iframe element should not have
+ // resized, however, its clip layer should resize to reveal content as the
+ // browser controls hide.
+ EXPECT_EQ(childFrame->view()->visibleContentSize().height(), 400);
+ EXPECT_EQ(childPLC->containerLayer()->size().height(), 450);
+ EXPECT_EQ(childPLC->rootGraphicsLayer()->size().height(), 450);
+ }
+
+ RuntimeEnabledFeatures::setInertTopControlsEnabled(oldInertTopControls);
+}
+
// Tests that removing the root scroller element from the DOM resets the
// effective root scroller without waiting for any lifecycle events.
TEST_F(RootScrollerTest, RemoveRootScrollerFromDom) {
« no previous file with comments | « third_party/WebKit/Source/platform/scroll/ScrollableArea.h ('k') | third_party/WebKit/Source/web/tests/VisualViewportTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698