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

Side by Side Diff: third_party/WebKit/Source/core/layout/ColumnBalancer.cpp

Issue 2509813004: Improve strut handling in initial column balancing pass. (Closed)
Patch Set: Rebaseline for column-rules-fixed-height. This test no longer triggers deep layout. Created 4 years, 1 month 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/layout/ColumnBalancer.h" 5 #include "core/layout/ColumnBalancer.h"
6 6
7 #include "core/layout/LayoutMultiColumnFlowThread.h" 7 #include "core/layout/LayoutMultiColumnFlowThread.h"
8 #include "core/layout/LayoutMultiColumnSet.h" 8 #include "core/layout/LayoutMultiColumnSet.h"
9 #include "core/layout/api/LineLayoutBlockFlow.h" 9 #include "core/layout/api/LineLayoutBlockFlow.h"
10 10
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 LayoutUnit startOffset = index > 0 ? m_contentRuns[index - 1].breakOffset() 166 LayoutUnit startOffset = index > 0 ? m_contentRuns[index - 1].breakOffset()
167 : logicalTopInFlowThread(); 167 : logicalTopInFlowThread();
168 LayoutUnit height = m_contentRuns[index].columnLogicalHeight(startOffset); 168 LayoutUnit height = m_contentRuns[index].columnLogicalHeight(startOffset);
169 return rowLogicalTop + std::max(height, m_tallestUnbreakableLogicalHeight); 169 return rowLogicalTop + std::max(height, m_tallestUnbreakableLogicalHeight);
170 } 170 }
171 171
172 void InitialColumnHeightFinder::examineBoxAfterEntering( 172 void InitialColumnHeightFinder::examineBoxAfterEntering(
173 const LayoutBox& box, 173 const LayoutBox& box,
174 LayoutUnit childLogicalHeight, 174 LayoutUnit childLogicalHeight,
175 EBreak previousBreakAfterValue) { 175 EBreak previousBreakAfterValue) {
176 if (m_lastBreakSeen > flowThreadOffset()) {
177 // We have moved backwards. We're probably in a parallel flow, caused by
178 // floats, sibling table cells, etc.
179 m_lastBreakSeen = LayoutUnit();
180 }
176 if (isLogicalTopWithinBounds(flowThreadOffset() - box.paginationStrut())) { 181 if (isLogicalTopWithinBounds(flowThreadOffset() - box.paginationStrut())) {
177 if (box.needsForcedBreakBefore(previousBreakAfterValue)) { 182 if (box.needsForcedBreakBefore(previousBreakAfterValue)) {
178 addContentRun(flowThreadOffset()); 183 addContentRun(flowThreadOffset());
179 } else { 184 } else if (isFirstAfterBreak(flowThreadOffset()) &&
180 if (isFirstAfterBreak(flowThreadOffset())) { 185 m_lastBreakSeen != flowThreadOffset()) {
181 // This box is first after a soft break. 186 // This box is first after a soft break.
182 recordStrutBeforeOffset(flowThreadOffset(), box.paginationStrut()); 187 m_lastBreakSeen = flowThreadOffset();
183 } 188 recordStrutBeforeOffset(flowThreadOffset(), box.paginationStrut());
184 } 189 }
185 } 190 }
186 191
187 if (box.getPaginationBreakability() != LayoutBox::AllowAnyBreaks) { 192 if (box.getPaginationBreakability() != LayoutBox::AllowAnyBreaks) {
188 m_tallestUnbreakableLogicalHeight = 193 m_tallestUnbreakableLogicalHeight =
189 std::max(m_tallestUnbreakableLogicalHeight, childLogicalHeight); 194 std::max(m_tallestUnbreakableLogicalHeight, childLogicalHeight);
190 return; 195 return;
191 } 196 }
192 // Need to examine inner multicol containers to find their tallest unbreakable 197 // Need to examine inner multicol containers to find their tallest unbreakable
193 // piece of content. 198 // piece of content.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 void InitialColumnHeightFinder::examineLine(const RootInlineBox& line) { 231 void InitialColumnHeightFinder::examineLine(const RootInlineBox& line) {
227 LayoutUnit lineTop = line.lineTopWithLeading(); 232 LayoutUnit lineTop = line.lineTopWithLeading();
228 LayoutUnit lineTopInFlowThread = flowThreadOffset() + lineTop; 233 LayoutUnit lineTopInFlowThread = flowThreadOffset() + lineTop;
229 LayoutUnit minimumLogialHeight = 234 LayoutUnit minimumLogialHeight =
230 columnLogicalHeightRequirementForLine(line.block().styleRef(), line); 235 columnLogicalHeightRequirementForLine(line.block().styleRef(), line);
231 m_tallestUnbreakableLogicalHeight = 236 m_tallestUnbreakableLogicalHeight =
232 std::max(m_tallestUnbreakableLogicalHeight, minimumLogialHeight); 237 std::max(m_tallestUnbreakableLogicalHeight, minimumLogialHeight);
233 ASSERT( 238 ASSERT(
234 isFirstAfterBreak(lineTopInFlowThread) || !line.paginationStrut() || 239 isFirstAfterBreak(lineTopInFlowThread) || !line.paginationStrut() ||
235 !isLogicalTopWithinBounds(lineTopInFlowThread - line.paginationStrut())); 240 !isLogicalTopWithinBounds(lineTopInFlowThread - line.paginationStrut()));
236 if (isFirstAfterBreak(lineTopInFlowThread)) 241 if (isFirstAfterBreak(lineTopInFlowThread) &&
242 m_lastBreakSeen != lineTopInFlowThread) {
243 m_lastBreakSeen = lineTopInFlowThread;
237 recordStrutBeforeOffset(lineTopInFlowThread, line.paginationStrut()); 244 recordStrutBeforeOffset(lineTopInFlowThread, line.paginationStrut());
245 }
238 } 246 }
239 247
240 void InitialColumnHeightFinder::recordStrutBeforeOffset( 248 void InitialColumnHeightFinder::recordStrutBeforeOffset(
241 LayoutUnit offsetInFlowThread, 249 LayoutUnit offsetInFlowThread,
242 LayoutUnit strut) { 250 LayoutUnit strut) {
243 unsigned columnCount = columnSet().usedColumnCount(); 251 unsigned columnCount = columnSet().usedColumnCount();
244 ASSERT(m_shortestStruts.size() == columnCount); 252 ASSERT(m_shortestStruts.size() == columnCount);
245 unsigned index = groupAtOffset(offsetInFlowThread) 253 unsigned index = groupAtOffset(offsetInFlowThread)
246 .columnIndexAtOffset(offsetInFlowThread - strut, 254 .columnIndexAtOffset(offsetInFlowThread - strut,
247 LayoutBox::AssociateWithLatterPage); 255 LayoutBox::AssociateWithFormerPage);
248 if (index >= columnCount) 256 if (index >= columnCount)
249 return; 257 return;
250 m_shortestStruts[index] = std::min(m_shortestStruts[index], strut); 258 m_shortestStruts[index] = std::min(m_shortestStruts[index], strut);
251 } 259 }
252 260
253 LayoutUnit InitialColumnHeightFinder::spaceUsedByStrutsAt( 261 LayoutUnit InitialColumnHeightFinder::spaceUsedByStrutsAt(
254 LayoutUnit offsetInFlowThread) const { 262 LayoutUnit offsetInFlowThread) const {
255 unsigned stopBeforeColumn = 263 unsigned stopBeforeColumn =
256 groupAtOffset(offsetInFlowThread) 264 groupAtOffset(offsetInFlowThread)
257 .columnIndexAtOffset(offsetInFlowThread, 265 .columnIndexAtOffset(offsetInFlowThread,
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 if (group.columnLogicalTopForOffset(lineTopInFlowThread) != 482 if (group.columnLogicalTopForOffset(lineTopInFlowThread) !=
475 group.columnLogicalTopForOffset(lineBottomWithOverflow)) { 483 group.columnLogicalTopForOffset(lineBottomWithOverflow)) {
476 LayoutUnit shortage = 484 LayoutUnit shortage =
477 lineBottomWithOverflow - 485 lineBottomWithOverflow -
478 group.columnLogicalTopForOffset(lineBottomWithOverflow); 486 group.columnLogicalTopForOffset(lineBottomWithOverflow);
479 recordSpaceShortage(shortage); 487 recordSpaceShortage(shortage);
480 } 488 }
481 } 489 }
482 490
483 } // namespace blink 491 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698