Commit 1f45b474 authored by Koji Ishii's avatar Koji Ishii Committed by Commit Bot

[LayoutNG] Fix NGLineBreaker infinite loop when `break-word`

This patch fixes NGLineBreaker not to go to an infinite loop
when `break-word` and `nowrap` appear in specific
combinations.

Bug: 1001359
Change-Id: I0fb282e96eb29cd65033232329aaa5dc5be3da49
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1792040
Commit-Queue: Emil A Eklund <eae@chromium.org>
Reviewed-by: default avatarEmil A Eklund <eae@chromium.org>
Cr-Commit-Position: refs/heads/master@{#694787}
parent e5570a22
......@@ -1483,16 +1483,19 @@ void NGLineBreaker::HandleCloseTag(const NGInlineItem& item,
MoveToNextOf(item);
// If the line can break after the previous item, prohibit it and allow break
// after this close tag instead.
if (was_auto_wrap) {
const NGInlineItemResults& item_results = line_info->Results();
if (item_results.size() >= 2) {
NGInlineItemResult* last = std::prev(item_result);
// after this close tag instead. Even when the close tag has "nowrap", break
// after it is allowed if the line is breakable after the previous item.
const NGInlineItemResults& item_results = line_info->Results();
if (item_results.size() >= 2) {
NGInlineItemResult* last = std::prev(item_result);
if (was_auto_wrap || last->can_break_after) {
item_result->can_break_after = last->can_break_after;
last->can_break_after = false;
return;
}
return;
}
if (was_auto_wrap)
return;
DCHECK(!item_result->can_break_after);
if (!auto_wrap_)
......
<!DOCTYPE html>
<title>CSS Text Test: A combination of `overflow-wrap: break-word` and `white-space` should not crash</title>
<link rel="help" href="https://crbug.com/1001359">
<link rel="author" title="Koji Ishii" href="mailto:kojii@chromium.org">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
.container {
font-family: sans-serif;
font-size: 14px;
width: 680px;
word-wrap: break-word;
}
spacer {
display: inline-block;
width: 620px;
}
pre-wrap {
white-space: pre-wrap;
}
nowrap {
white-space: nowrap;
}
inline-block {
display: inline-block;
}
</style>
<body>
<div class="container">
<spacer></spacer>
<nowrap><span><pre-wrap><inline-block></inline-block></pre-wrap></span>123456</nowrap>987654321
</div>
<script>
test(() => { });
</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