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

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

Issue 1399493002: Column balancing refactoring. Don't propagate data during layout. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more code review Created 5 years, 2 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
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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 void LayoutMultiColumnSet::updateMinimumColumnHeight(LayoutUnit offsetInFlowThre ad, LayoutUnit height) 212 void LayoutMultiColumnSet::updateMinimumColumnHeight(LayoutUnit offsetInFlowThre ad, LayoutUnit height)
213 { 213 {
214 fragmentainerGroupAtFlowThreadOffset(offsetInFlowThread).updateMinimumColumn Height(height); 214 fragmentainerGroupAtFlowThreadOffset(offsetInFlowThread).updateMinimumColumn Height(height);
215 } 215 }
216 216
217 LayoutUnit LayoutMultiColumnSet::pageLogicalTopForOffset(LayoutUnit offset) cons t 217 LayoutUnit LayoutMultiColumnSet::pageLogicalTopForOffset(LayoutUnit offset) cons t
218 { 218 {
219 return fragmentainerGroupAtFlowThreadOffset(offset).columnLogicalTopForOffse t(offset); 219 return fragmentainerGroupAtFlowThreadOffset(offset).columnLogicalTopForOffse t(offset);
220 } 220 }
221 221
222 void LayoutMultiColumnSet::addContentRun(LayoutUnit endOffsetFromFirstPage)
223 {
224 if (!heightIsAuto())
225 return;
226 fragmentainerGroupAtFlowThreadOffset(endOffsetFromFirstPage).addContentRun(e ndOffsetFromFirstPage);
227 }
228
229 bool LayoutMultiColumnSet::recalculateColumnHeight(BalancedColumnHeightCalculati on calculationMode) 222 bool LayoutMultiColumnSet::recalculateColumnHeight(BalancedColumnHeightCalculati on calculationMode)
230 { 223 {
231 bool changed = false; 224 bool changed = false;
232 for (auto& group : m_fragmentainerGroups) 225 for (auto& group : m_fragmentainerGroups)
233 changed = group.recalculateColumnHeight(calculationMode) || changed; 226 changed = group.recalculateColumnHeight(calculationMode) || changed;
234 return changed; 227 return changed;
235 } 228 }
236 229
237 void LayoutMultiColumnSet::recordSpaceShortage(LayoutUnit offsetInFlowThread, La youtUnit spaceShortage)
238 {
239 MultiColumnFragmentainerGroup& row = fragmentainerGroupAtFlowThreadOffset(of fsetInFlowThread);
240 row.recordSpaceShortage(spaceShortage);
241
242 // Since we're at a potential break here, take the opportunity to check if w e need another
243 // fragmentainer group. If we've run out of columns in the last fragmentaine r group (column
244 // row), we need to insert another fragmentainer group to hold more columns.
245 if (!row.isLastGroup())
246 return;
247 LayoutMultiColumnFlowThread* flowThread = multiColumnFlowThread();
248 if (!flowThread->multiColumnBlockFlow()->isInsideFlowThread())
249 return; // Early bail. We're not nested, so waste no more time on this.
250 if (!flowThread->isInInitialLayoutPass())
251 return;
252 // Move the offset to where the next column starts, if we're not there alrea dy.
253 offsetInFlowThread += flowThread->pageRemainingLogicalHeightForOffset(offset InFlowThread, AssociateWithFormerPage);
254
255 flowThread->appendNewFragmentainerGroupIfNeeded(offsetInFlowThread);
256 }
257
258 void LayoutMultiColumnSet::resetColumnHeight() 230 void LayoutMultiColumnSet::resetColumnHeight()
259 { 231 {
260 m_fragmentainerGroups.deleteExtraGroups(); 232 m_fragmentainerGroups.deleteExtraGroups();
261 m_fragmentainerGroups.first().resetColumnHeight(); 233 m_fragmentainerGroups.first().resetColumnHeight();
262 } 234 }
263 235
264 void LayoutMultiColumnSet::beginFlow(LayoutUnit offsetInFlowThread) 236 void LayoutMultiColumnSet::beginFlow(LayoutUnit offsetInFlowThread)
265 { 237 {
266 // At this point layout is exactly at the beginning of this set. Store block offset from flow 238 // At this point layout is exactly at the beginning of this set. Store block offset from flow
267 // thread start. 239 // thread start.
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 353
382 LayoutRect LayoutMultiColumnSet::flowThreadPortionRect() const 354 LayoutRect LayoutMultiColumnSet::flowThreadPortionRect() const
383 { 355 {
384 LayoutRect portionRect(LayoutUnit(), logicalTopInFlowThread(), pageLogicalWi dth(), logicalHeightInFlowThread()); 356 LayoutRect portionRect(LayoutUnit(), logicalTopInFlowThread(), pageLogicalWi dth(), logicalHeightInFlowThread());
385 if (!isHorizontalWritingMode()) 357 if (!isHorizontalWritingMode())
386 return portionRect.transposedRect(); 358 return portionRect.transposedRect();
387 return portionRect; 359 return portionRect;
388 } 360 }
389 361
390 } 362 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698