void InitialColumnHeightFinder::distributeImplicitBreaks() { // Insert a final content run to encompass all content. This will include // overflow if we're at the end of the multicol container. addContentRun(logicalBottomInFlowThread()); unsigned columnCount = m_contentRuns.size(); // If there is room for more breaks (to reach the used value of column-count), // imagine that we insert implicit breaks at suitable locations. At any given // time, the content run with the currently tallest columns will get another // implicit break "inserted", which will increase its column count by one and // shrink its columns' height. Repeat until we have the desired total number // of breaks. The largest column height among the runs will then be the // initial column height for the balancer to use. if (columnCount > columnSet().usedColumnCount()) { // If we exceed used column-count (which we are allowed to do if we're at // the initial balancing pass for a multicol that lives inside another // to-be-balanced outer multicol container), we only care about content that // could end up in the last row. We need to pad up the number of columns, so // that all rows will contain as many columns as used column-count dictates. columnCount %= columnSet().usedColumnCount(); // If there are just enough explicit breaks to fill all rows with the right // amount of columns, we won't be needing any implicit breaks. if (!columnCount) return; } while (columnCount < columnSet().usedColumnCount()) { unsigned index = contentRunIndexWithTallestColumns(); m_contentRuns[index].assumeAnotherImplicitBreak(); columnCount++; } }
LayoutUnit InitialColumnHeightFinder::initialMinimalBalancedHeight() const { unsigned index = contentRunIndexWithTallestColumns(); LayoutUnit startOffset = index > 0 ? m_contentRuns[index - 1].breakOffset() : group().logicalTopInFlowThread(); LayoutUnit logicalHeightEstimate = m_contentRuns[index].columnLogicalHeight(startOffset); return std::max(logicalHeightEstimate, m_minimumColumnLogicalHeight); }
void InitialColumnHeightFinder::distributeImplicitBreaks() { // Insert a final content run to encompass all content. This will include // overflow if we're at the end of the multicol container. addContentRun(logicalBottomInFlowThread()); unsigned columnCount = m_contentRuns.size(); // If there is room for more breaks (to reach the used value of column-count), // imagine that we insert implicit breaks at suitable locations. At any given // time, the content run with the currently tallest columns will get another // implicit break "inserted", which will increase its column count by one and // shrink its columns' height. Repeat until we have the desired total number // of breaks. The largest column height among the runs will then be the // initial column height for the balancer to use. while (columnCount < columnSet().usedColumnCount()) { unsigned index = contentRunIndexWithTallestColumns(); m_contentRuns[index].assumeAnotherImplicitBreak(); columnCount++; } }
LayoutUnit InitialColumnHeightFinder::initialMinimalBalancedHeight() const { LayoutUnit rowLogicalTop; if (m_contentRuns.size() > columnSet().usedColumnCount()) { // We have not inserted additional fragmentainer groups yet (because we // aren't able to calculate their constraints yet), but we already know for // sure that there'll be more than one of them, due to the number of forced // breaks in a nested multicol container. We will now attempt to take all // the imaginary rows into account and calculate a minimal balanced logical // height for everything. unsigned stride = columnSet().usedColumnCount(); LayoutUnit rowStartOffset = logicalTopInFlowThread(); for (unsigned i = 0; i < firstContentRunIndexInLastRow(); i += stride) { LayoutUnit rowEndOffset = m_contentRuns[i + stride - 1].breakOffset(); float rowHeight = float(rowEndOffset - rowStartOffset) / float(stride); rowLogicalTop += LayoutUnit::fromFloatCeil(rowHeight); rowStartOffset = rowEndOffset; } } unsigned index = contentRunIndexWithTallestColumns(); LayoutUnit startOffset = index > 0 ? m_contentRuns[index - 1].breakOffset() : logicalTopInFlowThread(); LayoutUnit height = m_contentRuns[index].columnLogicalHeight(startOffset); return rowLogicalTop + std::max(height, m_tallestUnbreakableLogicalHeight); }
LayoutUnit InitialColumnHeightFinder::initialMinimalBalancedHeight() const { unsigned index = contentRunIndexWithTallestColumns(); LayoutUnit startOffset = index > 0 ? m_contentRuns[index - 1].breakOffset() : logicalTopInFlowThread(); return m_contentRuns[index].columnLogicalHeight(startOffset); }