Index: third_party/WebKit/Source/core/layout/LayoutMultiColumnSet.cpp |
diff --git a/third_party/WebKit/Source/core/layout/LayoutMultiColumnSet.cpp b/third_party/WebKit/Source/core/layout/LayoutMultiColumnSet.cpp |
index ae91b71fe1c5340f14bba856be3975153e35ee28..11569461db423d50d34a3b094d703197d5b0fd72 100644 |
--- a/third_party/WebKit/Source/core/layout/LayoutMultiColumnSet.cpp |
+++ b/third_party/WebKit/Source/core/layout/LayoutMultiColumnSet.cpp |
@@ -89,23 +89,24 @@ LayoutUnit LayoutMultiColumnSet::pageLogicalHeightForOffset( |
LayoutUnit offsetInFlowThread) const { |
const MultiColumnFragmentainerGroup& lastRow = lastFragmentainerGroup(); |
if (!lastRow.logicalHeight()) { |
- // In the first layout pass of an auto-height multicol container, height isn't set. No need |
- // to perform the series of complicated dance steps below to figure out that we should |
- // simply return 0. Bail now. |
+ // In the first layout pass of an auto-height multicol container, height |
+ // isn't set. No need to perform the series of complicated dance steps below |
+ // to figure out that we should simply return 0. Bail now. |
ASSERT(m_fragmentainerGroups.size() == 1); |
return LayoutUnit(); |
} |
if (offsetInFlowThread >= |
lastRow.logicalTopInFlowThread() + fragmentainerGroupCapacity(lastRow)) { |
- // The offset is outside the bounds of the fragmentainer groups that we have established at |
- // this point. If we're nested inside another fragmentation context, we need to calculate |
- // the height on our own. |
+ // The offset is outside the bounds of the fragmentainer groups that we have |
+ // established at this point. If we're nested inside another fragmentation |
+ // context, we need to calculate the height on our own. |
const LayoutMultiColumnFlowThread* flowThread = multiColumnFlowThread(); |
if (FragmentationContext* enclosingFragmentationContext = |
flowThread->enclosingFragmentationContext()) { |
- // We'd ideally like to translate |offsetInFlowThread| to an offset in the coordinate |
- // space of the enclosing fragmentation context here, but that's hard, since the offset |
- // is out of bounds. So just use the bottom we have found so far. |
+ // We'd ideally like to translate |offsetInFlowThread| to an offset in the |
+ // coordinate space of the enclosing fragmentation context here, but |
+ // that's hard, since the offset is out of bounds. So just use the bottom |
+ // we have found so far. |
LayoutUnit enclosingContextBottom = |
lastRow.blockOffsetInEnclosingFragmentationContext() + |
lastRow.logicalHeight(); |
@@ -136,22 +137,23 @@ LayoutUnit LayoutMultiColumnSet::pageRemainingLogicalHeightForOffset( |
fragmentainerGroupAtFlowThreadOffset(offsetInFlowThread, |
pageBoundaryRule); |
LayoutUnit pageLogicalHeight = row.logicalHeight(); |
- ASSERT( |
- pageLogicalHeight); // It's not allowed to call this method if the height is unknown. |
+ // It's not allowed to call this method if the height is unknown. |
+ DCHECK(pageLogicalHeight); |
LayoutUnit pageLogicalBottom = |
row.columnLogicalTopForOffset(offsetInFlowThread) + pageLogicalHeight; |
LayoutUnit remainingLogicalHeight = pageLogicalBottom - offsetInFlowThread; |
if (pageBoundaryRule == AssociateWithFormerPage) { |
- // An offset exactly at a column boundary will act as being part of the former column in |
- // question (i.e. no remaining space), rather than being part of the latter (i.e. one whole |
- // column length of remaining space). |
+ // An offset exactly at a column boundary will act as being part of the |
+ // former column in question (i.e. no remaining space), rather than being |
+ // part of the latter (i.e. one whole column length of remaining space). |
remainingLogicalHeight = intMod(remainingLogicalHeight, pageLogicalHeight); |
} else if (!remainingLogicalHeight) { |
- // When pageBoundaryRule is AssociateWithLatterPage, we should never return 0, because if |
- // there's no space left, it means that we should be at a column boundary, in which case we |
- // should return the amount of space remaining in the *next* column. But this is not true if |
- // the offset is "infinite" (saturated), so allow this to happen in that case. |
+ // When pageBoundaryRule is AssociateWithLatterPage, we should never return |
+ // 0, because if there's no space left, it means that we should be at a |
+ // column boundary, in which case we should return the amount of space |
+ // remaining in the *next* column. But this is not true if the offset is |
+ // "infinite" (saturated), so allow this to happen in that case. |
ASSERT(offsetInFlowThread.mightBeSaturated()); |
remainingLogicalHeight = pageLogicalHeight; |
} |
@@ -170,18 +172,18 @@ LayoutUnit LayoutMultiColumnSet::nextLogicalTopForUnbreakableContent( |
FragmentationContext* enclosingFragmentationContext = |
multiColumnFlowThread()->enclosingFragmentationContext(); |
if (!enclosingFragmentationContext) { |
- // If there's no enclosing fragmentation context, there'll ever be only one row, and all |
- // columns there will have the same height. |
+ // If there's no enclosing fragmentation context, there'll ever be only one |
+ // row, and all columns there will have the same height. |
return flowThreadOffset; |
} |
- // Assert the problematic situation. If we have no problem with the column height, why are we |
- // even here? |
+ // Assert the problematic situation. If we have no problem with the column |
+ // height, why are we even here? |
ASSERT(pageLogicalHeightForOffset(flowThreadOffset) < contentLogicalHeight); |
// There's a likelihood for subsequent rows to be taller than the first one. |
- // TODO(mstensho): if we're doubly nested (e.g. multicol in multicol in multicol), we need to |
- // look beyond the first row here. |
+ // TODO(mstensho): if we're doubly nested (e.g. multicol in multicol in |
+ // multicol), we need to look beyond the first row here. |
const MultiColumnFragmentainerGroup& firstRow = firstFragmentainerGroup(); |
LayoutUnit firstRowLogicalBottomInFlowThread = |
firstRow.logicalTopInFlowThread() + fragmentainerGroupCapacity(firstRow); |
@@ -192,8 +194,8 @@ LayoutUnit LayoutMultiColumnSet::nextLogicalTopForUnbreakableContent( |
firstRow.blockOffsetInEnclosingFragmentationContext() + |
firstRow.logicalHeight()); |
if (contentLogicalHeight > newLogicalHeight) { |
- // The next outer column or page doesn't have enough space either. Give up and stay where |
- // we are. |
+ // The next outer column or page doesn't have enough space either. Give up |
+ // and stay where we are. |
return flowThreadOffset; |
} |
return firstRowLogicalBottomInFlowThread; |
@@ -232,10 +234,12 @@ bool LayoutMultiColumnSet::hasFragmentainerGroupForColumnAt( |
MultiColumnFragmentainerGroup& |
LayoutMultiColumnSet::appendNewFragmentainerGroup() { |
MultiColumnFragmentainerGroup newGroup(*this); |
- { // Extra scope here for previousGroup; it's potentially invalid once we modify the m_fragmentainerGroups Vector. |
+ { // Extra scope here for previousGroup; it's potentially invalid once we |
+ // modify the m_fragmentainerGroups Vector. |
MultiColumnFragmentainerGroup& previousGroup = m_fragmentainerGroups.last(); |
- // This is the flow thread block offset where |previousGroup| ends and |newGroup| takes over. |
+ // This is the flow thread block offset where |previousGroup| ends and |
+ // |newGroup| takes over. |
LayoutUnit blockOffsetInFlowThread = |
previousGroup.logicalTopInFlowThread() + |
fragmentainerGroupCapacity(previousGroup); |
@@ -250,17 +254,20 @@ LayoutMultiColumnSet::appendNewFragmentainerGroup() { |
} |
LayoutUnit LayoutMultiColumnSet::logicalTopFromMulticolContentEdge() const { |
- // We subtract the position of the first column set or spanner placeholder, rather than the |
- // "before" border+padding of the multicol container. This distinction doesn't matter after |
- // layout, but during layout it does: The flow thread (i.e. the multicol contents) is laid out |
- // before the column sets and spanner placeholders, which means that compesating for a top |
- // border+padding that hasn't yet been baked into the offset will produce the wrong results in |
- // the first layout pass, and we'd end up performing a wasted layout pass in many cases. |
+ // We subtract the position of the first column set or spanner placeholder, |
+ // rather than the "before" border+padding of the multicol container. This |
+ // distinction doesn't matter after layout, but during layout it does: |
+ // The flow thread (i.e. the multicol contents) is laid out before the column |
+ // sets and spanner placeholders, which means that compesating for a top |
+ // border+padding that hasn't yet been baked into the offset will produce the |
+ // wrong results in the first layout pass, and we'd end up performing a wasted |
+ // layout pass in many cases. |
const LayoutBox& firstColumnBox = |
*multiColumnFlowThread()->firstMultiColumnBox(); |
- // The top margin edge of the first column set or spanner placeholder is flush with the top |
- // content edge of the multicol container. The margin here never collapses with other margins, |
- // so we can just subtract it. Column sets never have margins, but spanner placeholders may. |
+ // The top margin edge of the first column set or spanner placeholder is flush |
+ // with the top content edge of the multicol container. The margin here never |
+ // collapses with other margins, so we can just subtract it. Column sets never |
+ // have margins, but spanner placeholders may. |
LayoutUnit firstColumnBoxMarginEdge = |
firstColumnBox.logicalTop() - |
multiColumnBlockFlow()->marginBeforeForChild(firstColumnBox); |
@@ -322,12 +329,13 @@ LayoutRect LayoutMultiColumnSet::overflowRectForFlowThreadPortion( |
bool LayoutMultiColumnSet::heightIsAuto() const { |
LayoutMultiColumnFlowThread* flowThread = multiColumnFlowThread(); |
if (!flowThread->isLayoutPagedFlowThread()) { |
- // If support for the column-fill property isn't enabled, we want to behave as if |
- // column-fill were auto, so that multicol containers with specified height don't get their |
- // columns balanced (auto-height multicol containers will still get their columns balanced, |
- // even if column-fill isn't 'balance' - in accordance with the spec). Pretending that |
- // column-fill is auto also matches the old multicol implementation, which has no support |
- // for this property. |
+ // If support for the column-fill property isn't enabled, we want to behave |
+ // as if column-fill were auto, so that multicol containers with specified |
+ // height don't get their columns balanced (auto-height multicol containers |
+ // will still get their columns balanced, even if column-fill isn't |
+ // 'balance' - in accordance with the spec). |
+ // Pretending that column-fill is auto also matches the old multicol |
+ // implementation, which has no support for this property. |
if (multiColumnBlockFlow()->style()->getColumnFill() == ColumnFillBalance) |
return true; |
if (LayoutBox* next = nextSiblingBox()) { |
@@ -365,9 +373,9 @@ LayoutUnit LayoutMultiColumnSet::pageLogicalTopForOffset( |
bool LayoutMultiColumnSet::recalculateColumnHeight() { |
if (m_oldLogicalTop != logicalTop() && |
multiColumnFlowThread()->enclosingFragmentationContext()) { |
- // Preceding spanners or column sets have been moved or resized. This means that the |
- // fragmentainer groups that we have inserted need to be re-inserted. Restart column |
- // balancing. |
+ // Preceding spanners or column sets have been moved or resized. This means |
+ // that the fragmentainer groups that we have inserted need to be |
+ // re-inserted. Restart column balancing. |
resetColumnHeight(); |
return true; |
} |
@@ -387,16 +395,17 @@ void LayoutMultiColumnSet::resetColumnHeight() { |
} |
void LayoutMultiColumnSet::beginFlow(LayoutUnit offsetInFlowThread) { |
- // At this point layout is exactly at the beginning of this set. Store block offset from flow |
- // thread start. |
+ // At this point layout is exactly at the beginning of this set. Store block |
+ // offset from flow thread start. |
m_fragmentainerGroups.first().setLogicalTopInFlowThread(offsetInFlowThread); |
} |
void LayoutMultiColumnSet::endFlow(LayoutUnit offsetInFlowThread) { |
- // At this point layout is exactly at the end of this set. Store block offset from flow thread |
- // start. This set is now considered "flowed", although we may have to revisit it later (with |
- // beginFlow()), e.g. if a subtree in the flow thread has to be laid out over again because the |
- // initial margin collapsing estimates were wrong. |
+ // At this point layout is exactly at the end of this set. Store block offset |
+ // from flow thread start. This set is now considered "flowed", although we |
+ // may have to revisit it later (with beginFlow()), e.g. if a subtree in the |
+ // flow thread has to be laid out over again because the initial margin |
+ // collapsing estimates were wrong. |
m_fragmentainerGroups.last().setLogicalBottomInFlowThread(offsetInFlowThread); |
} |
@@ -404,13 +413,15 @@ void LayoutMultiColumnSet::styleDidChange(StyleDifference diff, |
const ComputedStyle* oldStyle) { |
LayoutBlockFlow::styleDidChange(diff, oldStyle); |
- // column-rule is specified on the parent (the multicol container) of this object, but it's the |
- // column sets that are in charge of painting them. A column rule is pretty much like any other |
- // box decoration, like borders. We need to say that we have box decorations here, so that the |
- // columnn set is invalidated when it gets laid out. We cannot check here whether the multicol |
- // container actually has a visible column rule or not, because we may not have been inserted |
- // into the tree yet. Painting a column set is cheap anyway, because the only thing it can |
- // paint is the column rule, while actual multicol content is handled by the flow thread. |
+ // column-rule is specified on the parent (the multicol container) of this |
+ // object, but it's the column sets that are in charge of painting them. |
+ // A column rule is pretty much like any other box decoration, like borders. |
+ // We need to say that we have box decorations here, so that the columnn set |
+ // is invalidated when it gets laid out. We cannot check here whether the |
+ // multicol container actually has a visible column rule or not, because we |
+ // may not have been inserted into the tree yet. Painting a column set is |
+ // cheap anyway, because the only thing it can paint is the column rule, while |
+ // actual multicol content is handled by the flow thread. |
setHasBoxDecorationBackground(true); |
} |
@@ -451,17 +462,18 @@ PositionWithAffinity LayoutMultiColumnSet::positionForPoint( |
LayoutUnit LayoutMultiColumnSet::columnGap() const { |
LayoutBlockFlow* parentBlock = multiColumnBlockFlow(); |
- if (parentBlock->style()->hasNormalColumnGap()) |
+ |
+ if (parentBlock->style()->hasNormalColumnGap()) { |
+ // "1em" is recommended as the normal gap setting. Matches <p> margins. |
return LayoutUnit( |
- parentBlock->style() |
- ->getFontDescription() |
- .computedPixelSize()); // "1em" is recommended as the normal gap setting. Matches <p> margins. |
+ parentBlock->style()->getFontDescription().computedPixelSize()); |
+ } |
return LayoutUnit(parentBlock->style()->columnGap()); |
} |
unsigned LayoutMultiColumnSet::actualColumnCount() const { |
- // FIXME: remove this method. It's a meaningless question to ask the set "how many columns do |
- // you actually have?", since that may vary for each row. |
+ // FIXME: remove this method. It's a meaningless question to ask the set "how |
+ // many columns do you actually have?", since that may vary for each row. |
return firstFragmentainerGroup().actualColumnCount(); |
} |