LayoutUnit MultiColumnFragmentainerGroup::rebalanceColumnHeightIfNeeded() const { if (actualColumnCount() <= m_columnSet.usedColumnCount()) { // With the current column height, the content fits without creating overflowing columns. We're done. return m_columnHeight; } if (m_columnHeight >= m_maxColumnHeight) { // We cannot stretch any further. We'll just have to live with the overflowing columns. This // typically happens if the max column height is less than the height of the tallest piece // of unbreakable content (e.g. lines). return m_columnHeight; } MinimumSpaceShortageFinder shortageFinder(*this); if (shortageFinder.forcedBreaksCount() + 1 >= m_columnSet.usedColumnCount()) { // Too many forced breaks to allow any implicit breaks. Initial balancing should already // have set a good height. There's nothing more we should do. return m_columnHeight; } // If the initial guessed column height wasn't enough, stretch it now. Stretch by the lowest // amount of space. LayoutUnit minSpaceShortage = shortageFinder.minimumSpaceShortage(); ASSERT(minSpaceShortage > 0); // We should never _shrink_ the height! ASSERT(minSpaceShortage != LayoutUnit::max()); // If this happens, we probably have a bug. if (minSpaceShortage == LayoutUnit::max()) return m_columnHeight; // So bail out rather than looping infinitely. return m_columnHeight + minSpaceShortage; }
LayoutUnit MultiColumnFragmentainerGroup::calculateColumnHeight(BalancedColumnHeightCalculation calculationMode) const { if (calculationMode == GuessFromFlowThreadPortion) { // Initial balancing. Start with the lowest imaginable column height. We use the tallest // content run (after having "inserted" implicit breaks), and find its start offset (by // looking at the previous run's end offset, or, if there's no previous run, the set's start // offset in the flow thread). return std::max(InitialColumnHeightFinder::initialMinimalBalancedHeight(*this), m_minimumColumnHeight); } if (actualColumnCount() <= m_columnSet.usedColumnCount()) { // With the current column height, the content fits without creating overflowing columns. We're done. return m_columnHeight; } if (m_columnHeight >= m_maxColumnHeight) { // We cannot stretch any further. We'll just have to live with the overflowing columns. This // typically happens if the max column height is less than the height of the tallest piece // of unbreakable content (e.g. lines). return m_columnHeight; } MinimumSpaceShortageFinder shortageFinder(*this); if (shortageFinder.forcedBreaksCount() + 1 >= m_columnSet.usedColumnCount()) { // Too many forced breaks to allow any implicit breaks. Initial balancing should already // have set a good height. There's nothing more we should do. return m_columnHeight; } // If the initial guessed column height wasn't enough, stretch it now. Stretch by the lowest // amount of space. LayoutUnit minSpaceShortage = shortageFinder.minimumSpaceShortage(); ASSERT(minSpaceShortage > 0); // We should never _shrink_ the height! ASSERT(minSpaceShortage != LayoutUnit::max()); // If this happens, we probably have a bug. if (minSpaceShortage == LayoutUnit::max()) return m_columnHeight; // So bail out rather than looping infinitely. return m_columnHeight + minSpaceShortage; }