Skip to content

Commit d2c58dc

Browse files
committed
Merge 3163: 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 [email protected] (cherry picked from commit 14ec221) Bug: 746222 Change-Id: Ic58b58716502f4ae9a06c1e91d2f5de944bc7978 Reviewed-on: https://chromium-review.googlesource.com/581249 Reviewed-by: Dominik Röttsches <[email protected]> Commit-Queue: Koji Ishii <[email protected]> Cr-Original-Commit-Position: refs/heads/master@{#488813} Reviewed-on: https://chromium-review.googlesource.com/587705 Reviewed-by: Koji Ishii <[email protected]> Cr-Commit-Position: refs/branch-heads/3163@{#74} Cr-Branched-From: ff259ba-refs/heads/master@{#488528}
1 parent e87856f commit d2c58dc

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

third_party/WebKit/Source/core/layout/line/BreakingContextInlineHeaders.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -711,8 +711,11 @@ ALWAYS_INLINE bool BreakingContext::ShouldMidWordBreak(
711711
// However, doing so can hit the performance when a "word" is really long,
712712
// such as minimized JS, because the next line will re-shape the rest of the
713713
// word in the current architecture.
714-
// This function is a heuristic optimization to stop at 2em overflow.
715-
float overflow_allowance = 2 * font.GetFontDescription().ComputedSize();
714+
// This function is a heuristic optimization to stop at 4em overflow.
715+
// The longest common ligature is Emoji ZWJ sequence, which ligates 4 Emoji
716+
// into 1 at maximum as of v5.0. This sequence requires 3em overflow, and 1em
717+
// for a rainy day fund.
718+
float overflow_allowance = 4 * font.GetFontDescription().ComputedSize();
716719

717720
width_from_last_breaking_opportunity += char_width;
718721
bool mid_word_break_is_before_surrogate_pair =

0 commit comments

Comments
 (0)