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

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

Issue 1471403002: Look inside inner nested multicols to calculate minimum space shortage. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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 "config.h" 5 #include "config.h"
6 6
7 #include "core/layout/ColumnBalancer.h" 7 #include "core/layout/ColumnBalancer.h"
8 8
9 #include "core/layout/LayoutMultiColumnFlowThread.h"
9 #include "core/layout/LayoutMultiColumnSet.h" 10 #include "core/layout/LayoutMultiColumnSet.h"
10 11
11 namespace blink { 12 namespace blink {
12 13
13 ColumnBalancer::ColumnBalancer(const MultiColumnFragmentainerGroup& group) 14 ColumnBalancer::ColumnBalancer(const MultiColumnFragmentainerGroup& group)
14 : m_group(group) 15 : m_group(group)
15 { 16 {
16 } 17 }
17 18
18 void ColumnBalancer::traverse() 19 void ColumnBalancer::traverse()
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 if (isFirstAfterBreak || group().columnLogicalTopForOffset(flowThreadOff set()) != group().columnLogicalTopForOffset(bottomInFlowThread)) { 267 if (isFirstAfterBreak || group().columnLogicalTopForOffset(flowThreadOff set()) != group().columnLogicalTopForOffset(bottomInFlowThread)) {
267 // If the child crosses a column boundary, record space shortage, in case nothing 268 // If the child crosses a column boundary, record space shortage, in case nothing
268 // inside it has already done so. The column balancer needs to know by how much it 269 // inside it has already done so. The column balancer needs to know by how much it
269 // has to stretch the columns to make more content fit. If no breaks are reported 270 // has to stretch the columns to make more content fit. If no breaks are reported
270 // (but do occur), the balancer will have no clue. Only measure the space after the 271 // (but do occur), the balancer will have no clue. Only measure the space after the
271 // last column boundary, in case it crosses more than one. 272 // last column boundary, in case it crosses more than one.
272 LayoutUnit spaceUsedInLastColumn = bottomInFlowThread - group().colu mnLogicalTopForOffset(bottomInFlowThread); 273 LayoutUnit spaceUsedInLastColumn = bottomInFlowThread - group().colu mnLogicalTopForOffset(bottomInFlowThread);
273 recordSpaceShortage(spaceUsedInLastColumn); 274 recordSpaceShortage(spaceUsedInLastColumn);
274 } 275 }
275 } 276 }
277
278 // If this is an inner multicol container, look for space shortage inside it .
279 if (!box.isLayoutBlockFlow())
280 return;
281 LayoutMultiColumnFlowThread* flowThread = toLayoutBlockFlow(box).multiColumn FlowThread();
282 if (!flowThread)
283 return;
284 for (const LayoutMultiColumnSet* columnSet = flowThread->firstMultiColumnSet (); columnSet; columnSet = columnSet->nextSiblingMultiColumnSet()) {
285 for (const MultiColumnFragmentainerGroup& row : columnSet->fragmentainer Groups()) {
286 MinimumSpaceShortageFinder innerFinder(row);
287 recordSpaceShortage(innerFinder.minimumSpaceShortage());
288 }
289 }
276 } 290 }
277 291
278 void MinimumSpaceShortageFinder::examineBoxBeforeLeaving(const LayoutBox& box) 292 void MinimumSpaceShortageFinder::examineBoxBeforeLeaving(const LayoutBox& box)
279 { 293 {
280 if (m_pendingStrut == LayoutUnit::min() || box.paginationBreakability() != L ayoutBox::ForbidBreaks) 294 if (m_pendingStrut == LayoutUnit::min() || box.paginationBreakability() != L ayoutBox::ForbidBreaks)
281 return; 295 return;
282 296
283 // The previous break was before a breakable block. Here's the first piece o f unbreakable 297 // The previous break was before a breakable block. Here's the first piece o f unbreakable
284 // content after / inside that block. We want to record the distance from th e top of the column 298 // content after / inside that block. We want to record the distance from th e top of the column
285 // to the bottom of this box as space shortage. 299 // to the bottom of this box as space shortage.
(...skipping 15 matching lines...) Expand all
301 recordSpaceShortage(logicalOffsetFromCurrentColumn + lineHeight - m_pend ingStrut); 315 recordSpaceShortage(logicalOffsetFromCurrentColumn + lineHeight - m_pend ingStrut);
302 m_pendingStrut = LayoutUnit::min(); 316 m_pendingStrut = LayoutUnit::min();
303 return; 317 return;
304 } 318 }
305 ASSERT(isFirstAfterBreak(lineTopInFlowThread) || !line.paginationStrut()); 319 ASSERT(isFirstAfterBreak(lineTopInFlowThread) || !line.paginationStrut());
306 if (isFirstAfterBreak(lineTopInFlowThread)) 320 if (isFirstAfterBreak(lineTopInFlowThread))
307 recordSpaceShortage(lineHeight - line.paginationStrut()); 321 recordSpaceShortage(lineHeight - line.paginationStrut());
308 } 322 }
309 323
310 } // namespace blink 324 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698