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/MultiColumnFragmentainerGroup.h" | 5 #include "core/layout/MultiColumnFragmentainerGroup.h" |
6 | 6 |
7 #include "core/layout/ColumnBalancer.h" | 7 #include "core/layout/ColumnBalancer.h" |
8 #include "core/layout/FragmentationContext.h" | 8 #include "core/layout/FragmentationContext.h" |
9 #include "core/layout/LayoutMultiColumnSet.h" | 9 #include "core/layout/LayoutMultiColumnSet.h" |
10 | 10 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 // passes as well. | 68 // passes as well. |
69 if (isLastGroup() && m_columnSet.heightIsAuto()) { | 69 if (isLastGroup() && m_columnSet.heightIsAuto()) { |
70 LayoutUnit newColumnHeight; | 70 LayoutUnit newColumnHeight; |
71 if (!m_columnSet.isInitialHeightCalculated()) { | 71 if (!m_columnSet.isInitialHeightCalculated()) { |
72 // Initial balancing: Start with the lowest imaginable column height
. Also calculate the | 72 // Initial balancing: Start with the lowest imaginable column height
. Also calculate the |
73 // height of the tallest piece of unbreakable content. Columns shoul
d never get any | 73 // height of the tallest piece of unbreakable content. Columns shoul
d never get any |
74 // shorter than that (unless constrained by max-height). Propagate t
his to our | 74 // shorter than that (unless constrained by max-height). Propagate t
his to our |
75 // containing column set, in case there is an outer multicol contain
er that also needs | 75 // containing column set, in case there is an outer multicol contain
er that also needs |
76 // to balance. After having calculated the initial column height, th
e multicol container | 76 // to balance. After having calculated the initial column height, th
e multicol container |
77 // needs another layout pass with the column height that we just cal
culated. | 77 // needs another layout pass with the column height that we just cal
culated. |
78 InitialColumnHeightFinder initialHeightFinder(*this); | 78 InitialColumnHeightFinder initialHeightFinder(columnSet(), logicalTo
pInFlowThread(), logicalBottomInFlowThread()); |
79 LayoutUnit tallestUnbreakableLogicalHeight = initialHeightFinder.tal
lestUnbreakableLogicalHeight(); | 79 LayoutUnit tallestUnbreakableLogicalHeight = initialHeightFinder.tal
lestUnbreakableLogicalHeight(); |
80 m_columnSet.propagateTallestUnbreakableLogicalHeight(tallestUnbreaka
bleLogicalHeight); | 80 m_columnSet.propagateTallestUnbreakableLogicalHeight(tallestUnbreaka
bleLogicalHeight); |
81 newColumnHeight = std::max(initialHeightFinder.initialMinimalBalance
dHeight(), tallestUnbreakableLogicalHeight); | 81 newColumnHeight = std::max(initialHeightFinder.initialMinimalBalance
dHeight(), tallestUnbreakableLogicalHeight); |
82 } else { | 82 } else { |
83 // Rebalancing: After having laid out again, we'll need to rebalance
if the height | 83 // Rebalancing: After having laid out again, we'll need to rebalance
if the height |
84 // wasn't enough and we're allowed to stretch it, and then re-lay ou
t. There are further | 84 // wasn't enough and we're allowed to stretch it, and then re-lay ou
t. There are further |
85 // details on the column balancing machinery in ColumnBalancer and i
ts derivates. | 85 // details on the column balancing machinery in ColumnBalancer and i
ts derivates. |
86 newColumnHeight = rebalanceColumnHeightIfNeeded(); | 86 newColumnHeight = rebalanceColumnHeightIfNeeded(); |
87 } | 87 } |
88 setAndConstrainColumnHeight(newColumnHeight); | 88 setAndConstrainColumnHeight(newColumnHeight); |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 return m_columnHeight; | 329 return m_columnHeight; |
330 } | 330 } |
331 | 331 |
332 if (m_columnHeight >= m_maxColumnHeight) { | 332 if (m_columnHeight >= m_maxColumnHeight) { |
333 // We cannot stretch any further. We'll just have to live with the overf
lowing columns. This | 333 // We cannot stretch any further. We'll just have to live with the overf
lowing columns. This |
334 // typically happens if the max column height is less than the height of
the tallest piece | 334 // typically happens if the max column height is less than the height of
the tallest piece |
335 // of unbreakable content (e.g. lines). | 335 // of unbreakable content (e.g. lines). |
336 return m_columnHeight; | 336 return m_columnHeight; |
337 } | 337 } |
338 | 338 |
339 MinimumSpaceShortageFinder shortageFinder(*this); | 339 MinimumSpaceShortageFinder shortageFinder(columnSet(), logicalTopInFlowThrea
d(), logicalBottomInFlowThread()); |
340 | 340 |
341 if (shortageFinder.forcedBreaksCount() + 1 >= m_columnSet.usedColumnCount())
{ | 341 if (shortageFinder.forcedBreaksCount() + 1 >= m_columnSet.usedColumnCount())
{ |
342 // Too many forced breaks to allow any implicit breaks. Initial balancin
g should already | 342 // Too many forced breaks to allow any implicit breaks. Initial balancin
g should already |
343 // have set a good height. There's nothing more we should do. | 343 // have set a good height. There's nothing more we should do. |
344 return m_columnHeight; | 344 return m_columnHeight; |
345 } | 345 } |
346 | 346 |
347 // If the initial guessed column height wasn't enough, stretch it now. Stret
ch by the lowest | 347 // If the initial guessed column height wasn't enough, stretch it now. Stret
ch by the lowest |
348 // amount of space. | 348 // amount of space. |
349 LayoutUnit minSpaceShortage = shortageFinder.minimumSpaceShortage(); | 349 LayoutUnit minSpaceShortage = shortageFinder.minimumSpaceShortage(); |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 append(MultiColumnFragmentainerGroup(m_columnSet)); | 532 append(MultiColumnFragmentainerGroup(m_columnSet)); |
533 return last(); | 533 return last(); |
534 } | 534 } |
535 | 535 |
536 void MultiColumnFragmentainerGroupList::deleteExtraGroups() | 536 void MultiColumnFragmentainerGroupList::deleteExtraGroups() |
537 { | 537 { |
538 shrink(1); | 538 shrink(1); |
539 } | 539 } |
540 | 540 |
541 } // namespace blink | 541 } // namespace blink |
OLD | NEW |