| 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 "core/layout/MultiColumnFragmentainerGroup.h" | 5 #include "core/layout/MultiColumnFragmentainerGroup.h" |
| 6 | 6 |
| 7 #include "core/layout/ColumnBalancer.h" | 7 #include "core/layout/ColumnBalancer.h" |
| 8 #include "core/layout/FragmentationContext.h" | 8 #include "core/layout/FragmentationContext.h" |
| 9 #include "core/layout/LayoutMultiColumnSet.h" | 9 #include "core/layout/LayoutMultiColumnSet.h" |
| 10 | 10 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 // columns may have changed as well. | 91 // columns may have changed as well. |
| 92 setAndConstrainColumnHeight(m_columnHeight); | 92 setAndConstrainColumnHeight(m_columnHeight); |
| 93 } | 93 } |
| 94 | 94 |
| 95 if (m_columnHeight == oldColumnHeight) | 95 if (m_columnHeight == oldColumnHeight) |
| 96 return false; // No change. We're done. | 96 return false; // No change. We're done. |
| 97 | 97 |
| 98 return true; // Need another pass. | 98 return true; // Need another pass. |
| 99 } | 99 } |
| 100 | 100 |
| 101 LayoutSize MultiColumnFragmentainerGroup::flowThreadTranslationAtOffset(LayoutUn
it offsetInFlowThread) const | 101 LayoutSize MultiColumnFragmentainerGroup::flowThreadTranslationAtOffset(LayoutUn
it offsetInFlowThread, CoordinateSpaceConversion mode) const |
| 102 { | 102 { |
| 103 LayoutMultiColumnFlowThread* flowThread = m_columnSet.multiColumnFlowThread(
); | 103 LayoutMultiColumnFlowThread* flowThread = m_columnSet.multiColumnFlowThread(
); |
| 104 unsigned columnIndex = columnIndexAtOffset(offsetInFlowThread); | 104 unsigned columnIndex = columnIndexAtOffset(offsetInFlowThread); |
| 105 LayoutRect portionRect(flowThreadPortionRectAt(columnIndex)); | 105 LayoutRect portionRect(flowThreadPortionRectAt(columnIndex)); |
| 106 flowThread->flipForWritingMode(portionRect); | 106 flowThread->flipForWritingMode(portionRect); |
| 107 LayoutRect columnRect(columnRectAt(columnIndex)); | 107 LayoutRect columnRect(columnRectAt(columnIndex)); |
| 108 m_columnSet.flipForWritingMode(columnRect); | 108 m_columnSet.flipForWritingMode(columnRect); |
| 109 LayoutSize translationRelativeToGroup = columnRect.location() - portionRect.
location(); | 109 LayoutSize translationRelativeToGroup = columnRect.location() - portionRect.
location(); |
| 110 LayoutSize translationRelativeToFlowThread = translationRelativeToGroup + of
fsetFromColumnSet() + m_columnSet.topLeftLocationOffset() - flowThread->topLeftL
ocationOffset(); |
| 111 if (mode == CoordinateSpaceConversion::Containing) |
| 112 return translationRelativeToFlowThread; |
| 110 | 113 |
| 111 LayoutSize enclosingTranslation; | 114 LayoutSize enclosingTranslation; |
| 112 if (LayoutMultiColumnFlowThread* enclosingFlowThread = flowThread->enclosing
FlowThread()) { | 115 if (LayoutMultiColumnFlowThread* enclosingFlowThread = flowThread->enclosing
FlowThread()) { |
| 113 const MultiColumnFragmentainerGroup& firstRow = flowThread->firstMultiCo
lumnSet()->firstFragmentainerGroup(); | 116 const MultiColumnFragmentainerGroup& firstRow = flowThread->firstMultiCo
lumnSet()->firstFragmentainerGroup(); |
| 114 // Translation that would map points in the coordinate space of the oute
rmost flow thread to | 117 // 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 | 118 // visual points in the first column in the first fragmentainer group (r
ow) in our multicol |
| 116 // container. | 119 // container. |
| 117 LayoutSize enclosingTranslationOrigin = enclosingFlowThread->flowThreadT
ranslationAtOffset(firstRow.blockOffsetInEnclosingFragmentationContext()); | 120 LayoutSize enclosingTranslationOrigin = enclosingFlowThread->flowThreadT
ranslationAtOffset(firstRow.blockOffsetInEnclosingFragmentationContext(), mode); |
| 118 | 121 |
| 119 // Translation that would map points in the coordinate space of the oute
rmost flow thread to | 122 // 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. | 123 // visual points in the first column in this fragmentainer group. |
| 121 enclosingTranslation = enclosingFlowThread->flowThreadTranslationAtOffse
t(blockOffsetInEnclosingFragmentationContext()); | 124 enclosingTranslation = enclosingFlowThread->flowThreadTranslationAtOffse
t(blockOffsetInEnclosingFragmentationContext(), mode); |
| 122 | 125 |
| 123 // What we ultimately return from this method is a translation that maps
points in the | 126 // 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 | 127 // 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 | 128 // 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 | 129 // 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 | 130 // 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. | 131 // fragmentainer group and this fragmentainer group that we need to add
to the translation. |
| 129 enclosingTranslation -= enclosingTranslationOrigin; | 132 enclosingTranslation -= enclosingTranslationOrigin; |
| 130 } | 133 } |
| 131 | 134 |
| 132 return enclosingTranslation + translationRelativeToGroup + offsetFromColumnS
et() + m_columnSet.topLeftLocationOffset() - flowThread->topLeftLocationOffset()
; | 135 return enclosingTranslation + translationRelativeToFlowThread; |
| 133 } | 136 } |
| 134 | 137 |
| 135 LayoutUnit MultiColumnFragmentainerGroup::columnLogicalTopForOffset(LayoutUnit o
ffsetInFlowThread) const | 138 LayoutUnit MultiColumnFragmentainerGroup::columnLogicalTopForOffset(LayoutUnit o
ffsetInFlowThread) const |
| 136 { | 139 { |
| 137 unsigned columnIndex = columnIndexAtOffset(offsetInFlowThread, AssumeNewColu
mns); | 140 unsigned columnIndex = columnIndexAtOffset(offsetInFlowThread, AssumeNewColu
mns); |
| 138 return logicalTopInFlowThreadAt(columnIndex); | 141 return logicalTopInFlowThreadAt(columnIndex); |
| 139 } | 142 } |
| 140 | 143 |
| 141 LayoutPoint MultiColumnFragmentainerGroup::visualPointToFlowThreadPoint(const La
youtPoint& visualPoint) const | 144 LayoutPoint MultiColumnFragmentainerGroup::visualPointToFlowThreadPoint(const La
youtPoint& visualPoint) const |
| 142 { | 145 { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 if (boundingBoxLogicalBottom <= logicalTopInFlowThread() || boundingBoxLogic
alTop >= logicalBottomInFlowThread()) | 180 if (boundingBoxLogicalBottom <= logicalTopInFlowThread() || boundingBoxLogic
alTop >= logicalBottomInFlowThread()) |
| 178 return LayoutRect(); // The bounding box doesn't intersect this fragment
ainer group. | 181 return LayoutRect(); // The bounding box doesn't intersect this fragment
ainer group. |
| 179 unsigned startColumn; | 182 unsigned startColumn; |
| 180 unsigned endColumn; | 183 unsigned endColumn; |
| 181 columnIntervalForBlockRangeInFlowThread(boundingBoxLogicalTop, boundingBoxLo
gicalBottom, startColumn, endColumn); | 184 columnIntervalForBlockRangeInFlowThread(boundingBoxLogicalTop, boundingBoxLo
gicalBottom, startColumn, endColumn); |
| 182 | 185 |
| 183 LayoutRect startColumnFlowThreadOverflowPortion = flowThreadPortionOverflowR
ectAt(startColumn); | 186 LayoutRect startColumnFlowThreadOverflowPortion = flowThreadPortionOverflowR
ectAt(startColumn); |
| 184 flowThread->flipForWritingMode(startColumnFlowThreadOverflowPortion); | 187 flowThread->flipForWritingMode(startColumnFlowThreadOverflowPortion); |
| 185 LayoutRect startColumnRect(boundingBoxInFlowThread); | 188 LayoutRect startColumnRect(boundingBoxInFlowThread); |
| 186 startColumnRect.intersect(startColumnFlowThreadOverflowPortion); | 189 startColumnRect.intersect(startColumnFlowThreadOverflowPortion); |
| 187 startColumnRect.move(flowThreadTranslationAtOffset(logicalTopInFlowThreadAt(
startColumn))); | 190 startColumnRect.move(flowThreadTranslationAtOffset(logicalTopInFlowThreadAt(
startColumn), CoordinateSpaceConversion::Containing)); |
| 188 if (startColumn == endColumn) | 191 if (startColumn == endColumn) |
| 189 return startColumnRect; // It all takes place in one column. We're done. | 192 return startColumnRect; // It all takes place in one column. We're done. |
| 190 | 193 |
| 191 LayoutRect endColumnFlowThreadOverflowPortion = flowThreadPortionOverflowRec
tAt(endColumn); | 194 LayoutRect endColumnFlowThreadOverflowPortion = flowThreadPortionOverflowRec
tAt(endColumn); |
| 192 flowThread->flipForWritingMode(endColumnFlowThreadOverflowPortion); | 195 flowThread->flipForWritingMode(endColumnFlowThreadOverflowPortion); |
| 193 LayoutRect endColumnRect(boundingBoxInFlowThread); | 196 LayoutRect endColumnRect(boundingBoxInFlowThread); |
| 194 endColumnRect.intersect(endColumnFlowThreadOverflowPortion); | 197 endColumnRect.intersect(endColumnFlowThreadOverflowPortion); |
| 195 endColumnRect.move(flowThreadTranslationAtOffset(logicalTopInFlowThreadAt(en
dColumn))); | 198 endColumnRect.move(flowThreadTranslationAtOffset(logicalTopInFlowThreadAt(en
dColumn), CoordinateSpaceConversion::Containing)); |
| 196 return unionRect(startColumnRect, endColumnRect); | 199 return unionRect(startColumnRect, endColumnRect); |
| 197 } | 200 } |
| 198 | 201 |
| 199 void MultiColumnFragmentainerGroup::collectLayerFragments(PaintLayerFragments& f
ragments, const LayoutRect& layerBoundingBox, const LayoutRect& dirtyRect) const | 202 void MultiColumnFragmentainerGroup::collectLayerFragments(PaintLayerFragments& f
ragments, const LayoutRect& layerBoundingBox, const LayoutRect& dirtyRect) const |
| 200 { | 203 { |
| 201 // |layerBoundingBox| is in the flow thread coordinate space, relative to th
e top/left edge of | 204 // |layerBoundingBox| is in the flow thread coordinate space, relative to th
e top/left edge of |
| 202 // the flow thread, but note that it has been converted with respect to writ
ing mode (so that | 205 // the flow thread, but note that it has been converted with respect to writ
ing mode (so that |
| 203 // it's visual/physical in that sense). | 206 // it's visual/physical in that sense). |
| 204 // | 207 // |
| 205 // |dirtyRect| is visual, relative to the multicol container. | 208 // |dirtyRect| is visual, relative to the multicol container. |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 if (startColumn < firstColumnInDirtyRect) | 247 if (startColumn < firstColumnInDirtyRect) |
| 245 startColumn = firstColumnInDirtyRect; | 248 startColumn = firstColumnInDirtyRect; |
| 246 if (endColumn > lastColumnInDirtyRect) | 249 if (endColumn > lastColumnInDirtyRect) |
| 247 endColumn = lastColumnInDirtyRect; | 250 endColumn = lastColumnInDirtyRect; |
| 248 ASSERT(endColumn >= startColumn); | 251 ASSERT(endColumn >= startColumn); |
| 249 | 252 |
| 250 for (unsigned i = startColumn; i <= endColumn; i++) { | 253 for (unsigned i = startColumn; i <= endColumn; i++) { |
| 251 PaintLayerFragment fragment; | 254 PaintLayerFragment fragment; |
| 252 | 255 |
| 253 // Set the physical translation offset. | 256 // Set the physical translation offset. |
| 254 fragment.paginationOffset = toLayoutPoint(flowThreadTranslationAtOffset(
logicalTopInFlowThreadAt(i))); | 257 fragment.paginationOffset = toLayoutPoint(flowThreadTranslationAtOffset(
logicalTopInFlowThreadAt(i), CoordinateSpaceConversion::Visual)); |
| 255 | 258 |
| 256 // Set the overflow clip rect that corresponds to the column. | 259 // Set the overflow clip rect that corresponds to the column. |
| 257 fragment.paginationClip = flowThreadPortionOverflowRectAt(i); | 260 fragment.paginationClip = flowThreadPortionOverflowRectAt(i); |
| 258 // Flip it into more a physical (PaintLayer-style) rectangle. | 261 // Flip it into more a physical (PaintLayer-style) rectangle. |
| 259 flowThread->flipForWritingMode(fragment.paginationClip); | 262 flowThread->flipForWritingMode(fragment.paginationClip); |
| 260 | 263 |
| 261 fragments.append(fragment); | 264 fragments.append(fragment); |
| 262 } | 265 } |
| 263 } | 266 } |
| 264 | 267 |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 append(MultiColumnFragmentainerGroup(m_columnSet)); | 535 append(MultiColumnFragmentainerGroup(m_columnSet)); |
| 533 return last(); | 536 return last(); |
| 534 } | 537 } |
| 535 | 538 |
| 536 void MultiColumnFragmentainerGroupList::deleteExtraGroups() | 539 void MultiColumnFragmentainerGroupList::deleteExtraGroups() |
| 537 { | 540 { |
| 538 shrink(1); | 541 shrink(1); |
| 539 } | 542 } |
| 540 | 543 |
| 541 } // namespace blink | 544 } // namespace blink |
| OLD | NEW |