Chromium Code Reviews| Index: third_party/WebKit/Source/core/layout/ColumnBalancer.cpp |
| diff --git a/third_party/WebKit/Source/core/layout/ColumnBalancer.cpp b/third_party/WebKit/Source/core/layout/ColumnBalancer.cpp |
| index 65d3f4cb8a107682d467ffffa3ec44b395e26cc3..eb25bbf3d8e57a162f64f3bb443dcd56b65b7e5f 100644 |
| --- a/third_party/WebKit/Source/core/layout/ColumnBalancer.cpp |
| +++ b/third_party/WebKit/Source/core/layout/ColumnBalancer.cpp |
| @@ -25,13 +25,14 @@ void ColumnBalancer::traverseSubtree(const LayoutBox& box) |
| { |
| if (box.childrenInline() && box.isLayoutBlockFlow()) { |
| // Look for breaks between lines. |
| - for (const RootInlineBox* line = toLayoutBlockFlow(box).firstRootBox(); line; line = line->nextRootBox()) { |
| + const LayoutBlockFlow& blockFlow = toLayoutBlockFlow(box); |
| + for (const RootInlineBox* line = blockFlow.firstRootBox(); line; line = line->nextRootBox()) { |
| LayoutUnit lineTopInFlowThread = m_flowThreadOffset + line->lineTopWithLeading(); |
| if (lineTopInFlowThread < group().logicalTopInFlowThread()) |
| continue; |
| if (lineTopInFlowThread >= group().logicalBottomInFlowThread()) |
| break; |
| - examineLine(*line); |
| + examineLine(blockFlow, *line); |
| } |
| } |
| @@ -92,7 +93,8 @@ LayoutUnit InitialColumnHeightFinder::initialMinimalBalancedHeight() const |
| { |
| unsigned index = contentRunIndexWithTallestColumns(); |
| LayoutUnit startOffset = index > 0 ? m_contentRuns[index - 1].breakOffset() : group().logicalTopInFlowThread(); |
| - return m_contentRuns[index].columnLogicalHeight(startOffset); |
| + LayoutUnit logicalHeightEstimate = m_contentRuns[index].columnLogicalHeight(startOffset); |
| + return std::max(logicalHeightEstimate, m_minimumColumnLogicalHeight); |
| } |
| void InitialColumnHeightFinder::examineBoxAfterEntering(const LayoutBox& box) |
| @@ -107,16 +109,38 @@ void InitialColumnHeightFinder::examineBoxAfterEntering(const LayoutBox& box) |
| if (box.hasForcedBreakAfter()) |
| addContentRun(flowThreadOffset() + box.logicalHeight()); |
| + |
| + if (box.paginationBreakability() != LayoutBox::AllowAnyBreaks) { |
|
leviw_travelin_and_unemployed
2015/11/05 18:44:26
This is new code?
mstensho (USE GERRIT)
2015/11/05 19:15:56
This used to be handled in LayoutBlockFlow::adjust
|
| + LayoutUnit unsplittableLogicalHeight = box.logicalHeight(); |
| + if (box.isFloating()) |
| + unsplittableLogicalHeight += box.marginBefore() + box.marginAfter(); |
| + if (m_minimumColumnLogicalHeight < unsplittableLogicalHeight) |
| + m_minimumColumnLogicalHeight = unsplittableLogicalHeight; |
| + } |
| } |
| void InitialColumnHeightFinder::examineBoxBeforeLeaving(const LayoutBox& box) |
| { |
| } |
| -void InitialColumnHeightFinder::examineLine(const RootInlineBox& line) |
| +static inline LayoutUnit columnLogicalHeightRequirementForLine(const ComputedStyle& style, const RootInlineBox& lastLine) |
| +{ |
| + // We may require a certain minimum number of lines per page in order to satisfy |
| + // orphans and widows, and that may affect the minimum page height. |
| + unsigned lineCount = std::max<unsigned>(style.hasAutoOrphans() ? 1 : style.orphans(), style.widows()); |
|
leviw_travelin_and_unemployed
2015/11/05 18:44:26
minimumLineCount?
mstensho (USE GERRIT)
2015/11/05 19:15:56
Good idea. This code was just copied from LayoutBl
mstensho (USE GERRIT)
2015/11/05 22:17:10
Done.
|
| + const RootInlineBox* firstLine = &lastLine; |
| + for (unsigned i = 1; i < lineCount && firstLine->prevRootBox(); i++) |
| + firstLine = firstLine->prevRootBox(); |
| + return lastLine.lineBottomWithLeading() - firstLine->lineTopWithLeading(); |
| +} |
| + |
| +void InitialColumnHeightFinder::examineLine(const LayoutBlockFlow& containingBlock, const RootInlineBox& line) |
| { |
| LayoutUnit lineTop = line.lineTopWithLeading(); |
| LayoutUnit lineTopInFlowThread = flowThreadOffset() + lineTop; |
| + LayoutUnit minimumLogialHeight = columnLogicalHeightRequirementForLine(containingBlock.styleRef(), line); |
| + if (m_minimumColumnLogicalHeight < minimumLogialHeight) |
| + m_minimumColumnLogicalHeight = minimumLogialHeight; |
| ASSERT(isFirstAfterBreak(lineTopInFlowThread) || !line.paginationStrut()); |
| if (isFirstAfterBreak(lineTopInFlowThread)) |
| recordStrutBeforeOffset(lineTopInFlowThread, line.paginationStrut()); |
| @@ -262,7 +286,7 @@ void MinimumSpaceShortageFinder::examineBoxBeforeLeaving(const LayoutBox& box) |
| m_pendingStrut = LayoutUnit::min(); |
| } |
| -void MinimumSpaceShortageFinder::examineLine(const RootInlineBox& line) |
| +void MinimumSpaceShortageFinder::examineLine(const LayoutBlockFlow& containingBlock, const RootInlineBox& line) |
| { |
| LayoutUnit lineTop = line.lineTopWithLeading(); |
| LayoutUnit lineTopInFlowThread = flowThreadOffset() + lineTop; |