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-220861-20210227135447.patch (text/plain), 15.58 KB, created by
Rob Buis
on 2021-02-27 04:54:48 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Rob Buis
Created:
2021-02-27 04:54:48 PST
Size:
15.58 KB
patch
obsolete
>Subversion Revision: 273621 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 270bf3ecc2f7edd294a8fffd0261a1a425ef66f2..ba31550c0257014ab4dee06b701a773496986a03 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,22 @@ >+2021-02-27 Rob Buis <rbuis@igalia.com> >+ >+ Support aspect-ratio in intrinsic sizing >+ https://bugs.webkit.org/show_bug.cgi?id=220861 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ WIP. >+ >+ * rendering/RenderBlock.cpp: >+ (WebCore::RenderBlock::computeChildPreferredLogicalWidths const): >+ * rendering/RenderBox.cpp: >+ (WebCore::RenderBox::constrainLogicalWidthInFragmentByMinMax const): >+ (WebCore::RenderBox::computeIntrinsicLogicalWidths const): >+ (WebCore::RenderBox::computeIntrinsicLogicalWidthUsing const): >+ (WebCore::RenderBox::shouldComputeLogicalHeightFromAspectRatio const): >+ (WebCore::RenderBox::computeLogicalWidthFromAspectRatio const): >+ * rendering/RenderBox.h: >+ > 2021-02-27 Antti Koivisto <antti@apple.com> > > Render tree updates for Text node content mutations should happen during rendering update >diff --git a/Source/WebCore/rendering/RenderBlock.cpp b/Source/WebCore/rendering/RenderBlock.cpp >index 1bf9694ccb06ba6fd5706206be9d92621eeec732..148714cb9cc5e3bb78b84875371bda4c40bb0a3e 100644 >--- a/Source/WebCore/rendering/RenderBlock.cpp >+++ b/Source/WebCore/rendering/RenderBlock.cpp >@@ -2282,6 +2282,8 @@ void RenderBlock::computePreferredLogicalWidths() > if (!isTableCell() && styleToUse.logicalWidth().isFixed() && styleToUse.logicalWidth().value() >= 0 > && !(isDeprecatedFlexItem() && !styleToUse.logicalWidth().intValue())) > m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = adjustContentBoxLogicalWidthForBoxSizing(styleToUse.logicalWidth()); >+ else if (shouldComputeLogicalWidthFromAspectRatio()) >+ m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = computeLogicalWidthFromAspectRatio(); > else > computeIntrinsicLogicalWidths(m_minPreferredLogicalWidth, m_maxPreferredLogicalWidth); > >diff --git a/Source/WebCore/rendering/RenderBox.cpp b/Source/WebCore/rendering/RenderBox.cpp >index 53fd0f0f38ca5afd1079fdc340748b14c9c29000..08d0656e44a420e045c34bd7d497cd52af94d6e1 100644 >--- a/Source/WebCore/rendering/RenderBox.cpp >+++ b/Source/WebCore/rendering/RenderBox.cpp >@@ -651,7 +651,7 @@ void RenderBox::updateLayerTransform() > layer()->updateTransform(); > } > >-LayoutUnit RenderBox::constrainLogicalWidthInFragmentByMinMax(LayoutUnit logicalWidth, LayoutUnit availableWidth, RenderBlock& cb, RenderFragmentContainer* fragment) const >+LayoutUnit RenderBox::constrainLogicalWidthInFragmentByMinMax(LayoutUnit logicalWidth, LayoutUnit availableWidth, RenderBlock& cb, RenderFragmentContainer* fragment, bool allowIntrinsic) const > { > const RenderStyle& styleToUse = style(); > >@@ -660,13 +660,15 @@ LayoutUnit RenderBox::constrainLogicalWidthInFragmentByMinMax(LayoutUnit logical > logicalWidth = std::clamp(logicalWidth, logicalMinWidth, logicalMaxWidth); > } > >- if (!styleToUse.logicalMaxWidth().isUndefined()) >+ if (!styleToUse.logicalMaxWidth().isUndefined() && (allowIntrinsic || !styleToUse.logicalMaxWidth().isIntrinsic())) > logicalWidth = std::min(logicalWidth, computeLogicalWidthInFragmentUsing(MaxSize, styleToUse.logicalMaxWidth(), availableWidth, cb, fragment)); >+ if (!allowIntrinsic && styleToUse.logicalMinWidth().isIntrinsic()) >+ return logicalWidth; > auto minLength = styleToUse.logicalMinWidth(); >- if (styleToUse.hasAspectRatio() && styleToUse.logicalWidth().isAuto() && minLength.isAuto() && styleToUse.overflowInlineDirection() == Overflow::Visible) { >+ if (styleToUse.hasAspectRatio() && minLength.isAuto() && (styleToUse.logicalWidth().isAuto() || styleToUse.logicalWidth().isMinContent() || styleToUse.logicalWidth().isMaxContent()) && styleToUse.overflowInlineDirection() == Overflow::Visible) { > // Make sure we actually used the aspect ratio. > if (shouldComputeLogicalWidthFromAspectRatio()) >- minLength = Length(LengthType::MinContent); >+ minLength = Length(LengthType::MinIntrinsic); > } > return std::max(logicalWidth, computeLogicalWidthInFragmentUsing(MinSize, minLength, availableWidth, cb, fragment)); > } >@@ -681,7 +683,7 @@ LayoutUnit RenderBox::constrainLogicalHeightByMinMax(LayoutUnit logicalHeight, O > auto logicalMinHeight = styleToUse.logicalMinHeight(); > if (logicalMinHeight.isAuto() && shouldComputeLogicalHeightFromAspectRatio() && intrinsicContentHeight && styleToUse.overflowBlockDirection() == Overflow::Visible) > logicalMinHeight = Length(*intrinsicContentHeight, LengthType::Fixed); >- if (logicalMinHeight.isMinContent() || logicalMinHeight.isMaxContent()) >+ if (logicalMinHeight.isMinContent() || logicalMinHeight.isMaxContent() || logicalMinHeight.isMinIntrinsic()) > logicalMinHeight = Length(); > if (Optional<LayoutUnit> computedLogicalHeight = computeLogicalHeightUsing(MinSize, logicalMinHeight, intrinsicContentHeight)) > return std::max(logicalHeight, computedLogicalHeight.value()); >@@ -2605,6 +2607,15 @@ LayoutUnit RenderBox::fillAvailableMeasure(LayoutUnit availableLogicalWidth, Lay > return availableLogicalWidth - marginStart - marginEnd; > } > >+void RenderBox::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth, bool allowIntrinsic) const >+{ >+ if (allowIntrinsic && shouldComputeLogicalWidthFromAspectRatio()) { >+ minLogicalWidth = maxLogicalWidth = computeLogicalWidthFromAspectRatio(); >+ return; >+ } >+ computeIntrinsicLogicalWidths(minLogicalWidth, maxLogicalWidth); >+} >+ > LayoutUnit RenderBox::computeIntrinsicLogicalWidthUsing(Length logicalWidthLength, LayoutUnit availableLogicalWidth, LayoutUnit borderAndPadding) const > { > if (logicalWidthLength.isFillAvailable()) >@@ -2612,9 +2623,9 @@ LayoutUnit RenderBox::computeIntrinsicLogicalWidthUsing(Length logicalWidthLengt > > LayoutUnit minLogicalWidth; > LayoutUnit maxLogicalWidth; >- computeIntrinsicLogicalWidths(minLogicalWidth, maxLogicalWidth); >+ computeIntrinsicLogicalWidths(minLogicalWidth, maxLogicalWidth, !logicalWidthLength.isMinIntrinsic()); > >- if (logicalWidthLength.isMinContent()) >+ if (logicalWidthLength.isMinContent() || logicalWidthLength.isMinIntrinsic()) > return minLogicalWidth + borderAndPadding; > > if (logicalWidthLength.isMaxContent()) >@@ -2637,12 +2648,12 @@ LayoutUnit RenderBox::computeLogicalWidthInFragmentUsing(SizeType widthType, Len > if (widthType == MinSize && logicalWidth.isAuto()) > return adjustBorderBoxLogicalWidthForBoxSizing(0, logicalWidth.type()); > >- if (!logicalWidth.isIntrinsicOrAuto()) { >+ if (!logicalWidth.isIntrinsicOrAuto() && !logicalWidth.isMinIntrinsic()) { > // FIXME: If the containing block flow is perpendicular to our direction we need to use the available logical height instead. > return adjustBorderBoxLogicalWidthForBoxSizing(valueForLength(logicalWidth, availableLogicalWidth), logicalWidth.type()); > } > >- if (logicalWidth.isIntrinsic()) >+ if (logicalWidth.isIntrinsic() || logicalWidth.isMinIntrinsic()) > return computeIntrinsicLogicalWidthUsing(logicalWidth, availableLogicalWidth, borderAndPaddingLogicalWidth()); > > LayoutUnit marginStart; >@@ -5098,7 +5109,7 @@ bool RenderBox::shouldComputeLogicalHeightFromAspectRatio() const > return false; > > auto h = style().logicalHeight(); >- return h.isAuto() || (!isOutOfFlowPositioned() && h.isPercentOrCalculated() && !percentageLogicalHeightIsResolvable()); >+ return h.isAuto() || h.isIntrinsic() || (!isOutOfFlowPositioned() && h.isPercentOrCalculated() && !percentageLogicalHeightIsResolvable()); > } > > bool RenderBox::shouldComputeLogicalWidthFromAspectRatio() const >@@ -5134,7 +5145,7 @@ LayoutUnit RenderBox::computeLogicalWidthFromAspectRatio(RenderFragmentContainer > auto logicalWidth = inlineSizeFromAspectRatio(horizontalBorderAndPaddingExtent(), verticalBorderAndPaddingExtent(), LayoutUnit(style().logicalAspectRatio()), style().boxSizingForAspectRatio(), logicalHeightforAspectRatio); > > LayoutUnit containerWidthInInlineDirection = std::max<LayoutUnit>(0, containingBlockLogicalWidthForContentInFragment(fragment)); >- return constrainLogicalWidthInFragmentByMinMax(logicalWidth, containerWidthInInlineDirection, *containingBlock(), fragment); >+ return constrainLogicalWidthInFragmentByMinMax(logicalWidth, containerWidthInInlineDirection, *containingBlock(), fragment, false); > } > > std::pair<LayoutUnit, LayoutUnit> RenderBox::computeMinMaxLogicalWidthFromAspectRatio() const >diff --git a/Source/WebCore/rendering/RenderBox.h b/Source/WebCore/rendering/RenderBox.h >index 6de6ed6ac6b9688fcb3648dbb4b2ec9a09bb1424..cebdd91e35a6fe37409d6dd90ca073a99fa1dc46 100644 >--- a/Source/WebCore/rendering/RenderBox.h >+++ b/Source/WebCore/rendering/RenderBox.h >@@ -85,7 +85,7 @@ public: > LayoutUnit logicalWidth() const { return style().isHorizontalWritingMode() ? width() : height(); } > LayoutUnit logicalHeight() const { return style().isHorizontalWritingMode() ? height() : width(); } > >- LayoutUnit constrainLogicalWidthInFragmentByMinMax(LayoutUnit, LayoutUnit, RenderBlock&, RenderFragmentContainer* = nullptr) const; >+ LayoutUnit constrainLogicalWidthInFragmentByMinMax(LayoutUnit, LayoutUnit, RenderBlock&, RenderFragmentContainer*, bool allowIntrinsic = true) const; > LayoutUnit constrainLogicalHeightByMinMax(LayoutUnit logicalHeight, Optional<LayoutUnit> intrinsicContentHeight) const; > LayoutUnit constrainContentBoxLogicalHeightByMinMax(LayoutUnit logicalHeight, Optional<LayoutUnit> intrinsicContentHeight) const; > >@@ -649,6 +649,10 @@ override; > > LayoutRect absoluteAnchorRectWithScrollMargin(bool* insideFixed = nullptr) const override; > >+ bool shouldComputeLogicalHeightFromAspectRatio() const; >+ bool shouldComputeLogicalWidthFromAspectRatio() const; >+ LayoutUnit computeLogicalWidthFromAspectRatio(RenderFragmentContainer* = nullptr) const; >+ > protected: > RenderBox(Element&, RenderStyle&&, BaseTypeFlags); > RenderBox(Document&, RenderStyle&&, BaseTypeFlags); >@@ -698,10 +702,7 @@ protected: > > void incrementVisuallyNonEmptyPixelCountIfNeeded(const IntSize&); > >- bool shouldComputeLogicalHeightFromAspectRatio() const; >- bool shouldComputeLogicalWidthFromAspectRatio() const; > bool shouldComputeLogicalWidthFromAspectRatioAndInsets() const; >- LayoutUnit computeLogicalWidthFromAspectRatio(RenderFragmentContainer* = nullptr) const; > std::pair<LayoutUnit, LayoutUnit> computeMinMaxLogicalWidthFromAspectRatio() const; > > static LayoutUnit blockSizeFromAspectRatio(LayoutUnit borderPaddingInlineSum, LayoutUnit borderPaddingBlockSum, LayoutUnit aspectRatio, BoxSizing boxSizing, LayoutUnit inlineSize) >@@ -749,6 +750,7 @@ private: > LayoutUnit fillAvailableMeasure(LayoutUnit availableLogicalWidth, LayoutUnit& marginStart, LayoutUnit& marginEnd) const; > > virtual void computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const; >+ void computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth, bool allowIntrinsic) const; > > // This function calculates the minimum and maximum preferred widths for an object. > // These values are used in shrink-to-fit layout systems. >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index 2c030c94cee3c0540667fe7425d9a6fb3a8700d3..5e182aae1594e3cc86d8b4bf93f5c0a937c275f7 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,14 @@ >+2021-02-27 Rob Buis <rbuis@igalia.com> >+ >+ Support aspect-ratio in intrinsic sizing >+ https://bugs.webkit.org/show_bug.cgi?id=220861 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Enable some tests that pass now. >+ >+ * TestExpectations: >+ > 2021-02-27 Antti Koivisto <antti@apple.com> > > Render tree updates for Text node content mutations should happen during rendering update >diff --git a/LayoutTests/TestExpectations b/LayoutTests/TestExpectations >index d95d40f613cf7781e41cef03df79e7b6364694f3..45373037d427065711f768b999c229cc0572818a 100644 >--- a/LayoutTests/TestExpectations >+++ b/LayoutTests/TestExpectations >@@ -4547,6 +4547,7 @@ webkit.org/b/214462 imported/w3c/web-platform-tests/css/css-scoping/shadow-direc > webkit.org/b/214462 imported/w3c/web-platform-tests/css/css-scoping/shadow-directionality-002.tentative.html [ ImageOnlyFailure ] > webkit.org/b/214462 imported/w3c/web-platform-tests/css/css-scoping/slotted-placeholder.html [ ImageOnlyFailure ] > >+# contain-intrinsic-size > 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 ] >@@ -4556,21 +4557,8 @@ webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/ > 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 ] > webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/flex-aspect-ratio-026.html [ ImageOnlyFailure ] >-webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/grid-aspect-ratio-015.html [ ImageOnlyFailure ] >-webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/grid-aspect-ratio-016.html [ ImageOnlyFailure ] >-webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/grid-aspect-ratio-017.html [ ImageOnlyFailure ] >-webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/intrinsic-size-001.html [ ImageOnlyFailure ] >-webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/intrinsic-size-002.html [ ImageOnlyFailure ] >-webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/intrinsic-size-004.html [ ImageOnlyFailure ] > webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/intrinsic-size-005.html [ ImageOnlyFailure ] >-webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/intrinsic-size-006.html [ ImageOnlyFailure ] > webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/intrinsic-size-008.html [ ImageOnlyFailure ] >-webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/intrinsic-size-010.html [ ImageOnlyFailure ] >-webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/intrinsic-size-011.html [ ImageOnlyFailure ] >-webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/intrinsic-size-012.html [ ImageOnlyFailure ] >-webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/intrinsic-size-013.html [ ImageOnlyFailure ] >-webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/intrinsic-size-014.html [ ImageOnlyFailure ] >-webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/intrinsic-size-015.html [ ImageOnlyFailure ] > webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/replaced-element-031.html [ ImageOnlyFailure ] > webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/replaced-element-032.html [ ImageOnlyFailure ] > webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/replaced-element-033.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 220861
:
418150
|
418632
|
419498
|
420826
|
420831
|
420944
|
421135
|
421148
|
421210
|
421228
|
421393
|
421744
|
421751
|
421754
|
421779
|
422053
|
422528
|
422552