Changeset 254402 in webkit
- Timestamp:
- Jan 11, 2020 3:47:56 PM (4 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r254400 r254402 1 2020-01-11 Zalan Butjtas <zalan@apple.com> 2 3 [LFC][IFC] Visually collapse hanging pre-wrap content. 4 https://bugs.webkit.org/show_bug.cgi?id=206133 5 <rdar://problem/58505750> 6 7 Reviewed by Antti Koivisto. 8 9 This change is to comply with other rendering engines when it comes to visually collapsing hanging pre-wrap content. 10 11 https://www.w3.org/TR/css-text-3/#white-space-phase-2 12 "If white-space is set to pre-wrap, the UA must (unconditionally) hang this sequence, unless the sequence 13 is followed by a forced line break, in which case it must conditionally hang the sequence is instead. 14 It ___may___ also visually collapse the character advance widths of any that would otherwise overflow." 15 16 * layout/inlineformatting/InlineLineBuilder.cpp: 17 (WebCore::Layout::LineBuilder::close): 18 (WebCore::Layout::LineBuilder::visuallyCollapsePreWrapOverflowContent): 19 * layout/inlineformatting/InlineLineBuilder.h: 20 (WebCore::Layout::LineBuilder::InlineItemRun::adjustLogicalWidth): 21 1 22 2020-01-10 Dean Jackson <dino@apple.com> 2 23 -
trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.cpp
r254087 r254402 235 235 // 3. Align merged runs both vertically and horizontally. 236 236 removeTrailingCollapsibleContent(); 237 visuallyCollapsePreWrapOverflowContent(); 237 238 auto hangingContent = collectHangingContent(isLastLineWithInlineContent); 238 239 … … 509 510 } 510 511 512 void LineBuilder::visuallyCollapsePreWrapOverflowContent() 513 { 514 ASSERT(m_collapsibleContent.isEmpty()); 515 // If white-space is set to pre-wrap, the UA must 516 // ... 517 // It may also visually collapse the character advance widths of any that would otherwise overflow. 518 auto overflowWidth = -availableWidth(); 519 if (overflowWidth <= 0) 520 return; 521 // Let's just find the trailing pre-wrap whitespace content for now (e.g check if there are multiple trailing runs with 522 // different set of white-space values and decide if the in-between pre-wrap content should be collapsed as well.) 523 InlineLayoutUnit trimmedContentWidth = 0; 524 for (auto& inlineItemRun : WTF::makeReversedRange(m_inlineItemRuns)) { 525 if (inlineItemRun.style().whiteSpace() != WhiteSpace::PreWrap) { 526 // We are only interested in pre-wrap trailing content. 527 break; 528 } 529 auto preWrapVisuallyCollapsibleInlineItem = inlineItemRun.isContainerStart() || inlineItemRun.isContainerEnd() || inlineItemRun.isWhitespace(); 530 if (!preWrapVisuallyCollapsibleInlineItem) 531 break; 532 auto runLogicalWidth = inlineItemRun.logicalWidth(); 533 // Never partially collapse inline container start/end items. 534 auto isPartialCollapsingAllowed = inlineItemRun.isText(); 535 // FIXME: We should always collapse the run at a glyph boundary as the spec indicates: "collapse the character advance widths of any that would otherwise overflow" 536 auto runLogicalWidthAfterCollapsing = isPartialCollapsingAllowed ? std::max<InlineLayoutUnit>(0, runLogicalWidth - overflowWidth) : 0; 537 auto trimmed = runLogicalWidth - runLogicalWidthAfterCollapsing; 538 trimmedContentWidth += trimmed; 539 overflowWidth -= trimmed; 540 inlineItemRun.adjustLogicalWidth(runLogicalWidthAfterCollapsing); 541 if (overflowWidth <= 0) 542 break; 543 } 544 m_lineBox.shrinkHorizontally(trimmedContentWidth); 545 } 546 511 547 HangingContent LineBuilder::collectHangingContent(IsLastLineWithInlineContent isLastLineWithInlineContent) 512 548 { -
trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.h
r254032 r254402 143 143 144 144 void removeTrailingCollapsibleContent(); 145 void visuallyCollapsePreWrapOverflowContent(); 145 146 HangingContent collectHangingContent(IsLastLineWithInlineContent); 146 147 void alignHorizontally(RunList&, const HangingContent&, IsLastLineWithInlineContent); … … 180 181 181 182 void moveHorizontally(InlineLayoutUnit offset) { m_logicalLeft += offset; } 183 void adjustLogicalWidth(InlineLayoutUnit adjustedWidth) { m_logicalWidth = adjustedWidth; } 182 184 183 185 bool isCollapsibleWhitespace() const;
Note: See TracChangeset
for help on using the changeset viewer.