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/LayoutMultiColumnSet.h" | 5 #include "core/layout/LayoutMultiColumnSet.h" |
6 | 6 |
7 namespace blink { | 7 namespace blink { |
8 | 8 |
9 // A column balancer traverses a portion of the subtree of a flow thread that | 9 // A column balancer traverses a portion of the subtree of a flow thread that |
10 // belongs to one or more fragmentainer groups within one column set, in order | 10 // belongs to one or more fragmentainer groups within one column set, in order |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 logicalBottomInFlowThread <= m_logicalBottomInFlowThread; | 66 logicalBottomInFlowThread <= m_logicalBottomInFlowThread; |
67 } | 67 } |
68 | 68 |
69 // Examine and collect column balancing data from a layout box that has been | 69 // Examine and collect column balancing data from a layout box that has been |
70 // found to intersect with the flow thread portion we're examining. Does not | 70 // found to intersect with the flow thread portion we're examining. Does not |
71 // recurse into children. flowThreadOffset() will return the offset from |box| | 71 // recurse into children. flowThreadOffset() will return the offset from |box| |
72 // to the flow thread. Two hooks are provided here. The first one is called | 72 // to the flow thread. Two hooks are provided here. The first one is called |
73 // right after entering and before traversing the subtree of the box, and the | 73 // right after entering and before traversing the subtree of the box, and the |
74 // second one right after having traversed the subtree. | 74 // second one right after having traversed the subtree. |
75 virtual void examineBoxAfterEntering(const LayoutBox&, | 75 virtual void examineBoxAfterEntering(const LayoutBox&, |
76 LayoutUnit childLogicalHeight, | |
77 EBreak previousBreakAfterValue) = 0; | 76 EBreak previousBreakAfterValue) = 0; |
78 virtual void examineBoxBeforeLeaving(const LayoutBox&, | 77 virtual void examineBoxBeforeLeaving(const LayoutBox&) = 0; |
79 LayoutUnit childLogicalHeight) = 0; | |
80 | 78 |
81 // Examine and collect column balancing data from a line that has been found | 79 // Examine and collect column balancing data from a line that has been found |
82 // to intersect with the flow thread portion. Does not recurse into layout | 80 // to intersect with the flow thread portion. Does not recurse into layout |
83 // objects on that line. | 81 // objects on that line. |
84 virtual void examineLine(const RootInlineBox&) = 0; | 82 virtual void examineLine(const RootInlineBox&) = 0; |
85 | 83 |
86 // Examine and collect column balancing data for everything in the flow thread | 84 // Examine and collect column balancing data for everything in the flow thread |
87 // portion. Will trigger calls to examineBoxAfterEntering(), | 85 // portion. Will trigger calls to examineBoxAfterEntering(), |
88 // examineBoxBeforeLeaving() and examineLine() for interesting boxes and | 86 // examineBoxBeforeLeaving() and examineLine() for interesting boxes and |
89 // lines. | 87 // lines. |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 // column logical height required to avoid fragmentation where it shouldn't | 122 // column logical height required to avoid fragmentation where it shouldn't |
125 // occur (inside unbreakable content, between orphans and widows, etc.). This | 123 // occur (inside unbreakable content, between orphans and widows, etc.). This |
126 // will be used as a hint to the column balancer to help set a good initial | 124 // will be used as a hint to the column balancer to help set a good initial |
127 // column height. | 125 // column height. |
128 LayoutUnit tallestUnbreakableLogicalHeight() const { | 126 LayoutUnit tallestUnbreakableLogicalHeight() const { |
129 return m_tallestUnbreakableLogicalHeight; | 127 return m_tallestUnbreakableLogicalHeight; |
130 } | 128 } |
131 | 129 |
132 private: | 130 private: |
133 void examineBoxAfterEntering(const LayoutBox&, | 131 void examineBoxAfterEntering(const LayoutBox&, |
134 LayoutUnit childLogicalHeight, | |
135 EBreak previousBreakAfterValue); | 132 EBreak previousBreakAfterValue); |
136 void examineBoxBeforeLeaving(const LayoutBox&, LayoutUnit childLogicalHeight); | 133 void examineBoxBeforeLeaving(const LayoutBox&); |
137 void examineLine(const RootInlineBox&); | 134 void examineLine(const RootInlineBox&); |
138 | 135 |
139 // Record that there's a pagination strut that ends at the specified | 136 // Record that there's a pagination strut that ends at the specified |
140 // |offsetInFlowThread|, which is an offset exactly at the top of some column. | 137 // |offsetInFlowThread|, which is an offset exactly at the top of some column. |
141 void recordStrutBeforeOffset(LayoutUnit offsetInFlowThread, LayoutUnit strut); | 138 void recordStrutBeforeOffset(LayoutUnit offsetInFlowThread, LayoutUnit strut); |
142 | 139 |
143 // Return the accumulated space used by struts at all column boundaries | 140 // Return the accumulated space used by struts at all column boundaries |
144 // preceding the specified flowthread offset. | 141 // preceding the specified flowthread offset. |
145 LayoutUnit spaceUsedByStrutsAt(LayoutUnit offsetInFlowThread) const; | 142 LayoutUnit spaceUsedByStrutsAt(LayoutUnit offsetInFlowThread) const; |
146 | 143 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 public: | 216 public: |
220 MinimumSpaceShortageFinder(const LayoutMultiColumnSet&, | 217 MinimumSpaceShortageFinder(const LayoutMultiColumnSet&, |
221 LayoutUnit logicalTopInFlowThread, | 218 LayoutUnit logicalTopInFlowThread, |
222 LayoutUnit logicalBottomInFlowThread); | 219 LayoutUnit logicalBottomInFlowThread); |
223 | 220 |
224 LayoutUnit minimumSpaceShortage() const { return m_minimumSpaceShortage; } | 221 LayoutUnit minimumSpaceShortage() const { return m_minimumSpaceShortage; } |
225 unsigned forcedBreaksCount() const { return m_forcedBreaksCount; } | 222 unsigned forcedBreaksCount() const { return m_forcedBreaksCount; } |
226 | 223 |
227 private: | 224 private: |
228 void examineBoxAfterEntering(const LayoutBox&, | 225 void examineBoxAfterEntering(const LayoutBox&, |
229 LayoutUnit childLogicalHeight, | |
230 EBreak previousBreakAfterValue); | 226 EBreak previousBreakAfterValue); |
231 void examineBoxBeforeLeaving(const LayoutBox&, LayoutUnit childLogicalHeight); | 227 void examineBoxBeforeLeaving(const LayoutBox&); |
232 void examineLine(const RootInlineBox&); | 228 void examineLine(const RootInlineBox&); |
233 | 229 |
234 void recordSpaceShortage(LayoutUnit shortage) { | 230 void recordSpaceShortage(LayoutUnit shortage) { |
235 // Only positive values are interesting (and allowed) here. Zero space | 231 // Only positive values are interesting (and allowed) here. Zero space |
236 // shortage may be reported when we're at the top of a column and the | 232 // shortage may be reported when we're at the top of a column and the |
237 // element has zero height. | 233 // element has zero height. |
238 if (shortage > 0) | 234 if (shortage > 0) |
239 m_minimumSpaceShortage = std::min(m_minimumSpaceShortage, shortage); | 235 m_minimumSpaceShortage = std::min(m_minimumSpaceShortage, shortage); |
240 } | 236 } |
241 | 237 |
242 // The smallest amout of space shortage that caused a column break. | 238 // The smallest amout of space shortage that caused a column break. |
243 LayoutUnit m_minimumSpaceShortage; | 239 LayoutUnit m_minimumSpaceShortage; |
244 | 240 |
245 // Set when breaking before a block, and we're looking for the first | 241 // Set when breaking before a block, and we're looking for the first |
246 // unbreakable descendant, in order to report correct space shortage for that | 242 // unbreakable descendant, in order to report correct space shortage for that |
247 // one. | 243 // one. |
248 LayoutUnit m_pendingStrut; | 244 LayoutUnit m_pendingStrut; |
249 | 245 |
250 unsigned m_forcedBreaksCount; | 246 unsigned m_forcedBreaksCount; |
251 }; | 247 }; |
252 | 248 |
253 } // namespace blink | 249 } // namespace blink |
OLD | NEW |