Changeset 252189 in webkit
- Timestamp:
- Nov 7, 2019 10:03:15 AM (4 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r252185 r252189 1 2019-11-07 Zalan Bujtas <zalan@apple.com> 2 3 [LFC][MarginCollapsing] Drag anonymous block level boxes into margin collapsing 4 https://bugs.webkit.org/show_bug.cgi?id=203927 5 <rdar://problem/56963636> 6 7 Reviewed by Antti Koivisto. 8 9 We've been ignoring anonymous block level boxes in the context of margin collapsing. Now with IFC, we can't really do that anymore. 10 This patch removes the early bailout on anon boxes and addresses the fallout. 11 12 * layout/MarginTypes.h: 13 * layout/blockformatting/BlockMarginCollapse.cpp: 14 (WebCore::Layout::BlockFormattingContext::MarginCollapse::marginBeforeCollapsesWithParentMarginBefore const): 15 (WebCore::Layout::BlockFormattingContext::MarginCollapse::marginBeforeCollapsesWithPreviousSiblingMarginAfter const): 16 (WebCore::Layout::BlockFormattingContext::MarginCollapse::marginBeforeCollapsesWithFirstInFlowChildMarginBefore const): 17 (WebCore::Layout::BlockFormattingContext::MarginCollapse::marginAfterCollapsesWithParentMarginAfter const): 18 (WebCore::Layout::BlockFormattingContext::MarginCollapse::marginAfterCollapsesWithLastInFlowChildMarginAfter const): 19 (WebCore::Layout::BlockFormattingContext::MarginCollapse::updateMarginAfterForPreviousSibling): 20 (WebCore::Layout::BlockFormattingContext::MarginCollapse::positiveNegativeMarginAfter const): 21 (WebCore::Layout::BlockFormattingContext::MarginCollapse::estimatedMarginBefore): 22 (WebCore::Layout::BlockFormattingContext::MarginCollapse::marginBeforeIgnoringCollapsingThrough): 23 (WebCore::Layout::BlockFormattingContext::MarginCollapse::collapsedVerticalValues): 24 1 25 2019-11-07 Alex Christensen <achristensen@webkit.org> 2 26 -
trunk/Source/WebCore/layout/MarginTypes.h
r240583 r252189 83 83 }; 84 84 85 // FIXME: This structure might need to change to indicate that the cached value is not necessarily the same as the box's computed margin value. 86 // This only matters in case of collapse through margins when they collapse into another sibling box. 87 // <div style="margin: 1px"></div><div style="margin: 10px"></div> <- the second div's before/after marings collapse through and the same time they collapse into 88 // the first div. When the parent computes its before margin, it should see the second div's collapsed through margin as the value to collapse width (adjoining margin value). 89 // So while the first div's before margin is not 10px, the cached value is 10px so that when we compute the parent's margin we just need to check the fist 90 // inflow child's cached margin value. 85 91 struct PositiveAndNegativeVerticalMargin { 86 92 struct Values { -
trunk/Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp
r252143 r252189 113 113 // The first inflow child could propagate its top margin to parent. 114 114 // https://www.w3.org/TR/CSS21/box.html#collapsing-margins 115 if (layoutBox.isAnonymous())116 return false;117 118 115 ASSERT(layoutBox.isBlockLevelBox()); 119 116 … … 156 153 ASSERT(layoutBox.isBlockLevelBox()); 157 154 158 if (layoutBox.isAnonymous())159 return false;160 161 155 if (!layoutBox.previousInFlowSibling()) 162 156 return false; 163 157 164 158 auto& previousInFlowSibling = *layoutBox.previousInFlowSibling(); 165 if (previousInFlowSibling.isAnonymous())166 return false;167 168 159 // Margins between a floated box and any other box do not collapse. 169 160 if (layoutBox.isFloatingPositioned() || previousInFlowSibling.isFloatingPositioned()) … … 189 180 bool BlockFormattingContext::MarginCollapse::marginBeforeCollapsesWithFirstInFlowChildMarginBefore(const Box& layoutBox) const 190 181 { 191 if (layoutBox.isAnonymous())192 return false;193 194 182 ASSERT(layoutBox.isBlockLevelBox()); 195 183 // Margins of elements that establish new block formatting contexts do not collapse with their in-flow children. … … 260 248 bool BlockFormattingContext::MarginCollapse::marginAfterCollapsesWithParentMarginAfter(const Box& layoutBox) const 261 249 { 262 if (layoutBox.isAnonymous())263 return false;264 265 250 ASSERT(layoutBox.isBlockLevelBox()); 266 251 … … 349 334 // Margins of inline-block boxes do not collapse. 350 335 if (lastInFlowChild.isInlineBlockBox()) 336 return false; 337 338 // This is a quirk behavior: When the margin after of the last inflow child (or a previous sibling with collapsed through margins) 339 // collapses with a quirk parent's the margin before, then the same margin after does not collapses with the parent's margin after. 340 if (formattingContext().quirks().shouldIgnoreCollapsedQuirkMargin(layoutBox) && marginAfterCollapsesWithParentMarginBefore(lastInFlowChild)) 351 341 return false; 352 342 … … 476 466 // 2. Update the collapsed margin after value as well as the positive/negative cache. 477 467 // 3. Check if the box's margins collapse through. 478 // 4. If so, update the collapsed margin before value as well as thepositive/negative cache.468 // 4. If so, update the positive/negative cache. 479 469 // 5. In case of collapsed through margins check if the before margin collapes with the previous inflow sibling's after margin. 480 470 // 6. If so, jump to #2. … … 494 484 collapsedVerticalMarginBefore = collapsedVerticalMarginAfter; 495 485 496 // Update collapsed vertical margin values.497 previousSiblingVerticalMargin.setCollapsedValues({ collapsedVerticalMarginBefore, collapsedVerticalMarginAfter });498 previousSiblingDisplayBox.setVerticalMargin(previousSiblingVerticalMargin);499 500 486 // Update positive/negative cache. 501 487 auto previousSiblingPositiveNegativeMargin = blockFormattingState.positiveAndNegativeVerticalMargin(previousSibling); … … 573 559 574 560 // We don't know yet the margin before value of the next sibling. Let's just pretend it does not have one and 575 // update it later when we compute the next sibling's margin before. See update CollapsedMarginAfter.561 // update it later when we compute the next sibling's margin before. See updateMarginAfterForPreviousSibling. 576 562 PositiveAndNegativeVerticalMargin::Values nonCollapsedAfter; 577 563 if (nonCollapsedValues.after > 0) … … 585 571 EstimatedMarginBefore BlockFormattingContext::MarginCollapse::estimatedMarginBefore(const Box& layoutBox, UsedVerticalMargin::NonCollapsedValues usedNonCollapsedMargin) 586 572 { 587 if (layoutBox.isAnonymous())588 return { };589 590 573 ASSERT(layoutBox.isBlockLevelBox()); 591 574 // Don't estimate vertical margins for out of flow boxes. … … 604 587 LayoutUnit BlockFormattingContext::MarginCollapse::marginBeforeIgnoringCollapsingThrough(const Box& layoutBox, UsedVerticalMargin::NonCollapsedValues nonCollapsedValues) 605 588 { 606 ASSERT(!layoutBox.isAnonymous());607 589 ASSERT(layoutBox.isBlockLevelBox()); 608 590 return marginValue(positiveNegativeMarginBefore(layoutBox, nonCollapsedValues)).valueOr(nonCollapsedValues.before); … … 626 608 UsedVerticalMargin::CollapsedValues BlockFormattingContext::MarginCollapse::collapsedVerticalValues(const Box& layoutBox, UsedVerticalMargin::NonCollapsedValues nonCollapsedValues) 627 609 { 628 if (layoutBox.isAnonymous())629 return { };630 631 610 ASSERT(layoutBox.isBlockLevelBox()); 632 611 // 1. Get min/max margin top values from the first in-flow child if we are collapsing margin top with it.
Note: See TracChangeset
for help on using the changeset viewer.