Changeset 201516 in webkit
- Timestamp:
- May 31, 2016, 11:42:17 AM (10 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 4 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/fast/flexbox/aspect-ratio-intrinsic-adjust-expected.html (added)
-
LayoutTests/fast/flexbox/aspect-ratio-intrinsic-adjust.html (added)
-
LayoutTests/fast/flexbox/resources/subjects_sm.png (added)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/rendering/RenderFlexibleBox.cpp (modified) (8 diffs)
-
Source/WebCore/rendering/RenderFlexibleBox.h (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r201510 r201516 1 2016-05-31 Dave Hyatt <hyatt@apple.com> 2 3 REGRESSION (r189567): Elements with aspect ratios not handled correctly inside flexbox. 4 https://bugs.webkit.org/show_bug.cgi?id=158040 5 6 Reviewed by Zalan Bujtas. 7 8 * fast/flexbox/aspect-ratio-intrinsic-adjust-expected.html: Added. 9 * fast/flexbox/aspect-ratio-intrinsic-adjust.html: Added. 10 * fast/flexbox/resources/subjects_sm.png: Added. 11 1 12 2016-05-25 Sergio Villar Senin <svillar@igalia.com> 2 13 -
trunk/Source/WebCore/ChangeLog
r201515 r201516 1 2016-05-31 Dave Hyatt <hyatt@apple.com> 2 3 REGRESSION (r189567): Elements with aspect ratios not handled correctly inside flexbox. 4 https://bugs.webkit.org/show_bug.cgi?id=158040 5 6 Reviewed by Zalan Bujtas. 7 8 Added new tests in fast/flexbox. 9 10 * rendering/RenderFlexibleBox.cpp: 11 (WebCore::RenderFlexibleBox::clientLogicalBottomAfterRepositioning): 12 (WebCore::RenderFlexibleBox::hasOrthogonalFlow): 13 (WebCore::RenderFlexibleBox::mainAxisContentExtent): 14 (WebCore::RenderFlexibleBox::computeMainAxisExtentForChild): 15 (WebCore::RenderFlexibleBox::mainAxisBorderAndPaddingExtentForChild): 16 (WebCore::RenderFlexibleBox::mainAxisLengthIsDefinite): 17 (WebCore::RenderFlexibleBox::mainAxisScrollbarExtentForChild): 18 (WebCore::RenderFlexibleBox::prepareOrderIteratorAndMargins): 19 (WebCore::RenderFlexibleBox::crossAxisLengthIsDefinite): 20 (WebCore::RenderFlexibleBox::computeMainSizeFromAspectRatioUsing): 21 (WebCore::RenderFlexibleBox::adjustChildSizeForAspectRatioCrossAxisMinAndMax): 22 (WebCore::RenderFlexibleBox::useChildAspectRatio): 23 (WebCore::RenderFlexibleBox::adjustChildSizeForMinAndMax): 24 (WebCore::RenderFlexibleBox::resetAutoMarginsAndLogicalTopInCrossAxis): 25 (WebCore::RenderFlexibleBox::mainAxisOverflowForChild): 26 (WebCore::RenderFlexibleBox::mainAxisExtentIsDefinite): Deleted. 27 (WebCore::RenderFlexibleBox::mainAxisLengthIsIndefinite): Deleted. 28 * rendering/RenderFlexibleBox.h: 29 (WebCore::RenderFlexibleBox::isFlexibleBoxImpl): 30 1 31 2016-05-31 Alex Christensen <achristensen@webkit.org> 2 32 -
trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp
r201498 r201516 368 368 } 369 369 370 bool RenderFlexibleBox::hasOrthogonalFlow( RenderBox& child) const370 bool RenderFlexibleBox::hasOrthogonalFlow(const RenderBox& child) const 371 371 { 372 372 // FIXME: If the child is a flexbox, then we need to check isHorizontalFlow. … … 455 455 } 456 456 457 Optional<LayoutUnit> RenderFlexibleBox::computeMainAxisExtentForChild( RenderBox& child, SizeType sizeType, const Length& size)457 Optional<LayoutUnit> RenderFlexibleBox::computeMainAxisExtentForChild(const RenderBox& child, SizeType sizeType, const Length& size) 458 458 { 459 459 // FIXME: This is wrong for orthogonal flows. It should use the flexbox's writing-mode, not the child's in order … … 462 462 // We don't have to check for "auto" here - computeContentLogicalHeight will just return Nullopt for that case anyway. 463 463 if (size.isIntrinsic()) 464 c hild.layoutIfNeeded();464 const_cast<RenderBox&>(child).layoutIfNeeded(); // FIXME: Should not need to do a layout here. 465 465 return child.computeContentLogicalHeight(sizeType, size, child.logicalHeight() - child.borderAndPaddingLogicalHeight()); 466 466 } … … 653 653 return isHorizontalFlow() ? child.horizontalBorderAndPaddingExtent() : child.verticalBorderAndPaddingExtent(); 654 654 } 655 656 bool RenderFlexibleBox::mainAxisExtentIsDefinite() const 657 { 658 return isColumnFlow() ? hasDefiniteLogicalHeight() : hasDefiniteLogicalWidth(); 659 } 660 661 bool RenderFlexibleBox::mainAxisLengthIsIndefinite(const Length& flexBasis) const 662 { 663 return flexBasis.isAuto() || (flexBasis.isPercentOrCalculated() && !mainAxisExtentIsDefinite()); 655 656 bool RenderFlexibleBox::mainAxisLengthIsDefinite(const RenderBox& child, const Length& flexBasis) const 657 { 658 if (flexBasis.isAuto()) 659 return false; 660 if (flexBasis.isPercentOrCalculated()) 661 return isColumnFlow() ? bool(child.computePercentageLogicalHeight(flexBasis)) : hasDefiniteLogicalWidth(); 662 return true; 664 663 } 665 664 … … 860 859 } 861 860 862 LayoutUnit RenderFlexibleBox::adjustChildSizeForMinAndMax(RenderBox& child, LayoutUnit childSize) 861 bool RenderFlexibleBox::crossAxisLengthIsDefinite(const RenderBox& child, const Length& length) const 862 { 863 if (length.isAuto()) 864 return false; 865 if (length.isPercentOrCalculated()) 866 return hasOrthogonalFlow(child) ? hasDefiniteLogicalWidth() : bool(child.computePercentageLogicalHeight(length)); 867 return length.isFixed(); 868 } 869 870 871 Optional<LayoutUnit> RenderFlexibleBox::computeMainSizeFromAspectRatioUsing(const RenderBox& child, Length crossSizeLength) const 872 { 873 ASSERT(child.hasAspectRatio()); 874 ASSERT(child.intrinsicSize().height() > 0); 875 876 Optional<LayoutUnit> crossSize; 877 if (crossSizeLength.isFixed()) 878 crossSize = LayoutUnit(crossSizeLength.value()); 879 else { 880 ASSERT(crossSizeLength.isPercentOrCalculated()); 881 crossSize = hasOrthogonalFlow(child) ? 882 adjustBorderBoxLogicalWidthForBoxSizing(valueForLength(crossSizeLength, contentWidth())) : 883 child.computePercentageLogicalHeight(crossSizeLength); 884 } 885 886 if (!crossSize) 887 return crossSize; 888 889 const LayoutSize& childIntrinsicSize = child.intrinsicSize(); 890 double ratio = childIntrinsicSize.width().toFloat() / childIntrinsicSize.height().toFloat(); 891 if (isHorizontalFlow()) 892 return LayoutUnit(crossSize.value() * ratio); 893 return LayoutUnit(crossSize.value() / ratio); 894 } 895 896 LayoutUnit RenderFlexibleBox::adjustChildSizeForAspectRatioCrossAxisMinAndMax(const RenderBox& child, LayoutUnit childSize) 897 { 898 Length crossMin = isHorizontalFlow() ? child.style().minHeight() : child.style().minWidth(); 899 Length crossMax = isHorizontalFlow() ? child.style().maxHeight() : child.style().maxWidth(); 900 901 if (crossAxisLengthIsDefinite(child, crossMax)) { 902 Optional<LayoutUnit> maxValue = computeMainSizeFromAspectRatioUsing(child, crossMax); 903 if (maxValue) 904 childSize = std::min(maxValue.value(), childSize); 905 } 906 907 if (crossAxisLengthIsDefinite(child, crossMin)) { 908 Optional<LayoutUnit> minValue = computeMainSizeFromAspectRatioUsing(child, crossMin); 909 if (minValue) 910 childSize = std::max(minValue.value(), childSize); 911 } 912 913 return childSize; 914 } 915 916 bool RenderFlexibleBox::useChildAspectRatio(const RenderBox& child) const 917 { 918 if (!child.hasAspectRatio()) 919 return false; 920 if (!child.intrinsicSize().height()) 921 return false; 922 Length crossSize = isHorizontalFlow() ? child.style().height() : child.style().width(); 923 return crossAxisLengthIsDefinite(child, crossSize); 924 } 925 926 LayoutUnit RenderFlexibleBox::adjustChildSizeForMinAndMax(const RenderBox& child, LayoutUnit childSize) 863 927 { 864 928 Length max = isHorizontalFlow() ? child.style().maxWidth() : child.style().maxHeight(); … … 868 932 childSize = std::min(childSize, maxExtent.valueOr(childSize)); 869 933 } 870 934 871 935 Length min = isHorizontalFlow() ? child.style().minWidth() : child.style().minHeight(); 872 936 if (min.isSpecifiedOrIntrinsic()) 873 937 return std::max(childSize, computeMainAxisExtentForChild(child, MinSize, min).valueOr(childSize)); 874 938 875 939 if (!isFlexibleBoxImpl() && min.isAuto() && mainAxisOverflowForChild(child) == OVISIBLE && !(isColumnFlow() && is<RenderFlexibleBox>(child))) { 876 940 // This is the implementation of CSS flexbox section 4.5 which defines the minimum size of "pure" flex … … 881 945 LayoutUnit contentSize = computeMainAxisExtentForChild(child, MinSize, Length(MinContent)).value(); 882 946 ASSERT(contentSize >= 0); 947 if (child.hasAspectRatio() && child.intrinsicSize().height() > 0) 948 contentSize = adjustChildSizeForAspectRatioCrossAxisMinAndMax(child, contentSize); 883 949 contentSize = std::min(contentSize, maxExtent.valueOr(contentSize)); 884 950 885 951 Length mainSize = isHorizontalFlow() ? child.style().width() : child.style().height(); 886 if ( !mainAxisLengthIsIndefinite(mainSize)) {952 if (mainAxisLengthIsDefinite(child, mainSize)) { 887 953 LayoutUnit resolvedMainSize = computeMainAxisExtentForChild(child, MainOrPreferredSize, mainSize).value(); 888 954 ASSERT(resolvedMainSize >= 0); 889 955 LayoutUnit specifiedSize = std::min(resolvedMainSize, maxExtent.valueOr(resolvedMainSize)); 890 891 956 return std::max(childSize, std::min(specifiedSize, contentSize)); 957 } else if (useChildAspectRatio(child)) { 958 Length crossSizeLength = isHorizontalFlow() ? child.style().height() : child.style().width(); 959 Optional<LayoutUnit> transferredSize = computeMainSizeFromAspectRatioUsing(child, crossSizeLength); 960 if (transferredSize) { 961 transferredSize = adjustChildSizeForAspectRatioCrossAxisMinAndMax(child, transferredSize.value()); 962 return std::max(childSize, std::min(transferredSize.value(), contentSize)); 963 } 892 964 } 893 965 return std::max(childSize, contentSize); … … 1092 1164 } 1093 1165 1094 EOverflow RenderFlexibleBox::mainAxisOverflowForChild( RenderBox& child) const1166 EOverflow RenderFlexibleBox::mainAxisOverflowForChild(const RenderBox& child) const 1095 1167 { 1096 1168 if (isHorizontalFlow()) -
trunk/Source/WebCore/rendering/RenderFlexibleBox.h
r200041 r201516 87 87 88 88 bool isFlexibleBox() const final { return true; } 89 bool hasOrthogonalFlow( RenderBox& child) const;89 bool hasOrthogonalFlow(const RenderBox& child) const; 90 90 bool isColumnFlow() const; 91 91 bool isLeftToRightFlow() const; … … 99 99 LayoutUnit crossAxisContentExtent() const; 100 100 LayoutUnit mainAxisContentExtent(LayoutUnit contentLogicalHeight); 101 Optional<LayoutUnit> computeMainAxisExtentForChild( RenderBox& child, SizeType, const Length& size);101 Optional<LayoutUnit> computeMainAxisExtentForChild(const RenderBox& child, SizeType, const Length& size); 102 102 WritingMode transformedWritingMode() const; 103 103 LayoutUnit flowAwareBorderStart() const; … … 123 123 LayoutUnit mainAxisScrollbarExtentForChild(RenderBox& child) const; 124 124 LayoutUnit preferredMainAxisContentExtentForChild(RenderBox& child, bool hasInfiniteLineLength); 125 EOverflow mainAxisOverflowForChild( RenderBox&) const;125 EOverflow mainAxisOverflowForChild(const RenderBox&) const; 126 126 127 127 void layoutFlexItems(bool relayoutChildren, Vector<LineContext>&); … … 140 140 LayoutUnit computeChildMarginValue(const Length& margin); 141 141 void prepareOrderIteratorAndMargins(); 142 LayoutUnit adjustChildSizeForMinAndMax(RenderBox&, LayoutUnit childSize); 142 LayoutUnit adjustChildSizeForMinAndMax(const RenderBox&, LayoutUnit childSize); 143 LayoutUnit adjustChildSizeForAspectRatioCrossAxisMinAndMax(const RenderBox&, LayoutUnit childSize); 143 144 bool computeNextFlexLine(OrderedFlexItemList& orderedChildren, LayoutUnit& preferredMainAxisExtent, double& totalFlexGrow, double& totalWeightedFlexShrink, LayoutUnit& minMaxAppliedMainAxisExtent, bool& hasInfiniteLineLength); 144 145 … … 159 160 void flipForWrapReverse(const Vector<LineContext>&, LayoutUnit crossAxisStartEdge); 160 161 161 bool mainAxisExtentIsDefinite() const; 162 bool mainAxisLengthIsIndefinite(const Length& flexBasis) const; 163 162 bool mainAxisLengthIsDefinite(const RenderBox&, const Length&) const; 163 bool crossAxisLengthIsDefinite(const RenderBox&, const Length&) const; 164 bool useChildAspectRatio(const RenderBox&) const; 165 Optional<LayoutUnit> computeMainSizeFromAspectRatioUsing(const RenderBox& child, Length crossSizeLength) const; 166 164 167 virtual bool isFlexibleBoxImpl() const { return false; }; 165 168
Note:
See TracChangeset
for help on using the changeset viewer.