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

Side by Side Diff: Source/core/layout/LayoutFlexibleBox.cpp

Issue 1167323003: Need deeper layout passes inside flexboxes when fragmenting (pagination, multicol). (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/layout/LayoutFlexibleBox.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) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 void LayoutFlexibleBox::layoutBlock(bool relayoutChildren) 226 void LayoutFlexibleBox::layoutBlock(bool relayoutChildren)
227 { 227 {
228 ASSERT(needsLayout()); 228 ASSERT(needsLayout());
229 229
230 if (!relayoutChildren && simplifiedLayout()) 230 if (!relayoutChildren && simplifiedLayout())
231 return; 231 return;
232 232
233 if (updateLogicalWidthAndColumnWidth()) 233 if (updateLogicalWidthAndColumnWidth())
234 relayoutChildren = true; 234 relayoutChildren = true;
235 235
236 SubtreeLayoutScope layoutScope(*this);
236 LayoutUnit previousHeight = logicalHeight(); 237 LayoutUnit previousHeight = logicalHeight();
237 setLogicalHeight(borderAndPaddingLogicalHeight() + scrollbarLogicalHeight()) ; 238 setLogicalHeight(borderAndPaddingLogicalHeight() + scrollbarLogicalHeight()) ;
238 239
239 { 240 {
240 TextAutosizer::LayoutScope textAutosizerLayoutScope(this); 241 TextAutosizer::LayoutScope textAutosizerLayoutScope(this);
241 LayoutState state(*this, locationOffset()); 242 LayoutState state(*this, locationOffset());
242 243
243 m_numberOfInFlowChildrenOnFirstLine = -1; 244 m_numberOfInFlowChildrenOnFirstLine = -1;
244 245
245 LayoutBlock::startDelayUpdateScrollInfo(); 246 LayoutBlock::startDelayUpdateScrollInfo();
246 247
247 prepareOrderIteratorAndMargins(); 248 prepareOrderIteratorAndMargins();
248 249
249 ChildFrameRects oldChildRects; 250 ChildFrameRects oldChildRects;
250 appendChildFrameRects(oldChildRects); 251 appendChildFrameRects(oldChildRects);
251 252
252 layoutFlexItems(relayoutChildren); 253 layoutFlexItems(relayoutChildren, layoutScope);
253 254
254 LayoutBlock::finishDelayUpdateScrollInfo(); 255 LayoutBlock::finishDelayUpdateScrollInfo();
255 256
256 if (logicalHeight() != previousHeight) 257 if (logicalHeight() != previousHeight)
257 relayoutChildren = true; 258 relayoutChildren = true;
258 259
259 layoutPositionedObjects(relayoutChildren || isDocumentElement()); 260 layoutPositionedObjects(relayoutChildren || isDocumentElement());
260 261
261 // FIXME: css3/flexbox/repaint-rtl-column.html seems to issue paint inva lidations for more overflow than it needs to. 262 // FIXME: css3/flexbox/repaint-rtl-column.html seems to issue paint inva lidations for more overflow than it needs to.
262 computeOverflow(clientLogicalBottomAfterRepositioning()); 263 computeOverflow(clientLogicalBottomAfterRepositioning());
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 mainAxisExtent = m_intrinsicSizeAlongMainAxis.get(&child); 639 mainAxisExtent = m_intrinsicSizeAlongMainAxis.get(&child);
639 } else { 640 } else {
640 mainAxisExtent = child.maxPreferredLogicalWidth(); 641 mainAxisExtent = child.maxPreferredLogicalWidth();
641 } 642 }
642 ASSERT(mainAxisExtent - mainAxisBorderAndPaddingExtentForChild(child) >= 0); 643 ASSERT(mainAxisExtent - mainAxisBorderAndPaddingExtentForChild(child) >= 0);
643 return mainAxisExtent - mainAxisBorderAndPaddingExtentForChild(child); 644 return mainAxisExtent - mainAxisBorderAndPaddingExtentForChild(child);
644 } 645 }
645 return std::max(LayoutUnit(), computeMainAxisExtentForChild(child, MainOrPre ferredSize, flexBasis)); 646 return std::max(LayoutUnit(), computeMainAxisExtentForChild(child, MainOrPre ferredSize, flexBasis));
646 } 647 }
647 648
648 void LayoutFlexibleBox::layoutFlexItems(bool relayoutChildren) 649 void LayoutFlexibleBox::layoutFlexItems(bool relayoutChildren, SubtreeLayoutScop e& layoutScope)
649 { 650 {
650 Vector<LineContext> lineContexts; 651 Vector<LineContext> lineContexts;
651 OrderedFlexItemList orderedChildren; 652 OrderedFlexItemList orderedChildren;
652 LayoutUnit sumFlexBaseSize; 653 LayoutUnit sumFlexBaseSize;
653 double totalFlexGrow; 654 double totalFlexGrow;
654 double totalWeightedFlexShrink; 655 double totalWeightedFlexShrink;
655 LayoutUnit sumHypotheticalMainSize; 656 LayoutUnit sumHypotheticalMainSize;
656 657
657 Vector<LayoutUnit, 16> childSizes; 658 Vector<LayoutUnit, 16> childSizes;
658 659
659 m_orderIterator.first(); 660 m_orderIterator.first();
660 LayoutUnit crossAxisOffset = flowAwareBorderBefore() + flowAwarePaddingBefor e(); 661 LayoutUnit crossAxisOffset = flowAwareBorderBefore() + flowAwarePaddingBefor e();
661 while (computeNextFlexLine(orderedChildren, sumFlexBaseSize, totalFlexGrow, totalWeightedFlexShrink, sumHypotheticalMainSize, relayoutChildren)) { 662 while (computeNextFlexLine(orderedChildren, sumFlexBaseSize, totalFlexGrow, totalWeightedFlexShrink, sumHypotheticalMainSize, relayoutChildren)) {
662 LayoutUnit containerMainInnerSize = mainAxisContentExtent(sumHypothetica lMainSize); 663 LayoutUnit containerMainInnerSize = mainAxisContentExtent(sumHypothetica lMainSize);
663 LayoutUnit availableFreeSpace = containerMainInnerSize - sumFlexBaseSize ; 664 LayoutUnit availableFreeSpace = containerMainInnerSize - sumFlexBaseSize ;
664 FlexSign flexSign = (sumHypotheticalMainSize < containerMainInnerSize) ? PositiveFlexibility : NegativeFlexibility; 665 FlexSign flexSign = (sumHypotheticalMainSize < containerMainInnerSize) ? PositiveFlexibility : NegativeFlexibility;
665 InflexibleFlexItemSize inflexibleItems; 666 InflexibleFlexItemSize inflexibleItems;
666 childSizes.reserveCapacity(orderedChildren.size()); 667 childSizes.reserveCapacity(orderedChildren.size());
667 while (!resolveFlexibleLengths(flexSign, orderedChildren, availableFreeS pace, totalFlexGrow, totalWeightedFlexShrink, inflexibleItems, childSizes)) { 668 while (!resolveFlexibleLengths(flexSign, orderedChildren, availableFreeS pace, totalFlexGrow, totalWeightedFlexShrink, inflexibleItems, childSizes)) {
668 ASSERT(totalFlexGrow >= 0 && totalWeightedFlexShrink >= 0); 669 ASSERT(totalFlexGrow >= 0 && totalWeightedFlexShrink >= 0);
669 ASSERT(inflexibleItems.size() > 0); 670 ASSERT(inflexibleItems.size() > 0);
670 } 671 }
671 672
672 layoutAndPlaceChildren(crossAxisOffset, orderedChildren, childSizes, ava ilableFreeSpace, relayoutChildren, lineContexts); 673 layoutAndPlaceChildren(crossAxisOffset, orderedChildren, childSizes, ava ilableFreeSpace, relayoutChildren, layoutScope, lineContexts);
673 } 674 }
674 if (hasLineIfEmpty()) { 675 if (hasLineIfEmpty()) {
675 // Even if computeNextFlexLine returns true, the flexbox might not have 676 // Even if computeNextFlexLine returns true, the flexbox might not have
676 // a line because all our children might be out of flow positioned. 677 // a line because all our children might be out of flow positioned.
677 // Instead of just checking if we have a line, make sure the flexbox 678 // Instead of just checking if we have a line, make sure the flexbox
678 // has at least a line's worth of height to cover this case. 679 // has at least a line's worth of height to cover this case.
679 LayoutUnit minHeight = minimumLogicalHeightForEmptyLine(); 680 LayoutUnit minHeight = minimumLogicalHeightForEmptyLine();
680 if (size().height() < minHeight) 681 if (size().height() < minHeight)
681 setLogicalHeight(minHeight); 682 setLogicalHeight(minHeight);
682 } 683 }
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
1103 return isHorizontalFlow() && child.style()->height().isAuto(); 1104 return isHorizontalFlow() && child.style()->height().isAuto();
1104 } 1105 }
1105 1106
1106 EOverflow LayoutFlexibleBox::mainAxisOverflowForChild(LayoutBox& child) const 1107 EOverflow LayoutFlexibleBox::mainAxisOverflowForChild(LayoutBox& child) const
1107 { 1108 {
1108 if (isHorizontalFlow()) 1109 if (isHorizontalFlow())
1109 return child.styleRef().overflowX(); 1110 return child.styleRef().overflowX();
1110 return child.styleRef().overflowY(); 1111 return child.styleRef().overflowY();
1111 } 1112 }
1112 1113
1113 void LayoutFlexibleBox::layoutAndPlaceChildren(LayoutUnit& crossAxisOffset, cons t OrderedFlexItemList& children, const Vector<LayoutUnit, 16>& childSizes, Layou tUnit availableFreeSpace, bool relayoutChildren, Vector<LineContext>& lineContex ts) 1114 void LayoutFlexibleBox::layoutAndPlaceChildren(LayoutUnit& crossAxisOffset, cons t OrderedFlexItemList& children, const Vector<LayoutUnit, 16>& childSizes, Layou tUnit availableFreeSpace, bool relayoutChildren, SubtreeLayoutScope& layoutScope , Vector<LineContext>& lineContexts)
1114 { 1115 {
1115 ASSERT(childSizes.size() == children.size()); 1116 ASSERT(childSizes.size() == children.size());
1116 1117
1117 size_t numberOfChildrenForJustifyContent = numberOfInFlowPositionedChildren( children); 1118 size_t numberOfChildrenForJustifyContent = numberOfInFlowPositionedChildren( children);
1118 LayoutUnit autoMarginOffset = autoMarginOffsetInMainAxis(children, available FreeSpace); 1119 LayoutUnit autoMarginOffset = autoMarginOffsetInMainAxis(children, available FreeSpace);
1119 LayoutUnit mainAxisOffset = flowAwareBorderStart() + flowAwarePaddingStart() ; 1120 LayoutUnit mainAxisOffset = flowAwareBorderStart() + flowAwarePaddingStart() ;
1120 mainAxisOffset += initialJustifyContentOffset(availableFreeSpace, style()->j ustifyContentPosition(), style()->justifyContentDistribution(), numberOfChildren ForJustifyContent); 1121 mainAxisOffset += initialJustifyContentOffset(availableFreeSpace, style()->j ustifyContentPosition(), style()->justifyContentDistribution(), numberOfChildren ForJustifyContent);
1121 if (style()->flexDirection() == FlowRowReverse) 1122 if (style()->flexDirection() == FlowRowReverse)
1122 mainAxisOffset += isHorizontalFlow() ? verticalScrollbarWidth() : horizo ntalScrollbarHeight(); 1123 mainAxisOffset += isHorizontalFlow() ? verticalScrollbarWidth() : horizo ntalScrollbarHeight();
1123 1124
(...skipping 17 matching lines...) Expand all
1141 setOverrideMainAxisSizeForChild(*child, childPreferredSize); 1142 setOverrideMainAxisSizeForChild(*child, childPreferredSize);
1142 if (childPreferredSize != mainAxisExtentForChild(*child)) { 1143 if (childPreferredSize != mainAxisExtentForChild(*child)) {
1143 child->setChildNeedsLayout(MarkOnlyThis); 1144 child->setChildNeedsLayout(MarkOnlyThis);
1144 } else { 1145 } else {
1145 // To avoid double applying margin changes in updateAutoMarginsInCro ssAxis, we reset the margins here. 1146 // To avoid double applying margin changes in updateAutoMarginsInCro ssAxis, we reset the margins here.
1146 resetAutoMarginsAndLogicalTopInCrossAxis(*child); 1147 resetAutoMarginsAndLogicalTopInCrossAxis(*child);
1147 } 1148 }
1148 // We may have already forced relayout for orthogonal flowing children i n computeInnerFlexBaseSizeForChild. 1149 // We may have already forced relayout for orthogonal flowing children i n computeInnerFlexBaseSizeForChild.
1149 bool forceChildRelayout = relayoutChildren && !childFlexBaseSizeRequires Layout(*child); 1150 bool forceChildRelayout = relayoutChildren && !childFlexBaseSizeRequires Layout(*child);
1150 updateBlockChildDirtyBitsBeforeLayout(forceChildRelayout, *child); 1151 updateBlockChildDirtyBitsBeforeLayout(forceChildRelayout, *child);
1152 if (!child->needsLayout())
1153 child->markForPaginationRelayoutIfNeeded(layoutScope);
1151 child->layoutIfNeeded(); 1154 child->layoutIfNeeded();
1152 1155
1153 updateAutoMarginsInMainAxis(*child, autoMarginOffset); 1156 updateAutoMarginsInMainAxis(*child, autoMarginOffset);
1154 1157
1155 LayoutUnit childCrossAxisMarginBoxExtent; 1158 LayoutUnit childCrossAxisMarginBoxExtent;
1156 if (alignmentForChild(*child) == ItemPositionBaseline && !hasAutoMargins InCrossAxis(*child)) { 1159 if (alignmentForChild(*child) == ItemPositionBaseline && !hasAutoMargins InCrossAxis(*child)) {
1157 LayoutUnit ascent = marginBoxAscentForChild(*child); 1160 LayoutUnit ascent = marginBoxAscentForChild(*child);
1158 LayoutUnit descent = (crossAxisMarginExtentForChild(*child) + crossA xisExtentForChild(*child)) - ascent; 1161 LayoutUnit descent = (crossAxisMarginExtentForChild(*child) + crossA xisExtentForChild(*child)) - ascent;
1159 1162
1160 maxAscent = std::max(maxAscent, ascent); 1163 maxAscent = std::max(maxAscent, ascent);
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
1452 ASSERT(child); 1455 ASSERT(child);
1453 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE xtent; 1456 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE xtent;
1454 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset - crossAxisStartEdge; 1457 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset - crossAxisStartEdge;
1455 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi sExtent; 1458 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi sExtent;
1456 adjustAlignmentForChild(*child, newOffset - originalOffset); 1459 adjustAlignmentForChild(*child, newOffset - originalOffset);
1457 } 1460 }
1458 } 1461 }
1459 } 1462 }
1460 1463
1461 } 1464 }
OLDNEW
« no previous file with comments | « Source/core/layout/LayoutFlexibleBox.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698