Changeset 252952 in webkit
- Timestamp:
- Nov 29, 2019 4:03:08 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r252951 r252952 1 2019-11-29 Zalan Bujtas <zalan@apple.com> 2 3 [LFC][IFC] Add support for hyphenate-limit-before and hyphenate-limit-after 4 https://bugs.webkit.org/show_bug.cgi?id=204710 5 <rdar://problem/57535210> 6 7 Reviewed by Antti Koivisto. 8 9 * layout/inlineformatting/InlineLineBreaker.cpp: 10 (WebCore::Layout::LineBreaker::tryBreakingTextRun const): 11 1 12 2019-11-29 Commit Queue <commit-queue@webkit.org> 2 13 -
trunk/Source/WebCore/layout/inlineformatting/InlineLineBreaker.cpp
r252947 r252952 148 148 return { }; 149 149 150 auto runLength = inlineTextItem.length(); 151 unsigned limitBefore = style.hyphenationLimitBefore() == RenderStyle::initialHyphenationLimitBefore() ? 0 : style.hyphenationLimitBefore(); 152 unsigned limitAfter = style.hyphenationLimitAfter() == RenderStyle::initialHyphenationLimitAfter() ? 0 : style.hyphenationLimitAfter(); 153 // Check if this run can accommodate the before/after limits at all before start measuring text. 154 if (limitBefore >= runLength || limitAfter >= runLength || limitBefore + limitAfter > runLength) 155 return { }; 156 150 157 auto& fontCascade = style.fontCascade(); 151 158 // FIXME: We might want to cache the hyphen width. 152 159 auto hyphenWidth = LayoutUnit { fontCascade.width(TextRun { StringView { style.hyphenString() } }) }; 153 160 auto availableWidthExcludingHyphen = availableWidth - hyphenWidth; 154 if (availableWidthExcludingHyphen <= 0 || !enoughWidthForHyphenation(availableWidthExcludingHyphen, fontCascade.pixelSize())) 155 return { }; 156 157 auto splitData = TextUtil::split(inlineTextItem.layoutBox(), inlineTextItem.start(), inlineTextItem.length(), overflowRun.logicalWidth, availableWidthExcludingHyphen, { }); 161 162 // For spaceWidth() see webkit.org/b/169613 163 if (availableWidthExcludingHyphen <= 0 || !enoughWidthForHyphenation(availableWidthExcludingHyphen + fontCascade.spaceWidth(), fontCascade.pixelSize())) 164 return { }; 165 166 auto splitData = TextUtil::split(inlineTextItem.layoutBox(), inlineTextItem.start(), runLength, overflowRun.logicalWidth, availableWidthExcludingHyphen, { }); 167 if (splitData.length < limitBefore) 168 return { }; 169 158 170 auto textContent = inlineTextItem.layoutBox().textContext()->content; 159 auto hyphenBefore = inlineTextItem.start() + splitData.length; 171 // Adjust before index to accommodate the limit-after value (it's the last potential hyphen location in this run). 172 auto hyphenBefore = std::min(splitData.length, runLength - limitAfter) + 1; 160 173 unsigned hyphenLocation = lastHyphenLocation(StringView(textContent).substring(inlineTextItem.start(), inlineTextItem.length()), hyphenBefore, style.locale()); 161 if (!hyphenLocation )174 if (!hyphenLocation || hyphenLocation < limitBefore) 162 175 return { }; 163 176 return SplitLengthAndWidth { hyphenLocation, TextUtil::width(inlineTextItem.layoutBox(), inlineTextItem.start(), hyphenLocation) }; -
trunk/Tools/ChangeLog
r252948 r252952 1 2019-11-29 Zalan Bujtas <zalan@apple.com> 2 3 [LFC][IFC] Add support for hyphenate-limit-before and hyphenate-limit-after 4 https://bugs.webkit.org/show_bug.cgi?id=204710 5 <rdar://problem/57535210> 6 7 Reviewed by Antti Koivisto. 8 9 * LayoutReloaded/misc/LFC-passing-tests.txt: 10 1 11 2019-11-29 Antti Koivisto <antti@apple.com> 2 12 -
trunk/Tools/LayoutReloaded/misc/LFC-passing-tests.txt
r252916 r252952 841 841 fast/text/system-font-zero-size.html 842 842 fast/text/system-ui-chinese-bold-fallback.html 843 fast/text/simple-line-layout-hyphen-limit-after.html 844 fast/text/simple-line-layout-hyphen-limit-before.html 843 845 fast/text/tab-with-kerning.html 844 846 fast/text/text-combine-first-line-crash.html
Note: See TracChangeset
for help on using the changeset viewer.