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 20 matching lines...) Expand all Loading... | |
31 // Examine and collect column balancing data from a layout box that has been found to intersect | 31 // Examine and collect column balancing data from a layout box that has been found to intersect |
32 // with this fragmentainer group. Does not recurse into children. flowThread Offset() will | 32 // with this fragmentainer group. Does not recurse into children. flowThread Offset() will |
33 // return the offset from |box| to the flow thread. Two hooks are provided h ere. The first one | 33 // return the offset from |box| to the flow thread. Two hooks are provided h ere. The first one |
34 // is called right after entering and before traversing the subtree of the b ox, and the second | 34 // is called right after entering and before traversing the subtree of the b ox, and the second |
35 // one right after having traversed the subtree. | 35 // one right after having traversed the subtree. |
36 virtual void examineBoxAfterEntering(const LayoutBox&) = 0; | 36 virtual void examineBoxAfterEntering(const LayoutBox&) = 0; |
37 virtual void examineBoxBeforeLeaving(const LayoutBox&) = 0; | 37 virtual void examineBoxBeforeLeaving(const LayoutBox&) = 0; |
38 | 38 |
39 // Examine and collect column balancing data from a line that has been found to intersect with | 39 // Examine and collect column balancing data from a line that has been found to intersect with |
40 // this fragmentainer group. Does not recurse into layout objects on that li ne. | 40 // this fragmentainer group. Does not recurse into layout objects on that li ne. |
41 virtual void examineLine(const RootInlineBox&) = 0; | 41 virtual void examineLine(const LayoutBlockFlow& containingBlock, const RootI nlineBox&) = 0; |
42 | 42 |
43 // Examine and collect column balancing data for everything in the fragmenta iner group. Will | 43 // Examine and collect column balancing data for everything in the fragmenta iner group. Will |
44 // trigger calls to examineBoxAfterEntering(), examineBoxBeforeLeaving() and examineLine() for | 44 // trigger calls to examineBoxAfterEntering(), examineBoxBeforeLeaving() and examineLine() for |
45 // interesting boxes and lines. | 45 // interesting boxes and lines. |
46 void traverse(); | 46 void traverse(); |
47 | 47 |
48 private: | 48 private: |
49 void traverseSubtree(const LayoutBox&); | 49 void traverseSubtree(const LayoutBox&); |
50 | 50 |
51 const MultiColumnFragmentainerGroup& m_group; | 51 const MultiColumnFragmentainerGroup& m_group; |
(...skipping 15 matching lines...) Expand all Loading... | |
67 return InitialColumnHeightFinder(group).initialMinimalBalancedHeight(); | 67 return InitialColumnHeightFinder(group).initialMinimalBalancedHeight(); |
68 } | 68 } |
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 LayoutBlockFlow& containingBlock, const RootInlineBox &); |
leviw_travelin_and_unemployed
2015/11/05 18:44:26
Since we're only looking at RootInlineBoxes, the c
mstensho (USE GERRIT)
2015/11/05 19:15:56
I was unsure, with the ongoing efforts to untangle
mstensho (USE GERRIT)
2015/11/05 22:17:10
Done.
| |
78 | 78 |
79 // Record that there's a pagination strut that ends at the specified |offset InFlowThread|, which | 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. | 80 // is an offset exactly at the top of some column. |
81 void recordStrutBeforeOffset(LayoutUnit offsetInFlowThread, LayoutUnit strut ); | 81 void recordStrutBeforeOffset(LayoutUnit offsetInFlowThread, LayoutUnit strut ); |
82 | 82 |
83 // Return the accumulated space used by struts at all column boundaries prec eding the specified | 83 // Return the accumulated space used by struts at all column boundaries prec eding the specified |
84 // flowthread offset. | 84 // flowthread offset. |
85 LayoutUnit spaceUsedByStrutsAt(LayoutUnit offsetInFlowThread) const; | 85 LayoutUnit spaceUsedByStrutsAt(LayoutUnit offsetInFlowThread) const; |
86 | 86 |
87 // 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 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
131 // so on). There may be several objects that cross the same column boundary, and we're only | 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 | 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 | 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 | 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 | 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 | 136 // column row too tall. An entry set to LayoutUnit::max() means that we didn 't detect any object |
137 // crossing that boundary. | 137 // crossing that boundary. |
138 // | 138 // |
139 // [1] http://www.w3.org/TR/css3-break/#parallel-flows | 139 // [1] http://www.w3.org/TR/css3-break/#parallel-flows |
140 Vector<LayoutUnit, 32> m_shortestStruts; | 140 Vector<LayoutUnit, 32> m_shortestStruts; |
141 | |
142 LayoutUnit m_minimumColumnLogicalHeight; | |
141 }; | 143 }; |
142 | 144 |
143 // If we have previously used InitialColumnHeightFinder to estimate an initial c olumn height, and | 145 // If we have previously used InitialColumnHeightFinder to estimate an initial c olumn height, and |
144 // that didn't result in tall enough columns, we need subsequent layout passes w here we increase | 146 // that didn't result in tall enough columns, we need subsequent layout passes w here we increase |
145 // the column height by the minimum space shortage at column breaks. This class finds the minimum | 147 // the column height by the minimum space shortage at column breaks. This class finds the minimum |
146 // space shortage after having laid out with the current column height. | 148 // space shortage after having laid out with the current column height. |
147 class MinimumSpaceShortageFinder final : public ColumnBalancer { | 149 class MinimumSpaceShortageFinder final : public ColumnBalancer { |
148 public: | 150 public: |
149 MinimumSpaceShortageFinder(const MultiColumnFragmentainerGroup&); | 151 MinimumSpaceShortageFinder(const MultiColumnFragmentainerGroup&); |
150 | 152 |
151 LayoutUnit minimumSpaceShortage() const { return m_minimumSpaceShortage; } | 153 LayoutUnit minimumSpaceShortage() const { return m_minimumSpaceShortage; } |
152 unsigned forcedBreaksCount() const { return m_forcedBreaksCount; } | 154 unsigned forcedBreaksCount() const { return m_forcedBreaksCount; } |
153 | 155 |
154 private: | 156 private: |
155 void examineBoxAfterEntering(const LayoutBox&); | 157 void examineBoxAfterEntering(const LayoutBox&); |
156 void examineBoxBeforeLeaving(const LayoutBox&); | 158 void examineBoxBeforeLeaving(const LayoutBox&); |
157 void examineLine(const RootInlineBox&); | 159 void examineLine(const LayoutBlockFlow& containingBlock, const RootInlineBox &); |
158 | 160 |
159 void recordSpaceShortage(LayoutUnit shortage) | 161 void recordSpaceShortage(LayoutUnit shortage) |
160 { | 162 { |
161 // Only positive values are interesting (and allowed) here. Zero space s hortage may | 163 // Only positive values are interesting (and allowed) here. Zero space s hortage may |
162 // be reported when we're at the top of a column and the element has zer o | 164 // be reported when we're at the top of a column and the element has zer o |
163 // height. | 165 // height. |
164 if (shortage > 0) | 166 if (shortage > 0) |
165 m_minimumSpaceShortage = std::min(m_minimumSpaceShortage, shortage); | 167 m_minimumSpaceShortage = std::min(m_minimumSpaceShortage, shortage); |
166 } | 168 } |
167 | 169 |
168 // The smallest amout of space shortage that caused a column break. | 170 // The smallest amout of space shortage that caused a column break. |
169 LayoutUnit m_minimumSpaceShortage; | 171 LayoutUnit m_minimumSpaceShortage; |
170 | 172 |
171 // Set when breaking before a block, and we're looking for the first unbreak able descendant, in | 173 // Set when breaking before a block, and we're looking for the first unbreak able descendant, in |
172 // order to report correct space shortage for that one. | 174 // order to report correct space shortage for that one. |
173 LayoutUnit m_pendingStrut; | 175 LayoutUnit m_pendingStrut; |
174 | 176 |
175 unsigned m_forcedBreaksCount; | 177 unsigned m_forcedBreaksCount; |
176 }; | 178 }; |
177 | 179 |
178 } // namespace blink | 180 } // namespace blink |
OLD | NEW |