Chromium Code Reviews| 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 1077 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1088 LayoutUnit definiteHeight = computeDefiniteLogicalHeight(); | 1088 LayoutUnit definiteHeight = computeDefiniteLogicalHeight(); |
| 1089 if (definiteHeight == LayoutUnit(-1)) | 1089 if (definiteHeight == LayoutUnit(-1)) |
| 1090 return definiteHeight; | 1090 return definiteHeight; |
| 1091 | 1091 |
| 1092 childCrossSize = definiteHeight - borderAndPaddingLogicalHeight() - scro llbarLogicalHeight(); | 1092 childCrossSize = definiteHeight - borderAndPaddingLogicalHeight() - scro llbarLogicalHeight(); |
| 1093 childCrossSize = child.constrainLogicalHeightByMinMax(childCrossSize, La youtUnit(-1)) - child.scrollbarLogicalHeight() - child.borderAndPaddingLogicalHe ight(); | 1093 childCrossSize = child.constrainLogicalHeightByMinMax(childCrossSize, La youtUnit(-1)) - child.scrollbarLogicalHeight() - child.borderAndPaddingLogicalHe ight(); |
| 1094 } | 1094 } |
| 1095 return childCrossSize; | 1095 return childCrossSize; |
| 1096 } | 1096 } |
| 1097 | 1097 |
| 1098 LayoutUnit LayoutFlexibleBox::mainSizeForPercentageResolution(const LayoutBox& c hild) | |
| 1099 { | |
| 1100 // This function implements section 9.8. Definite and Indefinite Sizes, case | |
| 1101 // 2) of the flexbox spec. | |
| 1102 // We need to check for the flexbox to have a definite main size, and for th e | |
| 1103 // flex item to have a definite flex basis. | |
| 1104 const Length& flexBasis = flexBasisForChild(child); | |
| 1105 if (!mainAxisLengthIsDefinite(child, flexBasis)) | |
| 1106 return LayoutUnit(-1); | |
| 1107 LayoutUnit mainSize = isColumnFlow() ? computeDefiniteLogicalHeight() : comp uteDefiniteLogicalWidth(); | |
| 1108 if (mainSize == LayoutUnit(-1)) { | |
|
leviw_travelin_and_unemployed
2016/03/16 00:57:49
Nit: unnecessary brackets.
| |
| 1109 return mainSize; | |
| 1110 } | |
| 1111 if (hasOrthogonalFlow(child)) { | |
|
leviw_travelin_and_unemployed
2016/03/16 00:57:49
Ditto.
| |
| 1112 return child.hasOverrideLogicalContentHeight() ? child.overrideLogicalCo ntentHeight() : LayoutUnit(-1); | |
| 1113 } | |
| 1114 return child.hasOverrideLogicalContentWidth() ? child.overrideLogicalContent Width() : LayoutUnit(-1); | |
| 1115 } | |
| 1116 | |
| 1098 LayoutUnit LayoutFlexibleBox::childLogicalHeightForPercentageResolution(const La youtBox& child) | 1117 LayoutUnit LayoutFlexibleBox::childLogicalHeightForPercentageResolution(const La youtBox& child) |
| 1099 { | 1118 { |
| 1100 if (!hasOrthogonalFlow(child)) | 1119 if (!hasOrthogonalFlow(child)) |
| 1101 return crossSizeForPercentageResolution(child); | 1120 return crossSizeForPercentageResolution(child); |
| 1102 return LayoutUnit(-1); | 1121 return mainSizeForPercentageResolution(child); |
| 1103 } | 1122 } |
| 1104 | 1123 |
| 1105 LayoutUnit LayoutFlexibleBox::childLogicalWidthForPercentageResolution(const Lay outBox& child) | 1124 LayoutUnit LayoutFlexibleBox::childLogicalWidthForPercentageResolution(const Lay outBox& child) |
| 1106 { | 1125 { |
| 1107 if (hasOrthogonalFlow(child)) | 1126 if (hasOrthogonalFlow(child)) |
| 1108 return crossSizeForPercentageResolution(child); | 1127 return crossSizeForPercentageResolution(child); |
| 1109 return LayoutUnit(-1); | 1128 return mainSizeForPercentageResolution(child); |
| 1110 } | 1129 } |
| 1111 | 1130 |
| 1112 LayoutUnit LayoutFlexibleBox::adjustChildSizeForAspectRatioCrossAxisMinAndMax(co nst LayoutBox& child, LayoutUnit childSize) | 1131 LayoutUnit LayoutFlexibleBox::adjustChildSizeForAspectRatioCrossAxisMinAndMax(co nst LayoutBox& child, LayoutUnit childSize) |
| 1113 { | 1132 { |
| 1114 Length crossMin = isHorizontalFlow() ? child.style()->minHeight() : child.st yle()->minWidth(); | 1133 Length crossMin = isHorizontalFlow() ? child.style()->minHeight() : child.st yle()->minWidth(); |
| 1115 Length crossMax = isHorizontalFlow() ? child.style()->maxHeight() : child.st yle()->maxWidth(); | 1134 Length crossMax = isHorizontalFlow() ? child.style()->maxHeight() : child.st yle()->maxWidth(); |
| 1116 | 1135 |
| 1117 | 1136 |
| 1118 if (crossAxisLengthIsDefinite(child, crossMax)) { | 1137 if (crossAxisLengthIsDefinite(child, crossMax)) { |
| 1119 LayoutUnit maxValue = computeMainSizeFromAspectRatioUsing(child, crossMa x); | 1138 LayoutUnit maxValue = computeMainSizeFromAspectRatioUsing(child, crossMa x); |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1423 prepareChildForPositionedLayout(*child, mainAxisOffset, crossAxisOff set, FlipForRowReverse); | 1442 prepareChildForPositionedLayout(*child, mainAxisOffset, crossAxisOff set, FlipForRowReverse); |
| 1424 continue; | 1443 continue; |
| 1425 } | 1444 } |
| 1426 | 1445 |
| 1427 // FIXME Investigate if this can be removed based on other flags. crbug. com/370010 | 1446 // FIXME Investigate if this can be removed based on other flags. crbug. com/370010 |
| 1428 child->setMayNeedPaintInvalidation(); | 1447 child->setMayNeedPaintInvalidation(); |
| 1429 | 1448 |
| 1430 LayoutUnit childPreferredSize = childSizes[i] + mainAxisBorderAndPadding ExtentForChild(*child); | 1449 LayoutUnit childPreferredSize = childSizes[i] + mainAxisBorderAndPadding ExtentForChild(*child); |
| 1431 setOverrideMainAxisSizeForChild(*child, childPreferredSize); | 1450 setOverrideMainAxisSizeForChild(*child, childPreferredSize); |
| 1432 if (childPreferredSize != mainAxisExtentForChild(*child)) { | 1451 if (childPreferredSize != mainAxisExtentForChild(*child)) { |
| 1452 // We will correctly handle percentage sizing even without re-laying out here, because | |
| 1453 // if our size was already correct, then percentage resolution was a lso correct due | |
| 1454 // to the way percentage sizing is defined by flexbox (ie. it requir es a definite flex basis) | |
| 1455 // TODO(cbiesinger): When flex-basis is used instead of width/height , this is not the case. That | |
| 1456 // problem is not limited to percentages. See http://crbug.com/53165 6#c11 | |
| 1433 child->setChildNeedsLayout(MarkOnlyThis); | 1457 child->setChildNeedsLayout(MarkOnlyThis); |
| 1434 } else { | 1458 } else { |
| 1435 // To avoid double applying margin changes in updateAutoMarginsInCro ssAxis, we reset the margins here. | 1459 // To avoid double applying margin changes in updateAutoMarginsInCro ssAxis, we reset the margins here. |
| 1436 resetAutoMarginsAndLogicalTopInCrossAxis(*child); | 1460 resetAutoMarginsAndLogicalTopInCrossAxis(*child); |
| 1437 } | 1461 } |
| 1438 // We may have already forced relayout for orthogonal flowing children i n computeInnerFlexBaseSizeForChild. | 1462 // We may have already forced relayout for orthogonal flowing children i n computeInnerFlexBaseSizeForChild. |
| 1439 bool forceChildRelayout = relayoutChildren && !childFlexBaseSizeRequires Layout(*child); | 1463 bool forceChildRelayout = relayoutChildren && !childFlexBaseSizeRequires Layout(*child); |
| 1440 updateBlockChildDirtyBitsBeforeLayout(forceChildRelayout, *child); | 1464 updateBlockChildDirtyBitsBeforeLayout(forceChildRelayout, *child); |
| 1441 if (!child->needsLayout()) | 1465 if (!child->needsLayout()) |
| 1442 child->markForPaginationRelayoutIfNeeded(layoutScope); | 1466 child->markForPaginationRelayoutIfNeeded(layoutScope); |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1745 ASSERT(child); | 1769 ASSERT(child); |
| 1746 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE xtent; | 1770 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE xtent; |
| 1747 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset - crossAxisStartEdge; | 1771 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset - crossAxisStartEdge; |
| 1748 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi sExtent; | 1772 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi sExtent; |
| 1749 adjustAlignmentForChild(*child, newOffset - originalOffset); | 1773 adjustAlignmentForChild(*child, newOffset - originalOffset); |
| 1750 } | 1774 } |
| 1751 } | 1775 } |
| 1752 } | 1776 } |
| 1753 | 1777 |
| 1754 } // namespace blink | 1778 } // namespace blink |
| OLD | NEW |