| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 MarginInfo m_marginInfo; | 243 MarginInfo m_marginInfo; |
| 244 LayoutUnit m_previousFloatLogicalBottom; | 244 LayoutUnit m_previousFloatLogicalBottom; |
| 245 EBreakBetween m_previousBreakAfterValue; | 245 EBreakBetween m_previousBreakAfterValue; |
| 246 bool m_isAtFirstInFlowChild; | 246 bool m_isAtFirstInFlowChild; |
| 247 }; | 247 }; |
| 248 | 248 |
| 249 LayoutBlockFlow::LayoutBlockFlow(ContainerNode* node) : LayoutBlock(node) { | 249 LayoutBlockFlow::LayoutBlockFlow(ContainerNode* node) : LayoutBlock(node) { |
| 250 static_assert(sizeof(MarginInfo) == sizeof(SameSizeAsMarginInfo), | 250 static_assert(sizeof(MarginInfo) == sizeof(SameSizeAsMarginInfo), |
| 251 "MarginInfo should stay small"); | 251 "MarginInfo should stay small"); |
| 252 setChildrenInline(true); | 252 setChildrenInline(true); |
| 253 m_rareStat.addReason(ReasonLBFAll); |
| 253 } | 254 } |
| 254 | 255 |
| 255 LayoutBlockFlow::~LayoutBlockFlow() {} | 256 LayoutBlockFlow::~LayoutBlockFlow() {} |
| 256 | 257 |
| 257 LayoutBlockFlow* LayoutBlockFlow::createAnonymous(Document* document) { | 258 LayoutBlockFlow* LayoutBlockFlow::createAnonymous(Document* document) { |
| 258 LayoutBlockFlow* layoutBlockFlow = new LayoutBlockFlow(nullptr); | 259 LayoutBlockFlow* layoutBlockFlow = new LayoutBlockFlow(nullptr); |
| 259 layoutBlockFlow->setDocumentForAnonymous(document); | 260 layoutBlockFlow->setDocumentForAnonymous(document); |
| 260 return layoutBlockFlow; | 261 return layoutBlockFlow; |
| 261 } | 262 } |
| 262 | 263 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 279 return true; | 280 return true; |
| 280 } | 281 } |
| 281 return relayoutChildren; | 282 return relayoutChildren; |
| 282 } | 283 } |
| 283 | 284 |
| 284 void LayoutBlockFlow::setBreakAtLineToAvoidWidow(int lineToBreak) { | 285 void LayoutBlockFlow::setBreakAtLineToAvoidWidow(int lineToBreak) { |
| 285 ASSERT(lineToBreak >= 0); | 286 ASSERT(lineToBreak >= 0); |
| 286 ensureRareData(); | 287 ensureRareData(); |
| 287 ASSERT(!m_rareData->m_didBreakAtLineToAvoidWidow); | 288 ASSERT(!m_rareData->m_didBreakAtLineToAvoidWidow); |
| 288 m_rareData->m_lineBreakToAvoidWidow = lineToBreak; | 289 m_rareData->m_lineBreakToAvoidWidow = lineToBreak; |
| 290 m_rareStat.addReason(ReasonLBFLineBreakToAvoidWidow); |
| 289 } | 291 } |
| 290 | 292 |
| 291 void LayoutBlockFlow::setDidBreakAtLineToAvoidWidow() { | 293 void LayoutBlockFlow::setDidBreakAtLineToAvoidWidow() { |
| 292 ASSERT(!shouldBreakAtLineToAvoidWidow()); | 294 ASSERT(!shouldBreakAtLineToAvoidWidow()); |
| 293 | 295 |
| 294 // This function should be called only after a break was applied to avoid | 296 // This function should be called only after a break was applied to avoid |
| 295 // widows so assert |m_rareData| exists. | 297 // widows so assert |m_rareData| exists. |
| 296 ASSERT(m_rareData); | 298 ASSERT(m_rareData); |
| 297 | 299 |
| 298 m_rareData->m_didBreakAtLineToAvoidWidow = true; | 300 m_rareData->m_didBreakAtLineToAvoidWidow = true; |
| (...skipping 1923 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2222 return; | 2224 return; |
| 2223 } | 2225 } |
| 2224 | 2226 |
| 2225 if (!m_rareData && !value) | 2227 if (!m_rareData && !value) |
| 2226 return; | 2228 return; |
| 2227 | 2229 |
| 2228 if (!m_rareData) | 2230 if (!m_rareData) |
| 2229 m_rareData = WTF::makeUnique<LayoutBlockFlowRareData>(this); | 2231 m_rareData = WTF::makeUnique<LayoutBlockFlowRareData>(this); |
| 2230 | 2232 |
| 2231 m_rareData->m_discardMarginBefore = value; | 2233 m_rareData->m_discardMarginBefore = value; |
| 2234 |
| 2235 if (value) |
| 2236 m_rareStat.addReason(ReasonLBFDiscardMargin); |
| 2232 } | 2237 } |
| 2233 | 2238 |
| 2234 void LayoutBlockFlow::setMustDiscardMarginAfter(bool value) { | 2239 void LayoutBlockFlow::setMustDiscardMarginAfter(bool value) { |
| 2235 if (style()->marginAfterCollapse() == MarginCollapseDiscard) { | 2240 if (style()->marginAfterCollapse() == MarginCollapseDiscard) { |
| 2236 ASSERT(value); | 2241 ASSERT(value); |
| 2237 return; | 2242 return; |
| 2238 } | 2243 } |
| 2239 | 2244 |
| 2240 if (!m_rareData && !value) | 2245 if (!m_rareData && !value) |
| 2241 return; | 2246 return; |
| 2242 | 2247 |
| 2243 if (!m_rareData) | 2248 if (!m_rareData) |
| 2244 m_rareData = WTF::makeUnique<LayoutBlockFlowRareData>(this); | 2249 m_rareData = WTF::makeUnique<LayoutBlockFlowRareData>(this); |
| 2245 | 2250 |
| 2246 m_rareData->m_discardMarginAfter = value; | 2251 m_rareData->m_discardMarginAfter = value; |
| 2252 |
| 2253 if (value) |
| 2254 m_rareStat.addReason(ReasonLBFDiscardMargin); |
| 2247 } | 2255 } |
| 2248 | 2256 |
| 2249 bool LayoutBlockFlow::mustDiscardMarginBefore() const { | 2257 bool LayoutBlockFlow::mustDiscardMarginBefore() const { |
| 2250 return style()->marginBeforeCollapse() == MarginCollapseDiscard || | 2258 return style()->marginBeforeCollapse() == MarginCollapseDiscard || |
| 2251 (m_rareData && m_rareData->m_discardMarginBefore); | 2259 (m_rareData && m_rareData->m_discardMarginBefore); |
| 2252 } | 2260 } |
| 2253 | 2261 |
| 2254 bool LayoutBlockFlow::mustDiscardMarginAfter() const { | 2262 bool LayoutBlockFlow::mustDiscardMarginAfter() const { |
| 2255 return style()->marginAfterCollapse() == MarginCollapseDiscard || | 2263 return style()->marginAfterCollapse() == MarginCollapseDiscard || |
| 2256 (m_rareData && m_rareData->m_discardMarginAfter); | 2264 (m_rareData && m_rareData->m_discardMarginAfter); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2297 | 2305 |
| 2298 void LayoutBlockFlow::setMaxMarginBeforeValues(LayoutUnit pos, LayoutUnit neg) { | 2306 void LayoutBlockFlow::setMaxMarginBeforeValues(LayoutUnit pos, LayoutUnit neg) { |
| 2299 if (!m_rareData) { | 2307 if (!m_rareData) { |
| 2300 if (pos == LayoutBlockFlowRareData::positiveMarginBeforeDefault(this) && | 2308 if (pos == LayoutBlockFlowRareData::positiveMarginBeforeDefault(this) && |
| 2301 neg == LayoutBlockFlowRareData::negativeMarginBeforeDefault(this)) | 2309 neg == LayoutBlockFlowRareData::negativeMarginBeforeDefault(this)) |
| 2302 return; | 2310 return; |
| 2303 m_rareData = WTF::makeUnique<LayoutBlockFlowRareData>(this); | 2311 m_rareData = WTF::makeUnique<LayoutBlockFlowRareData>(this); |
| 2304 } | 2312 } |
| 2305 m_rareData->m_margins.setPositiveMarginBefore(pos); | 2313 m_rareData->m_margins.setPositiveMarginBefore(pos); |
| 2306 m_rareData->m_margins.setNegativeMarginBefore(neg); | 2314 m_rareData->m_margins.setNegativeMarginBefore(neg); |
| 2315 m_rareStat.addReason(ReasonLBFMargin); |
| 2307 } | 2316 } |
| 2308 | 2317 |
| 2309 void LayoutBlockFlow::setMaxMarginAfterValues(LayoutUnit pos, LayoutUnit neg) { | 2318 void LayoutBlockFlow::setMaxMarginAfterValues(LayoutUnit pos, LayoutUnit neg) { |
| 2310 if (!m_rareData) { | 2319 if (!m_rareData) { |
| 2311 if (pos == LayoutBlockFlowRareData::positiveMarginAfterDefault(this) && | 2320 if (pos == LayoutBlockFlowRareData::positiveMarginAfterDefault(this) && |
| 2312 neg == LayoutBlockFlowRareData::negativeMarginAfterDefault(this)) | 2321 neg == LayoutBlockFlowRareData::negativeMarginAfterDefault(this)) |
| 2313 return; | 2322 return; |
| 2314 m_rareData = WTF::makeUnique<LayoutBlockFlowRareData>(this); | 2323 m_rareData = WTF::makeUnique<LayoutBlockFlowRareData>(this); |
| 2315 } | 2324 } |
| 2316 m_rareData->m_margins.setPositiveMarginAfter(pos); | 2325 m_rareData->m_margins.setPositiveMarginAfter(pos); |
| 2317 m_rareData->m_margins.setNegativeMarginAfter(neg); | 2326 m_rareData->m_margins.setNegativeMarginAfter(neg); |
| 2327 m_rareStat.addReason(ReasonLBFMargin); |
| 2318 } | 2328 } |
| 2319 | 2329 |
| 2320 bool LayoutBlockFlow::mustSeparateMarginBeforeForChild( | 2330 bool LayoutBlockFlow::mustSeparateMarginBeforeForChild( |
| 2321 const LayoutBox& child) const { | 2331 const LayoutBox& child) const { |
| 2322 ASSERT(!child.selfNeedsLayout()); | 2332 ASSERT(!child.selfNeedsLayout()); |
| 2323 const ComputedStyle& childStyle = child.styleRef(); | 2333 const ComputedStyle& childStyle = child.styleRef(); |
| 2324 if (!child.isWritingModeRoot()) | 2334 if (!child.isWritingModeRoot()) |
| 2325 return childStyle.marginBeforeCollapse() == MarginCollapseSeparate; | 2335 return childStyle.marginBeforeCollapse() == MarginCollapseSeparate; |
| 2326 if (child.isHorizontalWritingMode() == isHorizontalWritingMode()) | 2336 if (child.isHorizontalWritingMode() == isHorizontalWritingMode()) |
| 2327 return childStyle.marginAfterCollapse() == MarginCollapseSeparate; | 2337 return childStyle.marginAfterCollapse() == MarginCollapseSeparate; |
| (...skipping 1802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4130 } | 4140 } |
| 4131 | 4141 |
| 4132 void LayoutBlockFlow::setPaginationStrutPropagatedFromChild(LayoutUnit strut) { | 4142 void LayoutBlockFlow::setPaginationStrutPropagatedFromChild(LayoutUnit strut) { |
| 4133 strut = std::max(strut, LayoutUnit()); | 4143 strut = std::max(strut, LayoutUnit()); |
| 4134 if (!m_rareData) { | 4144 if (!m_rareData) { |
| 4135 if (!strut) | 4145 if (!strut) |
| 4136 return; | 4146 return; |
| 4137 m_rareData = WTF::makeUnique<LayoutBlockFlowRareData>(this); | 4147 m_rareData = WTF::makeUnique<LayoutBlockFlowRareData>(this); |
| 4138 } | 4148 } |
| 4139 m_rareData->m_paginationStrutPropagatedFromChild = strut; | 4149 m_rareData->m_paginationStrutPropagatedFromChild = strut; |
| 4150 m_rareStat.addReason(ReasonLBFPaginationStrutFromChild); |
| 4140 } | 4151 } |
| 4141 | 4152 |
| 4142 void LayoutBlockFlow::setFirstForcedBreakOffset(LayoutUnit blockOffset) { | 4153 void LayoutBlockFlow::setFirstForcedBreakOffset(LayoutUnit blockOffset) { |
| 4143 if (!m_rareData) { | 4154 if (!m_rareData) { |
| 4144 if (!blockOffset) | 4155 if (!blockOffset) |
| 4145 return; | 4156 return; |
| 4146 m_rareData = WTF::makeUnique<LayoutBlockFlowRareData>(this); | 4157 m_rareData = WTF::makeUnique<LayoutBlockFlowRareData>(this); |
| 4147 } | 4158 } |
| 4148 m_rareData->m_firstForcedBreakOffset = blockOffset; | 4159 m_rareData->m_firstForcedBreakOffset = blockOffset; |
| 4149 } | 4160 } |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4292 m_paginationStateChanged = true; | 4303 m_paginationStateChanged = true; |
| 4293 | 4304 |
| 4294 // Check that addChild() put the flow thread as a direct child, and didn't do | 4305 // Check that addChild() put the flow thread as a direct child, and didn't do |
| 4295 // fancy things. | 4306 // fancy things. |
| 4296 ASSERT(flowThread->parent() == this); | 4307 ASSERT(flowThread->parent() == this); |
| 4297 | 4308 |
| 4298 flowThread->populate(); | 4309 flowThread->populate(); |
| 4299 LayoutBlockFlowRareData& rareData = ensureRareData(); | 4310 LayoutBlockFlowRareData& rareData = ensureRareData(); |
| 4300 ASSERT(!rareData.m_multiColumnFlowThread); | 4311 ASSERT(!rareData.m_multiColumnFlowThread); |
| 4301 rareData.m_multiColumnFlowThread = flowThread; | 4312 rareData.m_multiColumnFlowThread = flowThread; |
| 4313 m_rareStat.addReason(ReasonLBFMultiColumnFlowThread); |
| 4302 } | 4314 } |
| 4303 | 4315 |
| 4304 LayoutBlockFlow::LayoutBlockFlowRareData& LayoutBlockFlow::ensureRareData() { | 4316 LayoutBlockFlow::LayoutBlockFlowRareData& LayoutBlockFlow::ensureRareData() { |
| 4305 if (m_rareData) | 4317 if (m_rareData) |
| 4306 return *m_rareData; | 4318 return *m_rareData; |
| 4307 | 4319 |
| 4308 m_rareData = WTF::makeUnique<LayoutBlockFlowRareData>(this); | 4320 m_rareData = WTF::makeUnique<LayoutBlockFlowRareData>(this); |
| 4309 return *m_rareData; | 4321 return *m_rareData; |
| 4310 } | 4322 } |
| 4311 | 4323 |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4602 return LayoutBlock::invalidatePaintIfNeeded(paintInvalidationState); | 4614 return LayoutBlock::invalidatePaintIfNeeded(paintInvalidationState); |
| 4603 } | 4615 } |
| 4604 | 4616 |
| 4605 void LayoutBlockFlow::invalidateDisplayItemClients( | 4617 void LayoutBlockFlow::invalidateDisplayItemClients( |
| 4606 PaintInvalidationReason invalidationReason) const { | 4618 PaintInvalidationReason invalidationReason) const { |
| 4607 BlockFlowPaintInvalidator(*this).invalidateDisplayItemClients( | 4619 BlockFlowPaintInvalidator(*this).invalidateDisplayItemClients( |
| 4608 invalidationReason); | 4620 invalidationReason); |
| 4609 } | 4621 } |
| 4610 | 4622 |
| 4611 } // namespace blink | 4623 } // namespace blink |
| OLD | NEW |