OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2012 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 | 43 |
44 LayoutMultiColumnSet* LayoutMultiColumnSet::createAnonymous(LayoutFlowThread& fl
owThread, const ComputedStyle& parentStyle) | 44 LayoutMultiColumnSet* LayoutMultiColumnSet::createAnonymous(LayoutFlowThread& fl
owThread, const ComputedStyle& parentStyle) |
45 { | 45 { |
46 Document& document = flowThread.document(); | 46 Document& document = flowThread.document(); |
47 LayoutMultiColumnSet* layoutObject = new LayoutMultiColumnSet(&flowThread); | 47 LayoutMultiColumnSet* layoutObject = new LayoutMultiColumnSet(&flowThread); |
48 layoutObject->setDocumentForAnonymous(&document); | 48 layoutObject->setDocumentForAnonymous(&document); |
49 layoutObject->setStyle(ComputedStyle::createAnonymousStyleWithDisplay(parent
Style, BLOCK)); | 49 layoutObject->setStyle(ComputedStyle::createAnonymousStyleWithDisplay(parent
Style, BLOCK)); |
50 return layoutObject; | 50 return layoutObject; |
51 } | 51 } |
52 | 52 |
53 MultiColumnFragmentainerGroup& LayoutMultiColumnSet::fragmentainerGroupAtFlowThr
eadOffset(LayoutUnit) | 53 unsigned LayoutMultiColumnSet::fragmentainerGroupIndexAtFlowThreadOffset(LayoutU
nit flowThreadOffset) const |
54 { | 54 { |
55 // FIXME: implement this, once we have support for multiple rows. | 55 ASSERT(m_fragmentainerGroups.size() > 0); |
56 return m_fragmentainerGroups.first(); | 56 if (flowThreadOffset <= 0) |
57 } | 57 return 0; |
58 | 58 // TODO(mstensho): Introduce an interval tree or similar to speed up this. |
59 const MultiColumnFragmentainerGroup& LayoutMultiColumnSet::fragmentainerGroupAtF
lowThreadOffset(LayoutUnit) const | 59 for (unsigned index = 0; index < m_fragmentainerGroups.size(); index++) { |
60 { | 60 const auto& row = m_fragmentainerGroups[index]; |
61 // FIXME: implement this, once we have support for multiple rows. | 61 if (row.logicalTopInFlowThread() <= flowThreadOffset && row.logicalBotto
mInFlowThread() > flowThreadOffset) |
62 return m_fragmentainerGroups.first(); | 62 return index; |
| 63 } |
| 64 return m_fragmentainerGroups.size() - 1; |
63 } | 65 } |
64 | 66 |
65 const MultiColumnFragmentainerGroup& LayoutMultiColumnSet::fragmentainerGroupAtV
isualPoint(const LayoutPoint&) const | 67 const MultiColumnFragmentainerGroup& LayoutMultiColumnSet::fragmentainerGroupAtV
isualPoint(const LayoutPoint&) const |
66 { | 68 { |
67 // FIXME: implement this, once we have support for multiple rows. | 69 // FIXME: implement this, once we have support for multiple rows. |
68 return m_fragmentainerGroups.first(); | 70 return m_fragmentainerGroups.first(); |
69 } | 71 } |
70 | 72 |
71 LayoutUnit LayoutMultiColumnSet::pageLogicalHeightForOffset(LayoutUnit offsetInF
lowThread) const | 73 LayoutUnit LayoutMultiColumnSet::pageLogicalHeightForOffset(LayoutUnit offsetInF
lowThread) const |
72 { | 74 { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 | 108 |
107 LayoutMultiColumnSet* LayoutMultiColumnSet::previousSiblingMultiColumnSet() cons
t | 109 LayoutMultiColumnSet* LayoutMultiColumnSet::previousSiblingMultiColumnSet() cons
t |
108 { | 110 { |
109 for (LayoutObject* sibling = previousSibling(); sibling; sibling = sibling->
previousSibling()) { | 111 for (LayoutObject* sibling = previousSibling(); sibling; sibling = sibling->
previousSibling()) { |
110 if (sibling->isLayoutMultiColumnSet()) | 112 if (sibling->isLayoutMultiColumnSet()) |
111 return toLayoutMultiColumnSet(sibling); | 113 return toLayoutMultiColumnSet(sibling); |
112 } | 114 } |
113 return nullptr; | 115 return nullptr; |
114 } | 116 } |
115 | 117 |
| 118 MultiColumnFragmentainerGroup& LayoutMultiColumnSet::appendNewFragmentainerGroup
() |
| 119 { |
| 120 MultiColumnFragmentainerGroup newGroup(*this); |
| 121 { // Extra scope here for previousGroup; it's potentially invalid once we mo
dify the m_fragmentainerGroups Vector. |
| 122 MultiColumnFragmentainerGroup& previousGroup = m_fragmentainerGroups.las
t(); |
| 123 |
| 124 // This is the flow thread block offset where |previousGroup| ends and |
newGroup| takes over. |
| 125 LayoutUnit blockOffsetInFlowThread = previousGroup.logicalTopInFlowThrea
d() + previousGroup.logicalHeight() * usedColumnCount(); |
| 126 previousGroup.setLogicalBottomInFlowThread(blockOffsetInFlowThread); |
| 127 newGroup.setLogicalTopInFlowThread(blockOffsetInFlowThread); |
| 128 |
| 129 newGroup.setLogicalTop(previousGroup.logicalTop() + previousGroup.logica
lHeight()); |
| 130 newGroup.resetColumnHeight(); |
| 131 } |
| 132 m_fragmentainerGroups.append(newGroup); |
| 133 return m_fragmentainerGroups.last(); |
| 134 } |
| 135 |
116 LayoutUnit LayoutMultiColumnSet::logicalTopInFlowThread() const | 136 LayoutUnit LayoutMultiColumnSet::logicalTopInFlowThread() const |
117 { | 137 { |
118 return firstFragmentainerGroup().logicalTopInFlowThread(); | 138 return firstFragmentainerGroup().logicalTopInFlowThread(); |
119 } | 139 } |
120 | 140 |
121 LayoutUnit LayoutMultiColumnSet::logicalBottomInFlowThread() const | 141 LayoutUnit LayoutMultiColumnSet::logicalBottomInFlowThread() const |
122 { | 142 { |
123 return lastFragmentainerGroup().logicalBottomInFlowThread(); | 143 return lastFragmentainerGroup().logicalBottomInFlowThread(); |
124 } | 144 } |
125 | 145 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 bool LayoutMultiColumnSet::recalculateColumnHeight(BalancedColumnHeightCalculati
on calculationMode) | 229 bool LayoutMultiColumnSet::recalculateColumnHeight(BalancedColumnHeightCalculati
on calculationMode) |
210 { | 230 { |
211 bool changed = false; | 231 bool changed = false; |
212 for (auto& group : m_fragmentainerGroups) | 232 for (auto& group : m_fragmentainerGroups) |
213 changed = group.recalculateColumnHeight(calculationMode) || changed; | 233 changed = group.recalculateColumnHeight(calculationMode) || changed; |
214 return changed; | 234 return changed; |
215 } | 235 } |
216 | 236 |
217 void LayoutMultiColumnSet::recordSpaceShortage(LayoutUnit offsetInFlowThread, La
youtUnit spaceShortage) | 237 void LayoutMultiColumnSet::recordSpaceShortage(LayoutUnit offsetInFlowThread, La
youtUnit spaceShortage) |
218 { | 238 { |
219 fragmentainerGroupAtFlowThreadOffset(offsetInFlowThread).recordSpaceShortage
(spaceShortage); | 239 MultiColumnFragmentainerGroup& row = fragmentainerGroupAtFlowThreadOffset(of
fsetInFlowThread); |
| 240 row.recordSpaceShortage(spaceShortage); |
| 241 |
| 242 // Since we're at a potential break here, take the opportunity to check if w
e need another |
| 243 // fragmentainer group. If we've run out of columns in the last fragmentaine
r group (column |
| 244 // row), we need to insert another fragmentainer group to hold more columns. |
| 245 if (!row.isLastGroup()) |
| 246 return; |
| 247 LayoutMultiColumnFlowThread* flowThread = multiColumnFlowThread(); |
| 248 if (!flowThread->multiColumnBlockFlow()->isInsideFlowThread()) |
| 249 return; // Early bail. We're not nested, so waste no more time on this. |
| 250 if (!flowThread->isInInitialLayoutPass()) |
| 251 return; |
| 252 // Move the offset to where the next column starts, if we're not there alrea
dy. |
| 253 offsetInFlowThread += flowThread->pageRemainingLogicalHeightForOffset(offset
InFlowThread, AssociateWithFormerPage); |
| 254 |
| 255 flowThread->appendNewFragmentainerGroupIfNeeded(offsetInFlowThread); |
220 } | 256 } |
221 | 257 |
222 void LayoutMultiColumnSet::resetColumnHeight() | 258 void LayoutMultiColumnSet::resetColumnHeight() |
223 { | 259 { |
224 m_fragmentainerGroups.deleteExtraGroups(); | 260 m_fragmentainerGroups.deleteExtraGroups(); |
225 m_fragmentainerGroups.first().resetColumnHeight(); | 261 m_fragmentainerGroups.first().resetColumnHeight(); |
226 } | 262 } |
227 | 263 |
228 void LayoutMultiColumnSet::beginFlow(LayoutUnit offsetInFlowThread) | 264 void LayoutMultiColumnSet::beginFlow(LayoutUnit offsetInFlowThread) |
229 { | 265 { |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 | 381 |
346 LayoutRect LayoutMultiColumnSet::flowThreadPortionRect() const | 382 LayoutRect LayoutMultiColumnSet::flowThreadPortionRect() const |
347 { | 383 { |
348 LayoutRect portionRect(LayoutUnit(), logicalTopInFlowThread(), pageLogicalWi
dth(), logicalHeightInFlowThread()); | 384 LayoutRect portionRect(LayoutUnit(), logicalTopInFlowThread(), pageLogicalWi
dth(), logicalHeightInFlowThread()); |
349 if (!isHorizontalWritingMode()) | 385 if (!isHorizontalWritingMode()) |
350 return portionRect.transposedRect(); | 386 return portionRect.transposedRect(); |
351 return portionRect; | 387 return portionRect; |
352 } | 388 } |
353 | 389 |
354 } | 390 } |
OLD | NEW |