Skip to content

Commit

Permalink
[LayoutNG] Fix ScrollableOverflowForPropagation()
Browse files Browse the repository at this point in the history
NGPhysicalFragment::ScrollableOverflowForPropagation()
had an important different compared
to LayoutBox::LayoutOverflowRectForPropagation()
as it was not including the border box when computing
the overflow for propagation.

This was causing issues in some cases calculating the overflow
of replaced elements in LayoutNG, legacy was working fine.

This patch changes AdjustScrollableOverflowForPropagation()
to also include the element's border box.

Note that we cannot do this for ruby boxes
as they have some special behavior
(see crbug.com/1082087 and r784709 for details).

We need new rebaselines for the following test
fast/replaced/border-radius-clip.html
This is because when you scroll down you can see
the border of the embed object (which was hidden before).

BUG=1128984
TEST=css/css-overflow/overflow-replaced-element-001.html

Change-Id: I038ccb46db7e00a922e33a387cf10e3c805b81c6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2414313
Reviewed-by: Ian Kilpatrick <ikilpatrick@chromium.org>
Reviewed-by: Kent Tamura <tkent@chromium.org>
Commit-Queue: Manuel Rego <rego@igalia.com>
Cr-Commit-Position: refs/heads/master@{#808518}
  • Loading branch information
mrego authored and Commit Bot committed Sep 18, 2020
1 parent 141141b commit 918e6ac
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ void NGPhysicalContainerFragment::AddScrollableOverflowForInlineChild(
container, container_style, line, has_hanging, descendants,
height_type, &child_scroll_overflow);
child_box->AdjustScrollableOverflowForPropagation(
container, &child_scroll_overflow);
container, height_type, &child_scroll_overflow);
} else {
child_scroll_overflow =
child_box->ScrollableOverflowForPropagation(container, height_type);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -494,12 +494,13 @@ PhysicalRect NGPhysicalFragment::ScrollableOverflowForPropagation(
const NGPhysicalBoxFragment& container,
TextHeightType height_type) const {
PhysicalRect overflow = ScrollableOverflow(container, height_type);
AdjustScrollableOverflowForPropagation(container, &overflow);
AdjustScrollableOverflowForPropagation(container, height_type, &overflow);
return overflow;
}

void NGPhysicalFragment::AdjustScrollableOverflowForPropagation(
const NGPhysicalBoxFragment& container,
TextHeightType height_type,
PhysicalRect* overflow) const {
DCHECK(!IsLineBox());
if (!IsCSSBox())
Expand All @@ -509,6 +510,9 @@ void NGPhysicalFragment::AdjustScrollableOverflowForPropagation(
return;
}

if (height_type == TextHeightType::kNormalHeight)
overflow->Unite({{}, Size()});

const LayoutObject* layout_object = GetLayoutObject();
DCHECK(layout_object);
const LayoutObject* container_layout_object = container.GetLayoutObject();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ class CORE_EXPORT NGPhysicalFragment
TextHeightType height_type) const;
void AdjustScrollableOverflowForPropagation(
const NGPhysicalBoxFragment& container,
TextHeightType height_type,
PhysicalRect* overflow) const;

// The allowed touch action is the union of the effective touch action
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<title>CSS Overflow: overflow replaced element with borders and negative end margins</title>
<link rel="author" title="Manuel Rego Casasnovas" href="mailto:rego@igalia.com">
<link rel="help" href="https://drafts.csswg.org/css-overflow/#scrollable">
<meta name="assert" content="Checks that the scrollable overflow of a replaced elements with borders is properly computed even when it has a negative margin-right and margin-bottom.">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/check-layout-th.js"></script>
<body onload="checkLayout('#wrapper');">
<div id="wrapper" style="width: 200px; height: 100px; overflow: scroll;"
data-expected-scroll-width="400" data-expected-scroll-height="300">
<img style="border: 50px solid green; width: 300px; height: 200px;
margin-right: -100px; margin-bottom: -200px;" />
</div>
</body>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 918e6ac

Please sign in to comment.