Changeset 252923 in webkit
- Timestamp:
- Nov 28, 2019 6:44:32 AM (4 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r252922 r252923 1 2019-11-28 Zalan Bujtas <zalan@apple.com> 2 3 [LFC][IFC] Re-introduce LineBuilder::isVisuallyNonEmpty function 4 https://bugs.webkit.org/show_bug.cgi?id=204658 5 <rdar://problem/57512248> 6 7 Reviewed by Antti Koivisto. 8 9 LineBuilder::isVisuallyNonEmpty() used to loop through the runs an check if the runs are visually empty or not. 10 This time it takes the run as the parameter and decides whether this particular run is visually empty or not. 11 This patch is in preparation for fixing the line's visually-empty state after trimming the trailing runs. 12 13 * layout/inlineformatting/InlineLineBuilder.cpp: 14 (WebCore::Layout::LineBuilder::append): 15 (WebCore::Layout::LineBuilder::appendNonBreakableSpace): 16 (WebCore::Layout::LineBuilder::appendTextContent): 17 (WebCore::Layout::LineBuilder::appendNonReplacedInlineBox): 18 (WebCore::Layout::LineBuilder::appendReplacedInlineBox): 19 (WebCore::Layout::LineBuilder::appendLineBreak): 20 (WebCore::Layout::LineBuilder::isVisuallyNonEmpty const): 21 * layout/inlineformatting/InlineLineBuilder.h: 22 1 23 2019-11-28 Zalan Bujtas <zalan@apple.com> 2 24 -
trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.cpp
r252922 r252923 456 456 { 457 457 if (inlineItem.isText()) 458 return appendTextContent(downcast<InlineTextItem>(inlineItem), logicalWidth); 459 if (inlineItem.isForcedLineBreak()) 460 return appendLineBreak(inlineItem); 461 if (inlineItem.isContainerStart()) 462 return appendInlineContainerStart(inlineItem, logicalWidth); 463 if (inlineItem.isContainerEnd()) 464 return appendInlineContainerEnd(inlineItem, logicalWidth); 465 if (inlineItem.layoutBox().replaced()) 466 return appendReplacedInlineBox(inlineItem, logicalWidth); 467 appendNonReplacedInlineBox(inlineItem, logicalWidth); 458 appendTextContent(downcast<InlineTextItem>(inlineItem), logicalWidth); 459 else if (inlineItem.isForcedLineBreak()) 460 appendLineBreak(inlineItem); 461 else if (inlineItem.isContainerStart()) 462 appendInlineContainerStart(inlineItem, logicalWidth); 463 else if (inlineItem.isContainerEnd()) 464 appendInlineContainerEnd(inlineItem, logicalWidth); 465 else if (inlineItem.layoutBox().replaced()) 466 appendReplacedInlineBox(inlineItem, logicalWidth); 467 else if (inlineItem.isBox()) 468 appendNonReplacedInlineBox(inlineItem, logicalWidth); 469 else 470 ASSERT_NOT_REACHED(); 471 472 // Check if this freshly appended content makes the line visually non-empty. 473 ASSERT(!m_inlineItemRuns.isEmpty()); 474 if (m_lineBox.isConsideredEmpty() && isVisuallyNonEmpty(*m_inlineItemRuns.last())) 475 m_lineBox.setIsConsideredNonEmpty(); 468 476 } 469 477 … … 472 480 m_inlineItemRuns.append(makeUnique<InlineItemRun>(inlineItem, logicalRect)); 473 481 m_lineBox.expandHorizontally(logicalRect.width()); 474 if (logicalRect.width())475 m_lineBox.setIsConsideredNonEmpty();476 482 } 477 483 … … 532 538 if (collapsesToZeroAdvanceWidth) 533 539 lineRun->setCollapsesToZeroAdvanceWidth(); 534 else535 m_lineBox.setIsConsideredNonEmpty();536 540 537 541 if (collapsedRun) … … 551 555 m_inlineItemRuns.append(makeUnique<InlineItemRun>(inlineItem, Display::Rect { 0, contentLogicalWidth() + horizontalMargin.start, logicalWidth, { } })); 552 556 m_lineBox.expandHorizontally(logicalWidth + horizontalMargin.start + horizontalMargin.end); 553 m_lineBox.setIsConsideredNonEmpty();554 557 m_trimmableContent.clear(); 555 if (!layoutBox.establishesFormattingContext() || !boxGeometry.isEmpty())556 m_lineBox.setIsConsideredNonEmpty();557 558 } 558 559 … … 562 563 // FIXME: Surely replaced boxes behave differently. 563 564 appendNonReplacedInlineBox(inlineItem, logicalWidth); 564 m_lineBox.setIsConsideredNonEmpty();565 565 } 566 566 567 567 void LineBuilder::appendLineBreak(const InlineItem& inlineItem) 568 568 { 569 m_lineBox.setIsConsideredNonEmpty();570 569 m_inlineItemRuns.append(makeUnique<InlineItemRun>(inlineItem, Display::Rect { 0, contentLogicalWidth(), { }, { } })); 571 570 } … … 678 677 } 679 678 679 bool LineBuilder::isVisuallyNonEmpty(const InlineItemRun& run) const 680 { 681 if (run.isText()) 682 return !run.isCollapsedToZeroAdvanceWidth(); 683 684 // Note that this does not check whether the inline container has content. It simply checks if the container itself is considered non-empty. 685 if (run.isContainerStart() || run.isContainerEnd()) { 686 if (!run.logicalRect().width()) 687 return false; 688 // Margin does not make the container visually non-empty. Check if it has border or padding. 689 auto& boxGeometry = formattingContext().geometryForBox(run.layoutBox()); 690 if (run.isContainerStart()) 691 return boxGeometry.borderLeft() || (boxGeometry.paddingLeft() && boxGeometry.paddingLeft().value()); 692 return boxGeometry.borderRight() || (boxGeometry.paddingRight() && boxGeometry.paddingRight().value()); 693 } 694 695 if (run.isForcedLineBreak()) 696 return true; 697 698 if (run.isBox()) { 699 if (!run.layoutBox().establishesFormattingContext()) 700 return true; 701 ASSERT(run.layoutBox().isInlineBlockBox()); 702 if (!run.logicalRect().width()) 703 return false; 704 if (m_skipAlignment || formattingContext().geometryForBox(run.layoutBox()).height()) 705 return true; 706 return false; 707 } 708 709 ASSERT_NOT_REACHED(); 710 return false; 711 } 712 680 713 void LineBuilder::TrimmableContent::append(InlineItemRun& inlineItemRun) 681 714 { -
trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.h
r252905 r252923 146 146 void justifyRuns(RunList&) const; 147 147 148 bool isVisuallyNonEmpty(const InlineItemRun&) const; 149 148 150 LayoutState& layoutState() const; 149 151 const InlineFormattingContext& formattingContext() const;
Note: See TracChangeset
for help on using the changeset viewer.