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

[LayoutNG] Allow overflow-/word-wrap to work with keep-all

When `word-break: break-all` or `keep-all` is specified, this
patch fixes `overflow-/word-wrap: break-word` to be effective.

Before this patch, it was forced to be `normal`.

Bug: 1001378
Change-Id: I73f5956a6856f2cbd0944461a0aa7a2929e722cc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1806162
Commit-Queue: Koji Ishii <kojii@chromium.org>
Commit-Queue: Emil A Eklund <eae@chromium.org>
Reviewed-by: default avatarEmil A Eklund <eae@chromium.org>
Cr-Commit-Position: refs/heads/master@{#696724}
parent fb6c3f77
...@@ -1809,26 +1809,26 @@ void NGLineBreaker::SetCurrentStyle(const ComputedStyle& style) { ...@@ -1809,26 +1809,26 @@ void NGLineBreaker::SetCurrentStyle(const ComputedStyle& style) {
if (auto_wrap_) { if (auto_wrap_) {
LineBreakType line_break_type; LineBreakType line_break_type;
switch (style.WordBreak()) { EWordBreak word_break = style.WordBreak();
switch (word_break) {
case EWordBreak::kNormal: case EWordBreak::kNormal:
break_anywhere_if_overflow_ =
style.OverflowWrap() == EOverflowWrap::kBreakWord &&
mode_ == NGLineBreakerMode::kContent;
line_break_type = LineBreakType::kNormal; line_break_type = LineBreakType::kNormal;
break; break;
case EWordBreak::kBreakAll: case EWordBreak::kBreakAll:
break_anywhere_if_overflow_ = false;
line_break_type = LineBreakType::kBreakAll; line_break_type = LineBreakType::kBreakAll;
break; break;
case EWordBreak::kBreakWord: case EWordBreak::kBreakWord:
break_anywhere_if_overflow_ = true;
line_break_type = LineBreakType::kNormal; line_break_type = LineBreakType::kNormal;
break; break;
case EWordBreak::kKeepAll: case EWordBreak::kKeepAll:
break_anywhere_if_overflow_ = false;
line_break_type = LineBreakType::kKeepAll; line_break_type = LineBreakType::kKeepAll;
break; break;
} }
break_anywhere_if_overflow_ =
word_break == EWordBreak::kBreakWord ||
// `overflow-/word-wrap: break-word` affects layout but not min-content.
(style.OverflowWrap() == EOverflowWrap::kBreakWord &&
mode_ == NGLineBreakerMode::kContent);
if (UNLIKELY((override_break_anywhere_ && break_anywhere_if_overflow_) || if (UNLIKELY((override_break_anywhere_ && break_anywhere_if_overflow_) ||
style.GetLineBreak() == LineBreak::kAnywhere)) { style.GetLineBreak() == LineBreak::kAnywhere)) {
line_break_type = LineBreakType::kBreakCharacter; line_break_type = LineBreakType::kBreakCharacter;
......
<!DOCTYPE html>
<title>CSS Test: `break-word` should work with `word-break: keep-all`</title>
<link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-overflow-wrap-break-word">
<link rel="author" title="Koji Ishii" href="mailto:kojii@chromium.org">
<meta charset="utf-8">
<style>
div {
overflow-wrap: break-word;
word-break: keep-all;
font-size: 10px;
width: 7ch;
line-height: 20px;
background: lightgray;
margin-bottom: 1em;
}
</style>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<body>
<div>0000000000</div>
<div>헬로우월드헬로우월드헬로우월드헬로우월드헬로우월드</div>
<script>
for (let e of document.getElementsByTagName('div')) {
test(() => {
// All boxes should wrap to more than 1 line.
assert_greater_than(e.offsetHeight, 20);
}, e.textContent);
}
</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