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