| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 return logicalBottomInFlowThread > m_logicalTopInFlowThread && | 65 return logicalBottomInFlowThread > m_logicalTopInFlowThread && |
| 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( |
| 76 LayoutUnit childLogicalHeight, | 76 const LayoutBox&, |
| 77 EBreak previousBreakAfterValue) = 0; | 77 LayoutUnit childLogicalHeight, |
| 78 EBreakBetween previousBreakAfterValue) = 0; |
| 78 virtual void examineBoxBeforeLeaving(const LayoutBox&, | 79 virtual void examineBoxBeforeLeaving(const LayoutBox&, |
| 79 LayoutUnit childLogicalHeight) = 0; | 80 LayoutUnit childLogicalHeight) = 0; |
| 80 | 81 |
| 81 // Examine and collect column balancing data from a line that has been found | 82 // 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 | 83 // to intersect with the flow thread portion. Does not recurse into layout |
| 83 // objects on that line. | 84 // objects on that line. |
| 84 virtual void examineLine(const RootInlineBox&) = 0; | 85 virtual void examineLine(const RootInlineBox&) = 0; |
| 85 | 86 |
| 86 // Examine and collect column balancing data for everything in the flow thread | 87 // Examine and collect column balancing data for everything in the flow thread |
| 87 // portion. Will trigger calls to examineBoxAfterEntering(), | 88 // portion. Will trigger calls to examineBoxAfterEntering(), |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 // occur (inside unbreakable content, between orphans and widows, etc.). This | 126 // 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 | 127 // will be used as a hint to the column balancer to help set a good initial |
| 127 // column height. | 128 // column height. |
| 128 LayoutUnit tallestUnbreakableLogicalHeight() const { | 129 LayoutUnit tallestUnbreakableLogicalHeight() const { |
| 129 return m_tallestUnbreakableLogicalHeight; | 130 return m_tallestUnbreakableLogicalHeight; |
| 130 } | 131 } |
| 131 | 132 |
| 132 private: | 133 private: |
| 133 void examineBoxAfterEntering(const LayoutBox&, | 134 void examineBoxAfterEntering(const LayoutBox&, |
| 134 LayoutUnit childLogicalHeight, | 135 LayoutUnit childLogicalHeight, |
| 135 EBreak previousBreakAfterValue); | 136 EBreakBetween previousBreakAfterValue); |
| 136 void examineBoxBeforeLeaving(const LayoutBox&, LayoutUnit childLogicalHeight); | 137 void examineBoxBeforeLeaving(const LayoutBox&, LayoutUnit childLogicalHeight); |
| 137 void examineLine(const RootInlineBox&); | 138 void examineLine(const RootInlineBox&); |
| 138 | 139 |
| 139 // Record that there's a pagination strut that ends at the specified | 140 // 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. | 141 // |offsetInFlowThread|, which is an offset exactly at the top of some column. |
| 141 void recordStrutBeforeOffset(LayoutUnit offsetInFlowThread, LayoutUnit strut); | 142 void recordStrutBeforeOffset(LayoutUnit offsetInFlowThread, LayoutUnit strut); |
| 142 | 143 |
| 143 // Return the accumulated space used by struts at all column boundaries | 144 // Return the accumulated space used by struts at all column boundaries |
| 144 // preceding the specified flowthread offset. | 145 // preceding the specified flowthread offset. |
| 145 LayoutUnit spaceUsedByStrutsAt(LayoutUnit offsetInFlowThread) const; | 146 LayoutUnit spaceUsedByStrutsAt(LayoutUnit offsetInFlowThread) const; |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 MinimumSpaceShortageFinder(const LayoutMultiColumnSet&, | 239 MinimumSpaceShortageFinder(const LayoutMultiColumnSet&, |
| 239 LayoutUnit logicalTopInFlowThread, | 240 LayoutUnit logicalTopInFlowThread, |
| 240 LayoutUnit logicalBottomInFlowThread); | 241 LayoutUnit logicalBottomInFlowThread); |
| 241 | 242 |
| 242 LayoutUnit minimumSpaceShortage() const { return m_minimumSpaceShortage; } | 243 LayoutUnit minimumSpaceShortage() const { return m_minimumSpaceShortage; } |
| 243 unsigned forcedBreaksCount() const { return m_forcedBreaksCount; } | 244 unsigned forcedBreaksCount() const { return m_forcedBreaksCount; } |
| 244 | 245 |
| 245 private: | 246 private: |
| 246 void examineBoxAfterEntering(const LayoutBox&, | 247 void examineBoxAfterEntering(const LayoutBox&, |
| 247 LayoutUnit childLogicalHeight, | 248 LayoutUnit childLogicalHeight, |
| 248 EBreak previousBreakAfterValue); | 249 EBreakBetween previousBreakAfterValue); |
| 249 void examineBoxBeforeLeaving(const LayoutBox&, LayoutUnit childLogicalHeight); | 250 void examineBoxBeforeLeaving(const LayoutBox&, LayoutUnit childLogicalHeight); |
| 250 void examineLine(const RootInlineBox&); | 251 void examineLine(const RootInlineBox&); |
| 251 | 252 |
| 252 void recordSpaceShortage(LayoutUnit shortage) { | 253 void recordSpaceShortage(LayoutUnit shortage) { |
| 253 // Only positive values are interesting (and allowed) here. Zero space | 254 // Only positive values are interesting (and allowed) here. Zero space |
| 254 // shortage may be reported when we're at the top of a column and the | 255 // shortage may be reported when we're at the top of a column and the |
| 255 // element has zero height. | 256 // element has zero height. |
| 256 if (shortage > 0) | 257 if (shortage > 0) |
| 257 m_minimumSpaceShortage = std::min(m_minimumSpaceShortage, shortage); | 258 m_minimumSpaceShortage = std::min(m_minimumSpaceShortage, shortage); |
| 258 } | 259 } |
| 259 | 260 |
| 260 // The smallest amout of space shortage that caused a column break. | 261 // The smallest amout of space shortage that caused a column break. |
| 261 LayoutUnit m_minimumSpaceShortage; | 262 LayoutUnit m_minimumSpaceShortage; |
| 262 | 263 |
| 263 // Set when breaking before a block, and we're looking for the first | 264 // Set when breaking before a block, and we're looking for the first |
| 264 // unbreakable descendant, in order to report correct space shortage for that | 265 // unbreakable descendant, in order to report correct space shortage for that |
| 265 // one. | 266 // one. |
| 266 LayoutUnit m_pendingStrut; | 267 LayoutUnit m_pendingStrut; |
| 267 | 268 |
| 268 unsigned m_forcedBreaksCount; | 269 unsigned m_forcedBreaksCount; |
| 269 }; | 270 }; |
| 270 | 271 |
| 271 } // namespace blink | 272 } // namespace blink |
| OLD | NEW |