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

Fix outline when linebox has non-zero inline offset

When computing outline rects in an inline formatting context,
the coordinate system needs to be relative to the root of the
inline formatting context, because the algorithm needs to
call |LayoutObject| functions, which uses the coordinate
system for inline |LayoutObject|s.

This patch fixes not to accumulate line box offset. For the
inline direction, this is usually zero and is not visible,
but non-zero `padding-left` can expose this difference.

Bug: 1048070
Change-Id: I30dfabcca621136b6d78892a1856c1336c7438eb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2038296Reviewed-by: default avatarXianzhu Wang <wangxianzhu@chromium.org>
Reviewed-by: default avatarAleks Totic <atotic@chromium.org>
Commit-Queue: Koji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#738646}
parent a1de2314
......@@ -161,6 +161,8 @@ void NGPhysicalContainerFragment::AddOutlineRectsForDescendant(
// the LayoutInline needs to add rects for children and continuations
// only.
if (NGOutlineUtils::ShouldPaintOutline(*descendant_box)) {
// For inline fragments, don't accumulate |descendant.Offset()| because
// offsets are relative to its inline formatting context.
descendant_layout_inline->AddOutlineRectsForChildrenAndContinuations(
*outline_rects, additional_offset, outline_type);
}
......@@ -169,9 +171,10 @@ void NGPhysicalContainerFragment::AddOutlineRectsForDescendant(
if (const auto* descendant_line_box =
DynamicTo<NGPhysicalLineBoxFragment>(descendant.get())) {
// For inline fragments, don't accumulate |descendant.Offset()| because
// offsets are relative to its inline formatting context.
descendant_line_box->AddOutlineRectsForNormalChildren(
outline_rects, additional_offset + descendant.Offset(), outline_type,
containing_block);
outline_rects, additional_offset, outline_type, containing_block);
if (!descendant_line_box->Size().IsEmpty()) {
outline_rects->emplace_back(additional_offset,
......
<!DOCTYPE html>
<title>Outline with padding</title>
<link rel="match" href="reference/outline-with-padding-001-ref.html">
<link rel="help" href="https://drafts.csswg.org/css-ui/#outline-props">
<link rel="help" href="https://crbug.com/1048070">
<link rel="author" href="mailto:kojii@chromium.org">
<meta name="assert" content="Tests the rendering of outline applied to a box with padding">
<style>
inline-block {
display: inline-block;
width: 65px;
color: transparent;
background: orange;
}
</style>
<body>
<div style="display: flex">
<span style="padding-left: 99px; outline: auto">
<span>
<inline-block>Previous</inline-block>
</span>
</span>
</div>
<div style="width: 50px; padding-left: 99px; outline: auto">
<span>
<inline-block>Previous</inline-block>
</span>
</div>
</body>
<!DOCTYPE html>
<style>
inline-block {
display: inline-block;
width: 65px;
color: transparent;
background: orange;
}
spacer {
display: inline-block;
width: 99px;
}
</style>
<body>
<div style="display: flex">
<span style="outline: auto">
<spacer></spacer><inline-block>Previous</inline-block>
</span>
</div>
<div style="display: inline-block; outline: auto; white-space: nowrap;">
<spacer></spacer><inline-block>Previous</inline-block>
</div>
</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