Changeset 238735 in webkit
- Timestamp:
- Nov 30, 2018, 7:22:39 AM (8 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/layout/blockformatting/BlockFormattingContext.h (modified) (1 diff)
-
Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp (modified) (1 diff)
-
Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp (modified) (10 diffs)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/LayoutReloaded/misc/LFC-passing-tests.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r238727 r238735 1 2018-11-30 Zalan Bujtas <zalan@apple.com> 2 3 [LFC][BFC][MarginCollapsing] Do not use computed display box values for border and padding 4 https://bugs.webkit.org/show_bug.cgi?id=192214 5 6 Reviewed by Antti Koivisto. 7 8 Border and padding values are not necessarily computed yet when we try to estimate the margin top value. Estimating margin top is required 9 to be able to place floats (vertically) sooner than we would compute the final vertical position for a regular block box. 10 11 <body><div style="float: left"></div><div><div style="margin: 10px;"></div></div> 12 13 In the above example, to estimate a final vertical position of the floating box, we need to know whether the nested div's margin is collapsed 14 all the way up to the body. However in order to find it out we need to check for borders and paddings (they stop margin collapsing). 15 At the time when the floating box is being laied out, those <div> block boxes are still far down in the layout queue. 16 17 * layout/blockformatting/BlockFormattingContext.h: 18 * layout/blockformatting/BlockFormattingContextGeometry.cpp: 19 (WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedHeightAndMargin): 20 * layout/blockformatting/BlockMarginCollapse.cpp: 21 (WebCore::Layout::hasBorder): 22 (WebCore::Layout::hasPadding): 23 (WebCore::Layout::hasBorderBefore): 24 (WebCore::Layout::hasBorderAfter): 25 (WebCore::Layout::hasPaddingBefore): 26 (WebCore::Layout::hasPaddingAfter): 27 (WebCore::Layout::BlockFormattingContext::Geometry::MarginCollapse::isMarginTopCollapsedWithParent): 28 (WebCore::Layout::isMarginBottomCollapsedThrough): 29 (WebCore::Layout::BlockFormattingContext::Geometry::MarginCollapse::marginTop): 30 (WebCore::Layout::BlockFormattingContext::Geometry::MarginCollapse::marginBottom): 31 (WebCore::Layout::BlockFormattingContext::Geometry::MarginCollapse::isMarginBottomCollapsedWithParent): 32 (WebCore::Layout::BlockFormattingContext::Geometry::MarginCollapse::collapsedMarginBottomFromLastChild): 33 1 34 2018-11-29 Frederic Wang <fwang@igalia.com> 2 35 -
trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h
r238701 r238735 90 90 static LayoutUnit marginBottom(const LayoutState&, const Box&); 91 91 92 static bool isMarginBottomCollapsedWithParent(const LayoutState&, constBox&);92 static bool isMarginBottomCollapsedWithParent(const Box&); 93 93 static bool isMarginTopCollapsedWithParentMarginBottom(const Box&); 94 94 -
trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp
r238701 r238735 84 84 auto* lastInFlowChild = downcast<Container>(layoutBox).lastInFlowChild(); 85 85 ASSERT(lastInFlowChild); 86 if (!MarginCollapse::isMarginBottomCollapsedWithParent( layoutState,*lastInFlowChild)) {86 if (!MarginCollapse::isMarginBottomCollapsedWithParent(*lastInFlowChild)) { 87 87 auto& lastInFlowDisplayBox = layoutState.displayBoxForLayoutBox(*lastInFlowChild); 88 88 return { lastInFlowDisplayBox.bottom() + lastInFlowDisplayBox.marginBottom() - borderAndPaddingTop, nonCollapsedMargin, collapsedMargin }; -
trunk/Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp
r238667 r238735 37 37 namespace Layout { 38 38 39 static bool hasBorder(const BorderValue& borderValue) 40 { 41 if (borderValue.style() == BorderStyle::None || borderValue.style() == BorderStyle::Hidden) 42 return false; 43 return !!borderValue.width(); 44 } 45 46 static bool hasPadding(const Length& paddingValue) 47 { 48 // FIXME: Check if percent value needs to be resolved. 49 return !paddingValue.isZero(); 50 } 51 52 static bool hasBorderBefore(const Box& layoutBox) 53 { 54 return hasBorder(layoutBox.style().borderBefore()); 55 } 56 57 static bool hasBorderAfter(const Box& layoutBox) 58 { 59 return hasBorder(layoutBox.style().borderAfter()); 60 } 61 62 static bool hasPaddingBefore(const Box& layoutBox) 63 { 64 return hasPadding(layoutBox.style().paddingBefore()); 65 } 66 67 static bool hasPaddingAfter(const Box& layoutBox) 68 { 69 return hasPadding(layoutBox.style().paddingAfter()); 70 } 71 39 72 static LayoutUnit marginValue(LayoutUnit currentMarginValue, LayoutUnit candidateMarginValue) 40 73 { … … 95 128 return false; 96 129 130 // Only the first inlflow child collapses with parent. 131 if (layoutBox.previousInFlowSibling()) 132 return false; 133 97 134 // We never margin collapse the initial containing block. 98 135 ASSERT(layoutBox.parent()); 99 136 auto& parent = *layoutBox.parent(); 100 // Only the first inlflow child collapses with parent.101 if (layoutBox.previousInFlowSibling())102 return false;103 104 137 if (parent.establishesBlockFormattingContext()) 105 138 return false; … … 109 142 return false; 110 143 111 auto& parentDisplayBox = layoutState.displayBoxForLayoutBox(parent); 112 if (parentDisplayBox.borderTop()) 113 return false; 114 115 if (parentDisplayBox.paddingTop().value_or(0)) 144 if (hasBorderBefore(parent)) 145 return false; 146 147 if (hasPaddingBefore(parent)) 116 148 return false; 117 149 … … 122 154 } 123 155 124 static bool isMarginBottomCollapsedThrough(const LayoutState& layoutState, constBox& layoutBox)156 static bool isMarginBottomCollapsedThrough(const Box& layoutBox) 125 157 { 126 158 ASSERT(layoutBox.isBlockLevelBox()); 127 159 128 160 // If the top and bottom margins of a box are adjoining, then it is possible for margins to collapse through it. 129 auto& displayBox = layoutState.displayBoxForLayoutBox(layoutBox); 130 131 if (displayBox.borderTop() || displayBox.borderBottom()) 132 return false; 133 134 if (displayBox.paddingTop().value_or(0) || displayBox.paddingBottom().value_or(0)) 161 if (hasBorderBefore(layoutBox) || hasBorderAfter(layoutBox)) 162 return false; 163 164 if (hasPaddingBefore(layoutBox) || hasPaddingAfter(layoutBox)) 135 165 return false; 136 166 … … 220 250 221 251 if (!isMarginTopCollapsedWithSibling(layoutBox)) { 222 if (!isMarginBottomCollapsedThrough(layout State, layoutBox))252 if (!isMarginBottomCollapsedThrough(layoutBox)) 223 253 return nonCollapsedMarginTop(layoutState, layoutBox); 224 254 // Compute the collapsed through value. … … 247 277 248 278 // TODO: take _hasAdjoiningMarginTopAndBottom() into account. 249 if (isMarginBottomCollapsedWithParent(layout State, layoutBox))250 return 0; 251 252 if (isMarginBottomCollapsedThrough(layout State, layoutBox))279 if (isMarginBottomCollapsedWithParent(layoutBox)) 280 return 0; 281 282 if (isMarginBottomCollapsedThrough(layoutBox)) 253 283 return 0; 254 284 … … 264 294 } 265 295 266 bool BlockFormattingContext::Geometry::MarginCollapse::isMarginBottomCollapsedWithParent(const LayoutState& layoutState, constBox& layoutBox)296 bool BlockFormattingContext::Geometry::MarginCollapse::isMarginBottomCollapsedWithParent(const Box& layoutBox) 267 297 { 268 298 // last inflow box to parent. … … 276 306 return false; 277 307 278 if (isMarginBottomCollapsedThrough(layout State, layoutBox))308 if (isMarginBottomCollapsedThrough(layoutBox)) 279 309 return false; 280 310 … … 293 323 return false; 294 324 295 auto& parentDisplayBox = layoutState.displayBoxForLayoutBox(parent); 296 if (parentDisplayBox.borderTop()) 297 return false; 298 299 if (parentDisplayBox.paddingTop().value_or(0)) 325 if (hasBorderBefore(parent)) 326 return false; 327 328 if (hasPaddingBefore(parent)) 300 329 return false; 301 330 … … 325 354 // FIXME: Check for collapsed through margin. 326 355 auto& lastInFlowChild = *downcast<Container>(layoutBox).lastInFlowChild(); 327 if (!isMarginBottomCollapsedWithParent(la youtState, lastInFlowChild))356 if (!isMarginBottomCollapsedWithParent(lastInFlowChild)) 328 357 return 0; 329 358 -
trunk/Tools/ChangeLog
r238734 r238735 1 2018-11-30 Zalan Bujtas <zalan@apple.com> 2 3 [LFC][BFC][MarginCollapsing] Do not use computed display box values for border and padding 4 https://bugs.webkit.org/show_bug.cgi?id=192214 5 6 Reviewed by Antti Koivisto. 7 8 * LayoutReloaded/misc/LFC-passing-tests.txt: 9 1 10 2018-11-30 Thibault Saunier <tsaunier@igalia.com> 2 11 -
trunk/Tools/LayoutReloaded/misc/LFC-passing-tests.txt
r238701 r238735 141 141 fast/block/positioning/052.html 142 142 fast/block/positioning/054.html 143 fast/block/inside-inlines/basic-float-intrusion.html
Note:
See TracChangeset
for help on using the changeset viewer.