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

[LayoutNG] Fix not to break after leading out-of-flow objects

r694888 (crrev.com/c/1792467) gave a break opportunity after
OOF objects.

For leading OOF objects, there should not be a break
opportunity, but the patch gave to them too. This patch fixes
not to add a break opportunity if there were no preceding
in-flow objects.

Bug: 1018748
Change-Id: I89a8614cdfd85bed1bb8c2f3b6db892697f7add7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1886130
Commit-Queue: Koji Ishii <kojii@chromium.org>
Reviewed-by: default avatarYoshifumi Inoue <yosin@chromium.org>
Reviewed-by: default avatarIan Kilpatrick <ikilpatrick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#710527}
parent 906a04ae
...@@ -430,9 +430,7 @@ void NGLineBreaker::BreakLine( ...@@ -430,9 +430,7 @@ void NGLineBreaker::BreakLine(
continue; continue;
} }
if (item.Type() == NGInlineItem::kOutOfFlowPositioned) { if (item.Type() == NGInlineItem::kOutOfFlowPositioned) {
NGInlineItemResult* item_result = AddItem(item, line_info); HandleOutOfFlowPositioned(item, line_info);
ComputeCanBreakAfter(item_result, auto_wrap_, break_iterator_);
MoveToNextOf(item);
} else if (item.Length()) { } else if (item.Length()) {
NOTREACHED(); NOTREACHED();
// For other items with text (e.g., bidi controls), use their text to // For other items with text (e.g., bidi controls), use their text to
...@@ -1494,6 +1492,21 @@ void NGLineBreaker::HandleFloat(const NGInlineItem& item, ...@@ -1494,6 +1492,21 @@ void NGLineBreaker::HandleFloat(const NGInlineItem& item,
} }
} }
void NGLineBreaker::HandleOutOfFlowPositioned(const NGInlineItem& item,
NGLineInfo* line_info) {
DCHECK_EQ(item.Type(), NGInlineItem::kOutOfFlowPositioned);
NGInlineItemResult* item_result = AddItem(item, line_info);
// Break opportunity after OOF is not well-defined nor interoperable. Using
// |kObjectReplacementCharacter|, except when this is a leading OOF, seems to
// produce reasonable and interoperable results in common cases.
DCHECK(!item_result->can_break_after);
if (item_result->should_create_line_box)
ComputeCanBreakAfter(item_result, auto_wrap_, break_iterator_);
MoveToNextOf(item);
}
bool NGLineBreaker::ComputeOpenTagResult( bool NGLineBreaker::ComputeOpenTagResult(
const NGInlineItem& item, const NGInlineItem& item,
const NGConstraintSpace& constraint_space, const NGConstraintSpace& constraint_space,
......
...@@ -171,6 +171,7 @@ class CORE_EXPORT NGLineBreaker { ...@@ -171,6 +171,7 @@ class CORE_EXPORT NGLineBreaker {
const NGInlineItemResult& item_result) const; const NGInlineItemResult& item_result) const;
void HandleFloat(const NGInlineItem&, void HandleFloat(const NGInlineItem&,
NGLineInfo*); NGLineInfo*);
void HandleOutOfFlowPositioned(const NGInlineItem&, NGLineInfo*);
void HandleOpenTag(const NGInlineItem&, NGLineInfo*); void HandleOpenTag(const NGInlineItem&, NGLineInfo*);
void HandleCloseTag(const NGInlineItem&, NGLineInfo*); void HandleCloseTag(const NGInlineItem&, NGLineInfo*);
......
<!DOCTYPE html>
<style>
div {
text-indent: 3ch;
}
</style>
<body>
<div>123456</div>
</body>
<!DOCTYPE html>
<title>CSS Test: Line wrapping after leading out-of-flow objects</title>
<link rel="author" title="Koji Ishii" href="mailto:kojii@chromium.org">
<link rel="help" href="https://drafts.csswg.org/css2/visuren.html#propdef-position">
<style>
div {
width: 5ch;
/* When the line was broken after the leading OOF, it is hardly visible
because it is an empty line box.
Applying `text-indent` can make it visible; if the line is indented,
it is the first line, proving the line did not wrap. */
text-indent: 3ch;
}
</style>
<body>
<div><span style="position: absolute"></span>123456</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