| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/layout/ColumnBalancer.h" | 5 #include "core/layout/ColumnBalancer.h" |
| 6 | 6 |
| 7 #include "core/layout/LayoutMultiColumnFlowThread.h" | 7 #include "core/layout/LayoutMultiColumnFlowThread.h" |
| 8 #include "core/layout/LayoutMultiColumnSet.h" | 8 #include "core/layout/LayoutMultiColumnSet.h" |
| 9 #include "core/layout/api/LineLayoutBlockFlow.h" | 9 #include "core/layout/api/LineLayoutBlockFlow.h" |
| 10 | 10 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 unsigned index = contentRunIndexWithTallestColumns(); | 95 unsigned index = contentRunIndexWithTallestColumns(); |
| 96 LayoutUnit startOffset = index > 0 ? m_contentRuns[index - 1].breakOffset()
: group().logicalTopInFlowThread(); | 96 LayoutUnit startOffset = index > 0 ? m_contentRuns[index - 1].breakOffset()
: group().logicalTopInFlowThread(); |
| 97 return m_contentRuns[index].columnLogicalHeight(startOffset); | 97 return m_contentRuns[index].columnLogicalHeight(startOffset); |
| 98 } | 98 } |
| 99 | 99 |
| 100 void InitialColumnHeightFinder::examineBoxAfterEntering(const LayoutBox& box) | 100 void InitialColumnHeightFinder::examineBoxAfterEntering(const LayoutBox& box) |
| 101 { | 101 { |
| 102 if (isLogicalTopWithinBounds(flowThreadOffset() - box.paginationStrut())) { | 102 if (isLogicalTopWithinBounds(flowThreadOffset() - box.paginationStrut())) { |
| 103 if (box.needsForcedBreakBefore(previousBreakAfterValue())) { | 103 if (box.needsForcedBreakBefore(previousBreakAfterValue())) { |
| 104 addContentRun(flowThreadOffset()); | 104 addContentRun(flowThreadOffset()); |
| 105 } else if (isFirstAfterBreak(flowThreadOffset())) { | 105 } else { |
| 106 // This box is first after a soft break. | |
| 107 ASSERT(isFirstAfterBreak(flowThreadOffset()) || !box.paginationStrut
()); | 106 ASSERT(isFirstAfterBreak(flowThreadOffset()) || !box.paginationStrut
()); |
| 108 recordStrutBeforeOffset(flowThreadOffset(), box.paginationStrut()); | 107 if (isFirstAfterBreak(flowThreadOffset())) { |
| 108 // This box is first after a soft break. |
| 109 recordStrutBeforeOffset(flowThreadOffset(), box.paginationStrut(
)); |
| 110 } |
| 109 } | 111 } |
| 110 } | 112 } |
| 111 | 113 |
| 112 if (box.getPaginationBreakability() != LayoutBox::AllowAnyBreaks) { | 114 if (box.getPaginationBreakability() != LayoutBox::AllowAnyBreaks) { |
| 113 LayoutUnit unsplittableLogicalHeight = box.logicalHeight(); | 115 LayoutUnit unsplittableLogicalHeight = box.logicalHeight(); |
| 114 if (box.isFloating()) | 116 if (box.isFloating()) |
| 115 unsplittableLogicalHeight += box.marginBefore() + box.marginAfter(); | 117 unsplittableLogicalHeight += box.marginBefore() + box.marginAfter(); |
| 116 m_tallestUnbreakableLogicalHeight = std::max(m_tallestUnbreakableLogical
Height, unsplittableLogicalHeight); | 118 m_tallestUnbreakableLogicalHeight = std::max(m_tallestUnbreakableLogical
Height, unsplittableLogicalHeight); |
| 117 return; | 119 return; |
| 118 } | 120 } |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 } | 240 } |
| 239 | 241 |
| 240 void MinimumSpaceShortageFinder::examineBoxAfterEntering(const LayoutBox& box) | 242 void MinimumSpaceShortageFinder::examineBoxAfterEntering(const LayoutBox& box) |
| 241 { | 243 { |
| 242 LayoutBox::PaginationBreakability breakability = box.getPaginationBreakabili
ty(); | 244 LayoutBox::PaginationBreakability breakability = box.getPaginationBreakabili
ty(); |
| 243 | 245 |
| 244 // Look for breaks before the child box. | 246 // Look for breaks before the child box. |
| 245 if (isLogicalTopWithinBounds(flowThreadOffset() - box.paginationStrut())) { | 247 if (isLogicalTopWithinBounds(flowThreadOffset() - box.paginationStrut())) { |
| 246 if (box.needsForcedBreakBefore(previousBreakAfterValue())) { | 248 if (box.needsForcedBreakBefore(previousBreakAfterValue())) { |
| 247 m_forcedBreaksCount++; | 249 m_forcedBreaksCount++; |
| 248 } else if (isFirstAfterBreak(flowThreadOffset())) { | 250 } else { |
| 249 // This box is first after a soft break. | |
| 250 ASSERT(isFirstAfterBreak(flowThreadOffset()) || !box.paginationStrut
()); | 251 ASSERT(isFirstAfterBreak(flowThreadOffset()) || !box.paginationStrut
()); |
| 251 LayoutUnit strut = box.paginationStrut(); | 252 if (isFirstAfterBreak(flowThreadOffset())) { |
| 252 // Figure out how much more space we would need to prevent it from b
eing pushed to the next column. | 253 // This box is first after a soft break. |
| 253 recordSpaceShortage(box.logicalHeight() - strut); | 254 LayoutUnit strut = box.paginationStrut(); |
| 254 if (breakability != LayoutBox::ForbidBreaks && m_pendingStrut == Lay
outUnit::min()) { | 255 // Figure out how much more space we would need to prevent it fr
om being pushed to the next column. |
| 255 // We now want to look for the first piece of unbreakable conten
t (e.g. a line or a | 256 recordSpaceShortage(box.logicalHeight() - strut); |
| 256 // block-displayed image) inside this block. That ought to be a
good candidate for | 257 if (breakability != LayoutBox::ForbidBreaks && m_pendingStrut ==
LayoutUnit::min()) { |
| 257 // minimum space shortage; a much better one than reporting spac
e shortage for the | 258 // We now want to look for the first piece of unbreakable co
ntent (e.g. a line or a |
| 258 // entire block (which we'll also do (further down), in case we
couldn't find anything | 259 // block-displayed image) inside this block. That ought to b
e a good candidate for |
| 259 // more suitable). | 260 // minimum space shortage; a much better one than reporting
space shortage for the |
| 260 m_pendingStrut = strut; | 261 // entire block (which we'll also do (further down), in case
we couldn't find anything |
| 262 // more suitable). |
| 263 m_pendingStrut = strut; |
| 264 } |
| 261 } | 265 } |
| 262 } | 266 } |
| 263 } | 267 } |
| 264 | 268 |
| 265 if (breakability != LayoutBox::ForbidBreaks) { | 269 if (breakability != LayoutBox::ForbidBreaks) { |
| 266 // See if this breakable box crosses column boundaries. | 270 // See if this breakable box crosses column boundaries. |
| 267 LayoutUnit bottomInFlowThread = flowThreadOffset() + box.logicalHeight()
; | 271 LayoutUnit bottomInFlowThread = flowThreadOffset() + box.logicalHeight()
; |
| 268 if (isFirstAfterBreak(flowThreadOffset()) | 272 if (isFirstAfterBreak(flowThreadOffset()) |
| 269 || group().columnLogicalTopForOffset(flowThreadOffset()) != group().
columnLogicalTopForOffset(bottomInFlowThread)) { | 273 || group().columnLogicalTopForOffset(flowThreadOffset()) != group().
columnLogicalTopForOffset(bottomInFlowThread)) { |
| 270 // If the child crosses a column boundary, record space shortage, in
case nothing | 274 // If the child crosses a column boundary, record space shortage, in
case nothing |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 recordSpaceShortage(logicalOffsetFromCurrentColumn + lineHeight - m_pend
ingStrut); | 321 recordSpaceShortage(logicalOffsetFromCurrentColumn + lineHeight - m_pend
ingStrut); |
| 318 m_pendingStrut = LayoutUnit::min(); | 322 m_pendingStrut = LayoutUnit::min(); |
| 319 return; | 323 return; |
| 320 } | 324 } |
| 321 ASSERT(isFirstAfterBreak(lineTopInFlowThread) || !line.paginationStrut() ||
!isLogicalTopWithinBounds(lineTopInFlowThread - line.paginationStrut())); | 325 ASSERT(isFirstAfterBreak(lineTopInFlowThread) || !line.paginationStrut() ||
!isLogicalTopWithinBounds(lineTopInFlowThread - line.paginationStrut())); |
| 322 if (isFirstAfterBreak(lineTopInFlowThread)) | 326 if (isFirstAfterBreak(lineTopInFlowThread)) |
| 323 recordSpaceShortage(lineHeight - line.paginationStrut()); | 327 recordSpaceShortage(lineHeight - line.paginationStrut()); |
| 324 } | 328 } |
| 325 | 329 |
| 326 } // namespace blink | 330 } // namespace blink |
| OLD | NEW |