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 17 matching lines...) Expand all Loading... |
28 | 28 |
29 #include "core/rendering/RenderMultiColumnSet.h" | 29 #include "core/rendering/RenderMultiColumnSet.h" |
30 | 30 |
31 namespace WebCore { | 31 namespace WebCore { |
32 | 32 |
33 RenderMultiColumnFlowThread::RenderMultiColumnFlowThread() | 33 RenderMultiColumnFlowThread::RenderMultiColumnFlowThread() |
34 : m_columnCount(1) | 34 : m_columnCount(1) |
35 , m_columnWidth(0) | 35 , m_columnWidth(0) |
36 , m_columnHeightAvailable(0) | 36 , m_columnHeightAvailable(0) |
37 , m_inBalancingPass(false) | 37 , m_inBalancingPass(false) |
38 , m_needsRebalancing(false) | 38 , m_needsColumnHeightsRecalculation(false) |
39 { | 39 { |
40 setFlowThreadState(InsideInFlowThread); | 40 setFlowThreadState(InsideInFlowThread); |
41 } | 41 } |
42 | 42 |
43 RenderMultiColumnFlowThread::~RenderMultiColumnFlowThread() | 43 RenderMultiColumnFlowThread::~RenderMultiColumnFlowThread() |
44 { | 44 { |
45 } | 45 } |
46 | 46 |
47 RenderMultiColumnFlowThread* RenderMultiColumnFlowThread::createAnonymous(Docume
nt& document, RenderStyle* parentStyle) | 47 RenderMultiColumnFlowThread* RenderMultiColumnFlowThread::createAnonymous(Docume
nt& document, RenderStyle* parentStyle) |
48 { | 48 { |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 | 159 |
160 if (requiresBalancing()) { | 160 if (requiresBalancing()) { |
161 // At the end of multicol layout, relayoutForPagination() is called unco
nditionally, but if | 161 // At the end of multicol layout, relayoutForPagination() is called unco
nditionally, but if |
162 // no children are to be laid out (e.g. fixed width with layout already
being up-to-date), | 162 // no children are to be laid out (e.g. fixed width with layout already
being up-to-date), |
163 // we want to prevent it from doing any work, so that the column balanci
ng machinery doesn't | 163 // we want to prevent it from doing any work, so that the column balanci
ng machinery doesn't |
164 // kick in and trigger additional unnecessary layout passes. Actually, i
t's not just a good | 164 // kick in and trigger additional unnecessary layout passes. Actually, i
t's not just a good |
165 // idea in general to not waste time on balancing content that hasn't be
en re-laid out; we | 165 // idea in general to not waste time on balancing content that hasn't be
en re-laid out; we |
166 // are actually required to guarantee this. The calculation of implicit
breaks needs to be | 166 // are actually required to guarantee this. The calculation of implicit
breaks needs to be |
167 // preceded by a proper layout pass, since it's layout that sets up cont
ent runs, and the | 167 // preceded by a proper layout pass, since it's layout that sets up cont
ent runs, and the |
168 // runs get deleted right after every pass. | 168 // runs get deleted right after every pass. |
169 m_needsRebalancing = shouldInvalidateRegions || needsLayout(); | 169 m_needsColumnHeightsRecalculation = shouldInvalidateRegions || needsLayo
ut(); |
170 } | 170 } |
171 | 171 |
172 layoutIfNeeded(); | 172 layoutIfNeeded(); |
173 } | 173 } |
174 | 174 |
175 bool RenderMultiColumnFlowThread::computeColumnCountAndWidth() | 175 bool RenderMultiColumnFlowThread::computeColumnCountAndWidth() |
176 { | 176 { |
177 RenderBlock* columnBlock = multiColumnBlockFlow(); | 177 RenderBlock* columnBlock = multiColumnBlockFlow(); |
178 LayoutUnit oldColumnWidth = m_columnWidth; | 178 LayoutUnit oldColumnWidth = m_columnWidth; |
179 | 179 |
(...skipping 18 matching lines...) Expand all Loading... |
198 } else { | 198 } else { |
199 m_columnCount = std::max<LayoutUnit>(std::min<LayoutUnit>(colCount, (ava
ilWidth + colGap) / (colWidth + colGap)), 1); | 199 m_columnCount = std::max<LayoutUnit>(std::min<LayoutUnit>(colCount, (ava
ilWidth + colGap) / (colWidth + colGap)), 1); |
200 m_columnWidth = ((availWidth + colGap) / m_columnCount) - colGap; | 200 m_columnWidth = ((availWidth + colGap) / m_columnCount) - colGap; |
201 } | 201 } |
202 | 202 |
203 return m_columnWidth != oldColumnWidth; | 203 return m_columnWidth != oldColumnWidth; |
204 } | 204 } |
205 | 205 |
206 bool RenderMultiColumnFlowThread::recalculateColumnHeights() | 206 bool RenderMultiColumnFlowThread::recalculateColumnHeights() |
207 { | 207 { |
208 if (!m_needsRebalancing) | 208 if (!m_needsColumnHeightsRecalculation) |
209 return false; | 209 return false; |
210 | 210 |
211 // Column heights may change here because of balancing. We may have to do mu
ltiple layout | 211 // Column heights may change here because of balancing. We may have to do mu
ltiple layout |
212 // passes, depending on how the contents is fitted to the changed column hei
ghts. In most | 212 // passes, depending on how the contents is fitted to the changed column hei
ghts. In most |
213 // cases, laying out again twice or even just once will suffice. Sometimes w
e need more | 213 // cases, laying out again twice or even just once will suffice. Sometimes w
e need more |
214 // passes than that, though, but the number of retries should not exceed the
number of | 214 // passes than that, though, but the number of retries should not exceed the
number of |
215 // columns, unless we have a bug. | 215 // columns, unless we have a bug. |
216 bool needsRelayout = false; | 216 bool needsRelayout = false; |
217 for (RenderMultiColumnSet* multicolSet = firstMultiColumnSet(); multicolSet;
multicolSet = multicolSet->nextSiblingMultiColumnSet()) { | 217 for (RenderMultiColumnSet* multicolSet = firstMultiColumnSet(); multicolSet;
multicolSet = multicolSet->nextSiblingMultiColumnSet()) { |
218 if (multicolSet->recalculateBalancedHeight(!m_inBalancingPass)) { | 218 if (multicolSet->recalculateColumnHeight(!m_inBalancingPass)) { |
219 multicolSet->setChildNeedsLayout(MarkOnlyThis); | 219 multicolSet->setChildNeedsLayout(MarkOnlyThis); |
220 needsRelayout = true; | 220 needsRelayout = true; |
221 } | 221 } |
222 } | 222 } |
223 | 223 |
224 if (needsRelayout) | 224 if (needsRelayout) |
225 setChildNeedsLayout(MarkOnlyThis); | 225 setChildNeedsLayout(MarkOnlyThis); |
226 | 226 |
227 m_inBalancingPass = needsRelayout; | 227 m_inBalancingPass = needsRelayout; |
228 return needsRelayout; | 228 return needsRelayout; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 } | 299 } |
300 | 300 |
301 bool RenderMultiColumnFlowThread::isPageLogicalHeightKnown() const | 301 bool RenderMultiColumnFlowThread::isPageLogicalHeightKnown() const |
302 { | 302 { |
303 if (RenderMultiColumnSet* columnSet = lastMultiColumnSet()) | 303 if (RenderMultiColumnSet* columnSet = lastMultiColumnSet()) |
304 return columnSet->computedColumnHeight(); | 304 return columnSet->computedColumnHeight(); |
305 return false; | 305 return false; |
306 } | 306 } |
307 | 307 |
308 } | 308 } |
OLD | NEW |