Commit 3ae14708 authored by Koji Ishii's avatar Koji Ishii Committed by Commit Bot

Fix to wrap at the hyphenation point at the line end edge

|ShapingLineBreaker::Hyphenate| should look for hyphenation
points at the line edge or after, but it did not include the
character at the line edge. This patch fixes this.

This occurs often when `fit-content` inline size is used.

Also changes the test to use Ahem because Win uses U+2010
HYPHEN instead of U+002D HYPHEN-MINUS, but other platforms
use U+002D.

Bug: 1140738
Change-Id: I5e1157de07b58edddb92c6c80ff8df460fc064b3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2485352Reviewed-by: default avatarYoshifumi Inoue <yosin@chromium.org>
Commit-Queue: Koji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#819201}
parent b9d174e5
...@@ -98,21 +98,21 @@ unsigned ShapingLineBreaker::Hyphenate(unsigned offset, ...@@ -98,21 +98,21 @@ unsigned ShapingLineBreaker::Hyphenate(unsigned offset,
return 0; return 0;
const String& text = GetText(); const String& text = GetText();
const StringView word(text, word_start, word_len);
const unsigned word_offset = offset - word_start;
if (backwards) { if (backwards) {
unsigned before_index = offset - word_start; if (word_offset < Hyphenation::kMinimumPrefixLength)
if (before_index <= Hyphenation::kMinimumPrefixLength)
return 0; return 0;
unsigned prefix_length = hyphenation_->LastHyphenLocation( unsigned prefix_length =
StringView(text, word_start, word_len), before_index); hyphenation_->LastHyphenLocation(word, word_offset + 1);
DCHECK(!prefix_length || prefix_length < before_index); DCHECK(!prefix_length || prefix_length <= word_offset);
return prefix_length; return prefix_length;
} else { } else {
unsigned after_index = offset - word_start; if (word_len - word_offset < Hyphenation::kMinimumSuffixLength)
if (word_len <= after_index + Hyphenation::kMinimumSuffixLength)
return 0; return 0;
unsigned prefix_length = hyphenation_->FirstHyphenLocation( unsigned prefix_length = hyphenation_->FirstHyphenLocation(
StringView(text, word_start, word_len), after_index); word, word_offset ? word_offset - 1 : 0);
DCHECK(!prefix_length || prefix_length > after_index); DCHECK(!prefix_length || prefix_length >= word_offset);
return prefix_length; return prefix_length;
} }
} }
......
...@@ -1643,7 +1643,6 @@ crbug.com/639223 external/wpt/css/css-text/hyphens/hyphens-shaping-002.html [ Fa ...@@ -1643,7 +1643,6 @@ crbug.com/639223 external/wpt/css/css-text/hyphens/hyphens-shaping-002.html [ Fa
crbug.com/639223 external/wpt/css/css-text/hyphens/hyphens-span-001.html [ Failure ] crbug.com/639223 external/wpt/css/css-text/hyphens/hyphens-span-001.html [ Failure ]
crbug.com/639223 external/wpt/css/css-text/hyphens/hyphens-span-002.html [ Failure ] crbug.com/639223 external/wpt/css/css-text/hyphens/hyphens-span-002.html [ Failure ]
crbug.com/639223 external/wpt/css/css-text/hyphens/shy-styling-001.html [ Failure ] crbug.com/639223 external/wpt/css/css-text/hyphens/shy-styling-001.html [ Failure ]
crbug.com/870219 virtual/text-antialias/hyphens/hyphen-min-preferred-width-mock.html [ Failure ]
crbug.com/870219 virtual/text-antialias/hyphens/hyphens-auto-mock.html [ Failure ] crbug.com/870219 virtual/text-antialias/hyphens/hyphens-auto-mock.html [ Failure ]
crbug.com/1139693 virtual/text-antialias/hyphens/midword-break-priority.html [ Failure ] crbug.com/1139693 virtual/text-antialias/hyphens/midword-break-priority.html [ Failure ]
......
<!DOCTYPE html> <!DOCTYPE html>
<script src="../../../resources/ahem.js"></script>
<style> <style>
div { div {
display: inline-block; display: inline-block;
font: 20px Times; font: 20px Ahem;
} }
</style> </style>
<div lang="en-us"> <div lang="en-us">
......
<!DOCTYPE html> <!DOCTYPE html>
<script src="../../../resources/ahem.js"></script>
<style> <style>
div { div {
font: 20px Times; font: 20px Ahem;
-webkit-hyphens: auto; -webkit-hyphens: auto;
hyphens: auto; hyphens: auto;
} }
......
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