Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(218)

Side by Side Diff: Source/core/rendering/RenderMultiColumnBlock.cpp

Issue 147233002: Remove internal recursion for RenderBlockFlow and RenderMultiColumnBlock layout (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase to apply on latest trunk Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/rendering/RenderMultiColumnBlock.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 } 88 }
89 89
90 void RenderMultiColumnBlock::checkForPaginationLogicalHeightChange(LayoutUnit& / *pageLogicalHeight*/, bool& /*pageLogicalHeightChanged*/, bool& /*hasSpecifiedPa geLogicalHeight*/) 90 void RenderMultiColumnBlock::checkForPaginationLogicalHeightChange(LayoutUnit& / *pageLogicalHeight*/, bool& /*pageLogicalHeightChanged*/, bool& /*hasSpecifiedPa geLogicalHeight*/)
91 { 91 {
92 // We don't actually update any of the variables. We just subclassed to adju st our column height. 92 // We don't actually update any of the variables. We just subclassed to adju st our column height.
93 updateLogicalHeight(); 93 updateLogicalHeight();
94 m_columnHeightAvailable = max<LayoutUnit>(contentLogicalHeight(), 0); 94 m_columnHeightAvailable = max<LayoutUnit>(contentLogicalHeight(), 0);
95 setLogicalHeight(0); 95 setLogicalHeight(0);
96 } 96 }
97 97
98 bool RenderMultiColumnBlock::relayoutForPagination(bool, LayoutUnit, LayoutState Maintainer& statePusher) 98 bool RenderMultiColumnBlock::shouldRelayoutMultiColumnBlock() const
99 { 99 {
100 if (m_inBalancingPass || !requiresBalancing()) 100 if (!requiresBalancing())
101 return false; 101 return false;
102 m_inBalancingPass = true; // Prevent re-entering this method (and recursion into layout).
103 102
104 bool needsRelayout; 103 // Column heights may change here because of balancing. We may have to do mu ltiple layout
105 bool neededRelayout = false; 104 // passes, depending on how the contents is fitted to the changed column hei ghts. In most
106 bool firstPass = true; 105 // cases, laying out again twice or even just once will suffice. Sometimes w e need more
107 do { 106 // passes than that, though, but the number of retries should not exceed the number of
108 // Column heights may change here because of balancing. We may have to d o multiple layout 107 // columns, unless we have a bug.
109 // passes, depending on how the contents is fitted to the changed column heights. In most 108 bool needsRelayout = false;
110 // cases, laying out again twice or even just once will suffice. Sometim es we need more 109 for (RenderBox* childBox = firstChildBox(); childBox; childBox = childBox->n extSiblingBox()) {
111 // passes than that, though, but the number of retries should not exceed the number of 110 if (childBox != m_flowThread && childBox->isRenderMultiColumnSet()) {
112 // columns, unless we have a bug. 111 RenderMultiColumnSet* multicolSet = toRenderMultiColumnSet(childBox) ;
113 needsRelayout = false; 112 if (multicolSet->calculateBalancedHeight(!m_inBalancingPass)) {
114 for (RenderBox* childBox = firstChildBox(); childBox; childBox = childBo x->nextSiblingBox()) { 113 multicolSet->setChildNeedsLayout(MarkOnlyThis);
115 if (childBox != m_flowThread && childBox->isRenderMultiColumnSet()) { 114 needsRelayout = true;
116 RenderMultiColumnSet* multicolSet = toRenderMultiColumnSet(child Box);
117 if (multicolSet->calculateBalancedHeight(firstPass)) {
118 multicolSet->setChildNeedsLayout(MarkOnlyThis);
119 needsRelayout = true;
120 }
121 } 115 }
122 } 116 }
117 }
123 118
124 if (needsRelayout) { 119 if (needsRelayout)
125 // Layout again. Column balancing resulted in a new height. 120 m_flowThread->setChildNeedsLayout(MarkOnlyThis);
126 neededRelayout = true; 121
127 m_flowThread->setChildNeedsLayout(MarkOnlyThis); 122
128 setChildNeedsLayout(MarkOnlyThis); 123 m_inBalancingPass = needsRelayout;
129 if (firstPass) 124 return needsRelayout;
130 statePusher.pop();
131 layoutBlock(false);
132 }
133 firstPass = false;
134 } while (needsRelayout);
135 m_inBalancingPass = false;
136 return neededRelayout;
137 } 125 }
138 126
139 void RenderMultiColumnBlock::addChild(RenderObject* newChild, RenderObject* befo reChild) 127 void RenderMultiColumnBlock::addChild(RenderObject* newChild, RenderObject* befo reChild)
140 { 128 {
141 if (!m_flowThread) { 129 if (!m_flowThread) {
142 m_flowThread = RenderMultiColumnFlowThread::createAnonymous(&document()) ; 130 m_flowThread = RenderMultiColumnFlowThread::createAnonymous(&document()) ;
143 m_flowThread->setStyle(RenderStyle::createAnonymousStyleWithDisplay(styl e(), BLOCK)); 131 m_flowThread->setStyle(RenderStyle::createAnonymousStyleWithDisplay(styl e(), BLOCK));
144 RenderBlock::addChild(m_flowThread); 132 RenderBlock::addChild(m_flowThread);
145 } 133 }
146 m_flowThread->addChild(newChild, beforeChild); 134 m_flowThread->addChild(newChild, beforeChild);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 if (isPseudoElement()) 179 if (isPseudoElement())
192 return "RenderMultiColumnBlock (generated)"; 180 return "RenderMultiColumnBlock (generated)";
193 if (isAnonymous()) 181 if (isAnonymous())
194 return "RenderMultiColumnBlock (generated)"; 182 return "RenderMultiColumnBlock (generated)";
195 if (isRelPositioned()) 183 if (isRelPositioned())
196 return "RenderMultiColumnBlock (relative positioned)"; 184 return "RenderMultiColumnBlock (relative positioned)";
197 return "RenderMultiColumnBlock"; 185 return "RenderMultiColumnBlock";
198 } 186 }
199 187
200 } 188 }
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderMultiColumnBlock.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698