| 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 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 RenderFlowThread* flowThread = flowThreadContainingBlock(); | 286 RenderFlowThread* flowThread = flowThreadContainingBlock(); |
| 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 prepareOrderIteratorAndMargins(); |
| 297 Vector<int> orderValues; | |
| 298 computeMainAxisPreferredSizes(orderValues); | |
| 299 m_orderIterator.setOrderValues(orderValues); | |
| 300 | 297 |
| 301 ChildFrameRects oldChildRects; | 298 ChildFrameRects oldChildRects; |
| 302 appendChildFrameRects(oldChildRects); | 299 appendChildFrameRects(oldChildRects); |
| 300 |
| 301 Vector<LineContext> lineContexts; |
| 303 layoutFlexItems(relayoutChildren, lineContexts); | 302 layoutFlexItems(relayoutChildren, lineContexts); |
| 304 | 303 |
| 305 updateLogicalHeight(); | 304 updateLogicalHeight(); |
| 306 repositionLogicalHeightDependentFlexItems(lineContexts); | 305 repositionLogicalHeightDependentFlexItems(lineContexts); |
| 307 | 306 |
| 308 RenderBlock::finishDelayUpdateScrollInfo(); | 307 RenderBlock::finishDelayUpdateScrollInfo(); |
| 309 | 308 |
| 310 if (logicalHeight() != previousHeight) | 309 if (logicalHeight() != previousHeight) |
| 311 relayoutChildren = true; | 310 relayoutChildren = true; |
| 312 | 311 |
| (...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 864 } | 863 } |
| 865 | 864 |
| 866 LayoutUnit RenderFlexibleBox::computeChildMarginValue(Length margin, RenderView*
view) | 865 LayoutUnit RenderFlexibleBox::computeChildMarginValue(Length margin, RenderView*
view) |
| 867 { | 866 { |
| 868 // When resolving the margins, we use the content size for resolving percent
and calc (for percents in calc expressions) margins. | 867 // 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. | 868 // 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(); | 869 LayoutUnit availableSize = contentLogicalWidth(); |
| 871 return minimumValueForLength(margin, availableSize, view); | 870 return minimumValueForLength(margin, availableSize, view); |
| 872 } | 871 } |
| 873 | 872 |
| 874 void RenderFlexibleBox::computeMainAxisPreferredSizes(Vector<int>& orderValues) | 873 void RenderFlexibleBox::prepareOrderIteratorAndMargins() |
| 875 { | 874 { |
| 876 RenderView* renderView = view(); | 875 RenderView* renderView = view(); |
| 877 bool anyChildHasDefaultOrderValue = false; | 876 OrderIteratorPopulator populator(m_orderIterator); |
| 878 | 877 |
| 879 for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBo
x()) { | 878 for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBo
x()) { |
| 880 // Avoid growing the vector for the common-case default value of 0. | 879 populator.collectChild(child); |
| 881 if (int order = child->style()->order()) | |
| 882 orderValues.append(child->style()->order()); | |
| 883 else | |
| 884 anyChildHasDefaultOrderValue = true; | |
| 885 | 880 |
| 886 if (child->isOutOfFlowPositioned()) | 881 if (child->isOutOfFlowPositioned()) |
| 887 continue; | 882 continue; |
| 888 | 883 |
| 889 // Before running the flex algorithm, 'auto' has a margin of 0. | 884 // 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. | 885 // Also, if we're not auto sizing, we don't do a layout that computes th
e start/end margins. |
| 891 if (isHorizontalFlow()) { | 886 if (isHorizontalFlow()) { |
| 892 child->setMarginLeft(computeChildMarginValue(child->style()->marginL
eft(), renderView)); | 887 child->setMarginLeft(computeChildMarginValue(child->style()->marginL
eft(), renderView)); |
| 893 child->setMarginRight(computeChildMarginValue(child->style()->margin
Right(), renderView)); | 888 child->setMarginRight(computeChildMarginValue(child->style()->margin
Right(), renderView)); |
| 894 } else { | 889 } else { |
| 895 child->setMarginTop(computeChildMarginValue(child->style()->marginTo
p(), renderView)); | 890 child->setMarginTop(computeChildMarginValue(child->style()->marginTo
p(), renderView)); |
| 896 child->setMarginBottom(computeChildMarginValue(child->style()->margi
nBottom(), renderView)); | 891 child->setMarginBottom(computeChildMarginValue(child->style()->margi
nBottom(), renderView)); |
| 897 } | 892 } |
| 898 } | 893 } |
| 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 } | 894 } |
| 907 | 895 |
| 908 LayoutUnit RenderFlexibleBox::adjustChildSizeForMinAndMax(RenderBox* child, Layo
utUnit childSize) | 896 LayoutUnit RenderFlexibleBox::adjustChildSizeForMinAndMax(RenderBox* child, Layo
utUnit childSize) |
| 909 { | 897 { |
| 910 Length max = isHorizontalFlow() ? child->style()->maxWidth() : child->style(
)->maxHeight(); | 898 Length max = isHorizontalFlow() ? child->style()->maxWidth() : child->style(
)->maxHeight(); |
| 911 if (max.isSpecifiedOrIntrinsic()) { | 899 if (max.isSpecifiedOrIntrinsic()) { |
| 912 LayoutUnit maxExtent = computeMainAxisExtentForChild(child, MaxSize, max
); | 900 LayoutUnit maxExtent = computeMainAxisExtentForChild(child, MaxSize, max
); |
| 913 if (maxExtent != -1 && childSize > maxExtent) | 901 if (maxExtent != -1 && childSize > maxExtent) |
| 914 childSize = maxExtent; | 902 childSize = maxExtent; |
| 915 } | 903 } |
| (...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1427 ASSERT(child); | 1415 ASSERT(child); |
| 1428 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE
xtent; | 1416 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE
xtent; |
| 1429 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset
- crossAxisStartEdge; | 1417 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset
- crossAxisStartEdge; |
| 1430 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi
sExtent; | 1418 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi
sExtent; |
| 1431 adjustAlignmentForChild(child, newOffset - originalOffset); | 1419 adjustAlignmentForChild(child, newOffset - originalOffset); |
| 1432 } | 1420 } |
| 1433 } | 1421 } |
| 1434 } | 1422 } |
| 1435 | 1423 |
| 1436 } | 1424 } |
| OLD | NEW |