Commit c7b06ab2 authored by Koji Ishii's avatar Koji Ishii Committed by Commit Bot

[FragmentItem] Fix scroll overflow when inline box hangs

This patch applies hanging trailing spaces logic to inline
boxes.

When `white-space: pre-wrap`, trailing spaces can hang. They
should not affect scroll (layout) overflow though.

This was fixed for LayoutNG in crbug.com/966773. When the fix
was ported to FragmentItem, it was applied only to text runs.
It should be applied to inline boxes too, because inline
boxes that contain hanging trailing spaces can also hang.

Bug: 1130310
Change-Id: Ie03e178eb26b2c7270f536974cd617feb38c9169
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2425553Reviewed-by: default avatarIan Kilpatrick <ikilpatrick@chromium.org>
Commit-Queue: Koji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#809838}
parent 32afb795
......@@ -246,6 +246,11 @@ void NGPhysicalContainerFragment::AddScrollableOverflowForInlineChild(
height_type, &child_scroll_overflow);
child_box->AdjustScrollableOverflowForPropagation(
container, height_type, &child_scroll_overflow);
if (UNLIKELY(has_hanging)) {
AdjustScrollableOverflowForHanging(line.RectInContainerBlock(),
container_writing_mode,
&child_scroll_overflow);
}
} else {
child_scroll_overflow =
child_box->ScrollableOverflowForPropagation(container, height_type);
......
<!DOCTYPE html>
<title>Preserved trailing spaces in inline boxes should hang</title>
<link rel="help" href="https://drafts.csswg.org/css-text-3/#propdef-white-space">
<link rel="help" href="http://crbug.com/1130310">
<link rel="author" title="Koji Ishii" href="mailto:kojii@chromium.org">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
.target {
font-family: Consolas, 'Courier New', Courier, monospace;
font-size: 20px;
width: 5ch;
white-space: pre-wrap;
overflow: auto visible;
border: 1px solid blue;
}
.not-culled span {
background: orange;
}
</style>
<body>
<div class="target">12345 678</div>
<div class="target"><span>12345 678</span></div>
<div class="target not-culled"><span>12345 678</span></div>
<script>
for (let target of document.getElementsByClassName('target')) {
test(() => {
let width = target.offsetWidth;
let scroll_width = target.scrollWidth;
assert_less_than_equal(scroll_width, width);
});
}
</script>
</body>
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