OLD | NEW |
---|---|
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 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
287 if (logicalWidthChangedInRegions(flowThread)) | 287 if (logicalWidthChangedInRegions(flowThread)) |
288 relayoutChildren = true; | 288 relayoutChildren = true; |
289 if (updateRegionsAndShapesLogicalSize(flowThread)) | 289 if (updateRegionsAndShapesLogicalSize(flowThread)) |
290 relayoutChildren = true; | 290 relayoutChildren = true; |
291 | 291 |
292 m_numberOfInFlowChildrenOnFirstLine = -1; | 292 m_numberOfInFlowChildrenOnFirstLine = -1; |
293 | 293 |
294 RenderBlock::startDelayUpdateScrollInfo(); | 294 RenderBlock::startDelayUpdateScrollInfo(); |
295 | 295 |
296 Vector<LineContext> lineContexts; | 296 Vector<LineContext> lineContexts; |
297 Vector<int> orderValues; | 297 computeMainAxisPreferredSizes(); |
298 computeMainAxisPreferredSizes(orderValues); | |
299 m_orderIterator.setOrderValues(orderValues); | |
300 | 298 |
301 ChildFrameRects oldChildRects; | 299 ChildFrameRects oldChildRects; |
302 appendChildFrameRects(oldChildRects); | 300 appendChildFrameRects(oldChildRects); |
303 layoutFlexItems(relayoutChildren, lineContexts); | 301 layoutFlexItems(relayoutChildren, lineContexts); |
304 | 302 |
305 updateLogicalHeight(); | 303 updateLogicalHeight(); |
306 repositionLogicalHeightDependentFlexItems(lineContexts); | 304 repositionLogicalHeightDependentFlexItems(lineContexts); |
307 | 305 |
308 RenderBlock::finishDelayUpdateScrollInfo(); | 306 RenderBlock::finishDelayUpdateScrollInfo(); |
309 | 307 |
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
864 } | 862 } |
865 | 863 |
866 LayoutUnit RenderFlexibleBox::computeChildMarginValue(Length margin, RenderView* view) | 864 LayoutUnit RenderFlexibleBox::computeChildMarginValue(Length margin, RenderView* view) |
867 { | 865 { |
868 // When resolving the margins, we use the content size for resolving percent and calc (for percents in calc expressions) margins. | 866 // When resolving the margins, we use the content size for resolving percent and calc (for percents in calc expressions) margins. |
869 // Fortunately, percent margins are always computed with respect to the bloc k's width, even for margin-top and margin-bottom. | 867 // Fortunately, percent margins are always computed with respect to the bloc k's width, even for margin-top and margin-bottom. |
870 LayoutUnit availableSize = contentLogicalWidth(); | 868 LayoutUnit availableSize = contentLogicalWidth(); |
871 return minimumValueForLength(margin, availableSize, view); | 869 return minimumValueForLength(margin, availableSize, view); |
872 } | 870 } |
873 | 871 |
874 void RenderFlexibleBox::computeMainAxisPreferredSizes(Vector<int>& orderValues) | 872 void RenderFlexibleBox::computeMainAxisPreferredSizes() |
cbiesinger
2013/07/10 19:35:32
I think you should keep the rename of this functio
Julien - ping for review
2013/07/10 21:15:48
Done.
| |
875 { | 873 { |
876 RenderView* renderView = view(); | 874 RenderView* renderView = view(); |
877 bool anyChildHasDefaultOrderValue = false; | 875 OrderIteratorPopulator populator(m_orderIterator); |
878 | 876 |
879 for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBo x()) { | 877 for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBo x()) { |
880 // Avoid growing the vector for the common-case default value of 0. | 878 populator.collectChild(child); |
881 if (int order = child->style()->order()) | |
882 orderValues.append(child->style()->order()); | |
883 else | |
884 anyChildHasDefaultOrderValue = true; | |
885 | 879 |
886 if (child->isOutOfFlowPositioned()) | 880 if (child->isOutOfFlowPositioned()) |
887 continue; | 881 continue; |
888 | 882 |
889 // Before running the flex algorithm, 'auto' has a margin of 0. | 883 // Before running the flex algorithm, 'auto' has a margin of 0. |
890 // Also, if we're not auto sizing, we don't do a layout that computes th e start/end margins. | 884 // Also, if we're not auto sizing, we don't do a layout that computes th e start/end margins. |
891 if (isHorizontalFlow()) { | 885 if (isHorizontalFlow()) { |
892 child->setMarginLeft(computeChildMarginValue(child->style()->marginL eft(), renderView)); | 886 child->setMarginLeft(computeChildMarginValue(child->style()->marginL eft(), renderView)); |
893 child->setMarginRight(computeChildMarginValue(child->style()->margin Right(), renderView)); | 887 child->setMarginRight(computeChildMarginValue(child->style()->margin Right(), renderView)); |
894 } else { | 888 } else { |
895 child->setMarginTop(computeChildMarginValue(child->style()->marginTo p(), renderView)); | 889 child->setMarginTop(computeChildMarginValue(child->style()->marginTo p(), renderView)); |
896 child->setMarginBottom(computeChildMarginValue(child->style()->margi nBottom(), renderView)); | 890 child->setMarginBottom(computeChildMarginValue(child->style()->margi nBottom(), renderView)); |
897 } | 891 } |
898 } | 892 } |
899 | |
900 if (anyChildHasDefaultOrderValue) { | |
901 // Avoid growing the vector to the default capacity of 16 if we're only going to put one item in it. | |
902 if (orderValues.isEmpty()) | |
903 orderValues.reserveInitialCapacity(1); | |
904 orderValues.append(0); | |
905 } | |
906 } | 893 } |
907 | 894 |
908 LayoutUnit RenderFlexibleBox::adjustChildSizeForMinAndMax(RenderBox* child, Layo utUnit childSize) | 895 LayoutUnit RenderFlexibleBox::adjustChildSizeForMinAndMax(RenderBox* child, Layo utUnit childSize) |
909 { | 896 { |
910 Length max = isHorizontalFlow() ? child->style()->maxWidth() : child->style( )->maxHeight(); | 897 Length max = isHorizontalFlow() ? child->style()->maxWidth() : child->style( )->maxHeight(); |
911 if (max.isSpecifiedOrIntrinsic()) { | 898 if (max.isSpecifiedOrIntrinsic()) { |
912 LayoutUnit maxExtent = computeMainAxisExtentForChild(child, MaxSize, max ); | 899 LayoutUnit maxExtent = computeMainAxisExtentForChild(child, MaxSize, max ); |
913 if (maxExtent != -1 && childSize > maxExtent) | 900 if (maxExtent != -1 && childSize > maxExtent) |
914 childSize = maxExtent; | 901 childSize = maxExtent; |
915 } | 902 } |
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1427 ASSERT(child); | 1414 ASSERT(child); |
1428 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE xtent; | 1415 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE xtent; |
1429 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset - crossAxisStartEdge; | 1416 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset - crossAxisStartEdge; |
1430 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi sExtent; | 1417 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi sExtent; |
1431 adjustAlignmentForChild(child, newOffset - originalOffset); | 1418 adjustAlignmentForChild(child, newOffset - originalOffset); |
1432 } | 1419 } |
1433 } | 1420 } |
1434 } | 1421 } |
1435 | 1422 |
1436 } | 1423 } |
OLD | NEW |