Changeset 271061 in webkit
- Timestamp:
- Dec 22, 2020 12:30:23 PM (3 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r271060 r271061 1 2020-12-22 Rob Buis <rbuis@igalia.com> 2 3 Support aspect-ratio on positioned elements 4 https://bugs.webkit.org/show_bug.cgi?id=219741 5 6 Reviewed by Simon Fraser. 7 8 Enable some tests that pass now. 9 10 * TestExpectations: 11 1 12 2020-12-22 Youenn Fablet <youenn@apple.com> 2 13 -
trunk/LayoutTests/TestExpectations
r270955 r271061 4425 4425 webkit.org/b/214462 imported/w3c/web-platform-tests/css/css-scoping/slotted-placeholder.html [ ImageOnlyFailure ] 4426 4426 4427 webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/abspos-001.html [ ImageOnlyFailure ]4428 webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/abspos-002.html [ ImageOnlyFailure ]4429 webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/abspos-003.html [ ImageOnlyFailure ]4430 webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/abspos-004.html [ ImageOnlyFailure ]4431 webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/abspos-005.html [ ImageOnlyFailure ]4432 webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/abspos-006.html [ ImageOnlyFailure ]4433 webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/abspos-007.html [ ImageOnlyFailure ]4434 4427 webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/abspos-008.html [ ImageOnlyFailure ] 4435 webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/abspos-009.html [ ImageOnlyFailure ] 4436 webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/abspos-010.html [ ImageOnlyFailure ] 4437 webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/abspos-011.html [ ImageOnlyFailure ] 4428 webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/abspos-012.html [ ImageOnlyFailure ] 4429 webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/abspos-013.html [ ImageOnlyFailure ] 4438 4430 webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/abspos-014.html [ ImageOnlyFailure ] 4439 4431 webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/block-aspect-ratio-009.html [ ImageOnlyFailure ] -
trunk/Source/WebCore/ChangeLog
r271060 r271061 1 2020-12-22 Rob Buis <rbuis@igalia.com> 2 3 Support aspect-ratio on positioned elements 4 https://bugs.webkit.org/show_bug.cgi?id=219741 5 6 Reviewed by Simon Fraser. 7 8 Support aspect-ratio on positioned elements taking into account 9 insets in the case where no width/height is specified. 10 11 * rendering/RenderBox.cpp: 12 (WebCore::RenderBox::computePositionedLogicalWidthUsing const): 13 (WebCore::RenderBox::computePositionedLogicalHeightUsing const): 14 (WebCore::RenderBox::shouldComputeLogicalHeightFromAspectRatio const): We should not compute 15 the logical height if there is an implied height due to top/bottom. 16 (WebCore::RenderBox::shouldComputeLogicalWidthFromAspectRatio const): 17 (WebCore::RenderBox::shouldComputeLogicalWidthFromAspectRatioAndInsets const): Helper method 18 to determine whether logical width can be computed from inset information in the case where 19 no width/height are specified. 20 (WebCore::RenderBox::computeLogicalWidthFromAspectRatio const): compute logical width 21 from the computed logical height constriaining it by min max. 22 * rendering/RenderBox.h: 23 1 24 2020-12-22 Youenn Fablet <youenn@apple.com> 2 25 -
trunk/Source/WebCore/rendering/RenderBox.cpp
r271003 r271061 3716 3716 if (widthType == MinSize && logicalWidth.isAuto()) 3717 3717 logicalWidth = Length(0, Fixed); 3718 else if (widthType == MainOrPreferredSize && logicalWidth.isAuto() && shouldComputeLogicalWidthFromAspectRatio()) 3719 logicalWidth = Length(computeLogicalWidthFromAspectRatio(), Fixed); 3718 3720 else if (logicalWidth.isIntrinsic()) 3719 3721 logicalWidth = Length(computeIntrinsicLogicalWidthUsing(logicalWidth, containerLogicalWidth, bordersPlusPadding) - bordersPlusPadding, Fixed); … … 3727 3729 const LayoutUnit containerRelativeLogicalWidth = containingBlockLogicalWidthForPositioned(containerBlock, nullptr, false); 3728 3730 3729 bool logicalWidthIsAuto = logicalWidth.isIntrinsicOrAuto() ;3731 bool logicalWidthIsAuto = logicalWidth.isIntrinsicOrAuto() && !shouldComputeLogicalWidthFromAspectRatio(); 3730 3732 bool logicalLeftIsAuto = logicalLeft.isAuto(); 3731 3733 bool logicalRightIsAuto = logicalRight.isAuto(); … … 4064 4066 LayoutUnit logicalTopValue; 4065 4067 4066 bool logicalHeightIsAuto = logicalHeightLength.isAuto(); 4068 bool fromAspectRatio = heightType == MainOrPreferredSize && shouldComputeLogicalHeightFromAspectRatio(); 4069 bool logicalHeightIsAuto = logicalHeightLength.isAuto() && !fromAspectRatio; 4067 4070 bool logicalTopIsAuto = logicalTop.isAuto(); 4068 4071 bool logicalBottomIsAuto = logicalBottom.isAuto(); … … 4076 4079 if (logicalHeightLength.isIntrinsic()) 4077 4080 resolvedLogicalHeight = computeIntrinsicLogicalContentHeightUsing(logicalHeightLength, contentLogicalHeight, bordersPlusPadding).value(); 4078 else 4081 else if (fromAspectRatio) { 4082 resolvedLogicalHeight = blockSizeFromAspectRatio(horizontalBorderAndPaddingExtent(), verticalBorderAndPaddingExtent(), style().logicalAspectRatio() , style().boxSizing(), logicalWidth()); 4083 resolvedLogicalHeight = std::max(LayoutUnit(), resolvedLogicalHeight - bordersPlusPadding); 4084 } else 4079 4085 resolvedLogicalHeight = adjustContentBoxLogicalHeightForBoxSizing(valueForLength(logicalHeightLength, containerLogicalHeight)); 4080 4086 } … … 4998 5004 return false; 4999 5005 5006 if (shouldComputeLogicalWidthFromAspectRatioAndInsets()) 5007 return false; 5008 5000 5009 auto h = style().logicalHeight(); 5001 5010 return h.isAuto() || (!isOutOfFlowPositioned() && h.isPercentOrCalculated() && percentageLogicalHeightIsResolvable()); 5011 } 5012 5013 bool RenderBox::shouldComputeLogicalWidthFromAspectRatio() const 5014 { 5015 if (!style().hasAspectRatio()) 5016 return false; 5017 5018 if (!shouldComputeLogicalWidthFromAspectRatioAndInsets() && !style().logicalHeight().isFixed() && !style().logicalHeight().isPercentOrCalculated()) 5019 return false; 5020 5021 return true; 5022 } 5023 5024 bool RenderBox::shouldComputeLogicalWidthFromAspectRatioAndInsets() const 5025 { 5026 if (!isOutOfFlowPositioned()) 5027 return false; 5028 // FIXME: see if this can become a helper on RenderStyle. 5029 if (style().width().isAuto() && style().height().isAuto() && !style().top().isAuto() && !style().bottom().isAuto() && (style().left().isAuto() || style().right().isAuto())) 5030 return true; 5031 return false; 5032 } 5033 5034 LayoutUnit RenderBox::computeLogicalWidthFromAspectRatio(RenderFragmentContainer* fragment) const 5035 { 5036 ASSERT(shouldComputeLogicalWidthFromAspectRatio()); 5037 auto computedValues = computeLogicalHeight(logicalHeight(), logicalTop()); 5038 LayoutUnit logicalHeightforAspectRatio = computedValues.m_extent; 5039 5040 auto logicalWidth = inlineSizeFromAspectRatio(horizontalBorderAndPaddingExtent(), verticalBorderAndPaddingExtent(), style().logicalAspectRatio(), style().boxSizing(), logicalHeightforAspectRatio); 5041 5042 LayoutUnit containerWidthInInlineDirection = std::max<LayoutUnit>(0, containingBlockLogicalWidthForContentInFragment(fragment)); 5043 return constrainLogicalWidthInFragmentByMinMax(logicalWidth, containerWidthInInlineDirection, *containingBlock(), fragment); 5002 5044 } 5003 5045 -
trunk/Source/WebCore/rendering/RenderBox.h
r271003 r271061 746 746 747 747 bool shouldComputeLogicalHeightFromAspectRatio() const; 748 bool shouldComputeLogicalWidthFromAspectRatio() const; 749 bool shouldComputeLogicalWidthFromAspectRatioAndInsets() const; 750 LayoutUnit computeLogicalWidthFromAspectRatio(RenderFragmentContainer* = nullptr) const; 748 751 749 752 private:
Note: See TracChangeset
for help on using the changeset viewer.