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 22 matching lines...) Expand all Loading... |
33 | 33 |
34 using namespace std; | 34 using namespace std; |
35 | 35 |
36 namespace WebCore { | 36 namespace WebCore { |
37 | 37 |
38 RenderMultiColumnSet::RenderMultiColumnSet(RenderFlowThread* flowThread) | 38 RenderMultiColumnSet::RenderMultiColumnSet(RenderFlowThread* flowThread) |
39 : RenderRegionSet(0, flowThread) | 39 : RenderRegionSet(0, flowThread) |
40 , m_computedColumnCount(1) | 40 , m_computedColumnCount(1) |
41 , m_computedColumnWidth(0) | 41 , m_computedColumnWidth(0) |
42 , m_computedColumnHeight(0) | 42 , m_computedColumnHeight(0) |
43 , m_maxColumnHeight(LayoutUnit::max()) | 43 , m_maxColumnHeight(RenderFlowThread::maxLogicalHeight()) |
44 , m_minSpaceShortage(LayoutUnit::max()) | 44 , m_minSpaceShortage(RenderFlowThread::maxLogicalHeight()) |
45 , m_minimumColumnHeight(0) | 45 , m_minimumColumnHeight(0) |
46 { | 46 { |
47 } | 47 } |
48 | 48 |
49 RenderMultiColumnSet* RenderMultiColumnSet::createAnonymous(RenderFlowThread* fl
owThread) | 49 RenderMultiColumnSet* RenderMultiColumnSet::createAnonymous(RenderFlowThread* fl
owThread) |
50 { | 50 { |
51 Document& document = flowThread->document(); | 51 Document& document = flowThread->document(); |
52 RenderMultiColumnSet* renderer = new RenderMultiColumnSet(flowThread); | 52 RenderMultiColumnSet* renderer = new RenderMultiColumnSet(flowThread); |
53 renderer->setDocumentForAnonymous(&document); | 53 renderer->setDocumentForAnonymous(&document); |
54 return renderer; | 54 return renderer; |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 if (forcedBreaksCount() > 1 && forcedBreaksCount() >= computedColumnCount())
{ | 141 if (forcedBreaksCount() > 1 && forcedBreaksCount() >= computedColumnCount())
{ |
142 // Too many forced breaks to allow any implicit breaks. Initial balancin
g should already | 142 // Too many forced breaks to allow any implicit breaks. Initial balancin
g should already |
143 // have set a good height. There's nothing more we should do. | 143 // have set a good height. There's nothing more we should do. |
144 return m_computedColumnHeight; | 144 return m_computedColumnHeight; |
145 } | 145 } |
146 | 146 |
147 // If the initial guessed column height wasn't enough, stretch it now. Stret
ch by the lowest | 147 // If the initial guessed column height wasn't enough, stretch it now. Stret
ch by the lowest |
148 // amount of space shortage found during layout. | 148 // amount of space shortage found during layout. |
149 | 149 |
150 ASSERT(m_minSpaceShortage > 0); // We should never _shrink_ the height! | 150 ASSERT(m_minSpaceShortage > 0); // We should never _shrink_ the height! |
151 ASSERT(m_minSpaceShortage != LayoutUnit::max()); // If this happens, we prob
ably have a bug. | 151 ASSERT(m_minSpaceShortage != RenderFlowThread::maxLogicalHeight()); // If th
is happens, we probably have a bug. |
152 if (m_minSpaceShortage == LayoutUnit::max()) | 152 if (m_minSpaceShortage == RenderFlowThread::maxLogicalHeight()) |
153 return m_computedColumnHeight; // So bail out rather than looping infini
tely. | 153 return m_computedColumnHeight; // So bail out rather than looping infini
tely. |
154 | 154 |
155 return m_computedColumnHeight + m_minSpaceShortage; | 155 return m_computedColumnHeight + m_minSpaceShortage; |
156 } | 156 } |
157 | 157 |
158 void RenderMultiColumnSet::clearForcedBreaks() | 158 void RenderMultiColumnSet::clearForcedBreaks() |
159 { | 159 { |
160 m_contentRuns.clear(); | 160 m_contentRuns.clear(); |
161 } | 161 } |
162 | 162 |
(...skipping 21 matching lines...) Expand all Loading... |
184 | 184 |
185 // After having calculated an initial column height, the multicol container
typically needs at | 185 // After having calculated an initial column height, the multicol container
typically needs at |
186 // least one more layout pass with a new column height, but if a height was
specified, we only | 186 // least one more layout pass with a new column height, but if a height was
specified, we only |
187 // need to do this if we think that we need less space than specified. Conve
rsely, if we | 187 // need to do this if we think that we need less space than specified. Conve
rsely, if we |
188 // determined that the columns need to be as tall as the specified height of
the container, we | 188 // determined that the columns need to be as tall as the specified height of
the container, we |
189 // have already laid it out correctly, and there's no need for another pass. | 189 // have already laid it out correctly, and there's no need for another pass. |
190 | 190 |
191 if (m_computedColumnHeight == oldColumnHeight) | 191 if (m_computedColumnHeight == oldColumnHeight) |
192 return false; // No change. We're done. | 192 return false; // No change. We're done. |
193 | 193 |
194 m_minSpaceShortage = LayoutUnit::max(); | 194 m_minSpaceShortage = RenderFlowThread::maxLogicalHeight(); |
195 clearForcedBreaks(); | 195 clearForcedBreaks(); |
196 return true; // Need another pass. | 196 return true; // Need another pass. |
197 } | 197 } |
198 | 198 |
199 void RenderMultiColumnSet::recordSpaceShortage(LayoutUnit spaceShortage) | 199 void RenderMultiColumnSet::recordSpaceShortage(LayoutUnit spaceShortage) |
200 { | 200 { |
201 if (spaceShortage >= m_minSpaceShortage) | 201 if (spaceShortage >= m_minSpaceShortage) |
202 return; | 202 return; |
203 | 203 |
204 // The space shortage is what we use as our stretch amount. We need a positi
ve number here in | 204 // The space shortage is what we use as our stretch amount. We need a positi
ve number here in |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 | 237 |
238 // Set box logical top. | 238 // Set box logical top. |
239 ASSERT(!previousSiblingBox() || !previousSiblingBox()->isRenderMultiColumnSe
t()); // FIXME: multiple set not implemented; need to examine previous set to ca
lculate the correct logical top. | 239 ASSERT(!previousSiblingBox() || !previousSiblingBox()->isRenderMultiColumnSe
t()); // FIXME: multiple set not implemented; need to examine previous set to ca
lculate the correct logical top. |
240 setLogicalTop(multicolBlock->borderBefore() + multicolBlock->paddingBefore()
); | 240 setLogicalTop(multicolBlock->borderBefore() + multicolBlock->paddingBefore()
); |
241 | 241 |
242 // Set box width. | 242 // Set box width. |
243 updateLogicalWidth(); | 243 updateLogicalWidth(); |
244 | 244 |
245 if (multicolBlock->requiresBalancing()) { | 245 if (multicolBlock->requiresBalancing()) { |
246 // Set maximum column height. We will not stretch beyond this. | 246 // Set maximum column height. We will not stretch beyond this. |
247 m_maxColumnHeight = LayoutUnit::max(); | 247 m_maxColumnHeight = RenderFlowThread::maxLogicalHeight(); |
248 if (!multicolStyle->logicalHeight().isAuto()) | 248 if (!multicolStyle->logicalHeight().isAuto()) { |
249 m_maxColumnHeight = multicolBlock->computeContentLogicalHeight(multi
colStyle->logicalHeight(), -1); | 249 m_maxColumnHeight = multicolBlock->computeContentLogicalHeight(multi
colStyle->logicalHeight(), -1); |
| 250 if (m_maxColumnHeight == -1) |
| 251 m_maxColumnHeight = RenderFlowThread::maxLogicalHeight(); |
| 252 } |
250 if (!multicolStyle->logicalMaxHeight().isUndefined()) { | 253 if (!multicolStyle->logicalMaxHeight().isUndefined()) { |
251 LayoutUnit logicalMaxHeight = multicolBlock->computeContentLogicalHe
ight(multicolStyle->logicalMaxHeight(), -1); | 254 LayoutUnit logicalMaxHeight = multicolBlock->computeContentLogicalHe
ight(multicolStyle->logicalMaxHeight(), -1); |
252 if (m_maxColumnHeight > logicalMaxHeight) | 255 if (logicalMaxHeight != -1 && m_maxColumnHeight > logicalMaxHeight) |
253 m_maxColumnHeight = logicalMaxHeight; | 256 m_maxColumnHeight = logicalMaxHeight; |
254 } | 257 } |
255 m_maxColumnHeight = heightAdjustedForSetOffset(m_maxColumnHeight); | 258 m_maxColumnHeight = heightAdjustedForSetOffset(m_maxColumnHeight); |
256 m_computedColumnHeight = 0; // Restart balancing. | 259 m_computedColumnHeight = 0; // Restart balancing. |
257 } else { | 260 } else { |
258 setAndConstrainColumnHeight(heightAdjustedForSetOffset(multicolBlock->co
lumnHeightAvailable())); | 261 setAndConstrainColumnHeight(heightAdjustedForSetOffset(multicolBlock->co
lumnHeightAvailable())); |
259 } | 262 } |
260 | 263 |
261 clearForcedBreaks(); | 264 clearForcedBreaks(); |
262 | 265 |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
581 fragments.append(fragment); | 584 fragments.append(fragment); |
582 } | 585 } |
583 } | 586 } |
584 | 587 |
585 const char* RenderMultiColumnSet::renderName() const | 588 const char* RenderMultiColumnSet::renderName() const |
586 { | 589 { |
587 return "RenderMultiColumnSet"; | 590 return "RenderMultiColumnSet"; |
588 } | 591 } |
589 | 592 |
590 } | 593 } |
OLD | NEW |