Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: bbce6e1c2c581add31f4c3db328cc7f06d5e9fd8
      
https://github.com/WebKit/WebKit/commit/bbce6e1c2c581add31f4c3db328cc7f06d5e9fd8
  Author: Yulun Wu <[email protected]>
  Date:   2025-02-20 (Thu, 20 Feb 2025)

  Changed paths:
    M 
Source/WebCore/layout/formattingContexts/inline/InlineContentConstrainer.cpp
    M Source/WebCore/layout/formattingContexts/inline/InlineContentConstrainer.h

  Log Message:
  -----------
  [text-wrap-style:pretty] lazy hyphenation support.
https://bugs.webkit.org/show_bug.cgi?id=287903
<rdar://145096164>

Reviewed by Alan Baradlay.

This PR adds basic hyphenation support to text-wrap-style:pretty.

our implementation of prettifyRange() uses dynamic programming as described in:

https://www.eprg.org/G53DOC/pdfs/knuth-plass-breaking.pdf

to layout text such that words are not hyphenated and each line is as close to 
its
idealLineWidth as possible, with a maximum positive deviation of:

                        textWrapPrettyStretchability * textWrapPrettyMaxShrink

and a maximum negative deviation of

                        textWrapPrettyShrinkability * textWrapPrettyMaxStretch

However, there are certain cases where it is impossible to layout text according
to these hard limits without hyphenation. This PR add the stripped down lazy
hyphenation approach described in the paper to text-wrap-style:pretty.

This approach tries to lay out as many lines as possible using Knuth-Plass DP
until we are no longer able to find a valid (line length within our min-max 
range)
breaking point without hyphenation. We then perform a one line layout using 
greedy
wrapping to fit the idealLineWidth using:

InlineContentConstrainer::buildOneLineLayout()

We then layout the rest of the text using the Knuth-Plass algorithm while 
performing
single-line greedy layouts as needed.

Note that this PR does not currently handle EntryPretty.lineEnd.offset, which 
will be
added in a follow up PR.

* Source/WebCore/layout/formattingContexts/inline/InlineContentConstrainer.cpp:
(WebCore::Layout::buildPreviousLine):
(WebCore::Layout::InlineContentConstrainer::buildOneLineLayout):

Canonical link: https://commits.webkit.org/290752@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to