Commit b8ad7cfd authored by skobes's avatar skobes Committed by Commit bot

[Reland] Set overflow: auto in StyleResolver::styleForDocument.

Without this, the call to setStyle in Document::updateStyle would temporarily
mark the LayoutView as overflow: visible.  With root layer scrolling this causes
PaintLayerScrollableArea to remove the scrollbars.

This change has no effect on the document's final overflow style, which comes
from inheritHtmlAndBodyElementStyles (and is never "visible" regardless of RLS).

This relands r438533 which was reverted in r438537.

BUG=672335

Committed: https://crrev.com/0cc860d2c6075b9afb96f566a370f62972a758e0
Review-Url: https://codereview.chromium.org/2571893003
Cr-Original-Commit-Position: refs/heads/master@{#438533}
Cr-Commit-Position: refs/heads/master@{#438616}
parent da6e2412
......@@ -622,6 +622,12 @@ PassRefPtr<ComputedStyle> StyleResolver::styleForDocument(Document& document) {
documentStyle->setDisplay(EDisplay::Block);
documentStyle->setPosition(AbsolutePosition);
// Document::inheritHtmlAndBodyElementStyles will set the final overflow
// style values, but they should initially be auto to avoid premature
// scrollbar removal in PaintLayerScrollableArea::updateAfterStyleChange.
documentStyle->setOverflowX(EOverflow::Auto);
documentStyle->setOverflowY(EOverflow::Auto);
document.setupFontBuilder(*documentStyle);
return documentStyle.release();
......
......@@ -357,6 +357,7 @@ test("webkit_unit_tests") {
"tests/RootScrollerTest.cpp",
"tests/RunAllTests.cpp",
"tests/ScreenWakeLockTest.cpp",
"tests/ScrollbarsTest.cpp",
"tests/ScrollingCoordinatorTest.cpp",
"tests/SpinLockTest.cpp",
"tests/TextFinderTest.cpp",
......
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "core/layout/LayoutView.h"
#include "core/paint/PaintLayerScrollableArea.h"
#include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h"
#include "platform/testing/UnitTestHelpers.h"
#include "public/web/WebScriptSource.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "web/WebLocalFrameImpl.h"
#include "web/tests/sim/SimDisplayItemList.h"
#include "web/tests/sim/SimRequest.h"
#include "web/tests/sim/SimTest.h"
namespace blink {
namespace {
class ScrollbarsTest : private ScopedRootLayerScrollingForTest, public SimTest {
public:
ScrollbarsTest() : ScopedRootLayerScrollingForTest(true) {}
};
TEST_F(ScrollbarsTest, DocumentStyleRecalcPreservesScrollbars) {
v8::HandleScope handleScope(v8::Isolate::GetCurrent());
webView().resize(WebSize(800, 600));
SimRequest request("https://example.com/test.html", "text/html");
loadURL("https://example.com/test.html");
request.complete("<style> body { width: 1600px; height: 1200px; } </style>");
PaintLayerScrollableArea* plsa = document().layoutView()->getScrollableArea();
compositor().beginFrame();
ASSERT_TRUE(plsa->verticalScrollbar() && plsa->horizontalScrollbar());
// Forces recalc of LayoutView's computed style in Document::updateStyle,
// without invalidating layout.
mainFrame().executeScriptAndReturnValue(WebScriptSource(
"document.querySelector('style').sheet.insertRule('body {}', 1);"));
compositor().beginFrame();
ASSERT_TRUE(plsa->verticalScrollbar() && plsa->horizontalScrollbar());
}
} // namespace
} // namespace blink
......@@ -61,6 +61,10 @@ WebViewImpl& SimTest::webView() {
return *m_webViewHelper.webView();
}
WebLocalFrameImpl& SimTest::mainFrame() {
return *webView().mainFrameImpl();
}
const SimWebViewClient& SimTest::webViewClient() const {
return m_webViewClient;
}
......
......@@ -15,6 +15,7 @@
namespace blink {
class WebViewImpl;
class WebLocalFrameImpl;
class Document;
class LocalDOMWindow;
......@@ -29,6 +30,7 @@ class SimTest : public ::testing::Test {
SimPage& page();
Document& document();
WebViewImpl& webView();
WebLocalFrameImpl& mainFrame();
const SimWebViewClient& webViewClient() const;
SimCompositor& compositor();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment