Changeset 252915 in webkit
- Timestamp:
- Nov 27, 2019 6:34:02 PM (4 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r252913 r252915 1 2019-11-27 Zalan Bujtas <zalan@apple.com> 2 3 [LFC][IFC] Generate fewer InlineItems when new lines are not preserved 4 https://bugs.webkit.org/show_bug.cgi?id=204653 5 <rdar://problem/57510133> 6 7 Reviewed by Antti Koivisto. 8 9 This patch reduces the number of InlineItems by merging (non-preserved)new lines with neighboring whitespace characters. 10 [text\n\n text] -> [text][ ][text] 11 12 * layout/inlineformatting/InlineTextItem.cpp: 13 (WebCore::Layout::isWhitespaceCharacter): 14 (WebCore::Layout::moveToNextNonWhitespacePosition): 15 (WebCore::Layout::InlineTextItem::createAndAppendTextItems): 16 1 17 2019-11-27 Manuel Rego Casasnovas <rego@igalia.com> 2 18 -
trunk/Source/WebCore/layout/inlineformatting/InlineTextItem.cpp
r252869 r252915 35 35 namespace Layout { 36 36 37 static inline bool isWhitespaceCharacter(char character )37 static inline bool isWhitespaceCharacter(char character, bool preserveNewline) 38 38 { 39 return character == ' ' || character == '\t' ;39 return character == ' ' || character == '\t' || (character == '\n' && !preserveNewline); 40 40 } 41 41 42 static unsigned moveToNextNonWhitespacePosition(const StringView& textContent, unsigned startPosition )42 static unsigned moveToNextNonWhitespacePosition(const StringView& textContent, unsigned startPosition, bool preserveNewline) 43 43 { 44 44 auto nextNonWhiteSpacePosition = startPosition; 45 while (nextNonWhiteSpacePosition < textContent.length() && isWhitespaceCharacter(textContent[nextNonWhiteSpacePosition] ))45 while (nextNonWhiteSpacePosition < textContent.length() && isWhitespaceCharacter(textContent[nextNonWhiteSpacePosition], preserveNewline)) 46 46 ++nextNonWhiteSpacePosition; 47 47 return nextNonWhiteSpacePosition - startPosition; … … 105 105 }; 106 106 107 if (isSegmentBreakCandidate(text[currentPosition])) { 108 // Segment breaks with preserve new line style (white-space: pre, pre-wrap, break-spaces and pre-line) compute to forced line break. 109 inlineContent.append(style.preserveNewline() ? makeUnique<InlineItem>(inlineBox, Type::ForcedLineBreak) 110 : InlineTextItem::createSegmentBreakItem(inlineBox, currentPosition)); 107 // Segment breaks with preserve new line style (white-space: pre, pre-wrap, break-spaces and pre-line) compute to forced line break. 108 if (isSegmentBreakCandidate(text[currentPosition]) && style.preserveNewline()) { 109 inlineContent.append(makeUnique<InlineItem>(inlineBox, Type::ForcedLineBreak)); 111 110 ++currentPosition; 112 111 continue; 113 112 } 114 113 115 if (isWhitespaceCharacter(text[currentPosition] )) {116 auto length = moveToNextNonWhitespacePosition(text, currentPosition );114 if (isWhitespaceCharacter(text[currentPosition], style.preserveNewline())) { 115 auto length = moveToNextNonWhitespacePosition(text, currentPosition, style.preserveNewline()); 117 116 auto simpleSingleWhitespaceContent = textContext.canUseSimplifiedContentMeasuring && (length == 1 || style.collapseWhiteSpace()); 118 117 auto width = simpleSingleWhitespaceContent ? makeOptional(LayoutUnit { font.spaceWidth() }) : inlineItemWidth(currentPosition, length);
Note: See TracChangeset
for help on using the changeset viewer.