| 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 23 matching lines...) Expand all Loading... |
| 34 | 34 |
| 35 namespace WebCore { | 35 namespace WebCore { |
| 36 | 36 |
| 37 RenderMultiColumnBlock::RenderMultiColumnBlock(Element* element) | 37 RenderMultiColumnBlock::RenderMultiColumnBlock(Element* element) |
| 38 : RenderBlockFlow(element) | 38 : RenderBlockFlow(element) |
| 39 , m_flowThread(0) | 39 , m_flowThread(0) |
| 40 , m_columnCount(1) | 40 , m_columnCount(1) |
| 41 , m_columnWidth(0) | 41 , m_columnWidth(0) |
| 42 , m_columnHeightAvailable(0) | 42 , m_columnHeightAvailable(0) |
| 43 , m_inBalancingPass(false) | 43 , m_inBalancingPass(false) |
| 44 , m_needsRebalancing(false) |
| 44 { | 45 { |
| 45 } | 46 } |
| 46 | 47 |
| 47 void RenderMultiColumnBlock::styleDidChange(StyleDifference diff, const RenderSt
yle* oldStyle) | 48 void RenderMultiColumnBlock::styleDidChange(StyleDifference diff, const RenderSt
yle* oldStyle) |
| 48 { | 49 { |
| 49 RenderBlock::styleDidChange(diff, oldStyle); | 50 RenderBlock::styleDidChange(diff, oldStyle); |
| 50 for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBo
x()) | 51 for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBo
x()) |
| 51 child->setStyle(RenderStyle::createAnonymousStyleWithDisplay(style(), BL
OCK)); | 52 child->setStyle(RenderStyle::createAnonymousStyleWithDisplay(style(), BL
OCK)); |
| 52 } | 53 } |
| 53 | 54 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 void RenderMultiColumnBlock::checkForPaginationLogicalHeightChange(LayoutUnit& /
*pageLogicalHeight*/, bool& /*pageLogicalHeightChanged*/, bool& /*hasSpecifiedPa
geLogicalHeight*/) | 91 void RenderMultiColumnBlock::checkForPaginationLogicalHeightChange(LayoutUnit& /
*pageLogicalHeight*/, bool& /*pageLogicalHeightChanged*/, bool& /*hasSpecifiedPa
geLogicalHeight*/) |
| 91 { | 92 { |
| 92 // We don't actually update any of the variables. We just subclassed to adju
st our column height. | 93 // We don't actually update any of the variables. We just subclassed to adju
st our column height. |
| 93 updateLogicalHeight(); | 94 updateLogicalHeight(); |
| 94 m_columnHeightAvailable = max<LayoutUnit>(contentLogicalHeight(), 0); | 95 m_columnHeightAvailable = max<LayoutUnit>(contentLogicalHeight(), 0); |
| 95 setLogicalHeight(0); | 96 setLogicalHeight(0); |
| 96 } | 97 } |
| 97 | 98 |
| 98 bool RenderMultiColumnBlock::relayoutForPagination(bool, LayoutUnit, LayoutState
Maintainer& statePusher) | 99 bool RenderMultiColumnBlock::relayoutForPagination(bool, LayoutUnit, LayoutState
Maintainer& statePusher) |
| 99 { | 100 { |
| 100 if (m_inBalancingPass || !requiresBalancing()) | 101 if (m_inBalancingPass || !m_needsRebalancing) |
| 101 return false; | 102 return false; |
| 103 m_needsRebalancing = false; |
| 102 m_inBalancingPass = true; // Prevent re-entering this method (and recursion
into layout). | 104 m_inBalancingPass = true; // Prevent re-entering this method (and recursion
into layout). |
| 103 | 105 |
| 104 bool needsRelayout; | 106 bool needsRelayout; |
| 105 bool neededRelayout = false; | 107 bool neededRelayout = false; |
| 106 bool firstPass = true; | 108 bool firstPass = true; |
| 107 do { | 109 do { |
| 108 // Column heights may change here because of balancing. We may have to d
o multiple layout | 110 // Column heights may change here because of balancing. We may have to d
o multiple layout |
| 109 // passes, depending on how the contents is fitted to the changed column
heights. In most | 111 // passes, depending on how the contents is fitted to the changed column
heights. In most |
| 110 // cases, laying out again twice or even just once will suffice. Sometim
es we need more | 112 // cases, laying out again twice or even just once will suffice. Sometim
es we need more |
| 111 // passes than that, though, but the number of retries should not exceed
the number of | 113 // passes than that, though, but the number of retries should not exceed
the number of |
| 112 // columns, unless we have a bug. | 114 // columns, unless we have a bug. |
| 113 needsRelayout = false; | 115 needsRelayout = false; |
| 114 for (RenderBox* childBox = firstChildBox(); childBox; childBox = childBo
x->nextSiblingBox()) { | 116 for (RenderBox* childBox = firstChildBox(); childBox; childBox = childBo
x->nextSiblingBox()) { |
| 115 if (childBox != m_flowThread && childBox->isRenderMultiColumnSet())
{ | 117 if (childBox != m_flowThread && childBox->isRenderMultiColumnSet())
{ |
| 116 RenderMultiColumnSet* multicolSet = toRenderMultiColumnSet(child
Box); | 118 RenderMultiColumnSet* multicolSet = toRenderMultiColumnSet(child
Box); |
| 117 if (multicolSet->calculateBalancedHeight(firstPass)) { | 119 if (multicolSet->recalculateBalancedHeight(firstPass)) { |
| 118 multicolSet->setChildNeedsLayout(MarkOnlyThis); | 120 multicolSet->setChildNeedsLayout(MarkOnlyThis); |
| 119 needsRelayout = true; | 121 needsRelayout = true; |
| 120 } | 122 } |
| 121 } | 123 } |
| 122 } | 124 } |
| 123 | 125 |
| 124 if (needsRelayout) { | 126 if (needsRelayout) { |
| 125 // Layout again. Column balancing resulted in a new height. | 127 // Layout again. Column balancing resulted in a new height. |
| 126 neededRelayout = true; | 128 neededRelayout = true; |
| 127 m_flowThread->setChildNeedsLayout(MarkOnlyThis); | 129 m_flowThread->setChildNeedsLayout(MarkOnlyThis); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 shouldInvalidateRegions = true; | 167 shouldInvalidateRegions = true; |
| 166 } | 168 } |
| 167 } | 169 } |
| 168 | 170 |
| 169 if (shouldInvalidateRegions) | 171 if (shouldInvalidateRegions) |
| 170 m_flowThread->invalidateRegions(); | 172 m_flowThread->invalidateRegions(); |
| 171 | 173 |
| 172 if (relayoutChildren) | 174 if (relayoutChildren) |
| 173 layoutScope.setChildNeedsLayout(m_flowThread); | 175 layoutScope.setChildNeedsLayout(m_flowThread); |
| 174 | 176 |
| 177 if (requiresBalancing()) { |
| 178 // At the end of multicol layout, relayoutForPagination() is called unco
nditionally, but if |
| 179 // no children are to be laid out (e.g. fixed width with layout already
being up-to-date), |
| 180 // we want to prevent it from doing any work, so that the column balanci
ng machinery doesn't |
| 181 // kick in and trigger additional unnecessary layout passes. Actually, i
t's not just a good |
| 182 // idea in general to not waste time on balancing content that hasn't be
en re-laid out; we |
| 183 // are actually required to guarantee this. The calculation of implicit
breaks needs to be |
| 184 // preceded by a proper layout pass, since it's layout that sets up cont
ent runs, and the |
| 185 // runs get deleted right after every pass. |
| 186 m_needsRebalancing = shouldInvalidateRegions || m_flowThread->needsLayou
t(); |
| 187 } |
| 188 |
| 175 setLogicalTopForChild(m_flowThread, borderBefore() + paddingBefore()); | 189 setLogicalTopForChild(m_flowThread, borderBefore() + paddingBefore()); |
| 176 m_flowThread->layoutIfNeeded(); | 190 m_flowThread->layoutIfNeeded(); |
| 177 determineLogicalLeftPositionForChild(m_flowThread); | 191 determineLogicalLeftPositionForChild(m_flowThread); |
| 178 | 192 |
| 179 return m_flowThread; | 193 return m_flowThread; |
| 180 } | 194 } |
| 181 | 195 |
| 182 const char* RenderMultiColumnBlock::renderName() const | 196 const char* RenderMultiColumnBlock::renderName() const |
| 183 { | 197 { |
| 184 if (isFloating()) | 198 if (isFloating()) |
| 185 return "RenderMultiColumnBlock (floating)"; | 199 return "RenderMultiColumnBlock (floating)"; |
| 186 if (isOutOfFlowPositioned()) | 200 if (isOutOfFlowPositioned()) |
| 187 return "RenderMultiColumnBlock (positioned)"; | 201 return "RenderMultiColumnBlock (positioned)"; |
| 188 if (isAnonymousBlock()) | 202 if (isAnonymousBlock()) |
| 189 return "RenderMultiColumnBlock (anonymous)"; | 203 return "RenderMultiColumnBlock (anonymous)"; |
| 190 // FIXME: Temporary hack while the new generated content system is being imp
lemented. | 204 // FIXME: Temporary hack while the new generated content system is being imp
lemented. |
| 191 if (isPseudoElement()) | 205 if (isPseudoElement()) |
| 192 return "RenderMultiColumnBlock (generated)"; | 206 return "RenderMultiColumnBlock (generated)"; |
| 193 if (isAnonymous()) | 207 if (isAnonymous()) |
| 194 return "RenderMultiColumnBlock (generated)"; | 208 return "RenderMultiColumnBlock (generated)"; |
| 195 if (isRelPositioned()) | 209 if (isRelPositioned()) |
| 196 return "RenderMultiColumnBlock (relative positioned)"; | 210 return "RenderMultiColumnBlock (relative positioned)"; |
| 197 return "RenderMultiColumnBlock"; | 211 return "RenderMultiColumnBlock"; |
| 198 } | 212 } |
| 199 | 213 |
| 200 } | 214 } |
| OLD | NEW |