Changeset 240436 in webkit
- Timestamp:
- Jan 24, 2019 9:15:46 AM (5 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r240435 r240436 1 2019-01-24 Zalan Bujtas <zalan@apple.com> 2 3 [LFC][BFC][MarginCollapsing] MarginCollapse::collapsedVerticalValues should not return computed non-collapsed values. 4 https://bugs.webkit.org/show_bug.cgi?id=193768 5 6 Reviewed by Antti Koivisto. 7 8 When it comes to the actual used values it does not really matter, only from correctness point of view. 9 (This patch also moves some checks to their correct place.) 10 11 * layout/blockformatting/BlockMarginCollapse.cpp: 12 (WebCore::Layout::BlockFormattingContext::MarginCollapse::marginBeforeCollapsesWithPreviousSiblingMarginAfter): 13 (WebCore::Layout::BlockFormattingContext::MarginCollapse::marginBeforeCollapsesWithFirstInFlowChildMarginBefore): 14 (WebCore::Layout::BlockFormattingContext::MarginCollapse::marginAfterCollapsesWithLastInFlowChildMarginAfter): 15 (WebCore::Layout::BlockFormattingContext::MarginCollapse::positiveNegativeMarginBefore): 16 (WebCore::Layout::BlockFormattingContext::MarginCollapse::positiveNegativeMarginAfter): 17 (WebCore::Layout::BlockFormattingContext::MarginCollapse::collapsedVerticalValues): 18 1 19 2019-01-23 Simon Fraser <simon.fraser@apple.com> 2 20 -
trunk/Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp
r240337 r240436 157 157 auto& previousInFlowSibling = *layoutBox.previousInFlowSibling(); 158 158 159 if (Quirks::shouldIgnoreMarginAfter(layoutState, previousInFlowSibling)) 160 return false; 161 159 162 // Margins between a floated box and any other box do not collapse. 160 163 if (layoutBox.isFloatingPositioned() || previousInFlowSibling.isFloatingPositioned()) … … 201 204 202 205 auto& firstInFlowChild = *downcast<Container>(layoutBox).firstInFlowChild(); 206 if (Quirks::shouldIgnoreMarginBefore(layoutState, firstInFlowChild)) 207 return false; 208 203 209 if (!firstInFlowChild.isBlockLevelBox()) 204 210 return false; … … 321 327 322 328 auto& lastInFlowChild = *downcast<Container>(layoutBox).lastInFlowChild(); 329 if (Quirks::shouldIgnoreMarginAfter(layoutState, lastInFlowChild)) 330 return false; 331 323 332 if (!lastInFlowChild.isBlockLevelBox()) 324 333 return false; … … 536 545 { 537 546 auto firstChildCollapsedMarginBefore = [&]() -> PositiveAndNegativeVerticalMargin::Values { 538 if (!is<Container>(layoutBox))539 return { };540 auto* firstInFlowChild = downcast<Container>(layoutBox).firstInFlowChild();541 if (!firstInFlowChild)542 return { };543 547 if (!marginBeforeCollapsesWithFirstInFlowChildMarginBefore(layoutState, layoutBox)) 544 548 return { }; 545 if (Quirks::shouldIgnoreMarginBefore(layoutState, *firstInFlowChild)) 546 return { }; 547 return positiveNegativeValues(layoutState, *firstInFlowChild, MarginType::Before); 549 return positiveNegativeValues(layoutState, *downcast<Container>(layoutBox).firstInFlowChild(), MarginType::Before); 548 550 }; 549 551 550 552 auto previouSiblingCollapsedMarginAfter = [&]() -> PositiveAndNegativeVerticalMargin::Values { 551 auto* previousInFlowSibling = layoutBox.previousInFlowSibling();552 if (!previousInFlowSibling)553 return { };554 553 if (!marginBeforeCollapsesWithPreviousSiblingMarginAfter(layoutState, layoutBox)) 555 554 return { }; 556 if (Quirks::shouldIgnoreMarginAfter(layoutState, *previousInFlowSibling)) 557 return { }; 558 return positiveNegativeValues(layoutState, *previousInFlowSibling, MarginType::After); 555 return positiveNegativeValues(layoutState, *downcast<Container>(layoutBox).previousInFlowSibling(), MarginType::After); 559 556 }; 560 557 … … 569 566 { 570 567 auto lastChildCollapsedMarginAfter = [&]() -> PositiveAndNegativeVerticalMargin::Values { 571 if (!is<Container>(layoutBox))572 return { };573 auto* lastInFlowChild = downcast<Container>(layoutBox).lastInFlowChild();574 if (!lastInFlowChild)575 return { };576 568 if (!marginAfterCollapsesWithLastInFlowChildMarginAfter(layoutState, layoutBox)) 577 569 return { }; 578 if (Quirks::shouldIgnoreMarginAfter(layoutState, *lastInFlowChild)) 579 return { }; 580 return positiveNegativeValues(layoutState, *lastInFlowChild, MarginType::After); 570 return positiveNegativeValues(layoutState, *downcast<Container>(layoutBox).lastInFlowChild(), MarginType::After); 581 571 }; 582 572 … … 625 615 // 2. Get min/max margin top values from the previous in-flow sibling, if we are collapsing margin top with it. 626 616 // 3. Get this layout box's computed margin top value. 627 // 4. Update the min/max value and compute the final margin. 617 // 4. Update the min/max value and compute the final margin. 628 618 auto positiveNegativeMarginBefore = MarginCollapse::positiveNegativeMarginBefore(layoutState, layoutBox, nonCollapsedValues); 629 619 auto positiveNegativeMarginAfter = MarginCollapse::positiveNegativeMarginAfter(layoutState, layoutBox, nonCollapsedValues); 630 620 631 auto marginsCollapseThrough = MarginCollapse::marginsCollapseThrough(layoutState, layoutBox); 621 auto marginsCollapseThrough = MarginCollapse::marginsCollapseThrough(layoutState, layoutBox); 632 622 if (marginsCollapseThrough) { 633 623 positiveNegativeMarginBefore = computedPositiveAndNegativeMargin(positiveNegativeMarginBefore, positiveNegativeMarginAfter); 634 positiveNegativeMarginAfter = positiveNegativeMarginBefore; 635 } 636 624 positiveNegativeMarginAfter = positiveNegativeMarginBefore; 625 } 626 627 // FIXME: Move state saving out of this function. 637 628 auto& blockFormattingState = downcast<BlockFormattingState>(layoutState.formattingStateForBox(layoutBox)); 638 629 blockFormattingState.setPositiveAndNegativeVerticalMargin(layoutBox, { positiveNegativeMarginBefore, positiveNegativeMarginAfter }); 639 630 640 return { marginValue(positiveNegativeMarginBefore), marginValue(positiveNegativeMarginAfter), marginsCollapseThrough }; 631 auto beforeMarginIsCollapsedValue = marginBeforeCollapsesWithFirstInFlowChildMarginBefore(layoutState, layoutBox) || marginBeforeCollapsesWithPreviousSiblingMarginAfter(layoutState, layoutBox); 632 auto afterMarginIsCollapsedValue = marginAfterCollapsesWithLastInFlowChildMarginAfter(layoutState, layoutBox); 633 634 if ((beforeMarginIsCollapsedValue && afterMarginIsCollapsedValue) || marginsCollapseThrough) 635 return { marginValue(positiveNegativeMarginBefore), marginValue(positiveNegativeMarginAfter), marginsCollapseThrough }; 636 if (beforeMarginIsCollapsedValue) 637 return { marginValue(positiveNegativeMarginBefore), { }, false }; 638 return { { }, marginValue(positiveNegativeMarginAfter), false }; 641 639 } 642 640
Note: See TracChangeset
for help on using the changeset viewer.