Changeset 239330 in webkit
- Timestamp:
- Dec 18, 2018 7:19:21 AM (5 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r239320 r239330 1 2018-12-18 Zalan Bujtas <zalan@apple.com> 2 3 [LFC][BFC][MarginCollapsing] Expand marginAfterCollapsesWithParentMarginAfter and marginBeforeCollapsesWithParentMarginBefore collapsing logic 4 https://bugs.webkit.org/show_bug.cgi?id=192787 5 6 Reviewed by Antti Koivisto. 7 8 * layout/blockformatting/BlockFormattingContext.h: 9 * layout/blockformatting/BlockMarginCollapse.cpp: 10 (WebCore::Layout::hasClearance): 11 (WebCore::Layout::BlockFormattingContext::Geometry::MarginCollapse::marginBeforeCollapsesWithParentMarginBefore): 12 (WebCore::Layout::BlockFormattingContext::Geometry::MarginCollapse::marginAfterCollapsesWithSiblingMarginBeforeWithClearance): 13 (WebCore::Layout::BlockFormattingContext::Geometry::MarginCollapse::marginAfterCollapsesWithParentMarginBefore): 14 (WebCore::Layout::BlockFormattingContext::Geometry::MarginCollapse::marginAfterCollapsesWithParentMarginAfter): 15 1 16 2018-12-17 Fujii Hironori <Hironori.Fujii@sony.com> 2 17 -
trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h
r239267 r239330 106 106 static bool marginBeforeCollapsesWithPreviousSibling(const Box&); 107 107 static bool marginAfterCollapsesWithNextSibling(const Box&); 108 static bool marginAfterCollapsesWithSiblingMarginBeforeWithClearance(const Box&); 109 static bool marginAfterCollapsesWithParentMarginBefore(const Box&); 108 110 static bool marginsCollapseThrough(const Box&); 109 111 }; -
trunk/Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp
r239267 r239330 70 70 } 71 71 72 static bool hasClearance(const Box& layoutBox) 73 { 74 if (!layoutBox.hasFloatClear()) 75 return false; 76 // FIXME 77 return false; 78 } 79 72 80 static bool establishesBlockFormattingContext(const Box& layoutBox) 73 81 { … … 180 188 ASSERT(layoutBox.isBlockLevelBox()); 181 189 182 if (layoutBox.isFloatingOrOutOfFlowPositioned()) 190 // Margins between a floated box and any other box do not collapse. 191 if (layoutBox.isFloatingPositioned()) 192 return false; 193 194 // Margins of absolutely positioned boxes do not collapse. 195 if (layoutBox.isOutOfFlowPositioned()) 196 return false; 197 198 // Margins of inline-block boxes do not collapse. 199 if (layoutBox.isInlineBlockBox()) 183 200 return false; 184 201 … … 198 215 return false; 199 216 217 // ...and the child has no clearance. 218 if (hasClearance(layoutBox)) 219 return false; 220 200 221 if (BlockFormattingContext::Quirks::shouldIgnoreMarginBefore(layoutState, layoutBox)) 201 222 return false; … … 204 225 } 205 226 227 bool BlockFormattingContext::Geometry::MarginCollapse::marginAfterCollapsesWithSiblingMarginBeforeWithClearance(const Box&) 228 { 229 return false; 230 } 231 232 bool BlockFormattingContext::Geometry::MarginCollapse::marginAfterCollapsesWithParentMarginBefore(const Box&) 233 { 234 return false; 235 } 236 206 237 bool BlockFormattingContext::Geometry::MarginCollapse::marginAfterCollapsesWithParentMarginAfter(const Box& layoutBox) 207 238 { 208 // last inflow box to parent.209 // https://www.w3.org/TR/CSS21/box.html#collapsing-margins210 239 if (layoutBox.isAnonymous()) 211 240 return false; … … 213 242 ASSERT(layoutBox.isBlockLevelBox()); 214 243 215 if (layoutBox.isFloatingOrOutOfFlowPositioned()) 216 return false; 217 218 if (marginsCollapseThrough(layoutBox)) 244 // Margins between a floated box and any other box do not collapse. 245 if (layoutBox.isFloatingPositioned()) 246 return false; 247 248 // Margins of absolutely positioned boxes do not collapse. 249 if (layoutBox.isOutOfFlowPositioned()) 250 return false; 251 252 // Margins of inline-block boxes do not collapse. 253 if (layoutBox.isInlineBlockBox()) 219 254 return false; 220 255 … … 224 259 225 260 auto& parent = *layoutBox.parent(); 226 // Margins of elements that establish new block formatting contexts do not collapse with their in-flow children 261 // Margins of elements that establish new block formatting contexts do not collapse with their in-flow children. 227 262 if (establishesBlockFormattingContext(parent)) 228 263 return false; 229 264 265 // The bottom margin of an in-flow block box with a 'height' of 'auto' collapses with its last in-flow block-level child's bottom margin, if: 266 if (!parent.style().height().isAuto()) 267 return false; 268 269 // the box has no bottom padding, and 270 if (hasPaddingBefore(parent)) 271 return false; 272 273 // the box has no bottom border, and 230 274 if (hasBorderBefore(parent)) 231 275 return false; 232 276 233 if (hasPaddingBefore(parent)) 234 return false; 235 236 if (!parent.style().height().isAuto()) 277 // the child's bottom margin neither collapses with a top margin that has clearance... 278 if (marginAfterCollapsesWithSiblingMarginBeforeWithClearance(layoutBox)) 279 return false; 280 281 // nor (if the box's min-height is non-zero) with the box's top margin. 282 auto computedMinHeight = parent.style().logicalMinHeight(); 283 if (!computedMinHeight.isAuto() && computedMinHeight.value() && marginAfterCollapsesWithParentMarginBefore(layoutBox)) 237 284 return false; 238 285
Note: See TracChangeset
for help on using the changeset viewer.