void MinimumSpaceShortageFinder::examineBoxBeforeLeaving(const LayoutBox& box) { if (m_pendingStrut == LayoutUnit::min() || box.getPaginationBreakability() != LayoutBox::ForbidBreaks) return; // The previous break was before a breakable block. Here's the first piece of // unbreakable content after / inside that block. We want to record the // distance from the top of the column to the bottom of this box as space // shortage. LayoutUnit logicalOffsetFromCurrentColumn = offsetFromColumnLogicalTop(flowThreadOffset()); recordSpaceShortage(logicalOffsetFromCurrentColumn + box.logicalHeight() - m_pendingStrut); m_pendingStrut = LayoutUnit::min(); }
void MinimumSpaceShortageFinder::examineLine(const RootInlineBox& line) { LayoutUnit lineTop = line.lineTopWithLeading(); LayoutUnit lineTopInFlowThread = flowThreadOffset() + lineTop; LayoutUnit lineHeight = line.lineBottomWithLeading() - lineTop; if (m_pendingStrut != LayoutUnit::min()) { // The previous break was before a breakable block. Here's the first line // after / inside that block. We want to record the distance from the top of // the column to the bottom of this box as space shortage. LayoutUnit logicalOffsetFromCurrentColumn = offsetFromColumnLogicalTop(lineTopInFlowThread); recordSpaceShortage(logicalOffsetFromCurrentColumn + lineHeight - m_pendingStrut); m_pendingStrut = LayoutUnit::min(); return; } ASSERT( isFirstAfterBreak(lineTopInFlowThread) || !line.paginationStrut() || !isLogicalTopWithinBounds(lineTopInFlowThread - line.paginationStrut())); if (isFirstAfterBreak(lineTopInFlowThread)) recordSpaceShortage(lineHeight - line.paginationStrut()); // Even if the line box itself fits fine inside a column, some content may // overflow the line box bottom (due to restrictive line-height, for // instance). We should check if some portion of said overflow ends up in the // next column. That counts as space shortage. const MultiColumnFragmentainerGroup& group = groupAtOffset(lineTopInFlowThread); LayoutUnit lineBottomWithOverflow = lineTopInFlowThread + line.lineBottom() - lineTop; if (group.columnLogicalTopForOffset(lineTopInFlowThread) != group.columnLogicalTopForOffset(lineBottomWithOverflow)) { LayoutUnit shortage = lineBottomWithOverflow - group.columnLogicalTopForOffset(lineBottomWithOverflow); recordSpaceShortage(shortage); } }