Summary: | Simple line layout: Add support for -webkit-hyphenate-limit-lines | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Product: | WebKit | Reporter: | zalan <zalan> | ||||||||
Component: | Layout and Rendering | Assignee: | 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
zalan
2017-01-25 19:32:19 PST
Created attachment 299791 [details]
WIP patch
WIP patch.
Created attachment 299822 [details]
Patch
Comment on attachment 299822 [details]
Patch
r=me
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? Created attachment 299835 [details]
Patch
Comment on attachment 299835 [details] Patch Clearing flags on attachment: 299835 Committed r211228: <http://trac.webkit.org/changeset/211228> All reviewed patches have been landed. Closing bug. |