| 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 namespace blink { | 7 namespace blink { |
| 8 | 8 |
| 9 // A column balancer traverses the portion of the subtree of a flow thread that
belongs to a given | 9 // A column balancer traverses the portion of the subtree of a flow thread that
belongs to a given |
| 10 // fragmentainer group, in order to collect certain data to be used for column b
alancing. This is an | 10 // fragmentainer group, in order to collect certain data to be used for column b
alancing. This is an |
| 11 // abstract class that just walks the subtree and leaves it to subclasses to act
ualy collect data. | 11 // abstract class that just walks the subtree and leaves it to subclasses to act
ualy collect data. |
| 12 class ColumnBalancer { | 12 class ColumnBalancer { |
| 13 protected: | 13 protected: |
| 14 ColumnBalancer(const MultiColumnFragmentainerGroup&); | 14 ColumnBalancer(const MultiColumnFragmentainerGroup&); |
| 15 | 15 |
| 16 const MultiColumnFragmentainerGroup& group() const { return m_group; } | 16 const MultiColumnFragmentainerGroup& group() const { return m_group; } |
| 17 | 17 |
| 18 // Flow thread offset for the layout object that we're currently examining. | 18 // Flow thread offset for the layout object that we're currently examining. |
| 19 LayoutUnit flowThreadOffset() const { return m_flowThreadOffset; } | 19 LayoutUnit flowThreadOffset() const { return m_flowThreadOffset; } |
| 20 | 20 |
| 21 EBreak previousBreakAfterValue() const { return m_previousBreakAfterValue; } |
| 22 |
| 21 // Return true if the specified offset is at the top of a column, as long as
it's not the first | 23 // Return true if the specified offset is at the top of a column, as long as
it's not the first |
| 22 // column in the fragmentainer group. | 24 // column in the fragmentainer group. |
| 23 bool isFirstAfterBreak(LayoutUnit flowThreadOffset) const | 25 bool isFirstAfterBreak(LayoutUnit flowThreadOffset) const |
| 24 { | 26 { |
| 25 if (flowThreadOffset != m_group.columnLogicalTopForOffset(flowThreadOffs
et)) | 27 if (flowThreadOffset != m_group.columnLogicalTopForOffset(flowThreadOffs
et)) |
| 26 return false; // Not at the top of a column. | 28 return false; // Not at the top of a column. |
| 27 // The first column in the fragmentainer group is either not after any b
reak at all, or | 29 // The first column in the fragmentainer group is either not after any b
reak at all, or |
| 28 // after a break that belongs to the previous fragmentainer group. | 30 // after a break that belongs to the previous fragmentainer group. |
| 29 return flowThreadOffset > m_group.logicalTopInFlowThread(); | 31 return flowThreadOffset > m_group.logicalTopInFlowThread(); |
| 30 } | 32 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 56 // Examine and collect column balancing data for everything in the fragmenta
iner group. Will | 58 // Examine and collect column balancing data for everything in the fragmenta
iner group. Will |
| 57 // trigger calls to examineBoxAfterEntering(), examineBoxBeforeLeaving() and
examineLine() for | 59 // trigger calls to examineBoxAfterEntering(), examineBoxBeforeLeaving() and
examineLine() for |
| 58 // interesting boxes and lines. | 60 // interesting boxes and lines. |
| 59 void traverse(); | 61 void traverse(); |
| 60 | 62 |
| 61 private: | 63 private: |
| 62 void traverseSubtree(const LayoutBox&); | 64 void traverseSubtree(const LayoutBox&); |
| 63 | 65 |
| 64 const MultiColumnFragmentainerGroup& m_group; | 66 const MultiColumnFragmentainerGroup& m_group; |
| 65 LayoutUnit m_flowThreadOffset; | 67 LayoutUnit m_flowThreadOffset; |
| 68 |
| 69 // The break-after value from the previous in-flow block-level object to be
joined with the |
| 70 // break-before value of the next in-flow block-level object. |
| 71 EBreak m_previousBreakAfterValue; |
| 66 }; | 72 }; |
| 67 | 73 |
| 68 // After an initial layout pass, we know the height of the contents of a flow th
read. Based on | 74 // After an initial layout pass, we know the height of the contents of a flow th
read. Based on |
| 69 // this, we can estimate an initial minimal column height. This class will colle
ct the necessary | 75 // this, we can estimate an initial minimal column height. This class will colle
ct the necessary |
| 70 // information from the layout objects to make this estimate. This estimate may
be used to perform | 76 // information from the layout objects to make this estimate. This estimate may
be used to perform |
| 71 // another layout iteration. If we after such a layout iteration cannot fit the
contents with the | 77 // another layout iteration. If we after such a layout iteration cannot fit the
contents with the |
| 72 // given column height without creating overflowing columns, we will have to str
etch the columns by | 78 // given column height without creating overflowing columns, we will have to str
etch the columns by |
| 73 // some amount and lay out again. We may need to do this several times (but typi
cally not more | 79 // some amount and lay out again. We may need to do this several times (but typi
cally not more |
| 74 // times than the number of columns that we have). The amount to stretch is prov
ided by the sister | 80 // times than the number of columns that we have). The amount to stretch is prov
ided by the sister |
| 75 // of this class, named MinimumSpaceShortageFinder. | 81 // of this class, named MinimumSpaceShortageFinder. |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 LayoutUnit m_minimumSpaceShortage; | 195 LayoutUnit m_minimumSpaceShortage; |
| 190 | 196 |
| 191 // Set when breaking before a block, and we're looking for the first unbreak
able descendant, in | 197 // Set when breaking before a block, and we're looking for the first unbreak
able descendant, in |
| 192 // order to report correct space shortage for that one. | 198 // order to report correct space shortage for that one. |
| 193 LayoutUnit m_pendingStrut; | 199 LayoutUnit m_pendingStrut; |
| 194 | 200 |
| 195 unsigned m_forcedBreaksCount; | 201 unsigned m_forcedBreaksCount; |
| 196 }; | 202 }; |
| 197 | 203 |
| 198 } // namespace blink | 204 } // namespace blink |
| OLD | NEW |