Commit 14ec221a authored by Koji Ishii's avatar Koji Ishii Committed by Commit Bot

Adjust the mid-word-break heuristic limit to 4em for Emoji ZWJ sequence

Mid-word-break algorithm kicks in when CSS properties such as
'word-wrap: break-word' is used. Logically speaking, we should layout
as normal, and break words if overflow occurs.

However, Blink has 2em heuristic limit because of the performance
problem in certain cases. This means Blink measures characters that go
beyond the right edge only up to 2em before it starts mid-word-break.
See the previous CL[1] for more details.

This patch adjusts it to 4em. The longest common ligature is Emoji ZWJ
sequence, and its v5.0[2] can ligate 4 Emoji into 1 at maximum. To
handle this, 3em overflow is needed, and 1em for a rainy day fund.

[1] r403830, https://codereview.chromium.org/2077313002
[2] http://unicode.org/emoji/charts/emoji-zwj-sequences.html

Bug: 746222
Change-Id: Ic58b58716502f4ae9a06c1e91d2f5de944bc7978
Reviewed-on: https://chromium-review.googlesource.com/581249Reviewed-by: default avatarDominik Röttsches <drott@chromium.org>
Commit-Queue: Koji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#488813}
parent 7440d469
...@@ -711,8 +711,11 @@ ALWAYS_INLINE bool BreakingContext::ShouldMidWordBreak( ...@@ -711,8 +711,11 @@ ALWAYS_INLINE bool BreakingContext::ShouldMidWordBreak(
// However, doing so can hit the performance when a "word" is really long, // However, doing so can hit the performance when a "word" is really long,
// such as minimized JS, because the next line will re-shape the rest of the // such as minimized JS, because the next line will re-shape the rest of the
// word in the current architecture. // word in the current architecture.
// This function is a heuristic optimization to stop at 2em overflow. // This function is a heuristic optimization to stop at 4em overflow.
float overflow_allowance = 2 * font.GetFontDescription().ComputedSize(); // The longest common ligature is Emoji ZWJ sequence, which ligates 4 Emoji
// into 1 at maximum as of v5.0. This sequence requires 3em overflow, and 1em
// for a rainy day fund.
float overflow_allowance = 4 * font.GetFontDescription().ComputedSize();
width_from_last_breaking_opportunity += char_width; width_from_last_breaking_opportunity += char_width;
bool mid_word_break_is_before_surrogate_pair = bool mid_word_break_is_before_surrogate_pair =
......
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