| 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 1026 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1037 { | 1037 { |
| 1038 size_t count = 0; | 1038 size_t count = 0; |
| 1039 for (size_t i = 0; i < children.size(); ++i) { | 1039 for (size_t i = 0; i < children.size(); ++i) { |
| 1040 RenderBox* child = children[i]; | 1040 RenderBox* child = children[i]; |
| 1041 if (!child->isOutOfFlowPositioned()) | 1041 if (!child->isOutOfFlowPositioned()) |
| 1042 ++count; | 1042 ++count; |
| 1043 } | 1043 } |
| 1044 return count; | 1044 return count; |
| 1045 } | 1045 } |
| 1046 | 1046 |
| 1047 bool RenderFlexibleBox::needToStretchChild(RenderBox* child) | |
| 1048 { | |
| 1049 if (alignmentForChild(child) != AlignStretch) | |
| 1050 return false; | |
| 1051 | |
| 1052 Length crossAxisLength = isHorizontalFlow() ? child->style()->height() : chi
ld->style()->width(); | |
| 1053 return crossAxisLength.isAuto(); | |
| 1054 } | |
| 1055 | |
| 1056 void RenderFlexibleBox::resetAutoMarginsAndLogicalTopInCrossAxis(RenderBox* chil
d) | 1047 void RenderFlexibleBox::resetAutoMarginsAndLogicalTopInCrossAxis(RenderBox* chil
d) |
| 1057 { | 1048 { |
| 1058 if (hasAutoMarginsInCrossAxis(child)) | 1049 if (hasAutoMarginsInCrossAxis(child)) |
| 1059 child->updateLogicalHeight(); | 1050 child->updateLogicalHeight(); |
| 1060 } | 1051 } |
| 1061 | 1052 |
| 1062 void RenderFlexibleBox::layoutAndPlaceChildren(LayoutUnit& crossAxisOffset, cons
t OrderedFlexItemList& children, const Vector<LayoutUnit>& childSizes, LayoutUni
t availableFreeSpace, bool relayoutChildren, Vector<LineContext>& lineContexts) | 1053 void RenderFlexibleBox::layoutAndPlaceChildren(LayoutUnit& crossAxisOffset, cons
t OrderedFlexItemList& children, const Vector<LayoutUnit>& childSizes, LayoutUni
t availableFreeSpace, bool relayoutChildren, Vector<LineContext>& lineContexts) |
| 1063 { | 1054 { |
| 1064 ASSERT(childSizes.size() == children.size()); | 1055 ASSERT(childSizes.size() == children.size()); |
| 1065 | 1056 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1077 bool shouldFlipMainAxis = !isColumnFlow() && !isLeftToRightFlow(); | 1068 bool shouldFlipMainAxis = !isColumnFlow() && !isLeftToRightFlow(); |
| 1078 for (size_t i = 0; i < children.size(); ++i) { | 1069 for (size_t i = 0; i < children.size(); ++i) { |
| 1079 RenderBox* child = children[i]; | 1070 RenderBox* child = children[i]; |
| 1080 if (child->isOutOfFlowPositioned()) { | 1071 if (child->isOutOfFlowPositioned()) { |
| 1081 prepareChildForPositionedLayout(child, mainAxisOffset, crossAxisOffs
et, FlipForRowReverse); | 1072 prepareChildForPositionedLayout(child, mainAxisOffset, crossAxisOffs
et, FlipForRowReverse); |
| 1082 continue; | 1073 continue; |
| 1083 } | 1074 } |
| 1084 | 1075 |
| 1085 LayoutUnit childPreferredSize = childSizes[i] + mainAxisBorderAndPadding
ExtentForChild(child); | 1076 LayoutUnit childPreferredSize = childSizes[i] + mainAxisBorderAndPadding
ExtentForChild(child); |
| 1086 setLogicalOverrideSize(child, childPreferredSize); | 1077 setLogicalOverrideSize(child, childPreferredSize); |
| 1087 // FIXME: Can avoid laying out here in some cases. See https://webkit.or
g/b/87905. | 1078 if (childPreferredSize != mainAxisExtentForChild(child)) { |
| 1088 if (needToStretchChild(child) || childPreferredSize != mainAxisExtentFor
Child(child)) | |
| 1089 child->setChildNeedsLayout(MarkOnlyThis); | 1079 child->setChildNeedsLayout(MarkOnlyThis); |
| 1090 else { | 1080 } else { |
| 1091 // To avoid double applying margin changes in updateAutoMarginsInCro
ssAxis, we reset the margins here. | 1081 // To avoid double applying margin changes in updateAutoMarginsInCro
ssAxis, we reset the margins here. |
| 1092 resetAutoMarginsAndLogicalTopInCrossAxis(child); | 1082 resetAutoMarginsAndLogicalTopInCrossAxis(child); |
| 1093 } | 1083 } |
| 1094 updateBlockChildDirtyBitsBeforeLayout(relayoutChildren, child); | 1084 updateBlockChildDirtyBitsBeforeLayout(relayoutChildren, child); |
| 1095 child->layoutIfNeeded(); | 1085 child->layoutIfNeeded(); |
| 1096 | 1086 |
| 1097 updateAutoMarginsInMainAxis(child, autoMarginOffset); | 1087 updateAutoMarginsInMainAxis(child, autoMarginOffset); |
| 1098 | 1088 |
| 1099 LayoutUnit childCrossAxisMarginBoxExtent; | 1089 LayoutUnit childCrossAxisMarginBoxExtent; |
| 1100 if (alignmentForChild(child) == AlignBaseline && !hasAutoMarginsInCrossA
xis(child)) { | 1090 if (alignmentForChild(child) == AlignBaseline && !hasAutoMarginsInCrossA
xis(child)) { |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1366 ASSERT(child); | 1356 ASSERT(child); |
| 1367 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE
xtent; | 1357 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE
xtent; |
| 1368 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset
- crossAxisStartEdge; | 1358 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset
- crossAxisStartEdge; |
| 1369 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi
sExtent; | 1359 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi
sExtent; |
| 1370 adjustAlignmentForChild(child, newOffset - originalOffset); | 1360 adjustAlignmentForChild(child, newOffset - originalOffset); |
| 1371 } | 1361 } |
| 1372 } | 1362 } |
| 1373 } | 1363 } |
| 1374 | 1364 |
| 1375 } | 1365 } |
| OLD | NEW |