Changeset 251633 in webkit
- Timestamp:
- Oct 26, 2019, 5:53:00 AM (7 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 5 edited
-
ChangeLog (modified) (1 diff)
-
layout/inlineformatting/InlineFormattingContext.cpp (modified) (2 diffs)
-
layout/inlineformatting/InlineFormattingContextQuirks.cpp (modified) (1 diff)
-
layout/inlineformatting/InlineLine.cpp (modified) (6 diffs)
-
layout/inlineformatting/InlineLine.h (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r251632 r251633 1 2019-10-26 Zalan Bujtas <zalan@apple.com> 2 3 [LFC][IFC] Completely collapsed runs should not have advance width 4 https://bugs.webkit.org/show_bug.cgi?id=203457 5 <rdar://problem/56645024> 6 7 Reviewed by Antti Koivisto. 8 9 Let's reset the advance width for completely collapsed runs (any a collapsible space immediatelly following another 10 collapsible space). 11 https://drafts.csswg.org/css-text-3/#white-space-phase-1 12 13 * layout/inlineformatting/InlineFormattingContext.cpp: 14 (WebCore::Layout::InlineFormattingContext::setDisplayBoxesForLine): 15 * layout/inlineformatting/InlineFormattingContextQuirks.cpp: 16 (WebCore::Layout::InlineFormattingContext::Quirks::lineDescentNeedsCollapsing const): 17 * layout/inlineformatting/InlineLine.cpp: 18 (WebCore::Layout::Line::Run::canBeExtended const): 19 (WebCore::Layout::Line::isVisuallyEmpty const): 20 (WebCore::Layout::Line::removeTrailingTrimmableContent): 21 (WebCore::Layout::Line::trailingTrimmableWidth const): 22 (WebCore::Layout::Line::appendTextContent): 23 * layout/inlineformatting/InlineLine.h: 24 (WebCore::Layout::Line::Run::expand): 25 (WebCore::Layout::Line::Run::isCollapsedToZeroAdvanceWidth const): 26 (WebCore::Layout::Line::Run::setCollapsesToZeroAdvanceWidth): 27 (WebCore::Layout::Line::Run::isVisuallyEmpty const): Deleted. 28 (WebCore::Layout::Line::Run::setVisuallyIsEmpty): Deleted. 29 1 30 2019-10-26 Antti Koivisto <antti@apple.com> 2 31 -
trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp
r251617 r251633 436 436 if (lineRun->isContainerStart() || lineRun->isContainerEnd()) 437 437 continue; 438 // Co llapsed line runs don't generate display runs.439 if (lineRun->is VisuallyEmpty())438 // Completely collapsed line runs don't generate display runs. 439 if (lineRun->isCollapsedToZeroAdvanceWidth()) 440 440 continue; 441 441 formattingState.addInlineRun(lineRun->displayRun(), currentLine); … … 491 491 // FIXME take content breaking into account when part of the layout box is on the previous line. 492 492 auto firstInlineRunForLayoutBox = !previousLineRun || &previousLineRun->layoutBox() != &layoutBox; 493 auto logicalWidth = lineRun->isVisuallyEmpty() ? LayoutUnit() : logicalRect.width();494 493 if (firstInlineRunForLayoutBox) { 495 494 // Setup display box for the associated layout box. 496 495 displayBox.setTopLeft(logicalRect.topLeft()); 497 displayBox.setContentBoxWidth(logical Width);496 displayBox.setContentBoxWidth(logicalRect.width()); 498 497 displayBox.setContentBoxHeight(logicalRect.height()); 499 498 } else { 500 499 // FIXME fix it for multirun/multiline. 501 displayBox.setContentBoxWidth(displayBox.contentBoxWidth() + logical Width);500 displayBox.setContentBoxWidth(displayBox.contentBoxWidth() + logicalRect.width()); 502 501 } 503 502 continue; -
trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextQuirks.cpp
r251590 r251633 51 51 return false; 52 52 if (run->isText()) { 53 if (!run->is VisuallyEmpty())53 if (!run->isCollapsedToZeroAdvanceWidth()) 54 54 return false; 55 55 continue; -
trunk/Source/WebCore/layout/inlineformatting/InlineLine.cpp
r251590 r251633 56 56 return false; 57 57 // Non-collapsed text runs can be merged into one continuous run. 58 if (is VisuallyEmpty())58 if (isCollapsedToZeroAdvanceWidth()) 59 59 return false; 60 60 return !isCollapsed(); … … 121 121 continue; 122 122 } 123 if (!run->isText() || !run->is VisuallyEmpty())123 if (!run->isText() || !run->isCollapsedToZeroAdvanceWidth()) 124 124 return false; 125 125 } … … 273 273 for (auto* trimmableRun : m_trimmableContent) { 274 274 ASSERT(trimmableRun->isText()); 275 trimmableRun->setVisuallyIsEmpty();275 // FIXME: We might need to be able to differentiate between trimmed and collapsed runs. 276 276 trimmableWidth += trimmableRun->logicalRect().width(); 277 trimmableRun->setCollapsesToZeroAdvanceWidth(); 277 278 } 278 279 m_lineBox.shrinkHorizontally(trimmableWidth); … … 297 298 { 298 299 LayoutUnit trimmableWidth; 299 for (auto* trimmableRun : m_trimmableContent) { 300 ASSERT(!trimmableRun->isVisuallyEmpty()); 300 for (auto* trimmableRun : m_trimmableContent) 301 301 trimmableWidth += trimmableRun->logicalRect().width(); 302 }303 302 return trimmableWidth; 304 303 } … … 367 366 if (run->isBox()) 368 367 return false; 369 // When the previous text run is collapsed, this collapsible run collapses completely. 368 // https://drafts.csswg.org/css-text-3/#white-space-phase-1 369 // Any collapsible space immediately following another collapsible space—even one outside the boundary of the inline containing that space, 370 // provided both spaces are within the same inline formatting context—is collapsed to have zero advance width. 371 // : "<span> </span> " <- the trailing whitespace collapses completely. 372 // Not that when the inline container has preserve whitespace style, "<span style="white-space: pre"> </span> " <- this whitespace stays around. 370 373 if (run->isText()) 371 374 return run->isCollapsed(); 372 // Collapsing works across inline containers: "<span> </span> " <- the trailing whitespace collapses completely.373 // Not that when the inline container has preserve whitespace style, "<span style="white-space: pre"> </span> " <- this whitespace stays around.374 375 ASSERT(run->isContainerStart() || run->isContainerEnd()); 375 376 } … … 389 390 auto contentLength = collapseRun ? 1 : inlineItem.length(); 390 391 auto textContent = inlineItem.layoutBox().textContent().substring(contentStart, contentLength); 391 auto lineItem = makeUnique<Run>(inlineItem, Display::Run { inlineItem.style(), logicalRect, Display::Run::TextContext { contentStart, contentLength, textContent } }); 392 393 auto isVisuallyEmpty = willCollapseCompletely(); 394 if (collapseRun) 395 lineItem->setIsCollapsed(); 396 if (isVisuallyEmpty) 397 lineItem->setVisuallyIsEmpty(); 398 else if (isTrimmable) 399 m_trimmableContent.add(lineItem.get()); 400 401 m_runList.append(WTFMove(lineItem)); 402 // Collapsed line items don't contribute to the line width. 403 if (!isVisuallyEmpty) 404 m_lineBox.expandHorizontally(logicalWidth); 392 auto lineRun = makeUnique<Run>(inlineItem, Display::Run { inlineItem.style(), logicalRect, Display::Run::TextContext { contentStart, contentLength, textContent } }); 393 394 auto collapsesToZeroAdvanceWidth = willCollapseCompletely(); 395 if (collapsesToZeroAdvanceWidth) 396 lineRun->setCollapsesToZeroAdvanceWidth(); 397 else if (collapseRun) 398 lineRun->setIsCollapsed(); 399 if (isTrimmable) 400 m_trimmableContent.add(lineRun.get()); 401 402 m_lineBox.expandHorizontally(lineRun->logicalRect().width()); 403 m_runList.append(WTFMove(lineRun)); 405 404 } 406 405 -
trunk/Source/WebCore/layout/inlineformatting/InlineLine.h
r251590 r251633 74 74 75 75 const Display::Rect& logicalRect() const { return m_displayRun.logicalRect(); } 76 bool is VisuallyEmpty() const { return m_isVisuallyEmpty; }76 bool isCollapsedToZeroAdvanceWidth() const; 77 77 bool isCollapsed() const { return m_isCollapsed; } 78 78 … … 91 91 void expand(const Run&); 92 92 93 void setVisuallyIsEmpty() { m_isVisuallyEmpty = true; }94 93 void setIsCollapsed() { m_isCollapsed = true; } 94 void setCollapsesToZeroAdvanceWidth(); 95 95 96 96 bool isWhitespace() const; … … 100 100 Display::Run m_displayRun; 101 101 bool m_isCollapsed { false }; 102 bool m_ isVisuallyEmpty{ false };102 bool m_collapsedToZeroAdvanceWidth { false }; 103 103 }; 104 104 using RunList = Vector<std::unique_ptr<Run>>; … … 155 155 ASSERT(isText()); 156 156 ASSERT(other.isText()); 157 ASSERT(!isCollapsedToZeroAdvanceWidth()); 157 158 158 159 auto& otherDisplayRun = other.displayRun(); … … 161 162 } 162 163 164 inline bool Line::Run::isCollapsedToZeroAdvanceWidth() const 165 { 166 ASSERT(!m_collapsedToZeroAdvanceWidth || !m_displayRun.logicalWidth()); 167 return m_collapsedToZeroAdvanceWidth; 168 } 169 170 inline void Line::Run::setCollapsesToZeroAdvanceWidth() 171 { 172 m_collapsedToZeroAdvanceWidth = true; 173 m_isCollapsed = true; 174 m_displayRun.setLogicalWidth({ }); 175 } 176 163 177 } 164 178 }
Note:
See TracChangeset
for help on using the changeset viewer.