Commit 694d539c authored by Christian Biesinger's avatar Christian Biesinger Committed by Commit Bot

[AspectRatio] Correctly handle insets for legacy abspos

Given top: 0; bottom: 0; width: auto; aspect-ratio: 1/1;, we should
compute the width from the height.

R=ikilpatrick@chromium.org, mstensho@chromium.org

Bug: 1083010
Change-Id: I2ea7a791f827dc42ca07e0aaa1238584bfc47a32
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2442368
Commit-Queue: Christian Biesinger <cbiesinger@chromium.org>
Auto-Submit: Christian Biesinger <cbiesinger@chromium.org>
Reviewed-by: default avatarMorten Stenshorne <mstensho@chromium.org>
Cr-Commit-Position: refs/heads/master@{#812688}
parent 8bf9a42c
...@@ -3836,9 +3836,10 @@ LayoutUnit LayoutBox::ContainerWidthInInlineDirection() const { ...@@ -3836,9 +3836,10 @@ LayoutUnit LayoutBox::ContainerWidthInInlineDirection() const {
bool LayoutBox::ShouldComputeLogicalWidthFromAspectRatio( bool LayoutBox::ShouldComputeLogicalWidthFromAspectRatio(
LayoutUnit* out_logical_height) const { LayoutUnit* out_logical_height) const {
NOT_DESTROYED(); NOT_DESTROYED();
if (StyleRef().AspectRatio().IsAuto() || if (!ShouldComputeLogicalWidthFromAspectRatioAndInsets() &&
(!StyleRef().LogicalHeight().IsFixed() && (StyleRef().AspectRatio().IsAuto() ||
!StyleRef().LogicalHeight().IsPercentOrCalc())) { (!StyleRef().LogicalHeight().IsFixed() &&
!StyleRef().LogicalHeight().IsPercentOrCalc()))) {
return false; return false;
} }
......
...@@ -560,12 +560,25 @@ class CORE_EXPORT LayoutBox : public LayoutBoxModelObject { ...@@ -560,12 +560,25 @@ class CORE_EXPORT LayoutBox : public LayoutBoxModelObject {
LayoutUnit* logical_height = nullptr) const; LayoutUnit* logical_height = nullptr) const;
bool ShouldComputeLogicalHeightFromAspectRatio() const { bool ShouldComputeLogicalHeightFromAspectRatio() const {
NOT_DESTROYED(); NOT_DESTROYED();
if (ShouldComputeLogicalWidthFromAspectRatioAndInsets())
return false;
Length h = StyleRef().LogicalHeight(); Length h = StyleRef().LogicalHeight();
return !StyleRef().AspectRatio().IsAuto() && return !StyleRef().AspectRatio().IsAuto() &&
(h.IsAuto() || (h.IsAuto() ||
(!IsOutOfFlowPositioned() && h.IsPercentOrCalc() && (!IsOutOfFlowPositioned() && h.IsPercentOrCalc() &&
ComputePercentageLogicalHeight(h) == kIndefiniteSize)); ComputePercentageLogicalHeight(h) == kIndefiniteSize));
} }
bool ShouldComputeLogicalWidthFromAspectRatioAndInsets() const {
NOT_DESTROYED();
const ComputedStyle& style = StyleRef();
if (style.AspectRatio().IsAuto() || !IsOutOfFlowPositioned())
return false;
if (style.Width().IsAuto() && style.Height().IsAuto() &&
!style.LogicalTop().IsAuto() && !style.LogicalBottom().IsAuto() &&
(style.LogicalLeft().IsAuto() || style.LogicalRight().IsAuto()))
return true;
return false;
}
bool ComputeLogicalWidthFromAspectRatio(LayoutUnit* logical_width) const; bool ComputeLogicalWidthFromAspectRatio(LayoutUnit* logical_width) const;
MinMaxSizes ComputeMinMaxLogicalWidthFromAspectRatio() const; MinMaxSizes ComputeMinMaxLogicalWidthFromAspectRatio() const;
......
...@@ -118,7 +118,6 @@ crbug.com/591099 external/wpt/css/css-shapes/shape-outside/supported-shapes/inse ...@@ -118,7 +118,6 @@ crbug.com/591099 external/wpt/css/css-shapes/shape-outside/supported-shapes/inse
crbug.com/591099 external/wpt/css/css-shapes/shape-outside/supported-shapes/polygon/shape-outside-polygon-017.html [ Failure ] crbug.com/591099 external/wpt/css/css-shapes/shape-outside/supported-shapes/polygon/shape-outside-polygon-017.html [ Failure ]
### external/wpt/css/css-sizing/ ### external/wpt/css/css-sizing/
crbug.com/1045668 external/wpt/css/css-sizing/aspect-ratio/abspos-004.tentative.html [ Failure ]
crbug.com/1045668 external/wpt/css/css-sizing/aspect-ratio/abspos-013.tentative.html [ Pass ] crbug.com/1045668 external/wpt/css/css-sizing/aspect-ratio/abspos-013.tentative.html [ Pass ]
crbug.com/1045668 external/wpt/css/css-sizing/aspect-ratio/block-aspect-ratio-024.tentative.html [ Failure ] crbug.com/1045668 external/wpt/css/css-sizing/aspect-ratio/block-aspect-ratio-024.tentative.html [ Failure ]
crbug.com/1045668 external/wpt/css/css-sizing/aspect-ratio/block-aspect-ratio-028.tentative.html [ Failure ] crbug.com/1045668 external/wpt/css/css-sizing/aspect-ratio/block-aspect-ratio-028.tentative.html [ Failure ]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment