| 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 751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 762 | 762 |
| 763 LayoutUnit LayoutFlexibleBox::computeMainSizeFromAspectRatioUsing(const LayoutBo
x& child, Length crossSizeLength) const | 763 LayoutUnit LayoutFlexibleBox::computeMainSizeFromAspectRatioUsing(const LayoutBo
x& child, Length crossSizeLength) const |
| 764 { | 764 { |
| 765 DCHECK(hasAspectRatio(child)); | 765 DCHECK(hasAspectRatio(child)); |
| 766 DCHECK_NE(child.intrinsicSize().height(), 0); | 766 DCHECK_NE(child.intrinsicSize().height(), 0); |
| 767 | 767 |
| 768 LayoutUnit crossSize; | 768 LayoutUnit crossSize; |
| 769 if (crossSizeLength.isFixed()) { | 769 if (crossSizeLength.isFixed()) { |
| 770 crossSize = LayoutUnit(crossSizeLength.value()); | 770 crossSize = LayoutUnit(crossSizeLength.value()); |
| 771 } else { | 771 } else { |
| 772 DCHECK(crossSizeLength.hasPercent()); | 772 DCHECK(crossSizeLength.isPercentOrCalc()); |
| 773 crossSize = hasOrthogonalFlow(child) ? | 773 crossSize = hasOrthogonalFlow(child) ? |
| 774 adjustBorderBoxLogicalWidthForBoxSizing(valueForLength(crossSizeLeng
th, contentWidth())) : | 774 adjustBorderBoxLogicalWidthForBoxSizing(valueForLength(crossSizeLeng
th, contentWidth())) : |
| 775 child.computePercentageLogicalHeight(crossSizeLength); | 775 child.computePercentageLogicalHeight(crossSizeLength); |
| 776 } | 776 } |
| 777 | 777 |
| 778 const LayoutSize& childIntrinsicSize = child.intrinsicSize(); | 778 const LayoutSize& childIntrinsicSize = child.intrinsicSize(); |
| 779 double ratio = childIntrinsicSize.width().toFloat() / childIntrinsicSize.hei
ght().toFloat(); | 779 double ratio = childIntrinsicSize.width().toFloat() / childIntrinsicSize.hei
ght().toFloat(); |
| 780 if (isHorizontalFlow()) | 780 if (isHorizontalFlow()) |
| 781 return LayoutUnit(crossSize * ratio); | 781 return LayoutUnit(crossSize * ratio); |
| 782 return LayoutUnit(crossSize / ratio); | 782 return LayoutUnit(crossSize / ratio); |
| 783 } | 783 } |
| 784 | 784 |
| 785 void LayoutFlexibleBox::setFlowAwareLocationForChild(LayoutBox& child, const Lay
outPoint& location) | 785 void LayoutFlexibleBox::setFlowAwareLocationForChild(LayoutBox& child, const Lay
outPoint& location) |
| 786 { | 786 { |
| 787 if (isHorizontalFlow()) | 787 if (isHorizontalFlow()) |
| 788 child.setLocationAndUpdateOverflowControlsIfNeeded(location); | 788 child.setLocationAndUpdateOverflowControlsIfNeeded(location); |
| 789 else | 789 else |
| 790 child.setLocationAndUpdateOverflowControlsIfNeeded(location.transposedPo
int()); | 790 child.setLocationAndUpdateOverflowControlsIfNeeded(location.transposedPo
int()); |
| 791 } | 791 } |
| 792 | 792 |
| 793 bool LayoutFlexibleBox::mainAxisLengthIsDefinite(const LayoutBox& child, const L
ength& flexBasis) const | 793 bool LayoutFlexibleBox::mainAxisLengthIsDefinite(const LayoutBox& child, const L
ength& flexBasis) const |
| 794 { | 794 { |
| 795 if (flexBasis.isAuto()) | 795 if (flexBasis.isAuto()) |
| 796 return false; | 796 return false; |
| 797 if (flexBasis.hasPercent()) { | 797 if (flexBasis.isPercentOrCalc()) { |
| 798 if (!isColumnFlow() || m_hasDefiniteHeight == SizeDefiniteness::Definite
) | 798 if (!isColumnFlow() || m_hasDefiniteHeight == SizeDefiniteness::Definite
) |
| 799 return true; | 799 return true; |
| 800 if (m_hasDefiniteHeight == SizeDefiniteness::Indefinite) | 800 if (m_hasDefiniteHeight == SizeDefiniteness::Indefinite) |
| 801 return false; | 801 return false; |
| 802 bool definite = child.computePercentageLogicalHeight(flexBasis) != -1; | 802 bool definite = child.computePercentageLogicalHeight(flexBasis) != -1; |
| 803 m_hasDefiniteHeight = definite ? SizeDefiniteness::Definite : SizeDefini
teness::Indefinite; | 803 m_hasDefiniteHeight = definite ? SizeDefiniteness::Definite : SizeDefini
teness::Indefinite; |
| 804 return definite; | 804 return definite; |
| 805 } | 805 } |
| 806 return true; | 806 return true; |
| 807 } | 807 } |
| 808 | 808 |
| 809 bool LayoutFlexibleBox::crossAxisLengthIsDefinite(const LayoutBox& child, const
Length& length) const | 809 bool LayoutFlexibleBox::crossAxisLengthIsDefinite(const LayoutBox& child, const
Length& length) const |
| 810 { | 810 { |
| 811 if (length.isAuto()) | 811 if (length.isAuto()) |
| 812 return false; | 812 return false; |
| 813 if (length.hasPercent()) { | 813 if (length.isPercentOrCalc()) { |
| 814 if (hasOrthogonalFlow(child) || m_hasDefiniteHeight == SizeDefiniteness:
:Definite) | 814 if (hasOrthogonalFlow(child) || m_hasDefiniteHeight == SizeDefiniteness:
:Definite) |
| 815 return true; | 815 return true; |
| 816 if (m_hasDefiniteHeight == SizeDefiniteness::Indefinite) | 816 if (m_hasDefiniteHeight == SizeDefiniteness::Indefinite) |
| 817 return false; | 817 return false; |
| 818 bool definite = child.computePercentageLogicalHeight(length) != -1; | 818 bool definite = child.computePercentageLogicalHeight(length) != -1; |
| 819 m_hasDefiniteHeight = definite ? SizeDefiniteness::Definite : SizeDefini
teness::Indefinite; | 819 m_hasDefiniteHeight = definite ? SizeDefiniteness::Definite : SizeDefini
teness::Indefinite; |
| 820 return definite; | 820 return definite; |
| 821 } | 821 } |
| 822 // TODO(cbiesinger): Eventually we should support other types of sizes here.
Requires updating | 822 // TODO(cbiesinger): Eventually we should support other types of sizes here.
Requires updating |
| 823 // computeMainSizeFromAspectRatioUsing. | 823 // computeMainSizeFromAspectRatioUsing. |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1179 | 1179 |
| 1180 LayoutUnit LayoutFlexibleBox::mainSizeForPercentageResolution(const LayoutBox& c
hild) | 1180 LayoutUnit LayoutFlexibleBox::mainSizeForPercentageResolution(const LayoutBox& c
hild) |
| 1181 { | 1181 { |
| 1182 // This function implements section 9.8. Definite and Indefinite Sizes, case | 1182 // This function implements section 9.8. Definite and Indefinite Sizes, case |
| 1183 // 2) of the flexbox spec. | 1183 // 2) of the flexbox spec. |
| 1184 // We need to check for the flexbox to have a definite main size, and for th
e | 1184 // We need to check for the flexbox to have a definite main size, and for th
e |
| 1185 // flex item to have a definite flex basis. | 1185 // flex item to have a definite flex basis. |
| 1186 const Length& flexBasis = flexBasisForChild(child); | 1186 const Length& flexBasis = flexBasisForChild(child); |
| 1187 if (!mainAxisLengthIsDefinite(child, flexBasis)) | 1187 if (!mainAxisLengthIsDefinite(child, flexBasis)) |
| 1188 return LayoutUnit(-1); | 1188 return LayoutUnit(-1); |
| 1189 if (!flexBasis.hasPercent()) { | 1189 if (!flexBasis.isPercentOrCalc()) { |
| 1190 // If flex basis had a percentage, our size is guaranteed to be definite
or the flex item's | 1190 // If flex basis had a percentage, our size is guaranteed to be definite
or the flex item's |
| 1191 // size could not be definite. | 1191 // size could not be definite. |
| 1192 // Otherwise, we make up a percentage to check whether we have a definit
e size. | 1192 // Otherwise, we make up a percentage to check whether we have a definit
e size. |
| 1193 if (!mainAxisLengthIsDefinite(child, Length(0, Percent))) | 1193 if (!mainAxisLengthIsDefinite(child, Length(0, Percent))) |
| 1194 return LayoutUnit(-1); | 1194 return LayoutUnit(-1); |
| 1195 } | 1195 } |
| 1196 | 1196 |
| 1197 if (hasOrthogonalFlow(child)) | 1197 if (hasOrthogonalFlow(child)) |
| 1198 return child.hasOverrideLogicalContentHeight() ? child.overrideLogicalCo
ntentHeight() : LayoutUnit(-1); | 1198 return child.hasOverrideLogicalContentHeight() ? child.overrideLogicalCo
ntentHeight() : LayoutUnit(-1); |
| 1199 return child.hasOverrideLogicalContentWidth() ? child.overrideLogicalContent
Width() : LayoutUnit(-1); | 1199 return child.hasOverrideLogicalContentWidth() ? child.overrideLogicalContent
Width() : LayoutUnit(-1); |
| (...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1941 DCHECK(child); | 1941 DCHECK(child); |
| 1942 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE
xtent; | 1942 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE
xtent; |
| 1943 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset
- crossAxisStartEdge; | 1943 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset
- crossAxisStartEdge; |
| 1944 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi
sExtent; | 1944 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi
sExtent; |
| 1945 adjustAlignmentForChild(*child, newOffset - originalOffset); | 1945 adjustAlignmentForChild(*child, newOffset - originalOffset); |
| 1946 } | 1946 } |
| 1947 } | 1947 } |
| 1948 } | 1948 } |
| 1949 | 1949 |
| 1950 } // namespace blink | 1950 } // namespace blink |
| OLD | NEW |