| 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 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 | 69 |
| 70 private: | 70 private: |
| 71 InitialColumnHeightFinder(const MultiColumnFragmentainerGroup&); | 71 InitialColumnHeightFinder(const MultiColumnFragmentainerGroup&); |
| 72 | 72 |
| 73 LayoutUnit initialMinimalBalancedHeight() const; | 73 LayoutUnit initialMinimalBalancedHeight() const; |
| 74 | 74 |
| 75 void examineBoxAfterEntering(const LayoutBox&); | 75 void examineBoxAfterEntering(const LayoutBox&); |
| 76 void examineBoxBeforeLeaving(const LayoutBox&); | 76 void examineBoxBeforeLeaving(const LayoutBox&); |
| 77 void examineLine(const RootInlineBox&); | 77 void examineLine(const RootInlineBox&); |
| 78 | 78 |
| 79 // Record that there's a pagination strut that ends at the specified |offset
InFlowThread|, which |
| 80 // is an offset exactly at the top of some column. |
| 81 void recordStrutBeforeOffset(LayoutUnit offsetInFlowThread, LayoutUnit strut
); |
| 82 |
| 83 // Return the accumulated space used by struts at all column boundaries prec
eding the specified |
| 84 // flowthread offset. |
| 85 LayoutUnit spaceUsedByStrutsAt(LayoutUnit offsetInFlowThread) const; |
| 86 |
| 79 // Add a content run, specified by its end position. A content run is append
ed at every | 87 // Add a content run, specified by its end position. A content run is append
ed at every |
| 80 // forced/explicit break and at the end of the column set. The content runs
are used to | 88 // forced/explicit break and at the end of the column set. The content runs
are used to |
| 81 // determine where implicit/soft breaks will occur, in order to calculate an
initial column | 89 // determine where implicit/soft breaks will occur, in order to calculate an
initial column |
| 82 // height. | 90 // height. |
| 83 void addContentRun(LayoutUnit endOffsetInFlowThread); | 91 void addContentRun(LayoutUnit endOffsetInFlowThread); |
| 84 | 92 |
| 85 // Return the index of the content run with the currently tallest columns, t
aking all implicit | 93 // Return the index of the content run with the currently tallest columns, t
aking all implicit |
| 86 // breaks assumed so far into account. | 94 // breaks assumed so far into account. |
| 87 unsigned contentRunIndexWithTallestColumns() const; | 95 unsigned contentRunIndexWithTallestColumns() const; |
| 88 | 96 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 110 | 118 |
| 111 // Return the column height that this content run would require, conside
ring the implicit | 119 // Return the column height that this content run would require, conside
ring the implicit |
| 112 // breaks assumed so far. | 120 // breaks assumed so far. |
| 113 LayoutUnit columnLogicalHeight(LayoutUnit startOffset) const { return ce
ilf((m_breakOffset - startOffset).toFloat() / float(m_assumedImplicitBreaks + 1)
); } | 121 LayoutUnit columnLogicalHeight(LayoutUnit startOffset) const { return ce
ilf((m_breakOffset - startOffset).toFloat() / float(m_assumedImplicitBreaks + 1)
); } |
| 114 | 122 |
| 115 private: | 123 private: |
| 116 LayoutUnit m_breakOffset; // Flow thread offset where this run ends. | 124 LayoutUnit m_breakOffset; // Flow thread offset where this run ends. |
| 117 unsigned m_assumedImplicitBreaks; // Number of implicit breaks in this r
un assumed so far. | 125 unsigned m_assumedImplicitBreaks; // Number of implicit breaks in this r
un assumed so far. |
| 118 }; | 126 }; |
| 119 Vector<ContentRun, 32> m_contentRuns; | 127 Vector<ContentRun, 32> m_contentRuns; |
| 128 |
| 129 // Shortest strut found at each column boundary (index 0 being the boundary
between the first |
| 130 // and the second column, index 1 being the one between the second and the t
hird boundary, and |
| 131 // so on). There may be several objects that cross the same column boundary,
and we're only |
| 132 // interested in the shortest one. For example, when having a float beside r
egular in-flow |
| 133 // content, we end up with two parallel fragmentation flows [1]. The shortes
t strut found at a |
| 134 // column boundary is the amount of space that we wasted at said column boun
dary, and it needs |
| 135 // to be deducted when estimating the initial balanced column height, or we
risk making the |
| 136 // column row too tall. An entry set to LayoutUnit::max() means that we didn
't detect any object |
| 137 // crossing that boundary. |
| 138 // |
| 139 // [1] http://www.w3.org/TR/css3-break/#parallel-flows |
| 140 Vector<LayoutUnit, 32> m_shortestStruts; |
| 120 }; | 141 }; |
| 121 | 142 |
| 122 // If we have previously used InitialColumnHeightFinder to estimate an initial c
olumn height, and | 143 // If we have previously used InitialColumnHeightFinder to estimate an initial c
olumn height, and |
| 123 // that didn't result in tall enough columns, we need subsequent layout passes w
here we increase | 144 // that didn't result in tall enough columns, we need subsequent layout passes w
here we increase |
| 124 // the column height by the minimum space shortage at column breaks. This class
finds the minimum | 145 // the column height by the minimum space shortage at column breaks. This class
finds the minimum |
| 125 // space shortage after having laid out with the current column height. | 146 // space shortage after having laid out with the current column height. |
| 126 class MinimumSpaceShortageFinder final : public ColumnBalancer { | 147 class MinimumSpaceShortageFinder final : public ColumnBalancer { |
| 127 public: | 148 public: |
| 128 MinimumSpaceShortageFinder(const MultiColumnFragmentainerGroup&); | 149 MinimumSpaceShortageFinder(const MultiColumnFragmentainerGroup&); |
| 129 | 150 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 148 LayoutUnit m_minimumSpaceShortage; | 169 LayoutUnit m_minimumSpaceShortage; |
| 149 | 170 |
| 150 // Set when breaking before a block, and we're looking for the first unbreak
able descendant, in | 171 // Set when breaking before a block, and we're looking for the first unbreak
able descendant, in |
| 151 // order to report correct space shortage for that one. | 172 // order to report correct space shortage for that one. |
| 152 LayoutUnit m_pendingStrut; | 173 LayoutUnit m_pendingStrut; |
| 153 | 174 |
| 154 unsigned m_forcedBreaksCount; | 175 unsigned m_forcedBreaksCount; |
| 155 }; | 176 }; |
| 156 | 177 |
| 157 } // namespace blink | 178 } // namespace blink |
| OLD | NEW |