Changeset 232661 in webkit
- Timestamp:
- Jun 9, 2018 12:35:33 PM (6 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r232660 r232661 1 2018-06-09 Zalan Bujtas <zalan@apple.com> 2 3 [LFC] MarginCollapse functions should be able to resolve non-fixed margin values 4 https://bugs.webkit.org/show_bug.cgi?id=186461 5 6 Reviewed by Antti Koivisto. 7 8 We need the containing block's computed width to resolve vertical and horizontal margins. 9 10 * layout/blockformatting/BlockFormattingContext.h: 11 * layout/blockformatting/BlockMarginCollapse.cpp: 12 (WebCore::Layout::BlockFormattingContext::MarginCollapse::collapsedMarginTopFromFirstChild): 13 (WebCore::Layout::BlockFormattingContext::MarginCollapse::nonCollapsedMarginTop): 14 (WebCore::Layout::BlockFormattingContext::MarginCollapse::computedNonCollapsedMarginTop): 15 (WebCore::Layout::BlockFormattingContext::MarginCollapse::computedNonCollapsedMarginBottom): 16 (WebCore::Layout::BlockFormattingContext::MarginCollapse::marginTop): 17 (WebCore::Layout::BlockFormattingContext::MarginCollapse::marginBottom): 18 (WebCore::Layout::BlockFormattingContext::MarginCollapse::collapsedMarginBottomFromLastChild): 19 (WebCore::Layout::BlockFormattingContext::MarginCollapse::nonCollapsedMarginBottom): 20 (WebCore::Layout::collapsedMarginTopFromFirstChild): Deleted. 21 (WebCore::Layout::nonCollapsedMarginTop): Deleted. 22 1 23 2018-06-08 Darin Adler <darin@apple.com> 2 24 -
trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h
r232581 r232661 78 78 class MarginCollapse { 79 79 public: 80 static LayoutUnit marginTop(const Box&);81 static LayoutUnit marginBottom(const Box&);80 static LayoutUnit marginTop(const LayoutContext&, const Box&); 81 static LayoutUnit marginBottom(const LayoutContext&, const Box&); 82 82 83 83 static bool isMarginBottomCollapsedWithParent(const Box&); … … 85 85 86 86 private: 87 static LayoutUnit collapsedMarginBottomFromLastChild(const Box&); 88 static LayoutUnit nonCollapsedMarginBottom(const Box&); 87 static LayoutUnit collapsedMarginBottomFromLastChild(const LayoutContext&, const Box&); 88 static LayoutUnit nonCollapsedMarginBottom(const LayoutContext&, const Box&); 89 90 static LayoutUnit computedNonCollapsedMarginTop(const LayoutContext&, const Box&); 91 static LayoutUnit computedNonCollapsedMarginBottom(const LayoutContext&, const Box&); 92 93 static LayoutUnit collapsedMarginTopFromFirstChild(const LayoutContext&, const Box&); 94 static LayoutUnit nonCollapsedMarginTop(const LayoutContext&, const Box&); 89 95 }; 90 96 }; -
trunk/Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp
r232225 r232661 112 112 } 113 113 114 static LayoutUnit collapsedMarginTopFromFirstChild(const Box& layoutBox)114 LayoutUnit BlockFormattingContext::MarginCollapse::collapsedMarginTopFromFirstChild(const LayoutContext& layoutContext, const Box& layoutBox) 115 115 { 116 116 // Check if the first child collapses its margin top. … … 123 123 124 124 // Collect collapsed margin top recursively. 125 return marginValue( firstInFlowChild.style().marginTop().value(), collapsedMarginTopFromFirstChild(firstInFlowChild));126 } 127 128 static LayoutUnit nonCollapsedMarginTop(const Box& layoutBox)125 return marginValue(computedNonCollapsedMarginTop(layoutContext, firstInFlowChild), collapsedMarginTopFromFirstChild(layoutContext, firstInFlowChild)); 126 } 127 128 LayoutUnit BlockFormattingContext::MarginCollapse::nonCollapsedMarginTop(const LayoutContext& layoutContext, const Box& layoutBox) 129 129 { 130 130 // Non collapsed margin top includes collapsed margin from inflow first child. 131 return marginValue( layoutBox.style().marginTop().value(), collapsedMarginTopFromFirstChild(layoutBox));131 return marginValue(computedNonCollapsedMarginTop(layoutContext, layoutBox), collapsedMarginTopFromFirstChild(layoutContext, layoutBox)); 132 132 } 133 133 … … 146 146 return false; 147 147 }*/ 148 149 LayoutUnit BlockFormattingContext::MarginCollapse::marginTop(const Box& layoutBox) 148 LayoutUnit BlockFormattingContext::MarginCollapse::computedNonCollapsedMarginTop(const LayoutContext& layoutContext, const Box& layoutBox) 149 { 150 return FormattingContext::Geometry::computedNonCollapsedVerticalMarginValue(layoutContext, layoutBox).top; 151 } 152 153 LayoutUnit BlockFormattingContext::MarginCollapse::computedNonCollapsedMarginBottom(const LayoutContext& layoutContext, const Box& layoutBox) 154 { 155 return FormattingContext::Geometry::computedNonCollapsedVerticalMarginValue(layoutContext, layoutBox).bottom; 156 } 157 158 LayoutUnit BlockFormattingContext::MarginCollapse::marginTop(const LayoutContext& layoutContext, const Box& layoutBox) 150 159 { 151 160 if (layoutBox.isAnonymous()) … … 158 167 // Floats and out of flow positioned boxes do not collapse their margins. 159 168 if (!isMarginTopCollapsedWithSibling(layoutBox)) 160 return nonCollapsedMarginTop(layout Box);169 return nonCollapsedMarginTop(layoutContext, layoutBox); 161 170 162 171 // The bottom margin of an in-flow block-level element always collapses with the top margin of its next in-flow block-level sibling, … … 164 173 auto* previousInFlowSibling = layoutBox.previousInFlowSibling(); 165 174 if (!previousInFlowSibling) 166 return nonCollapsedMarginTop(layout Box);167 168 auto previousSiblingMarginBottom = nonCollapsedMarginBottom( *previousInFlowSibling);169 auto marginTop = nonCollapsedMarginTop(layout Box);175 return nonCollapsedMarginTop(layoutContext, layoutBox); 176 177 auto previousSiblingMarginBottom = nonCollapsedMarginBottom(layoutContext, *previousInFlowSibling); 178 auto marginTop = nonCollapsedMarginTop(layoutContext, layoutBox); 170 179 return marginValue(marginTop, previousSiblingMarginBottom); 171 180 } 172 181 173 LayoutUnit BlockFormattingContext::MarginCollapse::marginBottom(const Box& layoutBox)182 LayoutUnit BlockFormattingContext::MarginCollapse::marginBottom(const LayoutContext& layoutContext, const Box& layoutBox) 174 183 { 175 184 if (layoutBox.isAnonymous()) … … 182 191 // Floats and out of flow positioned boxes do not collapse their margins. 183 192 if (!isMarginBottomCollapsedWithSibling(layoutBox)) 184 return nonCollapsedMarginBottom(layout Box);193 return nonCollapsedMarginBottom(layoutContext, layoutBox); 185 194 186 195 // The bottom margin of an in-flow block-level element always collapses with the top margin of its next in-flow block-level sibling, … … 188 197 if (layoutBox.nextInFlowSibling()) 189 198 return 0; 190 return nonCollapsedMarginBottom(layout Box);199 return nonCollapsedMarginBottom(layoutContext, layoutBox); 191 200 } 192 201 … … 232 241 } 233 242 234 LayoutUnit BlockFormattingContext::MarginCollapse::collapsedMarginBottomFromLastChild(const Box& layoutBox)243 LayoutUnit BlockFormattingContext::MarginCollapse::collapsedMarginBottomFromLastChild(const LayoutContext& layoutContext, const Box& layoutBox) 235 244 { 236 245 // Check if the last child propagates its margin bottom. … … 243 252 244 253 // Collect collapsed margin bottom recursively. 245 return marginValue( lastInFlowChild.style().marginBottom().value(), collapsedMarginBottomFromLastChild(lastInFlowChild));246 } 247 248 LayoutUnit BlockFormattingContext::MarginCollapse::nonCollapsedMarginBottom(const Box& layoutBox)254 return marginValue(computedNonCollapsedMarginBottom(layoutContext, lastInFlowChild), collapsedMarginBottomFromLastChild(layoutContext, lastInFlowChild)); 255 } 256 257 LayoutUnit BlockFormattingContext::MarginCollapse::nonCollapsedMarginBottom(const LayoutContext& layoutContext, const Box& layoutBox) 249 258 { 250 259 // Non collapsed margin bottom includes collapsed margin from inflow last child. 251 return marginValue( layoutBox.style().marginBottom().value(), collapsedMarginBottomFromLastChild(layoutBox));260 return marginValue(computedNonCollapsedMarginBottom(layoutContext, layoutBox), collapsedMarginBottomFromLastChild(layoutContext, layoutBox)); 252 261 } 253 262
Note: See TracChangeset
for help on using the changeset viewer.