Bug 167446 - Simple line layout: Add support for -webkit-hyphenate-limit-lines
Summary: Simple line layout: Add support for -webkit-hyphenate-limit-lines
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: zalan
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2017-01-25 19:32 PST by zalan
Modified: 2017-01-26 13:21 PST (History)
9 users (show)

See Also:


Attachments
WIP patch (10.19 KB, patch)
2017-01-25 21:09 PST, zalan
no flags Details | Formatted Diff | Diff
Patch (25.78 KB, patch)
2017-01-26 11:13 PST, zalan
no flags Details | Formatted Diff | Diff
Patch (30.06 KB, patch)
2017-01-26 12:42 PST, zalan
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.