| 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 "config.h" | 5 #include "config.h" |
| 6 | 6 |
| 7 #include "core/layout/ColumnBalancer.h" | 7 #include "core/layout/ColumnBalancer.h" |
| 8 | 8 |
| 9 #include "core/layout/LayoutMultiColumnSet.h" | 9 #include "core/layout/LayoutMultiColumnSet.h" |
| 10 | 10 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 if (childBox.isOutOfFlowPositioned() || childBox.isColumnSpanAll()) | 59 if (childBox.isOutOfFlowPositioned() || childBox.isColumnSpanAll()) |
| 60 continue; | 60 continue; |
| 61 | 61 |
| 62 // Tables are wicked. Both table rows and table cells are relative to th
eir table section. | 62 // Tables are wicked. Both table rows and table cells are relative to th
eir table section. |
| 63 LayoutUnit offsetForThisChild = childBox.isTableRow() ? LayoutUnit() : c
hildBox.logicalTop(); | 63 LayoutUnit offsetForThisChild = childBox.isTableRow() ? LayoutUnit() : c
hildBox.logicalTop(); |
| 64 m_flowThreadOffset += offsetForThisChild; | 64 m_flowThreadOffset += offsetForThisChild; |
| 65 | 65 |
| 66 examineBoxAfterEntering(childBox); | 66 examineBoxAfterEntering(childBox); |
| 67 // Unless the child is unsplittable, or if the child establishes an inne
r multicol | 67 // Unless the child is unsplittable, or if the child establishes an inne
r multicol |
| 68 // container, we descend into its subtree for further examination. | 68 // container, we descend into its subtree for further examination. |
| 69 if (!childBox.isUnsplittableForPagination() | 69 if (childBox.paginationBreakability() != LayoutBox::ForbidBreaks |
| 70 && (!childBox.isLayoutBlockFlow() || !toLayoutBlockFlow(childBox).mu
ltiColumnFlowThread())) | 70 && (!childBox.isLayoutBlockFlow() || !toLayoutBlockFlow(childBox).mu
ltiColumnFlowThread())) |
| 71 traverseSubtree(childBox); | 71 traverseSubtree(childBox); |
| 72 examineBoxBeforeLeaving(childBox); | 72 examineBoxBeforeLeaving(childBox); |
| 73 | 73 |
| 74 m_flowThreadOffset -= offsetForThisChild; | 74 m_flowThreadOffset -= offsetForThisChild; |
| 75 } | 75 } |
| 76 } | 76 } |
| 77 | 77 |
| 78 InitialColumnHeightFinder::InitialColumnHeightFinder(const MultiColumnFragmentai
nerGroup& group) | 78 InitialColumnHeightFinder::InitialColumnHeightFinder(const MultiColumnFragmentai
nerGroup& group) |
| 79 : ColumnBalancer(group) | 79 : ColumnBalancer(group) |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 void MinimumSpaceShortageFinder::examineBoxAfterEntering(const LayoutBox& box) | 209 void MinimumSpaceShortageFinder::examineBoxAfterEntering(const LayoutBox& box) |
| 210 { | 210 { |
| 211 if (box.hasForcedBreakBefore()) | 211 if (box.hasForcedBreakBefore()) |
| 212 m_forcedBreaksCount++; | 212 m_forcedBreaksCount++; |
| 213 if (box.hasForcedBreakAfter()) | 213 if (box.hasForcedBreakAfter()) |
| 214 m_forcedBreaksCount++; | 214 m_forcedBreaksCount++; |
| 215 | 215 |
| 216 // Look for breaks before the child box. | 216 // Look for breaks before the child box. |
| 217 bool isFirstAfterBreak = this->isFirstAfterBreak(flowThreadOffset()); | 217 bool isFirstAfterBreak = this->isFirstAfterBreak(flowThreadOffset()); |
| 218 ASSERT(isFirstAfterBreak || !box.paginationStrut()); | 218 ASSERT(isFirstAfterBreak || !box.paginationStrut()); |
| 219 LayoutBox::PaginationBreakability breakability = box.paginationBreakability(
); |
| 219 if (isFirstAfterBreak && !box.hasForcedBreakBefore()) { | 220 if (isFirstAfterBreak && !box.hasForcedBreakBefore()) { |
| 220 // This box is first after a soft break. | 221 // This box is first after a soft break. |
| 221 LayoutUnit strut = box.paginationStrut(); | 222 LayoutUnit strut = box.paginationStrut(); |
| 222 if (box.isUnsplittableForPagination()) { | 223 if (breakability == LayoutBox::ForbidBreaks) { |
| 223 // Since we cannot break inside the box, just figure out how much mo
re space we would | 224 // Since we cannot break inside the box, just figure out how much mo
re space we would |
| 224 // need to prevent it from being pushed to the next column. | 225 // need to prevent it from being pushed to the next column. |
| 225 recordSpaceShortage(box.logicalHeight() - strut); | 226 recordSpaceShortage(box.logicalHeight() - strut); |
| 226 } else if (m_pendingStrut == LayoutUnit::min()) { | 227 } else if (m_pendingStrut == LayoutUnit::min()) { |
| 227 // We now want to look for the first piece of unbreakable content (e
.g. a line or a | 228 // We now want to look for the first piece of unbreakable content (e
.g. a line or a |
| 228 // block-displayed image) inside this block. That ought to be a good
candidate for | 229 // block-displayed image) inside this block. That ought to be a good
candidate for |
| 229 // minimum space shortage; a much better one than reporting space sh
ortage for the | 230 // minimum space shortage; a much better one than reporting space sh
ortage for the |
| 230 // entire block (which we'll also do (further down), in case we coul
dn't find anything | 231 // entire block (which we'll also do (further down), in case we coul
dn't find anything |
| 231 // more suitable). | 232 // more suitable). |
| 232 m_pendingStrut = strut; | 233 m_pendingStrut = strut; |
| 233 } | 234 } |
| 234 } | 235 } |
| 235 | 236 |
| 236 if (!box.isUnsplittableForPagination()) { | 237 if (breakability != LayoutBox::ForbidBreaks) { |
| 237 // See if this breakable box crosses column boundaries. | 238 // See if this breakable box crosses column boundaries. |
| 238 LayoutUnit bottomInFlowThread = flowThreadOffset() + box.logicalHeight()
; | 239 LayoutUnit bottomInFlowThread = flowThreadOffset() + box.logicalHeight()
; |
| 239 if (isFirstAfterBreak || group().columnLogicalTopForOffset(flowThreadOff
set()) != group().columnLogicalTopForOffset(bottomInFlowThread)) { | 240 if (isFirstAfterBreak || group().columnLogicalTopForOffset(flowThreadOff
set()) != group().columnLogicalTopForOffset(bottomInFlowThread)) { |
| 240 // If the child crosses a column boundary, record space shortage, in
case nothing | 241 // If the child crosses a column boundary, record space shortage, in
case nothing |
| 241 // inside it has already done so. The column balancer needs to know
by how much it | 242 // inside it has already done so. The column balancer needs to know
by how much it |
| 242 // has to stretch the columns to make more content fit. If no breaks
are reported | 243 // has to stretch the columns to make more content fit. If no breaks
are reported |
| 243 // (but do occur), the balancer will have no clue. Only measure the
space after the | 244 // (but do occur), the balancer will have no clue. Only measure the
space after the |
| 244 // last column boundary, in case it crosses more than one. | 245 // last column boundary, in case it crosses more than one. |
| 245 LayoutUnit spaceUsedInLastColumn = bottomInFlowThread - group().colu
mnLogicalTopForOffset(bottomInFlowThread); | 246 LayoutUnit spaceUsedInLastColumn = bottomInFlowThread - group().colu
mnLogicalTopForOffset(bottomInFlowThread); |
| 246 recordSpaceShortage(spaceUsedInLastColumn); | 247 recordSpaceShortage(spaceUsedInLastColumn); |
| 247 } | 248 } |
| 248 } | 249 } |
| 249 } | 250 } |
| 250 | 251 |
| 251 void MinimumSpaceShortageFinder::examineBoxBeforeLeaving(const LayoutBox& box) | 252 void MinimumSpaceShortageFinder::examineBoxBeforeLeaving(const LayoutBox& box) |
| 252 { | 253 { |
| 253 if (m_pendingStrut == LayoutUnit::min() || !box.isUnsplittableForPagination(
)) | 254 if (m_pendingStrut == LayoutUnit::min() || box.paginationBreakability() != L
ayoutBox::ForbidBreaks) |
| 254 return; | 255 return; |
| 255 | 256 |
| 256 // The previous break was before a breakable block. Here's the first piece o
f unbreakable | 257 // The previous break was before a breakable block. Here's the first piece o
f unbreakable |
| 257 // content after / inside that block. We want to record the distance from th
e top of the column | 258 // content after / inside that block. We want to record the distance from th
e top of the column |
| 258 // to the bottom of this box as space shortage. | 259 // to the bottom of this box as space shortage. |
| 259 LayoutUnit logicalOffsetFromCurrentColumn = flowThreadOffset() - group().col
umnLogicalTopForOffset(flowThreadOffset()); | 260 LayoutUnit logicalOffsetFromCurrentColumn = flowThreadOffset() - group().col
umnLogicalTopForOffset(flowThreadOffset()); |
| 260 recordSpaceShortage(logicalOffsetFromCurrentColumn + box.logicalHeight() - m
_pendingStrut); | 261 recordSpaceShortage(logicalOffsetFromCurrentColumn + box.logicalHeight() - m
_pendingStrut); |
| 261 m_pendingStrut = LayoutUnit::min(); | 262 m_pendingStrut = LayoutUnit::min(); |
| 262 } | 263 } |
| 263 | 264 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 274 recordSpaceShortage(logicalOffsetFromCurrentColumn + lineHeight - m_pend
ingStrut); | 275 recordSpaceShortage(logicalOffsetFromCurrentColumn + lineHeight - m_pend
ingStrut); |
| 275 m_pendingStrut = LayoutUnit::min(); | 276 m_pendingStrut = LayoutUnit::min(); |
| 276 return; | 277 return; |
| 277 } | 278 } |
| 278 ASSERT(isFirstAfterBreak(lineTopInFlowThread) || !line.paginationStrut()); | 279 ASSERT(isFirstAfterBreak(lineTopInFlowThread) || !line.paginationStrut()); |
| 279 if (isFirstAfterBreak(lineTopInFlowThread)) | 280 if (isFirstAfterBreak(lineTopInFlowThread)) |
| 280 recordSpaceShortage(lineHeight - line.paginationStrut()); | 281 recordSpaceShortage(lineHeight - line.paginationStrut()); |
| 281 } | 282 } |
| 282 | 283 |
| 283 } // namespace blink | 284 } // namespace blink |
| OLD | NEW |