Changeset 252947 in webkit
- Timestamp:
- Nov 29, 2019 10:34:16 AM (4 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r252945 r252947 1 2019-11-29 Zalan Bujtas <zalan@apple.com> 2 3 [LFC][IFC] Add support for simple hyphenation 4 https://bugs.webkit.org/show_bug.cgi?id=204706 5 <rdar://problem/57533803> 6 7 Reviewed by Antti Koivisto. 8 9 This is just -webkit-hyphens: auto, no limit-before/after/lines support yet. 10 11 * layout/Verification.cpp: 12 (WebCore::Layout::LayoutContext::verifyAndOutputMismatchingLayoutTree): 13 * layout/inlineformatting/InlineLineBreaker.cpp: 14 (WebCore::Layout::LineBreaker::tryBreakingTextRun const): 15 * layout/inlineformatting/text/TextUtil.cpp: 16 (WebCore::Layout::TextUtil::split): 17 1 18 2019-11-27 Antoine Quint <graouts@apple.com> 2 19 -
trunk/Source/WebCore/layout/inlineformatting/InlineLineBreaker.cpp
r252941 r252947 29 29 #if ENABLE(LAYOUT_FORMATTING_CONTEXT) 30 30 31 #include "FontCascade.h" 31 32 #include "Hyphenation.h" 32 33 #include "InlineItem.h" … … 131 132 { 132 133 ASSERT(overflowRun.inlineItem.isText()); 133 auto breakWords = overflowRun.inlineItem.style().wordBreak(); 134 auto& style = overflowRun.inlineItem.style(); 135 auto breakWords = style.wordBreak(); 134 136 if (breakWords == WordBreak::KeepAll) 135 137 return { }; … … 140 142 return SplitLengthAndWidth { splitData.length, splitData.logicalWidth }; 141 143 } 142 // FIXME: Find first soft wrap opportunity (e.g. hyphenation) 143 return { }; 144 // Find the hyphen position as follows: 145 // 1. Split the text by taking the hyphen width into account 146 // 2. Find the last hyphen position before the split position 147 if (style.hyphens() != Hyphens::Auto || !canHyphenate(style.locale())) 148 return { }; 149 150 auto& fontCascade = style.fontCascade(); 151 // FIXME: We might want to cache the hyphen width. 152 auto hyphenWidth = LayoutUnit { fontCascade.width(TextRun { StringView { style.hyphenString() } }) }; 153 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, { }); 158 auto textContent = inlineTextItem.layoutBox().textContext()->content; 159 auto hyphenBefore = inlineTextItem.start() + splitData.length; 160 unsigned hyphenLocation = lastHyphenLocation(StringView(textContent).substring(inlineTextItem.start(), inlineTextItem.length()), hyphenBefore, style.locale()); 161 if (!hyphenLocation) 162 return { }; 163 return SplitLengthAndWidth { hyphenLocation, TextUtil::width(inlineTextItem.layoutBox(), inlineTextItem.start(), hyphenLocation) }; 144 164 } 145 165 -
trunk/Source/WebCore/layout/inlineformatting/text/TextUtil.cpp
r252941 r252947 96 96 TextUtil::SplitData TextUtil::split(const Box& inlineBox, unsigned startPosition, unsigned length, LayoutUnit textWidth, LayoutUnit availableWidth, LayoutUnit contentLogicalLeft) 97 97 { 98 // FIXME This should take hypens into account.99 98 ASSERT(availableWidth >= 0); 100 99 auto left = startPosition;
Note: See TracChangeset
for help on using the changeset viewer.