| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 | 6 |
| 7 #include "core/layout/MultiColumnFragmentainerGroup.h" | 7 #include "core/layout/MultiColumnFragmentainerGroup.h" |
| 8 | 8 |
| 9 #include "core/layout/ColumnBalancer.h" | 9 #include "core/layout/ColumnBalancer.h" |
| 10 #include "core/layout/FragmentationContext.h" |
| 10 #include "core/layout/LayoutMultiColumnSet.h" | 11 #include "core/layout/LayoutMultiColumnSet.h" |
| 11 | 12 |
| 12 namespace blink { | 13 namespace blink { |
| 13 | 14 |
| 14 MultiColumnFragmentainerGroup::MultiColumnFragmentainerGroup(LayoutMultiColumnSe
t& columnSet) | 15 MultiColumnFragmentainerGroup::MultiColumnFragmentainerGroup(LayoutMultiColumnSe
t& columnSet) |
| 15 : m_columnSet(columnSet) | 16 : m_columnSet(columnSet) |
| 16 { | 17 { |
| 17 } | 18 } |
| 18 | 19 |
| 19 bool MultiColumnFragmentainerGroup::isFirstGroup() const | 20 bool MultiColumnFragmentainerGroup::isFirstGroup() const |
| 20 { | 21 { |
| 21 return &m_columnSet.firstFragmentainerGroup() == this; | 22 return &m_columnSet.firstFragmentainerGroup() == this; |
| 22 } | 23 } |
| 23 | 24 |
| 24 bool MultiColumnFragmentainerGroup::isLastGroup() const | 25 bool MultiColumnFragmentainerGroup::isLastGroup() const |
| 25 { | 26 { |
| 26 return &m_columnSet.lastFragmentainerGroup() == this; | 27 return &m_columnSet.lastFragmentainerGroup() == this; |
| 27 } | 28 } |
| 28 | 29 |
| 29 LayoutSize MultiColumnFragmentainerGroup::offsetFromColumnSet() const | 30 LayoutSize MultiColumnFragmentainerGroup::offsetFromColumnSet() const |
| 30 { | 31 { |
| 31 LayoutSize offset(LayoutUnit(), logicalTop()); | 32 LayoutSize offset(LayoutUnit(), logicalTop()); |
| 32 if (!m_columnSet.flowThread()->isHorizontalWritingMode()) | 33 if (!m_columnSet.flowThread()->isHorizontalWritingMode()) |
| 33 return offset.transposedSize(); | 34 return offset.transposedSize(); |
| 34 return offset; | 35 return offset; |
| 35 } | 36 } |
| 36 | 37 |
| 37 LayoutUnit MultiColumnFragmentainerGroup::blockOffsetInEnclosingFlowThread() con
st | 38 LayoutUnit MultiColumnFragmentainerGroup::blockOffsetInEnclosingFragmentationCon
text() const |
| 38 { | 39 { |
| 39 return logicalTop() + m_columnSet.logicalTop() + m_columnSet.multiColumnFlow
Thread()->blockOffsetInEnclosingFlowThread(); | 40 return logicalTop() + m_columnSet.logicalTop() + m_columnSet.multiColumnFlow
Thread()->blockOffsetInEnclosingFragmentationContext(); |
| 40 } | 41 } |
| 41 | 42 |
| 42 void MultiColumnFragmentainerGroup::resetColumnHeight() | 43 void MultiColumnFragmentainerGroup::resetColumnHeight() |
| 43 { | 44 { |
| 44 m_maxColumnHeight = calculateMaxColumnHeight(); | 45 m_maxColumnHeight = calculateMaxColumnHeight(); |
| 45 | 46 |
| 46 LayoutMultiColumnFlowThread* flowThread = m_columnSet.multiColumnFlowThread(
); | 47 LayoutMultiColumnFlowThread* flowThread = m_columnSet.multiColumnFlowThread(
); |
| 47 if (m_columnSet.heightIsAuto()) { | 48 if (m_columnSet.heightIsAuto()) { |
| 48 LayoutMultiColumnFlowThread* enclosingFlowThread = flowThread->enclosing
FlowThread(); | 49 FragmentationContext* enclosingFragmentationContext = flowThread->enclos
ingFragmentationContext(); |
| 49 if (enclosingFlowThread && enclosingFlowThread->isPageLogicalHeightKnown
()) { | 50 if (enclosingFragmentationContext && enclosingFragmentationContext->isFr
agmentainerLogicalHeightKnown()) { |
| 50 // Even if height is auto, we set an initial height, in order to tel
l how much content | 51 // Even if height is auto, we set an initial height, in order to tel
l how much content |
| 51 // this MultiColumnFragmentainerGroup can hold, and when we need to
append a new one. | 52 // this MultiColumnFragmentainerGroup can hold, and when we need to
append a new one. |
| 52 m_columnHeight = m_maxColumnHeight; | 53 m_columnHeight = m_maxColumnHeight; |
| 53 } else { | 54 } else { |
| 54 m_columnHeight = LayoutUnit(); | 55 m_columnHeight = LayoutUnit(); |
| 55 } | 56 } |
| 56 } else { | 57 } else { |
| 57 setAndConstrainColumnHeight(heightAdjustedForRowOffset(flowThread->colum
nHeightAvailable())); | 58 setAndConstrainColumnHeight(heightAdjustedForRowOffset(flowThread->colum
nHeightAvailable())); |
| 58 } | 59 } |
| 59 } | 60 } |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 flowThread->flipForWritingMode(portionRect); | 108 flowThread->flipForWritingMode(portionRect); |
| 108 LayoutRect columnRect(columnRectAt(columnIndex)); | 109 LayoutRect columnRect(columnRectAt(columnIndex)); |
| 109 m_columnSet.flipForWritingMode(columnRect); | 110 m_columnSet.flipForWritingMode(columnRect); |
| 110 LayoutSize translationRelativeToGroup = columnRect.location() - portionRect.
location(); | 111 LayoutSize translationRelativeToGroup = columnRect.location() - portionRect.
location(); |
| 111 | 112 |
| 112 LayoutSize enclosingTranslation; | 113 LayoutSize enclosingTranslation; |
| 113 if (LayoutMultiColumnFlowThread* enclosingFlowThread = flowThread->enclosing
FlowThread()) { | 114 if (LayoutMultiColumnFlowThread* enclosingFlowThread = flowThread->enclosing
FlowThread()) { |
| 114 // Translation that would map points in the coordinate space of the oute
rmost flow thread to | 115 // Translation that would map points in the coordinate space of the oute
rmost flow thread to |
| 115 // visual points in the first column in the first fragmentainer group (r
ow) in our multicol | 116 // visual points in the first column in the first fragmentainer group (r
ow) in our multicol |
| 116 // container. | 117 // container. |
| 117 LayoutSize enclosingTranslationOrigin = enclosingFlowThread->flowThreadT
ranslationAtOffset(flowThread->blockOffsetInEnclosingFlowThread()); | 118 LayoutSize enclosingTranslationOrigin = enclosingFlowThread->flowThreadT
ranslationAtOffset(flowThread->blockOffsetInEnclosingFragmentationContext()); |
| 118 | 119 |
| 119 // Translation that would map points in the coordinate space of the oute
rmost flow thread to | 120 // Translation that would map points in the coordinate space of the oute
rmost flow thread to |
| 120 // visual points in the first column in this fragmentainer group. | 121 // visual points in the first column in this fragmentainer group. |
| 121 enclosingTranslation = enclosingFlowThread->flowThreadTranslationAtOffse
t(blockOffsetInEnclosingFlowThread()); | 122 enclosingTranslation = enclosingFlowThread->flowThreadTranslationAtOffse
t(blockOffsetInEnclosingFragmentationContext()); |
| 122 | 123 |
| 123 // What we ultimately return from this method is a translation that maps
points in the | 124 // What we ultimately return from this method is a translation that maps
points in the |
| 124 // coordinate space of our flow thread to a visual point in a certain co
lumn in this | 125 // coordinate space of our flow thread to a visual point in a certain co
lumn in this |
| 125 // fragmentainer group. We had to go all the way up to the outermost flo
w thread, since this | 126 // fragmentainer group. We had to go all the way up to the outermost flo
w thread, since this |
| 126 // fragmentainer group may be in a different outer column than the first
outer column that | 127 // fragmentainer group may be in a different outer column than the first
outer column that |
| 127 // this multicol container lives in. It's the visual distance between th
e first | 128 // this multicol container lives in. It's the visual distance between th
e first |
| 128 // fragmentainer group and this fragmentainer group that we need to add
to the translation. | 129 // fragmentainer group and this fragmentainer group that we need to add
to the translation. |
| 129 enclosingTranslation -= enclosingTranslationOrigin; | 130 enclosingTranslation -= enclosingTranslationOrigin; |
| 130 } | 131 } |
| 131 | 132 |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 const ComputedStyle& multicolStyle = multicolBlock->styleRef(); | 317 const ComputedStyle& multicolStyle = multicolBlock->styleRef(); |
| 317 LayoutMultiColumnFlowThread* flowThread = m_columnSet.multiColumnFlowThread(
); | 318 LayoutMultiColumnFlowThread* flowThread = m_columnSet.multiColumnFlowThread(
); |
| 318 LayoutUnit availableHeight = flowThread->columnHeightAvailable(); | 319 LayoutUnit availableHeight = flowThread->columnHeightAvailable(); |
| 319 LayoutUnit maxColumnHeight = availableHeight ? availableHeight : LayoutUnit:
:max(); | 320 LayoutUnit maxColumnHeight = availableHeight ? availableHeight : LayoutUnit:
:max(); |
| 320 if (!multicolStyle.logicalMaxHeight().isMaxSizeNone()) { | 321 if (!multicolStyle.logicalMaxHeight().isMaxSizeNone()) { |
| 321 LayoutUnit logicalMaxHeight = multicolBlock->computeContentLogicalHeight
(MaxSize, multicolStyle.logicalMaxHeight(), -1); | 322 LayoutUnit logicalMaxHeight = multicolBlock->computeContentLogicalHeight
(MaxSize, multicolStyle.logicalMaxHeight(), -1); |
| 322 if (logicalMaxHeight != -1 && maxColumnHeight > logicalMaxHeight) | 323 if (logicalMaxHeight != -1 && maxColumnHeight > logicalMaxHeight) |
| 323 maxColumnHeight = logicalMaxHeight; | 324 maxColumnHeight = logicalMaxHeight; |
| 324 } | 325 } |
| 325 LayoutUnit maxHeight = heightAdjustedForRowOffset(maxColumnHeight); | 326 LayoutUnit maxHeight = heightAdjustedForRowOffset(maxColumnHeight); |
| 326 if (LayoutMultiColumnFlowThread* enclosingFlowThread = flowThread->enclosing
FlowThread()) { | 327 if (FragmentationContext* enclosingFragmentationContext = flowThread->enclos
ingFragmentationContext()) { |
| 327 if (enclosingFlowThread->isPageLogicalHeightKnown()) { | 328 if (enclosingFragmentationContext->isFragmentainerLogicalHeightKnown())
{ |
| 328 // We're nested inside another fragmentation context whose fragmenta
iner heights are | 329 // We're nested inside another fragmentation context whose fragmenta
iner heights are |
| 329 // known. This constrains the max height. | 330 // known. This constrains the max height. |
| 330 LayoutUnit remainingOuterLogicalHeight = enclosingFlowThread->pageRe
mainingLogicalHeightForOffset(blockOffsetInEnclosingFlowThread(), LayoutBlock::A
ssociateWithLatterPage); | 331 LayoutUnit remainingOuterLogicalHeight = enclosingFragmentationConte
xt->remainingLogicalHeightAt(blockOffsetInEnclosingFragmentationContext()); |
| 331 ASSERT(remainingOuterLogicalHeight > 0); | 332 ASSERT(remainingOuterLogicalHeight > 0); |
| 332 if (maxHeight > remainingOuterLogicalHeight) | 333 if (maxHeight > remainingOuterLogicalHeight) |
| 333 maxHeight = remainingOuterLogicalHeight; | 334 maxHeight = remainingOuterLogicalHeight; |
| 334 } | 335 } |
| 335 } | 336 } |
| 336 return maxHeight; | 337 return maxHeight; |
| 337 } | 338 } |
| 338 | 339 |
| 339 void MultiColumnFragmentainerGroup::setAndConstrainColumnHeight(LayoutUnit newHe
ight) | 340 void MultiColumnFragmentainerGroup::setAndConstrainColumnHeight(LayoutUnit newHe
ight) |
| 340 { | 341 { |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 append(MultiColumnFragmentainerGroup(m_columnSet)); | 554 append(MultiColumnFragmentainerGroup(m_columnSet)); |
| 554 return last(); | 555 return last(); |
| 555 } | 556 } |
| 556 | 557 |
| 557 void MultiColumnFragmentainerGroupList::deleteExtraGroups() | 558 void MultiColumnFragmentainerGroupList::deleteExtraGroups() |
| 558 { | 559 { |
| 559 shrink(1); | 560 shrink(1); |
| 560 } | 561 } |
| 561 | 562 |
| 562 } // namespace blink | 563 } // namespace blink |
| OLD | NEW |