Bug 167446

Summary: Simple line layout: Add support for -webkit-hyphenate-limit-lines
Product: WebKit Reporter: zalan <zalan>
Component: Layout and RenderingAssignee: zalan <zalan>
Status: RESOLVED FIXED    
Severity: Normal CC: bfulgham, commit-queue, esprehn+autocc, glenn, koivisto, kondapallykalyan, mmaxfield, simon.fraser, zalan
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
WIP patch
none
Patch
none
Patch none

Description zalan 2017-01-25 19:32:19 PST
rdar://problem/30194030
Comment 1 zalan 2017-01-25 21:09:21 PST
Created attachment 299791 [details]
WIP patch

WIP patch.
Comment 2 zalan 2017-01-26 11:13:36 PST
Created attachment 299822 [details]
Patch
Comment 3 Antti Koivisto 2017-01-26 11:24:21 PST
Comment on attachment 299822 [details]
Patch

r=me
Comment 4 Antti Koivisto 2017-01-26 11:30:35 PST
Comment on attachment 299822 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=299822&action=review

> Source/WebCore/rendering/SimpleLineLayout.cpp:651
> +        bool shouldHyphenate = style.shouldHyphenate && (!style.hyphenLimitLines || fragmentToSplit.wrappingWithHyphenCounter() < *style.hyphenLimitLines);
> +        if (shouldHyphenate && enoughWidthForHyphenation(availableWidth, style.font.pixelSize())) {
> +            // We might be able to fit the hyphen at the split position.
> +            auto splitPositionWithHyphen = splitPosition;
> +            // Find a splitting position where hyphen surely fits.
> +            auto leftSideWidth = textFragmentIterator.textWidth(start, splitPosition, 0);
> +            while (leftSideWidth + style.hyphenStringWidth > availableWidth) {
> +                if (--splitPositionWithHyphen <= start)
> +                    break; // No space for hyphen.
> +                leftSideWidth -= textFragmentIterator.textWidth(splitPositionWithHyphen, splitPositionWithHyphen + 1, 0);
> +            }
> +            if (splitPositionWithHyphen > start) {
> +                if (auto hyphenPosition = textFragmentIterator.lastHyphenPosition(fragmentToSplit, splitPositionWithHyphen + 1))
> +                    return fragmentToSplit.splitWithHyphen(*hyphenPosition, textFragmentIterator);
> +            }
>          }

Maybe the hyphenation branch could go to a helper function?
Comment 5 zalan 2017-01-26 12:42:46 PST
Created attachment 299835 [details]
Patch
Comment 6 WebKit Commit Bot 2017-01-26 13:20:57 PST
Comment on attachment 299835 [details]
Patch

Clearing flags on attachment: 299835

Committed r211228: <http://trac.webkit.org/changeset/211228>
Comment 7 WebKit Commit Bot 2017-01-26 13:21:01 PST
All reviewed patches have been landed.  Closing bug.