WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-219679-20210219100019.patch (text/plain), 11.70 KB, created by
Rob Buis
on 2021-02-19 01:00:20 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Rob Buis
Created:
2021-02-19 01:00:20 PST
Size:
11.70 KB
patch
obsolete
>Subversion Revision: 273130 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index f7e739592984881cfa3cc31880baadd2b9eabc79..5a163727256b62c4344187f2d37250de0a154e27 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,29 @@ >+2021-02-19 Rob Buis <rbuis@igalia.com> >+ >+ Support aspect-ratio on flexbox items >+ https://bugs.webkit.org/show_bug.cgi?id=219679 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Support aspect-ratio on flexbox items by not only >+ considering implicit aspect-ratio in items (for example >+ images) but also thorugh explicit aspect-ratio property >+ usage. >+ >+ * rendering/RenderBox.cpp: >+ (WebCore::RenderBox::constrainLogicalHeightByMinMax const): >+ We can't use intrinsic height here if it is unresolved. >+ (WebCore::RenderBox::cacheIntrinsicContentLogicalHeightForFlexItem const): >+ (WebCore::RenderBox::shouldComputeLogicalWidthFromAspectRatio const): >+ If override height is set then we can compute logical width from it. >+ * rendering/RenderFlexibleBox.cpp: >+ (WebCore::childHasAspectRatio): >+ (WebCore::RenderFlexibleBox::computeMainAxisExtentForChild): >+ (WebCore::RenderFlexibleBox::useChildAspectRatio const): >+ (WebCore::RenderFlexibleBox::computeMainSizeFromAspectRatioUsing const): >+ (WebCore::RenderFlexibleBox::childCrossSizeShouldUseContainerCrossSize const): >+ (WebCore::RenderFlexibleBox::needToStretchChildLogicalHeight const): >+ > 2021-02-18 Simon Fraser <simon.fraser@apple.com> > > Scrolling on https://www.apple.com/ipad-air/ can jitter on certain sections >diff --git a/Source/WebCore/rendering/RenderBox.cpp b/Source/WebCore/rendering/RenderBox.cpp >index d2d37a099c94d7be73a9a30cc705377e3dae2ccf..e9729cb77226a154d8d4de85a9ad86a16e4a6657 100644 >--- a/Source/WebCore/rendering/RenderBox.cpp >+++ b/Source/WebCore/rendering/RenderBox.cpp >@@ -679,7 +679,7 @@ LayoutUnit RenderBox::constrainLogicalHeightByMinMax(LayoutUnit logicalHeight, O > logicalHeight = std::min(logicalHeight, maxH.value()); > } > auto logicalMinHeight = styleToUse.logicalMinHeight(); >- if (logicalMinHeight.isAuto() && shouldComputeLogicalHeightFromAspectRatio() && intrinsicContentHeight && styleToUse.overflowBlockDirection() == Overflow::Visible) >+ if (logicalMinHeight.isAuto() && shouldComputeLogicalHeightFromAspectRatio() && intrinsicContentHeight && intrinsicContentHeight != LayoutUnit::max() && styleToUse.overflowBlockDirection() == Overflow::Visible) > logicalMinHeight = Length(*intrinsicContentHeight, LengthType::Fixed); > if (Optional<LayoutUnit> computedLogicalHeight = computeLogicalHeightUsing(MinSize, logicalMinHeight, intrinsicContentHeight)) > return std::max(logicalHeight, computedLogicalHeight.value()); >@@ -2862,7 +2862,7 @@ void RenderBox::cacheIntrinsicContentLogicalHeightForFlexItem(LayoutUnit height) > // FIXME: it should be enough with checking hasOverridingLogicalHeight() as this logic could be shared > // by any layout system using overrides like grid or flex. However this causes a never ending sequence of calls > // between layoutBlock() <-> relayoutToAvoidWidows(). >- if (isFloatingOrOutOfFlowPositioned() || !parent() || !parent()->isFlexibleBox() || hasOverridingLogicalHeight()) >+ if (isFloatingOrOutOfFlowPositioned() || !parent() || !parent()->isFlexibleBox() || hasOverridingLogicalHeight() || shouldComputeLogicalHeightFromAspectRatio()) > return; > downcast<RenderFlexibleBox>(parent())->setCachedChildIntrinsicContentLogicalHeight(*this, height); > } >@@ -5103,7 +5103,7 @@ bool RenderBox::shouldComputeLogicalWidthFromAspectRatio() const > auto isResolvablePercentageHeight = [this] () { > return style().logicalHeight().isPercentOrCalculated() && (isOutOfFlowPositioned() || percentageLogicalHeightIsResolvable()); > }; >- if (!shouldComputeLogicalWidthFromAspectRatioAndInsets() && !style().logicalHeight().isFixed() && !isResolvablePercentageHeight()) >+ if (!hasOverridingLogicalHeight() && !shouldComputeLogicalWidthFromAspectRatioAndInsets() && !style().logicalHeight().isFixed() && !isResolvablePercentageHeight()) > return false; > > return true; >diff --git a/Source/WebCore/rendering/RenderFlexibleBox.cpp b/Source/WebCore/rendering/RenderFlexibleBox.cpp >index cb23f6d1937a3d605ce194d3574d2670090c5fcc..9a57c02b0c063229557fa80877f02366da9b1067 100644 >--- a/Source/WebCore/rendering/RenderFlexibleBox.cpp >+++ b/Source/WebCore/rendering/RenderFlexibleBox.cpp >@@ -544,6 +544,11 @@ LayoutUnit RenderFlexibleBox::mainAxisContentExtent(LayoutUnit contentLogicalHei > return std::max(0_lu, computedValues.m_extent - borderPaddingAndScrollbar); > } > >+static bool childHasAspectRatio(const RenderBox& child) >+{ >+ return child.hasAspectRatio() || child.style().hasAspectRatio(); >+} >+ > Optional<LayoutUnit> RenderFlexibleBox::computeMainAxisExtentForChild(const RenderBox& child, SizeType sizeType, const Length& size) > { > // If we have a horizontal flow, that means the main size is the width. >@@ -570,7 +575,7 @@ Optional<LayoutUnit> RenderFlexibleBox::computeMainAxisExtentForChild(const Rend > // our logical width is auto, we can just use our cached value. So let's do > // that here. (Compare code in LayoutBlock::computePreferredLogicalWidths) > LayoutUnit borderAndPadding = child.borderAndPaddingLogicalWidth(); >- if (child.style().logicalWidth().isAuto() && !child.hasAspectRatio()) { >+ if (child.style().logicalWidth().isAuto() && !childHasAspectRatio(child)) { > if (size.isMinContent()) > return child.minPreferredLogicalWidth() - borderAndPadding; > if (size.isMaxContent()) >@@ -740,9 +745,9 @@ LayoutPoint RenderFlexibleBox::flowAwareLocationForChild(const RenderBox& child) > > bool RenderFlexibleBox::useChildAspectRatio(const RenderBox& child) const > { >- if (!child.hasAspectRatio()) >+ if (!childHasAspectRatio(child)) > return false; >- if (!child.intrinsicSize().height()) { >+ if (!child.intrinsicSize().height() && !child.style().hasAspectRatio()) { > // We can't compute a ratio in this case. > return false; > } >@@ -752,8 +757,7 @@ bool RenderFlexibleBox::useChildAspectRatio(const RenderBox& child) const > > LayoutUnit RenderFlexibleBox::computeMainSizeFromAspectRatioUsing(const RenderBox& child, Length crossSizeLength) const > { >- ASSERT(child.hasAspectRatio()); >- ASSERT(child.intrinsicSize().height()); >+ ASSERT(childHasAspectRatio(child)); > > auto adjustForBoxSizing = [this] (const RenderBox& box, Length length) -> LayoutUnit { > ASSERT(length.isFixed()); >@@ -783,7 +787,13 @@ LayoutUnit RenderFlexibleBox::computeMainSizeFromAspectRatioUsing(const RenderBo > } > > const LayoutSize& childIntrinsicSize = child.intrinsicSize(); >- double ratio = childIntrinsicSize.width().toFloat() / childIntrinsicSize.height().toFloat(); >+ double ratio; >+ if (child.style().aspectRatioType() == AspectRatioType::Ratio || (child.style().aspectRatioType() == AspectRatioType::AutoAndRatio && childIntrinsicSize.isEmpty())) >+ ratio = child.style().aspectRatioWidth() / child.style().aspectRatioHeight(); >+ else { >+ ASSERT(childIntrinsicSize.height()); >+ ratio = childIntrinsicSize.width().toFloat() / childIntrinsicSize.height().toFloat(); >+ } > if (isHorizontalFlow()) > return LayoutUnit(crossSize.value() * ratio); > return LayoutUnit(crossSize.value() / ratio); >@@ -825,7 +835,7 @@ bool RenderFlexibleBox::childMainSizeIsDefinite(const RenderBox& child, const Le > > bool RenderFlexibleBox::childCrossSizeShouldUseContainerCrossSize(const RenderBox& child) const > { >- if (!child.hasAspectRatio() || !child.intrinsicSize().height()) >+ if (!childHasAspectRatio(child) || !child.intrinsicSize().height()) > return false; > > // 9.8 https://drafts.csswg.org/css-flexbox/#definite-sizes >@@ -1591,7 +1601,7 @@ bool RenderFlexibleBox::needToStretchChildLogicalHeight(const RenderBox& child) > return false; > > // Aspect ratio is properly handled by RenderReplaced during layout. >- if (child.isRenderReplaced() && child.hasAspectRatio()) >+ if (child.isRenderReplaced() && childHasAspectRatio(child)) > return false; > > return child.style().logicalHeight().isAuto(); >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index cb77bb81470a53a15220a51dc7c9fde3bf44a03b..2dcd57329c2f08e1f8d6c34611c38efcd70b348e 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,14 @@ >+2021-02-19 Rob Buis <rbuis@igalia.com> >+ >+ Support aspect-ratio on flexbox items >+ https://bugs.webkit.org/show_bug.cgi?id=219679 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Unskip tests that pass now. >+ >+ * TestExpectations: >+ > 2021-02-18 Simon Fraser <simon.fraser@apple.com> > > Scrolling on https://www.apple.com/ipad-air/ can jitter on certain sections >diff --git a/LayoutTests/TestExpectations b/LayoutTests/TestExpectations >index 4670b3be25158a2071b87183e294966d9e77d06c..31320bcd850d666f9c33d59db6400d22f651dfbd 100644 >--- a/LayoutTests/TestExpectations >+++ b/LayoutTests/TestExpectations >@@ -4551,20 +4551,8 @@ webkit.org/b/214462 imported/w3c/web-platform-tests/css/css-scoping/slotted-plac > webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/abspos-014.html [ ImageOnlyFailure ] > webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/block-aspect-ratio-024.html [ ImageOnlyFailure ] > webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/block-aspect-ratio-028.html [ ImageOnlyFailure ] >-webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/flex-aspect-ratio-001.html [ ImageOnlyFailure ] >-webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/flex-aspect-ratio-002.html [ ImageOnlyFailure ] >-webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/flex-aspect-ratio-004.html [ ImageOnlyFailure ] >-webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/flex-aspect-ratio-005.html [ ImageOnlyFailure ] >-webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/flex-aspect-ratio-008.html [ ImageOnlyFailure ] > webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/flex-aspect-ratio-009.html [ ImageOnlyFailure ] >-webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/flex-aspect-ratio-011.html [ ImageOnlyFailure ] >-webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/flex-aspect-ratio-012.html [ ImageOnlyFailure ] >-webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/flex-aspect-ratio-014.html [ ImageOnlyFailure ] >-webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/flex-aspect-ratio-015.html [ ImageOnlyFailure ] >-webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/flex-aspect-ratio-016.html [ ImageOnlyFailure ] >-webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/flex-aspect-ratio-017.html [ ImageOnlyFailure ] >-webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/flex-aspect-ratio-018.html [ ImageOnlyFailure ] >-webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/flex-aspect-ratio-019.html [ ImageOnlyFailure ] >+# flex-basis:content > webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/flex-aspect-ratio-021.html [ ImageOnlyFailure ] > webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/flex-aspect-ratio-022.html [ ImageOnlyFailure ] > webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/flex-aspect-ratio-025.html [ ImageOnlyFailure ]
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 219679
:
415748
|
415761
|
417080
|
417261
|
417841
|
417966
|
417971
|
418553
|
418734
|
420005
|
420456
|
420624
|
420628
|
420814
|
420937
|
420958
|
420979