Changeset 252143 in webkit
- Timestamp:
- Nov 6, 2019 1:02:01 PM (4 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r252136 r252143 1 2019-11-06 Zalan Bujtas <zalan@apple.com> 2 3 [LFC][MarginCollapsing] Add Line::isConsideredEmpty 4 https://bugs.webkit.org/show_bug.cgi?id=203800 5 <rdar://problem/56854192> 6 7 Reviewed by Antti Koivisto. 8 9 https://www.w3.org/TR/CSS22/visuren.html#inline-formatting 10 Line boxes that contain no text, no preserved white space, no inline elements with non-zero margins, padding, or borders, 11 and no other in-flow content (such as images, inline blocks or inline tables), and do not end with a preserved newline 12 must be treated as zero-height line boxes for the purposes of determining the positions of any elements inside of them, 13 and must be treated as not existing for any other purpose. 14 15 Note that it does not necessarily mean visually non-empty line 16 <span style="font-size: 0px">this is still considered non-empty</span> 17 18 * layout/blockformatting/BlockMarginCollapse.cpp: 19 (WebCore::Layout::BlockFormattingContext::MarginCollapse::marginsCollapseThrough const): 20 * layout/inlineformatting/InlineLine.cpp: 21 (WebCore::Layout::Line::appendNonBreakableSpace): 22 (WebCore::Layout::Line::appendTextContent): 23 (WebCore::Layout::Line::appendNonReplacedInlineBox): 24 (WebCore::Layout::Line::appendReplacedInlineBox): 25 (WebCore::Layout::Line::appendLineBreak): 26 * layout/inlineformatting/InlineLineBox.h: 27 (WebCore::Layout::LineBox::isConsideredEmpty const): 28 (WebCore::Layout::LineBox::setIsConsideredNonEmpty): 29 1 30 2019-11-06 Chris Lord <clord@igalia.com> 2 31 -
trunk/Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp
r250064 r252143 403 403 if (!layoutState.hasFormattingState(layoutContainer)) 404 404 return false; 405 auto& formattingState = downcast<InlineFormattingState>(layoutState.establishedFormattingState(layoutContainer)); 406 if (!formattingState.inlineRuns().isEmpty()) 407 return false; 408 // Any float box in this formatting context prevents collapsing through. 409 auto& floats = formattingState.floatingState().floats(); 410 for (auto& floatItem : floats) { 411 if (floatItem.isDescendantOfFormattingRoot(layoutContainer)) 412 return false; 413 } 414 return true; 405 406 auto isConsideredEmpty = [&] { 407 auto& formattingState = downcast<InlineFormattingState>(layoutState.establishedFormattingState(layoutContainer)); 408 for (auto& lineBox : formattingState.lineBoxes()) { 409 if (!lineBox->isConsideredEmpty()) 410 return false; 411 } 412 // Any float box in this formatting context prevents collapsing through. 413 auto& floats = formattingState.floatingState().floats(); 414 for (auto& floatItem : floats) { 415 if (floatItem.isDescendantOfFormattingRoot(layoutContainer)) 416 return false; 417 } 418 return true; 419 }; 420 return isConsideredEmpty(); 415 421 } 416 422 -
trunk/Source/WebCore/layout/inlineformatting/InlineLine.cpp
r251973 r252143 385 385 m_runList.append(makeUnique<Run>(inlineItem, Display::Run { inlineItem.style(), logicalRect })); 386 386 m_lineBox.expandHorizontally(logicalRect.width()); 387 if (logicalRect.width()) 388 m_lineBox.setIsConsideredNonEmpty(); 387 389 } 388 390 … … 464 466 if (collapsesToZeroAdvanceWidth) 465 467 lineRun->setCollapsesToZeroAdvanceWidth(); 468 else 469 m_lineBox.setIsConsideredNonEmpty(); 470 466 471 if (collapsedRun) 467 472 lineRun->setIsCollapsed(); … … 489 494 m_runList.append(makeUnique<Run>(inlineItem, Display::Run { inlineItem.style(), logicalRect })); 490 495 m_lineBox.expandHorizontally(logicalWidth + horizontalMargin.start + horizontalMargin.end); 496 m_lineBox.setIsConsideredNonEmpty(); 491 497 m_trimmableContent.clear(); 492 498 } … … 497 503 // FIXME: Surely replaced boxes behave differently. 498 504 appendNonReplacedInlineBox(inlineItem, logicalWidth); 505 m_lineBox.setIsConsideredNonEmpty(); 499 506 if (auto* replaced = inlineItem.layoutBox().replaced(); replaced && replaced->cachedImage()) 500 507 m_runList.last()->m_displayRun.setImage(*replaced->cachedImage()); … … 510 517 logicalRect.setHeight(logicalHeight()); 511 518 } 519 m_lineBox.setIsConsideredNonEmpty(); 512 520 m_runList.append(makeUnique<Run>(inlineItem, Display::Run { inlineItem.style(), logicalRect })); 513 521 } -
trunk/Source/WebCore/layout/inlineformatting/InlineLineBox.h
r251238 r252143 109 109 void shrinkVertically(LayoutUnit delta) { expandVertically(-delta); } 110 110 111 // https://www.w3.org/TR/CSS22/visuren.html#inline-formatting 112 // Line boxes that contain no text, no preserved white space, no inline elements with non-zero margins, padding, or borders, 113 // and no other in-flow content (such as images, inline blocks or inline tables), and do not end with a preserved newline 114 // must be treated as zero-height line boxes for the purposes of determining the positions of any elements inside of them, 115 // and must be treated as not existing for any other purpose. 116 // Note that it does not necessarily mean visually non-empty line. <span style="font-size: 0px">this is still considered non-empty</span> 117 bool isConsideredEmpty() const { return m_isConsideredEmpty; } 118 void setIsConsideredNonEmpty() { m_isConsideredEmpty = false; } 119 111 120 private: 112 121 #if !ASSERT_DISABLED … … 117 126 Baseline m_baseline; 118 127 LayoutUnit m_baselineOffset; 128 bool m_isConsideredEmpty { true }; 119 129 }; 120 130
Note: See TracChangeset
for help on using the changeset viewer.