- Revision
- 273753
- Author
- [email protected]
- Date
- 2021-03-02 12:23:49 -0800 (Tue, 02 Mar 2021)
Log Message
Take box-sizing into account in replaced element intrinsic sizing
https://bugs.webkit.org/show_bug.cgi?id=221671
Patch by Rob Buis <[email protected]> on 2021-03-02
Reviewed by Simon Fraser.
LayoutTests/imported/w3c:
Sync test.
* web-platform-tests/css/css-sizing/aspect-ratio/replaced-element-032.html:
Source/WebCore:
Take box-sizing into account in replaced element intrinsic sizing when
using aspect-ratio, but keep using content-box when resolving
width/height when no aspect-ratio is set.
Tests: imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/replaced-element-031.html
imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/replaced-element-032.html
imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/replaced-element-033.html
* rendering/RenderReplaced.cpp:
(WebCore::resolveWidthForRatio):
(WebCore::RenderReplaced::computeReplacedLogicalWidth const):
(WebCore::resolveHeightForRatio):
(WebCore::RenderReplaced::computeReplacedLogicalHeight const):
LayoutTests:
Enable some tests that pass now.
* TestExpectations:
Modified Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (273752 => 273753)
--- trunk/LayoutTests/ChangeLog 2021-03-02 20:08:20 UTC (rev 273752)
+++ trunk/LayoutTests/ChangeLog 2021-03-02 20:23:49 UTC (rev 273753)
@@ -1,3 +1,14 @@
+2021-03-02 Rob Buis <[email protected]>
+
+ Take box-sizing into account in replaced element intrinsic sizing
+ https://bugs.webkit.org/show_bug.cgi?id=221671
+
+ Reviewed by Simon Fraser.
+
+ Enable some tests that pass now.
+
+ * TestExpectations:
+
2021-03-02 Chris Gambrell <[email protected]>
[LayoutTests] Convert http/tests/uri convert PHP to Python
Modified: trunk/LayoutTests/TestExpectations (273752 => 273753)
--- trunk/LayoutTests/TestExpectations 2021-03-02 20:08:20 UTC (rev 273752)
+++ trunk/LayoutTests/TestExpectations 2021-03-02 20:23:49 UTC (rev 273753)
@@ -4571,9 +4571,6 @@
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 ]
webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/table-element-001.html [ ImageOnlyFailure ]
webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/contain-intrinsic-size/contain-intrinsic-size-001.html [ ImageOnlyFailure ]
webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/contain-intrinsic-size/contain-intrinsic-size-002.html [ ImageOnlyFailure ]
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (273752 => 273753)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2021-03-02 20:08:20 UTC (rev 273752)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2021-03-02 20:23:49 UTC (rev 273753)
@@ -1,3 +1,14 @@
+2021-03-02 Rob Buis <[email protected]>
+
+ Take box-sizing into account in replaced element intrinsic sizing
+ https://bugs.webkit.org/show_bug.cgi?id=221671
+
+ Reviewed by Simon Fraser.
+
+ Sync test.
+
+ * web-platform-tests/css/css-sizing/aspect-ratio/replaced-element-032.html:
+
2021-02-28 Antoine Quint <[email protected]>
Blending of border-image-width should be discrete between "auto" values and other types
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/replaced-element-032.html (273752 => 273753)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/replaced-element-032.html 2021-03-02 20:08:20 UTC (rev 273752)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/replaced-element-032.html 2021-03-02 20:23:49 UTC (rev 273753)
@@ -23,12 +23,16 @@
border-top is 20x40 and the content box is 20x60.
(note: height here is the block size of content-box.)
- 3rd: A green rect 20x100.
- border-top is 20x40 and the content box is 20x60 because we compute
+ 3rd: A green rect 10x100.
+ border-top is 10x40 and the content box is 10x60 because we compute
the inline size by aspect-ratio which works with border-box and so the
- inline size is 100px / 5 = 20px.
+ inline size is 100px / 10 = 10px.
(note: height here is the block size of border-box.)
+
+ 4th: A green rect 10x100.
+ border-top is 10x40 and the content box is 10x60 to add up to 10x100.
-->
<img src="" style="height: 100px; aspect-ratio: auto 1/10; box-sizing: border-box;"
><img src="" style="height: 60px; aspect-ratio: 1/3; box-sizing: content-box;"
-><img src="" style="height: 100px; aspect-ratio: 1/5; box-sizing: border-box;">
+><img src="" style="height: 100px; aspect-ratio: 1/10; box-sizing: border-box;"
+><img src="" style="width: 10px; aspect-ratio: 1/6; box-sizing: content-box;">
Modified: trunk/Source/WebCore/ChangeLog (273752 => 273753)
--- trunk/Source/WebCore/ChangeLog 2021-03-02 20:08:20 UTC (rev 273752)
+++ trunk/Source/WebCore/ChangeLog 2021-03-02 20:23:49 UTC (rev 273753)
@@ -1,3 +1,24 @@
+2021-03-02 Rob Buis <[email protected]>
+
+ Take box-sizing into account in replaced element intrinsic sizing
+ https://bugs.webkit.org/show_bug.cgi?id=221671
+
+ Reviewed by Simon Fraser.
+
+ Take box-sizing into account in replaced element intrinsic sizing when
+ using aspect-ratio, but keep using content-box when resolving
+ width/height when no aspect-ratio is set.
+
+ Tests: imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/replaced-element-031.html
+ imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/replaced-element-032.html
+ imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/replaced-element-033.html
+
+ * rendering/RenderReplaced.cpp:
+ (WebCore::resolveWidthForRatio):
+ (WebCore::RenderReplaced::computeReplacedLogicalWidth const):
+ (WebCore::resolveHeightForRatio):
+ (WebCore::RenderReplaced::computeReplacedLogicalHeight const):
+
2021-03-02 Antoine Quint <[email protected]>
Crash under KeyframeEffect::setTarget()
Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (273752 => 273753)
--- trunk/Source/WebCore/rendering/RenderBox.cpp 2021-03-02 20:08:20 UTC (rev 273752)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp 2021-03-02 20:23:49 UTC (rev 273753)
@@ -2489,9 +2489,9 @@
static LayoutUnit inlineSizeFromAspectRatio(LayoutUnit borderPaddingInlineSum, LayoutUnit borderPaddingBlockSum, LayoutUnit aspectRatio, BoxSizing boxSizing, LayoutUnit blockSize)
{
if (boxSizing == BoxSizing::BorderBox)
- return blockSize * LayoutUnit(aspectRatio);
+ return blockSize * aspectRatio;
- return ((blockSize - borderPaddingBlockSum) * LayoutUnit(aspectRatio)) + borderPaddingInlineSum;
+ return ((blockSize - borderPaddingBlockSum) * aspectRatio) + borderPaddingInlineSum;
}
void RenderBox::computeLogicalWidthInFragment(LogicalExtentComputedValues& computedValues, RenderFragmentContainer* fragment) const
Modified: trunk/Source/WebCore/rendering/RenderReplaced.cpp (273752 => 273753)
--- trunk/Source/WebCore/rendering/RenderReplaced.cpp 2021-03-02 20:08:20 UTC (rev 273752)
+++ trunk/Source/WebCore/rendering/RenderReplaced.cpp 2021-03-02 20:23:49 UTC (rev 273753)
@@ -532,6 +532,13 @@
return computeReplacedLogicalWidthRespectingMinMaxWidth(logicalWidth, shouldComputePreferred);
}
+static inline LayoutUnit resolveWidthForRatio(LayoutUnit borderAndPaddingLogicalHeight, LayoutUnit borderAndPaddingLogicalWidth, LayoutUnit logicalHeight, double aspectRatio, BoxSizing boxSizing)
+{
+ if (boxSizing == BoxSizing::BorderBox)
+ return LayoutUnit(round((logicalHeight + borderAndPaddingLogicalHeight) * aspectRatio)) - borderAndPaddingLogicalWidth;
+ return LayoutUnit(round(logicalHeight * aspectRatio));
+}
+
LayoutUnit RenderReplaced::computeReplacedLogicalWidth(ShouldComputePreferred shouldComputePreferred) const
{
if (style().logicalWidth().isSpecified() || style().logicalWidth().isIntrinsic())
@@ -567,7 +574,10 @@
if (intrinsicRatio && ((computedHeightIsAuto && !hasIntrinsicWidth && hasIntrinsicHeight) || !computedHeightIsAuto)) {
LayoutUnit estimatedUsedWidth = hasIntrinsicWidth ? LayoutUnit(constrainedSize.width()) : computeConstrainedLogicalWidth(shouldComputePreferred);
LayoutUnit logicalHeight = computeReplacedLogicalHeight(Optional<LayoutUnit>(estimatedUsedWidth));
- return computeReplacedLogicalWidthRespectingMinMaxWidth(roundToInt(round(logicalHeight * intrinsicRatio)), shouldComputePreferred);
+ BoxSizing boxSizing = BoxSizing::ContentBox;
+ if (style().hasAspectRatio())
+ boxSizing = style().boxSizingForAspectRatio();
+ return computeReplacedLogicalWidthRespectingMinMaxWidth(resolveWidthForRatio(borderAndPaddingLogicalHeight(), borderAndPaddingLogicalWidth(), logicalHeight, intrinsicRatio, boxSizing), shouldComputePreferred);
}
@@ -596,6 +606,13 @@
return computeReplacedLogicalWidthRespectingMinMaxWidth(intrinsicLogicalWidth(), shouldComputePreferred);
}
+static inline LayoutUnit resolveHeightForRatio(LayoutUnit borderAndPaddingLogicalWidth, LayoutUnit borderAndPaddingLogicalHeight, LayoutUnit logicalWidth, double aspectRatio, BoxSizing boxSizing)
+{
+ if (boxSizing == BoxSizing::BorderBox)
+ return LayoutUnit(round((logicalWidth + borderAndPaddingLogicalWidth) / aspectRatio)) - borderAndPaddingLogicalHeight;
+ return LayoutUnit(round(logicalWidth / aspectRatio));
+}
+
LayoutUnit RenderReplaced::computeReplacedLogicalHeight(Optional<LayoutUnit> estimatedUsedWidth) const
{
// 10.5 Content height: the 'height' property: http://www.w3.org/TR/CSS21/visudet.html#propdef-height
@@ -625,7 +642,10 @@
// (used width) / (intrinsic ratio)
if (intrinsicRatio) {
LayoutUnit usedWidth = estimatedUsedWidth ? estimatedUsedWidth.value() : availableLogicalWidth();
- return computeReplacedLogicalHeightRespectingMinMaxHeight(roundToInt(round(usedWidth / intrinsicRatio)));
+ BoxSizing boxSizing = BoxSizing::ContentBox;
+ if (style().hasAspectRatio())
+ boxSizing = style().boxSizingForAspectRatio();
+ return computeReplacedLogicalHeightRespectingMinMaxHeight(resolveHeightForRatio(borderAndPaddingLogicalWidth(), borderAndPaddingLogicalHeight(), usedWidth, intrinsicRatio, boxSizing));
}
// Otherwise, if 'height' has a computed value of 'auto', and the element has an intrinsic height, then that intrinsic height is the used value of 'height'.