Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1458)

Unified Diff: Source/core/rendering/RenderMultiColumnSet.cpp

Issue 267373005: [New Multicolumn] Use the term "content run" in favor of "forced break". (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/rendering/RenderMultiColumnSet.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/rendering/RenderMultiColumnSet.cpp
diff --git a/Source/core/rendering/RenderMultiColumnSet.cpp b/Source/core/rendering/RenderMultiColumnSet.cpp
index 24dffefc8c6fba4254dd511de54be91d2c8da66e..9ec3dde0df6236ff783ed8be0f7ff0aaa636f6e3 100644
--- a/Source/core/rendering/RenderMultiColumnSet.cpp
+++ b/Source/core/rendering/RenderMultiColumnSet.cpp
@@ -101,7 +101,7 @@ unsigned RenderMultiColumnSet::findRunWithTallestColumns() const
{
unsigned indexWithLargestHeight = 0;
LayoutUnit largestHeight;
- LayoutUnit previousOffset;
+ LayoutUnit previousOffset = logicalTopInFlowThread();
size_t runCount = m_contentRuns.size();
ASSERT(runCount);
for (size_t i = 0; i < runCount; i++) {
@@ -120,14 +120,14 @@ void RenderMultiColumnSet::distributeImplicitBreaks()
{
#ifndef NDEBUG
// There should be no implicit breaks assumed at this point.
- for (unsigned i = 0; i < forcedBreaksCount(); i++)
+ for (unsigned i = 0; i < m_contentRuns.size(); i++)
ASSERT(!m_contentRuns[i].assumedImplicitBreaks());
#endif // NDEBUG
// Insert a final content run to encompass all content. This will include overflow if this is
// the last set.
- addForcedBreak(logicalBottomInFlowThread());
- unsigned breakCount = forcedBreaksCount();
+ 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
@@ -135,19 +135,22 @@ void RenderMultiColumnSet::distributeImplicitBreaks()
// 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 (breakCount < m_computedColumnCount) {
+ while (columnCount < m_computedColumnCount) {
unsigned index = findRunWithTallestColumns();
m_contentRuns[index].assumeAnotherImplicitBreak();
- breakCount++;
+ columnCount++;
}
}
LayoutUnit RenderMultiColumnSet::calculateColumnHeight(bool initial) const
{
if (initial) {
- // Start with the lowest imaginable column height.
+ // 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).
unsigned index = findRunWithTallestColumns();
- LayoutUnit startOffset = index > 0 ? m_contentRuns[index - 1].breakOffset() : LayoutUnit();
+ LayoutUnit startOffset = index > 0 ? m_contentRuns[index - 1].breakOffset() : logicalTopInFlowThread();
return std::max<LayoutUnit>(m_contentRuns[index].columnLogicalHeight(startOffset), m_minimumColumnHeight);
}
@@ -156,7 +159,7 @@ LayoutUnit RenderMultiColumnSet::calculateColumnHeight(bool initial) const
return m_computedColumnHeight;
}
- if (forcedBreaksCount() >= computedColumnCount()) {
+ if (m_contentRuns.size() >= computedColumnCount()) {
// 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_computedColumnHeight;
@@ -173,21 +176,16 @@ LayoutUnit RenderMultiColumnSet::calculateColumnHeight(bool initial) const
return m_computedColumnHeight + m_minSpaceShortage;
}
-void RenderMultiColumnSet::clearForcedBreaks()
-{
- m_contentRuns.clear();
-}
-
-void RenderMultiColumnSet::addForcedBreak(LayoutUnit offsetFromFirstPage)
+void RenderMultiColumnSet::addContentRun(LayoutUnit endOffsetFromFirstPage)
{
if (!multiColumnFlowThread()->requiresBalancing())
return;
- if (!m_contentRuns.isEmpty() && offsetFromFirstPage <= m_contentRuns.last().breakOffset())
+ if (!m_contentRuns.isEmpty() && endOffsetFromFirstPage <= m_contentRuns.last().breakOffset())
return;
// Append another item as long as we haven't exceeded used column count. What ends up in the
// overflow area shouldn't affect column balancing.
if (m_contentRuns.size() < m_computedColumnCount)
- m_contentRuns.append(ContentRun(offsetFromFirstPage));
+ m_contentRuns.append(ContentRun(endOffsetFromFirstPage));
}
bool RenderMultiColumnSet::recalculateColumnHeight(bool initial)
@@ -195,8 +193,10 @@ bool RenderMultiColumnSet::recalculateColumnHeight(bool initial)
ASSERT(multiColumnFlowThread()->requiresBalancing());
LayoutUnit oldColumnHeight = m_computedColumnHeight;
- if (initial)
+ if (initial) {
+ // Post-process the content runs and find out where the implicit breaks will occur.
distributeImplicitBreaks();
+ }
LayoutUnit newColumnHeight = calculateColumnHeight(initial);
setAndConstrainColumnHeight(newColumnHeight);
@@ -210,7 +210,7 @@ bool RenderMultiColumnSet::recalculateColumnHeight(bool initial)
return false; // No change. We're done.
m_minSpaceShortage = RenderFlowThread::maxLogicalHeight();
- clearForcedBreaks();
+ m_contentRuns.clear();
return true; // Need another pass.
}
@@ -279,7 +279,7 @@ void RenderMultiColumnSet::prepareForLayout()
setAndConstrainColumnHeight(heightAdjustedForSetOffset(multiColumnFlowThread()->columnHeightAvailable()));
}
- clearForcedBreaks();
+ m_contentRuns.clear();
// Nuke previously stored minimum column height. Contents may have changed for all we know.
m_minimumColumnHeight = 0;
« no previous file with comments | « Source/core/rendering/RenderMultiColumnSet.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698