Commit b74b7338 authored by Steve Kobes's avatar Steve Kobes Committed by Commit Bot

Ensure PLSA scroll height is not less than visible height.

Hiding browser controls can make the layout viewport larger than the
document's layout overflow.  Bottom-anchored fixed-position elements
were incorrectly clipped with RLS, because the scrolling contents layer
was sized to match the overflow rect.

Bug: 817714
Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2
Change-Id: I89c3488370e1bce02a7ed523e930ab9d634f60ac
Reviewed-on: https://chromium-review.googlesource.com/954016Reviewed-by: default avatarDavid Bokan <bokan@chromium.org>
Commit-Queue: Steve Kobes <skobes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#542087}
parent e4abdeef
layer at (0,0) size 1600x1200 scrollHeight 800 layer at (0,0) size 1600x1200 scrollWidth 1600 scrollHeight 1200
LayoutView at (0,0) size 800x600 LayoutView at (0,0) size 800x600
layer at (0,0) size 800x600 layer at (0,0) size 800x600
LayoutBlockFlow {HTML} at (0,0) size 800x600 LayoutBlockFlow {HTML} at (0,0) size 800x600
......
layer at (0,0) size 1600x1200 layer at (0,0) size 1600x1200 scrollWidth 1600 scrollHeight 1200
LayoutView at (0,0) size 800x600 LayoutView at (0,0) size 800x600
layer at (0,0) size 800x600 layer at (0,0) size 800x600
LayoutBlockFlow {HTML} at (0,0) size 800x600 LayoutBlockFlow {HTML} at (0,0) size 800x600
......
...@@ -11974,6 +11974,39 @@ TEST_P(WebFrameSimTest, RtlInitialScrollOffsetWithViewport) { ...@@ -11974,6 +11974,39 @@ TEST_P(WebFrameSimTest, RtlInitialScrollOffsetWithViewport) {
ASSERT_EQ(ScrollOffset(0, 0), area->GetScrollOffset()); ASSERT_EQ(ScrollOffset(0, 0), area->GetScrollOffset());
} }
TEST_P(WebFrameSimTest, LayoutViewportExceedsLayoutOverflow) {
// This test fails without RLS (but doesn't cause visible paint clipping due
// to differences in composited layer geometry logic).
if (!RuntimeEnabledFeatures::RootLayerScrollingEnabled())
return;
WebView().GetSettings()->SetViewportEnabled(true);
WebView().GetSettings()->SetViewportMetaEnabled(true);
WebView().ResizeWithBrowserControls(WebSize(400, 540), 60, 0, true);
WebView().SetDefaultPageScaleLimits(0.25f, 2);
SimRequest main_resource("https://example.com/test.html", "text/html");
LoadURL("https://example.com/test.html");
main_resource.Complete(R"HTML(
<meta name='viewport' content='width=device-width, minimum-scale=1'>
<body style='margin: 0; height: 95vh'>
)HTML");
Compositor().BeginFrame();
ScrollableArea* area = GetDocument().View()->LayoutViewportScrollableArea();
ASSERT_EQ(540, area->VisibleHeight());
ASSERT_EQ(IntSize(400, 570), area->ContentsSize());
// Hide browser controls, growing layout viewport without affecting ICB.
WebView().ResizeWithBrowserControls(WebSize(400, 600), 60, 0, false);
Compositor().BeginFrame();
// ContentsSize() should grow to accomodate new visible size.
ASSERT_EQ(600, area->VisibleHeight());
ASSERT_EQ(IntSize(400, 600), area->ContentsSize());
}
TEST_P(WebFrameSimTest, NamedLookupIgnoresEmptyNames) { TEST_P(WebFrameSimTest, NamedLookupIgnoresEmptyNames) {
SimRequest main_resource("https://example.com/main.html", "text/html"); SimRequest main_resource("https://example.com/main.html", "text/html");
LoadURL("https://example.com/main.html"); LoadURL("https://example.com/main.html");
......
...@@ -874,10 +874,19 @@ void PaintLayerScrollableArea::UpdateScrollOrigin() { ...@@ -874,10 +874,19 @@ void PaintLayerScrollableArea::UpdateScrollOrigin() {
} }
void PaintLayerScrollableArea::UpdateScrollDimensions() { void PaintLayerScrollableArea::UpdateScrollDimensions() {
if (overflow_rect_.Size() != GetLayoutBox()->LayoutOverflowRect().Size()) LayoutRect new_overflow_rect = GetLayoutBox()->LayoutOverflowRect();
GetLayoutBox()->FlipForWritingMode(new_overflow_rect);
// The layout viewport can be larger than the document's layout overflow when
// top controls are hidden. Expand the overflow here to ensure that our
// contents size >= visible size.
new_overflow_rect.Unite(
LayoutRect(new_overflow_rect.Location(),
LayoutContentRect(kExcludeScrollbars).Size()));
if (overflow_rect_.Size() != new_overflow_rect.Size())
ContentsResized(); ContentsResized();
overflow_rect_ = GetLayoutBox()->LayoutOverflowRect(); overflow_rect_ = new_overflow_rect;
GetLayoutBox()->FlipForWritingMode(overflow_rect_);
UpdateScrollOrigin(); UpdateScrollOrigin();
} }
......
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