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/LayoutMultiColumnSet.h" | 9 #include "core/layout/LayoutMultiColumnSet.h" |
10 | 10 |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 m_columnSet.flipForWritingMode(columnRect); | 139 m_columnSet.flipForWritingMode(columnRect); |
140 return columnRect.location() - portionRect.location(); | 140 return columnRect.location() - portionRect.location(); |
141 } | 141 } |
142 | 142 |
143 LayoutUnit MultiColumnFragmentainerGroup::columnLogicalTopForOffset(LayoutUnit o
ffsetInFlowThread) const | 143 LayoutUnit MultiColumnFragmentainerGroup::columnLogicalTopForOffset(LayoutUnit o
ffsetInFlowThread) const |
144 { | 144 { |
145 unsigned columnIndex = columnIndexAtOffset(offsetInFlowThread, AssumeNewColu
mns); | 145 unsigned columnIndex = columnIndexAtOffset(offsetInFlowThread, AssumeNewColu
mns); |
146 return m_logicalTopInFlowThread + columnIndex * m_columnHeight; | 146 return m_logicalTopInFlowThread + columnIndex * m_columnHeight; |
147 } | 147 } |
148 | 148 |
| 149 LayoutPoint MultiColumnFragmentainerGroup::visualPointToFlowThreadPoint(const La
youtPoint& visualPoint) const |
| 150 { |
| 151 unsigned columnIndex = columnIndexAtVisualPoint(visualPoint); |
| 152 LayoutRect columnRect = columnRectAt(columnIndex); |
| 153 LayoutPoint localPoint(visualPoint); |
| 154 localPoint.moveBy(-columnRect.location()); |
| 155 // Before converting to a flow thread position, if the block direction coord
inate is outside the |
| 156 // column, snap to the bounds of the column, and reset the inline direction
coordinate to the |
| 157 // start position in the column. The effect of this is that if the block pos
ition is before the |
| 158 // column rectangle, we'll get to the beginning of this column, while if the
block position is |
| 159 // after the column rectangle, we'll get to the beginning of the next column
. |
| 160 if (!m_columnSet.isHorizontalWritingMode()) { |
| 161 LayoutUnit columnStart = m_columnSet.style()->isLeftToRightDirection() ?
LayoutUnit() : columnRect.height(); |
| 162 if (localPoint.x() < 0) |
| 163 localPoint = LayoutPoint(LayoutUnit(), columnStart); |
| 164 else if (localPoint.x() > logicalHeight()) |
| 165 localPoint = LayoutPoint(logicalHeight(), columnStart); |
| 166 return LayoutPoint(localPoint.x() + logicalTopInFlowThreadAt(columnIndex
), localPoint.y()); |
| 167 } |
| 168 LayoutUnit columnStart = m_columnSet.style()->isLeftToRightDirection() ? Lay
outUnit() : columnRect.width(); |
| 169 if (localPoint.y() < 0) |
| 170 localPoint = LayoutPoint(columnStart, LayoutUnit()); |
| 171 else if (localPoint.y() > logicalHeight()) |
| 172 localPoint = LayoutPoint(columnStart, logicalHeight()); |
| 173 return LayoutPoint(localPoint.x(), localPoint.y() + logicalTopInFlowThreadAt
(columnIndex)); |
| 174 } |
| 175 |
149 void MultiColumnFragmentainerGroup::collectLayerFragments(LayerFragments& fragme
nts, const LayoutRect& layerBoundingBox, const LayoutRect& dirtyRect) const | 176 void MultiColumnFragmentainerGroup::collectLayerFragments(LayerFragments& fragme
nts, const LayoutRect& layerBoundingBox, const LayoutRect& dirtyRect) const |
150 { | 177 { |
151 // |layerBoundingBox| is in the flow thread coordinate space, relative to th
e top/left edge of | 178 // |layerBoundingBox| is in the flow thread coordinate space, relative to th
e top/left edge of |
152 // the flow thread, but note that it has been converted with respect to writ
ing mode (so that | 179 // the flow thread, but note that it has been converted with respect to writ
ing mode (so that |
153 // it's visual/physical in that sense). | 180 // it's visual/physical in that sense). |
154 // | 181 // |
155 // |dirtyRect| is visual, relative to the multicol container. | 182 // |dirtyRect| is visual, relative to the multicol container. |
156 // | 183 // |
157 // Then there's the output from this method - the stuff we put into the list
of fragments. The | 184 // Then there's the output from this method - the stuff we put into the list
of fragments. The |
158 // fragment.paginationOffset point is the actual visual translation required
to get from a | 185 // fragment.paginationOffset point is the actual visual translation required
to get from a |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 if (mode == ClampToExistingColumns) { | 510 if (mode == ClampToExistingColumns) { |
484 if (offsetInFlowThread >= m_logicalBottomInFlowThread) | 511 if (offsetInFlowThread >= m_logicalBottomInFlowThread) |
485 return actualColumnCount() - 1; | 512 return actualColumnCount() - 1; |
486 } | 513 } |
487 | 514 |
488 if (m_columnHeight) | 515 if (m_columnHeight) |
489 return (offsetInFlowThread - m_logicalTopInFlowThread).toFloat() / m_col
umnHeight.toFloat(); | 516 return (offsetInFlowThread - m_logicalTopInFlowThread).toFloat() / m_col
umnHeight.toFloat(); |
490 return 0; | 517 return 0; |
491 } | 518 } |
492 | 519 |
| 520 unsigned MultiColumnFragmentainerGroup::columnIndexAtVisualPoint(const LayoutPoi
nt& visualPoint) const |
| 521 { |
| 522 bool isColumnProgressionInline = m_columnSet.multiColumnFlowThread()->progre
ssionIsInline(); |
| 523 bool isHorizontalWritingMode = m_columnSet.isHorizontalWritingMode(); |
| 524 LayoutUnit columnLengthInColumnProgressionDirection = isColumnProgressionInl
ine ? m_columnSet.pageLogicalWidth() : m_columnSet.pageLogicalHeight(); |
| 525 LayoutUnit offsetInColumnProgressionDirection = isHorizontalWritingMode == i
sColumnProgressionInline ? visualPoint.x() : visualPoint.y(); |
| 526 if (!m_columnSet.style()->isLeftToRightDirection() && isColumnProgressionInl
ine) |
| 527 offsetInColumnProgressionDirection = m_columnSet.logicalWidth() - offset
InColumnProgressionDirection; |
| 528 LayoutUnit columnGap = m_columnSet.columnGap(); |
| 529 if (columnLengthInColumnProgressionDirection + columnGap <= 0) |
| 530 return 0; |
| 531 // Column boundaries are in the middle of the column gap. |
| 532 int index = (offsetInColumnProgressionDirection + columnGap / 2) / (columnLe
ngthInColumnProgressionDirection + columnGap); |
| 533 if (index < 0) |
| 534 return 0; |
| 535 return std::min(unsigned(index), actualColumnCount() - 1); |
| 536 } |
| 537 |
493 MultiColumnFragmentainerGroupList::MultiColumnFragmentainerGroupList(LayoutMulti
ColumnSet& columnSet) | 538 MultiColumnFragmentainerGroupList::MultiColumnFragmentainerGroupList(LayoutMulti
ColumnSet& columnSet) |
494 : m_columnSet(columnSet) | 539 : m_columnSet(columnSet) |
495 { | 540 { |
496 append(MultiColumnFragmentainerGroup(m_columnSet)); | 541 append(MultiColumnFragmentainerGroup(m_columnSet)); |
497 } | 542 } |
498 | 543 |
499 MultiColumnFragmentainerGroup& MultiColumnFragmentainerGroupList::addExtraGroup(
) | 544 MultiColumnFragmentainerGroup& MultiColumnFragmentainerGroupList::addExtraGroup(
) |
500 { | 545 { |
501 append(MultiColumnFragmentainerGroup(m_columnSet)); | 546 append(MultiColumnFragmentainerGroup(m_columnSet)); |
502 return last(); | 547 return last(); |
503 } | 548 } |
504 | 549 |
505 void MultiColumnFragmentainerGroupList::deleteExtraGroups() | 550 void MultiColumnFragmentainerGroupList::deleteExtraGroups() |
506 { | 551 { |
507 shrink(1); | 552 shrink(1); |
508 } | 553 } |
509 | 554 |
510 } // namespace blink | 555 } // namespace blink |
OLD | NEW |