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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 } | 174 } |
175 | 175 |
176 LayoutUnit MultiColumnFragmentainerGroup::columnLogicalTopForOffset( | 176 LayoutUnit MultiColumnFragmentainerGroup::columnLogicalTopForOffset( |
177 LayoutUnit offsetInFlowThread) const { | 177 LayoutUnit offsetInFlowThread) const { |
178 unsigned columnIndex = columnIndexAtOffset( | 178 unsigned columnIndex = columnIndexAtOffset( |
179 offsetInFlowThread, LayoutBox::AssociateWithLatterPage); | 179 offsetInFlowThread, LayoutBox::AssociateWithLatterPage); |
180 return logicalTopInFlowThreadAt(columnIndex); | 180 return logicalTopInFlowThreadAt(columnIndex); |
181 } | 181 } |
182 | 182 |
183 LayoutPoint MultiColumnFragmentainerGroup::visualPointToFlowThreadPoint( | 183 LayoutPoint MultiColumnFragmentainerGroup::visualPointToFlowThreadPoint( |
184 const LayoutPoint& visualPoint) const { | 184 const LayoutPoint& visualPoint, |
| 185 SnapToColumnPolicy snap) const { |
185 unsigned columnIndex = columnIndexAtVisualPoint(visualPoint); | 186 unsigned columnIndex = columnIndexAtVisualPoint(visualPoint); |
186 LayoutRect columnRect = columnRectAt(columnIndex); | 187 LayoutRect columnRect = columnRectAt(columnIndex); |
187 LayoutPoint localPoint(visualPoint); | 188 LayoutPoint localPoint(visualPoint); |
188 localPoint.moveBy(-columnRect.location()); | 189 localPoint.moveBy(-columnRect.location()); |
189 // Before converting to a flow thread position, if the block direction | |
190 // coordinate is outside the column, snap to the bounds of the column, and | |
191 // reset the inline direction coordinate to the start position in the column. | |
192 // The effect of this is that if the block position is before the column | |
193 // rectangle, we'll get to the beginning of this column, while if the block | |
194 // position is after the column rectangle, we'll get to the beginning of the | |
195 // next column. | |
196 if (!m_columnSet.isHorizontalWritingMode()) { | 190 if (!m_columnSet.isHorizontalWritingMode()) { |
197 LayoutUnit columnStart = m_columnSet.style()->isLeftToRightDirection() | 191 if (snap == SnapToColumn) { |
198 ? LayoutUnit() | 192 LayoutUnit columnStart = m_columnSet.style()->isLeftToRightDirection() |
199 : columnRect.height(); | 193 ? LayoutUnit() |
200 if (localPoint.x() < 0) | 194 : columnRect.height(); |
201 localPoint = LayoutPoint(LayoutUnit(), columnStart); | 195 if (localPoint.x() < 0) |
202 else if (localPoint.x() > logicalHeight()) | 196 localPoint = LayoutPoint(LayoutUnit(), columnStart); |
203 localPoint = LayoutPoint(logicalHeight(), columnStart); | 197 else if (localPoint.x() > logicalHeight()) |
| 198 localPoint = LayoutPoint(logicalHeight(), columnStart); |
| 199 } |
204 return LayoutPoint(localPoint.x() + logicalTopInFlowThreadAt(columnIndex), | 200 return LayoutPoint(localPoint.x() + logicalTopInFlowThreadAt(columnIndex), |
205 localPoint.y()); | 201 localPoint.y()); |
206 } | 202 } |
207 LayoutUnit columnStart = m_columnSet.style()->isLeftToRightDirection() | 203 if (snap == SnapToColumn) { |
208 ? LayoutUnit() | 204 LayoutUnit columnStart = m_columnSet.style()->isLeftToRightDirection() |
209 : columnRect.width(); | 205 ? LayoutUnit() |
210 if (localPoint.y() < 0) | 206 : columnRect.width(); |
211 localPoint = LayoutPoint(columnStart, LayoutUnit()); | 207 if (localPoint.y() < 0) |
212 else if (localPoint.y() > logicalHeight()) | 208 localPoint = LayoutPoint(columnStart, LayoutUnit()); |
213 localPoint = LayoutPoint(columnStart, logicalHeight()); | 209 else if (localPoint.y() > logicalHeight()) |
| 210 localPoint = LayoutPoint(columnStart, logicalHeight()); |
| 211 } |
214 return LayoutPoint(localPoint.x(), | 212 return LayoutPoint(localPoint.x(), |
215 localPoint.y() + logicalTopInFlowThreadAt(columnIndex)); | 213 localPoint.y() + logicalTopInFlowThreadAt(columnIndex)); |
216 } | 214 } |
217 | 215 |
218 LayoutRect MultiColumnFragmentainerGroup::fragmentsBoundingBox( | 216 LayoutRect MultiColumnFragmentainerGroup::fragmentsBoundingBox( |
219 const LayoutRect& boundingBoxInFlowThread) const { | 217 const LayoutRect& boundingBoxInFlowThread) const { |
220 // Find the start and end column intersected by the bounding box. | 218 // Find the start and end column intersected by the bounding box. |
221 LayoutRect flippedBoundingBoxInFlowThread(boundingBoxInFlowThread); | 219 LayoutRect flippedBoundingBoxInFlowThread(boundingBoxInFlowThread); |
222 LayoutFlowThread* flowThread = m_columnSet.flowThread(); | 220 LayoutFlowThread* flowThread = m_columnSet.flowThread(); |
223 flowThread->flipForWritingMode(flippedBoundingBoxInFlowThread); | 221 flowThread->flipForWritingMode(flippedBoundingBoxInFlowThread); |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
594 MultiColumnFragmentainerGroupList::addExtraGroup() { | 592 MultiColumnFragmentainerGroupList::addExtraGroup() { |
595 append(MultiColumnFragmentainerGroup(m_columnSet)); | 593 append(MultiColumnFragmentainerGroup(m_columnSet)); |
596 return last(); | 594 return last(); |
597 } | 595 } |
598 | 596 |
599 void MultiColumnFragmentainerGroupList::deleteExtraGroups() { | 597 void MultiColumnFragmentainerGroupList::deleteExtraGroups() { |
600 shrink(1); | 598 shrink(1); |
601 } | 599 } |
602 | 600 |
603 } // namespace blink | 601 } // namespace blink |
OLD | NEW |