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