| 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 1008 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1019 transferredSize = adjustChildSizeForAspectRatioCrossAxisMinAndMax(ch
ild, transferredSize); | 1019 transferredSize = adjustChildSizeForAspectRatioCrossAxisMinAndMax(ch
ild, transferredSize); |
| 1020 minExtent = std::min(transferredSize, contentSize); | 1020 minExtent = std::min(transferredSize, contentSize); |
| 1021 } else { | 1021 } else { |
| 1022 minExtent = contentSize; | 1022 minExtent = contentSize; |
| 1023 } | 1023 } |
| 1024 } | 1024 } |
| 1025 ASSERT(minExtent >= 0); | 1025 ASSERT(minExtent >= 0); |
| 1026 return std::max(childSize, minExtent); | 1026 return std::max(childSize, minExtent); |
| 1027 } | 1027 } |
| 1028 | 1028 |
| 1029 LayoutUnit LayoutFlexibleBox::crossSizeForPercentageResolution(const LayoutBox&
child) |
| 1030 { |
| 1031 // This function implements section 9.8. Definite and Indefinite Sizes, case |
| 1032 // 1) of the flexbox spec. |
| 1033 // We need to check for multiline and a definite cross size of the flexbox |
| 1034 // per https://drafts.csswg.org/css-flexbox/#definite-sizes, and for |
| 1035 // stretch, auto margins, and an indefinite cross size of the flex item per |
| 1036 // https://drafts.csswg.org/css-flexbox/#stretched (linked from that |
| 1037 // section) |
| 1038 if (isMultiline() || alignmentForChild(child) != ItemPositionStretch || hasA
utoMarginsInCrossAxis(child)) |
| 1039 return LayoutUnit(-1); |
| 1040 |
| 1041 const Length& childCrossLength = isHorizontalFlow() ? child.styleRef().heigh
t() : child.styleRef().width(); |
| 1042 if (crossAxisLengthIsDefinite(child, childCrossLength)) |
| 1043 return LayoutUnit(-1); |
| 1044 |
| 1045 LayoutUnit childCrossSize; |
| 1046 |
| 1047 LogicalExtentComputedValues computedValues; |
| 1048 if (isColumnFlow()) { |
| 1049 const Length& widthLength = styleRef().logicalWidth(); |
| 1050 if (widthLength.isAuto() || (widthLength.hasPercent() && !hasDefiniteLog
icalWidth())) |
| 1051 return LayoutUnit(-1); |
| 1052 |
| 1053 computeLogicalWidth(computedValues); |
| 1054 if (computedValues.m_extent == LayoutUnit(-1)) |
| 1055 return LayoutUnit(-1); |
| 1056 childCrossSize = computedValues.m_extent - borderAndPaddingLogicalWidth(
) - scrollbarLogicalWidth(); |
| 1057 childCrossSize = child.constrainLogicalWidthByMinMax(childCrossSize, chi
ldCrossSize, this) - child.scrollbarLogicalWidth() - child.borderAndPaddingLogic
alWidth(); |
| 1058 } else { |
| 1059 const Length& heightLength = styleRef().logicalHeight(); |
| 1060 if (heightLength.isAuto() || (heightLength.hasPercent() && computePercen
tageLogicalHeight(heightLength) == -1)) |
| 1061 return LayoutUnit(-1); |
| 1062 |
| 1063 computeLogicalHeight(LayoutUnit(-1), LayoutUnit(), computedValues); |
| 1064 childCrossSize = computedValues.m_extent - borderAndPaddingLogicalHeight
() - scrollbarLogicalHeight(); |
| 1065 childCrossSize = child.constrainLogicalHeightByMinMax(childCrossSize, La
youtUnit(-1)) - child.scrollbarLogicalHeight() - child.borderAndPaddingLogicalHe
ight(); |
| 1066 } |
| 1067 return childCrossSize; |
| 1068 } |
| 1069 |
| 1070 LayoutUnit LayoutFlexibleBox::childLogicalHeightForPercentageResolution(const La
youtBox& child) |
| 1071 { |
| 1072 if (!hasOrthogonalFlow(child)) |
| 1073 return crossSizeForPercentageResolution(child); |
| 1074 return LayoutUnit(-1); |
| 1075 } |
| 1076 |
| 1077 LayoutUnit LayoutFlexibleBox::childLogicalWidthForPercentageResolution(const Lay
outBox& child) |
| 1078 { |
| 1079 if (hasOrthogonalFlow(child)) |
| 1080 return crossSizeForPercentageResolution(child); |
| 1081 return LayoutUnit(-1); |
| 1082 } |
| 1083 |
| 1029 LayoutUnit LayoutFlexibleBox::adjustChildSizeForAspectRatioCrossAxisMinAndMax(co
nst LayoutBox& child, LayoutUnit childSize) | 1084 LayoutUnit LayoutFlexibleBox::adjustChildSizeForAspectRatioCrossAxisMinAndMax(co
nst LayoutBox& child, LayoutUnit childSize) |
| 1030 { | 1085 { |
| 1031 Length crossMin = isHorizontalFlow() ? child.style()->minHeight() : child.st
yle()->minWidth(); | 1086 Length crossMin = isHorizontalFlow() ? child.style()->minHeight() : child.st
yle()->minWidth(); |
| 1032 Length crossMax = isHorizontalFlow() ? child.style()->maxHeight() : child.st
yle()->maxWidth(); | 1087 Length crossMax = isHorizontalFlow() ? child.style()->maxHeight() : child.st
yle()->maxWidth(); |
| 1033 | 1088 |
| 1034 | 1089 |
| 1035 if (crossAxisLengthIsDefinite(child, crossMax)) { | 1090 if (crossAxisLengthIsDefinite(child, crossMax)) { |
| 1036 LayoutUnit maxValue = computeMainSizeFromAspectRatioUsing(child, crossMa
x); | 1091 LayoutUnit maxValue = computeMainSizeFromAspectRatioUsing(child, crossMa
x); |
| 1037 childSize = std::min(maxValue, childSize); | 1092 childSize = std::min(maxValue, childSize); |
| 1038 } | 1093 } |
| (...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1662 ASSERT(child); | 1717 ASSERT(child); |
| 1663 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE
xtent; | 1718 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE
xtent; |
| 1664 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset
- crossAxisStartEdge; | 1719 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset
- crossAxisStartEdge; |
| 1665 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi
sExtent; | 1720 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi
sExtent; |
| 1666 adjustAlignmentForChild(*child, newOffset - originalOffset); | 1721 adjustAlignmentForChild(*child, newOffset - originalOffset); |
| 1667 } | 1722 } |
| 1668 } | 1723 } |
| 1669 } | 1724 } |
| 1670 | 1725 |
| 1671 } // namespace blink | 1726 } // namespace blink |
| OLD | NEW |