Changeset 211222 in webkit
- Timestamp:
- Jan 26, 2017 11:36:27 AM (7 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r211219 r211222 1 2017-01-26 Zalan Bujtas <zalan@apple.com> 2 3 Simple line layout: Add support for -webkit-hyphenate-limit-after and -webkit-hyphenate-limit-before 4 https://bugs.webkit.org/show_bug.cgi?id=167439 5 <rdar://problem/30180184> 6 7 Reviewed by Antti Koivisto. 8 9 * fast/text/simple-line-layout-hyphen-limit-after.html: Added. 10 * fast/text/simple-line-layout-hyphen-limit-before-expected.html: Added. 11 * fast/text/simple-line-layout-hyphen-limit-before.html: Added. 12 * platform/mac/fast/text/hyphenate-limit-before-after-expected.txt: progression. 13 1 14 2017-01-26 Ryan Haddad <ryanhaddad@apple.com> 2 15 -
trunk/LayoutTests/platform/mac/fast/text/hyphenate-limit-before-after-expected.txt
r199818 r211222 54 54 text run at (434,123) width 4: " " 55 55 RenderBlock {DIV} at (446,84) size 126x60 [border: (3px solid #000000)] 56 RenderText {#text} at (3,3) size 74x5456 RenderText {#text} at (3,3) size 89x54 57 57 text run at (3,3) width 74: "There is re" + hyphen string "-" 58 text run at (3,21) width 60: "markable"59 text run at (3,39) width 61: "evidence."58 text run at (3,21) width 89: "markable evi" + hyphen string "-" 59 text run at (3,39) width 42: "dence." 60 60 RenderText {#text} at (580,123) size 4x18 61 61 text run at (580,123) width 4: " " 62 62 RenderBlock {DIV} at (592,84) size 126x60 [border: (3px solid #000000)] 63 RenderText {#text} at (3,3) size 72x5463 RenderText {#text} at (3,3) size 101x54 64 64 text run at (3,3) width 52: "There is" 65 text run at (3,21) width 72: "remarkable"66 text run at (3,39) width 61: "evidence."65 text run at (3,21) width 101: "remarkable evi" + hyphen string "-" 66 text run at (3,39) width 42: "dence." 67 67 RenderText {#text} at (0,0) size 0x0 -
trunk/Source/WebCore/ChangeLog
r211220 r211222 1 2017-01-26 Zalan Bujtas <zalan@apple.com> 2 3 Simple line layout: Add support for -webkit-hyphenate-limit-after and -webkit-hyphenate-limit-before 4 https://bugs.webkit.org/show_bug.cgi?id=167439 5 <rdar://problem/30180184> 6 7 Reviewed by Antti Koivisto. 8 9 Implement pre and post hyphen length constrains for simple line layout. 10 11 Tests: fast/text/simple-line-layout-hyphen-limit-after.html 12 fast/text/simple-line-layout-hyphen-limit-before.html 13 14 * rendering/SimpleLineLayout.cpp: 15 (WebCore::SimpleLineLayout::canUseForStyle): 16 (WebCore::SimpleLineLayout::printReason): 17 * rendering/SimpleLineLayoutTextFragmentIterator.cpp: 18 (WebCore::SimpleLineLayout::TextFragmentIterator::Style::Style): Same as normal line layout default values. 19 (WebCore::SimpleLineLayout::TextFragmentIterator::lastHyphenPosition): 20 * rendering/SimpleLineLayoutTextFragmentIterator.h: 21 1 22 2017-01-26 Brady Eidson <beidson@apple.com> 2 23 -
trunk/Source/WebCore/rendering/SimpleLineLayout.cpp
r211108 r211222 87 87 FlowHasLineAlignEdges = 1LLU << 21, 88 88 FlowHasLineSnap = 1LLU << 22, 89 FlowHasHypensLi mit= 1LLU << 23,89 FlowHasHypensLineLimit = 1LLU << 23, 90 90 FlowHasTextEmphasisFillOrMark = 1LLU << 24, 91 91 FlowHasTextShadow = 1LLU << 25, … … 238 238 if (style.lineSnap() != LineSnapNone) 239 239 SET_REASON_AND_RETURN_IF_NEEDED(FlowHasLineSnap, reasons, includeReasons); 240 if (style.hyphenationLimitBefore() != RenderStyle::initialHyphenationLimitBefore() 241 || style.hyphenationLimitAfter() != RenderStyle::initialHyphenationLimitAfter() 242 || style.hyphenationLimitLines() != RenderStyle::initialHyphenationLimitLines()) 243 SET_REASON_AND_RETURN_IF_NEEDED(FlowHasHypensLimit, reasons, includeReasons); 240 if (style.hyphenationLimitLines() != RenderStyle::initialHyphenationLimitLines()) 241 SET_REASON_AND_RETURN_IF_NEEDED(FlowHasHypensLineLimit, reasons, includeReasons); 244 242 if (style.textEmphasisFill() != TextEmphasisFillFilled || style.textEmphasisMark() != TextEmphasisMarkNone) 245 243 SET_REASON_AND_RETURN_IF_NEEDED(FlowHasTextEmphasisFillOrMark, reasons, includeReasons); … … 992 990 stream << "-webkit-line-snap property"; 993 991 break; 994 case FlowHasHypensLi mit:995 stream << " hyphen-limit-*property";992 case FlowHasHypensLineLimit: 993 stream << "-webkit-hyphenate-limit-lines property"; 996 994 break; 997 995 case FlowHasTextEmphasisFillOrMark: -
trunk/Source/WebCore/rendering/SimpleLineLayoutTextFragmentIterator.cpp
r211108 r211222 50 50 , shouldHyphenate(style.hyphens() == HyphensAuto && canHyphenate(style.locale())) 51 51 , hyphenStringWidth(shouldHyphenate ? font.width(TextRun(style.hyphenString())) : 0) 52 , hyphenLimitBefore(style.hyphenationLimitBefore() < 0 ? 2 : style.hyphenationLimitBefore()) 53 , hyphenLimitAfter(style.hyphenationLimitAfter() < 0 ? 2 : style.hyphenationLimitAfter()) 52 54 , locale(style.locale()) 53 55 { … … 177 179 } 178 180 179 std::optional<unsigned> TextFragmentIterator::lastHyphenPosition(const TextFragmentIterator::TextFragment& run, unsigned before Index) const180 { 181 ASSERT(run.start() < before Index);181 std::optional<unsigned> TextFragmentIterator::lastHyphenPosition(const TextFragmentIterator::TextFragment& run, unsigned before) const 182 { 183 ASSERT(run.start() < before); 182 184 auto& segment = *m_currentSegment; 183 ASSERT(segment.start <= before Index && beforeIndex<= segment.end);185 ASSERT(segment.start <= before && before <= segment.end); 184 186 ASSERT(is<RenderText>(segment.renderer)); 185 187 if (!m_style.shouldHyphenate || run.type() != TextFragment::NonWhitespace) 186 188 return std::nullopt; 187 189 // Check if there are enough characters in the run. 190 unsigned runLength = run.end() - run.start(); 191 if (m_style.hyphenLimitBefore >= runLength || m_style.hyphenLimitAfter >= runLength || m_style.hyphenLimitBefore + m_style.hyphenLimitAfter > runLength) 192 return std::nullopt; 188 193 auto runStart = segment.toSegmentPosition(run.start()); 189 auto before = segment.toSegmentPosition(beforeIndex) - runStart; 194 auto beforeIndex = segment.toSegmentPosition(before) - runStart; 195 if (beforeIndex <= m_style.hyphenLimitBefore) 196 return std::nullopt; 197 // Adjust before index to accommodate the limit-after value (this is the last potential hyphen location). 198 beforeIndex = std::min(beforeIndex, runLength - m_style.hyphenLimitAfter + 1); 190 199 auto substringForHyphenation = StringView(segment.text).substring(runStart, run.end() - run.start()); 191 auto hyphenLocation = lastHyphenLocation(substringForHyphenation, before, m_style.locale); 192 if (hyphenLocation) 200 auto hyphenLocation = lastHyphenLocation(substringForHyphenation, beforeIndex, m_style.locale); 201 // Check if there are enough characters before and after the hyphen. 202 if (hyphenLocation && hyphenLocation >= m_style.hyphenLimitBefore && m_style.hyphenLimitAfter <= (runLength - hyphenLocation)) 193 203 return segment.toRenderPosition(hyphenLocation + runStart); 194 204 return std::nullopt; -
trunk/Source/WebCore/rendering/SimpleLineLayoutTextFragmentIterator.h
r211108 r211222 119 119 bool shouldHyphenate; 120 120 float hyphenStringWidth; 121 unsigned hyphenLimitBefore; 122 unsigned hyphenLimitAfter; 121 123 AtomicString locale; 122 124 };
Note: See TracChangeset
for help on using the changeset viewer.