Changeset 251848 in webkit
- Timestamp:
- Oct 31, 2019 8:40:10 AM (4 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r251846 r251848 1 2019-10-31 Zalan Bujtas <zalan@apple.com> 2 3 [LFC][IFC] Do not merge completely collapsed run with the previous run 4 https://bugs.webkit.org/show_bug.cgi?id=203658 5 <rdar://problem/56769334> 6 7 Reviewed by Antti Koivisto. 8 9 When a whitespace run is completely collapsed (and visually empty), we should not try to merge it with previous text runs. 10 E.g. [before \nafter] -> [before][ ][\n][after] -> [before ][][after] -> [before ][after] 11 ^content ^inline items ^line runs ^display runs 12 13 * layout/inlineformatting/InlineLine.cpp: 14 (WebCore::Layout::Line::close): 15 * layout/inlineformatting/InlineLine.h: 16 (WebCore::Layout::Line::Run::hasTrailingCollapsedContent const): 17 (WebCore::Layout::Line::Run::canBeExtended const): Deleted. 18 1 19 2019-10-31 Zalan Bujtas <zalan@apple.com> 2 20 -
trunk/Source/WebCore/layout/inlineformatting/InlineLine.cpp
r251846 r251848 116 116 unsigned index = 1; 117 117 while (index < m_runList.size()) { 118 auto canMergeRuns = [](const auto& previousRun, const auto& currentRun) { 119 // Do not merge runs across inline boxes (<span>foo</span><span>bar</span>) 120 if (&previousRun->layoutBox() != ¤tRun->layoutBox()) 121 return false; 122 // Only text content can be merged. 123 if (!previousRun->isText() || !currentRun->isText()) 124 return false; 125 // Merged content needs to be continuous. 126 if (previousRun->hasTrailingCollapsedContent()) 127 return false; 128 // Visually empty runs are ignored. 129 if (currentRun->isCollapsedToZeroAdvanceWidth()) 130 return false; 131 return true; 132 }; 118 133 auto& previousRun = m_runList[index - 1]; 119 if (!previousRun->canBeExtended()) { 120 ++index; 134 auto& currentRun = m_runList[index]; 135 if (canMergeRuns(previousRun, currentRun)) { 136 previousRun->expand(*currentRun); 137 m_runList.remove(index); 121 138 continue; 122 139 } 123 auto& currentRun = m_runList[index]; 124 // Do not merge runs from different boxes (<span>foo</span><span>bar</span>) 125 // or within the same layout box but with preserved \n 126 // (<span>text\n<span <- both the "text" and "\" belong to the same layout box) 127 auto canAppendToPreviousRun = currentRun->isText() && ¤tRun->layoutBox() == &previousRun->layoutBox(); 128 if (!canAppendToPreviousRun) { 129 ++index; 130 continue; 131 } 132 // Only text content can be extended atm. 133 ASSERT(previousRun->isText()); 134 ASSERT(currentRun->isText()); 135 previousRun->expand(*currentRun); 136 m_runList.remove(index); 140 ++index; 137 141 } 138 142 -
trunk/Source/WebCore/layout/inlineformatting/InlineLine.h
r251845 r251848 95 95 96 96 bool isCollapsible() const { return m_inlineItem.isText() && downcast<InlineTextItem>(m_inlineItem).isCollapsible(); } 97 bool hasTrailingCollapsedContent() const { return m_hasTrailingCollapsedContent; } 97 98 bool isWhitespace() const; 98 bool canBeExtended() const;99 99 100 100 const InlineItem& m_inlineItem; … … 178 178 } 179 179 180 inline bool Line::Run::canBeExtended() const181 {182 return isText() && !m_hasTrailingCollapsedContent;183 }184 185 180 inline bool Line::Run::isCollapsedToZeroAdvanceWidth() const 186 181 {
Note: See TracChangeset
for help on using the changeset viewer.