Changeset 240467 in webkit
- Timestamp:
- Jan 24, 2019 8:14:32 PM (5 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r240457 r240467 1 2019-01-24 Zalan Bujtas <zalan@apple.com> 2 3 [LFC][BFC][MarginCollapsing] Refactor MarginCollapse::updateCollapsedMarginAfter 4 https://bugs.webkit.org/show_bug.cgi?id=193807 5 6 Reviewed by Simon Fraser. 7 8 Rename updateCollapsedMarginAfter to updateMarginAfterForPreviousSibling and make the margin updating logic more explicit. 9 10 * layout/blockformatting/BlockFormattingContext.cpp: 11 (WebCore::Layout::BlockFormattingContext::computeHeightAndMargin const): 12 * layout/blockformatting/BlockFormattingContext.h: 13 * layout/blockformatting/BlockMarginCollapse.cpp: 14 (WebCore::Layout::BlockFormattingContext::MarginCollapse::updateMarginAfterForPreviousSibling): 15 (WebCore::Layout::BlockFormattingContext::MarginCollapse::updateCollapsedMarginAfter): Deleted. 16 1 17 2019-01-24 Joseph Pecoraro <pecoraro@apple.com> 2 18 -
trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp
r240337 r240467 430 430 removeEstimatedMarginBefore(layoutBox); 431 431 displayBox.setTop(adjustedVerticalPositionAfterMarginCollapsing(layoutBox, verticalMargin)); 432 // Adjust the previous sibling's margin bottom now that this box's vertical margin is computed.433 if (MarginCollapse::marginBeforeCollapsesWithPreviousSiblingMarginAfter(layoutState, layoutBox))434 MarginCollapse::updateCollapsedMarginAfter(layoutState, *layoutBox.previousInFlowSibling(), verticalMargin);435 436 432 displayBox.setContentBoxHeight(heightAndMargin.height); 437 433 displayBox.setVerticalMargin(verticalMargin); 434 // Adjust the previous sibling's margin bottom now that this box's vertical margin is computed. 435 MarginCollapse::updateMarginAfterForPreviousSibling(layoutState, layoutBox); 438 436 } 439 437 -
trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h
r240337 r240467 97 97 static EstimatedMarginBefore estimatedMarginBefore(const LayoutState&, const Box&); 98 98 static LayoutUnit marginBeforeIgnoringCollapsingThrough(const LayoutState&, const Box&, const UsedVerticalMargin::NonCollapsedValues&); 99 static void update CollapsedMarginAfter(const LayoutState&, const Box&, const UsedVerticalMargin& nextSiblingVerticalMargin);99 static void updateMarginAfterForPreviousSibling(const LayoutState&, const Box&); 100 100 101 101 static bool marginBeforeCollapsesWithParentMarginBefore(const LayoutState&, const Box&); -
trunk/Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp
r240436 r240467 482 482 } 483 483 484 void BlockFormattingContext::MarginCollapse::update CollapsedMarginAfter(const LayoutState& layoutState, const Box& layoutBox, const UsedVerticalMargin& nextSiblingVerticalMargin)484 void BlockFormattingContext::MarginCollapse::updateMarginAfterForPreviousSibling(const LayoutState& layoutState, const Box& layoutBox) 485 485 { 486 486 // 1. Get the margin before value from the next in-flow sibling. This is the same as this box's margin after value now since they are collapsed. … … 490 490 // 5. In case of collapsed through margins check if the before margin collapes with the previous inflow sibling's after margin. 491 491 // 6. If so, jump to #2. 492 if (!marginAfterCollapsesWithNextSiblingMarginBefore(layoutState, layoutBox)) 493 return; 494 495 auto& displayBox = layoutState.displayBoxForLayoutBox(layoutBox); 496 auto verticalMargin = displayBox.verticalMargin(); 497 auto verticalMarginAfter = nextSiblingVerticalMargin.before(); 498 Optional<LayoutUnit> verticalMarginBefore; 499 500 auto marginsCollapseThrough = MarginCollapse::marginsCollapseThrough(layoutState, layoutBox); 501 if (marginsCollapseThrough) 502 verticalMarginBefore = verticalMarginAfter; 503 else if (verticalMargin.hasCollapsedValues()) 504 verticalMarginBefore = verticalMargin.collapsedValues().before; 505 506 // Update vertical margin values. 507 verticalMargin.setCollapsedValues({ verticalMarginBefore, verticalMarginAfter }); 508 displayBox.setVerticalMargin(verticalMargin); 509 510 // Update positive/negative cache. 511 auto& blockFormattingState = downcast<BlockFormattingState>(layoutState.formattingStateForBox(layoutBox)); 512 auto positiveNegativeMargin = blockFormattingState.positiveAndNegativeVerticalMargin(layoutBox); 513 auto nextSiblingPositiveNegativeMarginBefore = blockFormattingState.positiveAndNegativeVerticalMargin(*layoutBox.nextInFlowSibling()).before; 514 515 positiveNegativeMargin.after = computedPositiveAndNegativeMargin(nextSiblingPositiveNegativeMarginBefore, positiveNegativeMargin.after); 516 if (marginsCollapseThrough) { 517 positiveNegativeMargin.before = computedPositiveAndNegativeMargin(positiveNegativeMargin.before, positiveNegativeMargin.after); 518 positiveNegativeMargin.after = positiveNegativeMargin.before; 519 } 520 blockFormattingState.setPositiveAndNegativeVerticalMargin(layoutBox, positiveNegativeMargin); 521 522 if (!marginsCollapseThrough || !marginBeforeCollapsesWithPreviousSiblingMarginAfter(layoutState, layoutBox)) 523 return; 524 525 updateCollapsedMarginAfter(layoutState, *layoutBox.previousInFlowSibling(), verticalMargin); 492 // 7. No need to propagate to parent because its margin is not computed yet (estimated at most). 493 auto* currentBox = &layoutBox; 494 while (marginBeforeCollapsesWithPreviousSiblingMarginAfter(layoutState, *currentBox)) { 495 auto& previousSibling = *currentBox->previousInFlowSibling(); 496 auto& previousSiblingDisplayBox = layoutState.displayBoxForLayoutBox(previousSibling); 497 auto previousSiblingVerticalMargin = previousSiblingDisplayBox.verticalMargin(); 498 499 auto collapsedVerticalMarginBefore = previousSiblingVerticalMargin.collapsedValues().before; 500 auto collapsedVerticalMarginAfter = layoutState.displayBoxForLayoutBox(*currentBox).verticalMargin().before(); 501 502 auto marginsCollapseThrough = MarginCollapse::marginsCollapseThrough(layoutState, previousSibling); 503 if (marginsCollapseThrough) 504 collapsedVerticalMarginBefore = collapsedVerticalMarginAfter; 505 506 // Update collapsed vertical margin values. 507 previousSiblingVerticalMargin.setCollapsedValues({ collapsedVerticalMarginBefore, collapsedVerticalMarginAfter }); 508 previousSiblingDisplayBox.setVerticalMargin(previousSiblingVerticalMargin); 509 510 // Update positive/negative cache. 511 auto& blockFormattingState = downcast<BlockFormattingState>(layoutState.formattingStateForBox(previousSibling)); 512 auto previousSiblingPositiveNegativeMargin = blockFormattingState.positiveAndNegativeVerticalMargin(previousSibling); 513 auto positiveNegativeMarginBefore = blockFormattingState.positiveAndNegativeVerticalMargin(*currentBox).before; 514 515 previousSiblingPositiveNegativeMargin.after = computedPositiveAndNegativeMargin(positiveNegativeMarginBefore, previousSiblingPositiveNegativeMargin.after); 516 if (marginsCollapseThrough) { 517 previousSiblingPositiveNegativeMargin.before = computedPositiveAndNegativeMargin(previousSiblingPositiveNegativeMargin.before, previousSiblingPositiveNegativeMargin.after); 518 previousSiblingPositiveNegativeMargin.after = previousSiblingPositiveNegativeMargin.before; 519 } 520 blockFormattingState.setPositiveAndNegativeVerticalMargin(previousSibling, previousSiblingPositiveNegativeMargin); 521 522 if (!marginsCollapseThrough) 523 break; 524 525 currentBox = &previousSibling; 526 } 526 527 } 527 528
Note: See TracChangeset
for help on using the changeset viewer.