Changeset 239334 in webkit
- Timestamp:
- Dec 18, 2018 7:27:09 AM (5 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r239332 r239334 1 2018-12-18 Zalan Bujtas <zalan@apple.com> 2 3 [LFC][BFC][MarginCollapsing] Implement marginAfterCollapsesWithParentMarginBefore 4 https://bugs.webkit.org/show_bug.cgi?id=192798 5 6 Reviewed by Antti Koivisto. 7 8 * layout/blockformatting/BlockFormattingContext.h: 9 * layout/blockformatting/BlockFormattingContextGeometry.cpp: 10 (WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedHeightAndMargin): 11 * layout/blockformatting/BlockMarginCollapse.cpp: 12 (WebCore::Layout::BlockFormattingContext::Geometry::MarginCollapse::collapsedMarginAfterFromLastChild): 13 (WebCore::Layout::BlockFormattingContext::Geometry::MarginCollapse::marginAfterCollapsesWithParentMarginBefore): 14 (WebCore::Layout::BlockFormattingContext::Geometry::MarginCollapse::marginAfterCollapsesWithParentMarginAfter): 15 (WebCore::Layout::BlockFormattingContext::Geometry::MarginCollapse::marginAfter): 16 1 17 2018-12-18 Zalan Bujtas <zalan@apple.com> 2 18 -
trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h
r239332 r239334 91 91 92 92 static bool marginBeforeCollapsesWithParentMarginAfter(const Box&); 93 static bool marginAfterCollapsesWithParentMarginAfter(const Box&);93 static bool marginAfterCollapsesWithParentMarginAfter(const LayoutState&, const Box&); 94 94 95 95 private: … … 107 107 static bool marginAfterCollapsesWithNextSibling(const Box&); 108 108 static bool marginAfterCollapsesWithSiblingMarginBeforeWithClearance(const Box&); 109 static bool marginAfterCollapsesWithParentMarginBefore(const Box&);109 static bool marginAfterCollapsesWithParentMarginBefore(const LayoutState&, const Box&); 110 110 static bool marginsCollapseThrough(const LayoutState&, const Box&); 111 111 }; -
trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp
r239267 r239334 85 85 auto* lastInFlowChild = downcast<Container>(layoutBox).lastInFlowChild(); 86 86 ASSERT(lastInFlowChild); 87 if (!MarginCollapse::marginAfterCollapsesWithParentMarginAfter( *lastInFlowChild)) {87 if (!MarginCollapse::marginAfterCollapsesWithParentMarginAfter(layoutState, *lastInFlowChild)) { 88 88 auto& lastInFlowDisplayBox = layoutState.displayBoxForLayoutBox(*lastInFlowChild); 89 89 return { lastInFlowDisplayBox.bottom() + lastInFlowDisplayBox.marginAfter() - borderAndPaddingTop, { nonCollapsedMargin, collapsedMargin } }; -
trunk/Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp
r239332 r239334 168 168 // FIXME: Check for collapsed through margin. 169 169 auto& lastInFlowChild = *downcast<Container>(layoutBox).lastInFlowChild(); 170 if (!marginAfterCollapsesWithParentMarginAfter(la stInFlowChild))170 if (!marginAfterCollapsesWithParentMarginAfter(layoutState, lastInFlowChild)) 171 171 return 0; 172 172 … … 231 231 } 232 232 233 bool BlockFormattingContext::Geometry::MarginCollapse::marginAfterCollapsesWithParentMarginBefore(const Box&) 234 { 233 bool BlockFormattingContext::Geometry::MarginCollapse::marginAfterCollapsesWithParentMarginBefore(const LayoutState& layoutState, const Box& layoutBox) 234 { 235 // 1. This is the first in-flow child and its margins collapse through and the margin before collapses with parent's margin before or 236 // 2. This box's margin before collapses with the previous sibling's margin after and that sibling collapses through and 237 // we can get to the first in-flow child like that. 238 auto* firstInFlowChild = layoutBox.parent()->firstInFlowChild(); 239 for (auto* currentBox = &layoutBox; currentBox; currentBox = currentBox->previousInFlowSibling()) { 240 if (!marginsCollapseThrough(layoutState, *currentBox)) 241 return false; 242 if (currentBox == firstInFlowChild) 243 return marginBeforeCollapsesWithParentMarginBefore(layoutState, *currentBox); 244 if (!marginBeforeCollapsesWithPreviousSibling(*currentBox)) 245 return false; 246 } 247 ASSERT_NOT_REACHED(); 235 248 return false; 236 249 } 237 250 238 bool BlockFormattingContext::Geometry::MarginCollapse::marginAfterCollapsesWithParentMarginAfter(const Box& layoutBox)251 bool BlockFormattingContext::Geometry::MarginCollapse::marginAfterCollapsesWithParentMarginAfter(const LayoutState& layoutState, const Box& layoutBox) 239 252 { 240 253 if (layoutBox.isAnonymous()) … … 282 295 // nor (if the box's min-height is non-zero) with the box's top margin. 283 296 auto computedMinHeight = parent.style().logicalMinHeight(); 284 if (!computedMinHeight.isAuto() && computedMinHeight.value() && marginAfterCollapsesWithParentMarginBefore(layout Box))297 if (!computedMinHeight.isAuto() && computedMinHeight.value() && marginAfterCollapsesWithParentMarginBefore(layoutState, layoutBox)) 285 298 return false; 286 299 … … 407 420 408 421 // TODO: take _hasAdjoiningMarginBeforeAndBottom() into account. 409 if (marginAfterCollapsesWithParentMarginAfter(layout Box))422 if (marginAfterCollapsesWithParentMarginAfter(layoutState, layoutBox)) 410 423 return 0; 411 424
Note: See TracChangeset
for help on using the changeset viewer.