Commit 46e1ab33 authored by chaopeng's avatar chaopeng Committed by Commit Bot

Early return SetScrollbarsHiddenIfOverlay when PLSA has disposed paint layer

This crash is caused by query the page scrollbar theme settings after PLSA
disposed paint layer. In this patch, we added a HasBeenDisposed check before
query the page scrollbar theme settings to prevent the crash.

Bug: 828523
Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2
Change-Id: I9c47e4daf88c78aa178e3d355e764639580628a9
Reviewed-on: https://chromium-review.googlesource.com/994337Reviewed-by: default avatarDavid Bokan <bokan@chromium.org>
Reviewed-by: default avatarRick Byers <rbyers@chromium.org>
Commit-Queue: Jianpeng Chao <chaopeng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#548181}
parent 3e7dcc3d
...@@ -1826,6 +1826,48 @@ TEST_P(ScrollbarsTest, AutosizeTest) { ...@@ -1826,6 +1826,48 @@ TEST_P(ScrollbarsTest, AutosizeTest) {
} }
} }
TEST_P(ScrollbarsTest,
HideTheOverlayScrollbarNotCrashAfterPLSADisposedPaintLayer) {
WebView().Resize(WebSize(200, 200));
SimRequest request("https://example.com/test.html", "text/html");
LoadURL("https://example.com/test.html");
request.Complete(R"HTML(
<!DOCTYPE html>
<style>
#div{ height: 100px; overflow-y:scroll; }
.big{ height: 2000px; }
.hide { display: none; }
</style>
<div id='div'>
<div class='big'>
</div>
</div>
)HTML");
Compositor().BeginFrame();
Document& document = GetDocument();
Element* div = document.getElementById("div");
PaintLayerScrollableArea* scrollable_div =
ToLayoutBox(div->GetLayoutObject())->GetScrollableArea();
scrollable_div->SetScrollbarsHiddenIfOverlay(false);
ASSERT_TRUE(scrollable_div);
ASSERT_TRUE(scrollable_div->GetPageScrollbarTheme().UsesOverlayScrollbars());
ASSERT_TRUE(scrollable_div->VerticalScrollbar());
EXPECT_FALSE(scrollable_div->ScrollbarsHiddenIfOverlay());
// Set display:none calls Dispose().
div->setAttribute(HTMLNames::classAttr, "hide");
Compositor().BeginFrame();
// After paint layer in scrollable dispose, we can still call scrollbar hidden
// just not change scrollbar.
scrollable_div->SetScrollbarsHiddenIfOverlay(true);
EXPECT_FALSE(scrollable_div->ScrollbarsHiddenIfOverlay());
}
class ScrollbarTrackMarginsTest : public ScrollbarsTest { class ScrollbarTrackMarginsTest : public ScrollbarsTest {
public: public:
void PrepareTest(const String& track_style) { void PrepareTest(const String& track_style) {
......
...@@ -2544,6 +2544,10 @@ void PaintLayerScrollableArea::DelayScrollOffsetClampScope:: ...@@ -2544,6 +2544,10 @@ void PaintLayerScrollableArea::DelayScrollOffsetClampScope::
} }
ScrollbarTheme& PaintLayerScrollableArea::GetPageScrollbarTheme() const { ScrollbarTheme& PaintLayerScrollableArea::GetPageScrollbarTheme() const {
// If PaintLayer is destructed before PaintLayerScrollable area, we can not
// get the page scrollbar theme setting.
DCHECK(!HasBeenDisposed());
Page* page = GetLayoutBox()->GetFrame()->GetPage(); Page* page = GetLayoutBox()->GetFrame()->GetPage();
DCHECK(page); DCHECK(page);
......
...@@ -592,6 +592,11 @@ bool ScrollableArea::ScrollbarsHiddenIfOverlay() const { ...@@ -592,6 +592,11 @@ bool ScrollableArea::ScrollbarsHiddenIfOverlay() const {
} }
void ScrollableArea::SetScrollbarsHiddenIfOverlay(bool hidden) { void ScrollableArea::SetScrollbarsHiddenIfOverlay(bool hidden) {
// If scrollable area has been disposed, we can not get the page scrollbar
// theme setting. Should early return here.
if (HasBeenDisposed())
return;
if (!GetPageScrollbarTheme().UsesOverlayScrollbars()) if (!GetPageScrollbarTheme().UsesOverlayScrollbars())
return; return;
......
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