Changeset 272718 in webkit


Ignore:
Timestamp:
Feb 11, 2021 2:55:20 AM (17 months ago)
Author:
commit-queue@webkit.org
Message:

Handle min-width/min-height:auto for aspect-ratio
https://bugs.webkit.org/show_bug.cgi?id=220582

Patch by Rob Buis <rbuis@igalia.com> on 2021-02-11
Reviewed by Antti Koivisto.

Source/WebCore:

Implement automatic minimum size [1] handling for aspect-ratio
as specified here [2].

[1] https://drafts.csswg.org/css-sizing-3/#automatic-minimum-size
[2] https://drafts.csswg.org/css-sizing-4/#aspect-ratio-minimum

  • rendering/RenderBox.cpp:

(WebCore::RenderBox::constrainLogicalWidthInFragmentByMinMax const):
(WebCore::RenderBox::constrainLogicalHeightByMinMax const):
(WebCore::RenderBox::computePositionedLogicalWidthUsing const):
(WebCore::RenderBox::computePositionedLogicalHeight const):
(WebCore::RenderBox::computePositionedLogicalHeightUsing const):

LayoutTests:

Enable tests that pass now.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r272715 r272718  
     12021-02-11  Rob Buis  <rbuis@igalia.com>
     2
     3        Handle min-width/min-height:auto for aspect-ratio
     4        https://bugs.webkit.org/show_bug.cgi?id=220582
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Enable tests that pass now.
     9
     10        * TestExpectations:
     11
    1122021-02-11  Myles C. Maxfield  <mmaxfield@apple.com>
    213
  • trunk/LayoutTests/TestExpectations

    r272707 r272718  
    45564556webkit.org/b/214462 imported/w3c/web-platform-tests/css/css-scoping/slotted-placeholder.html [ ImageOnlyFailure ]
    45574557
    4558 webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/abspos-012.html [ ImageOnlyFailure ]
    4559 webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/abspos-013.html [ ImageOnlyFailure ]
    45604558webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/abspos-014.html [ ImageOnlyFailure ]
    4561 webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/block-aspect-ratio-009.html [ ImageOnlyFailure ]
    4562 webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/block-aspect-ratio-014.html [ ImageOnlyFailure ]
    4563 webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/block-aspect-ratio-015.html [ ImageOnlyFailure ]
    4564 webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/block-aspect-ratio-017.html [ ImageOnlyFailure ]
    45654559webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/block-aspect-ratio-024.html [ ImageOnlyFailure ]
    45664560webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/block-aspect-ratio-028.html [ ImageOnlyFailure ]
     
    45704564webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/flex-aspect-ratio-004.html [ ImageOnlyFailure ]
    45714565webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/flex-aspect-ratio-005.html [ ImageOnlyFailure ]
     4566webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/flex-aspect-ratio-008.html [ ImageOnlyFailure ]
    45724567webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/flex-aspect-ratio-009.html [ ImageOnlyFailure ]
    45734568webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/flex-aspect-ratio-011.html [ ImageOnlyFailure ]
  • trunk/Source/WebCore/ChangeLog

    r272715 r272718  
     12021-02-11  Rob Buis  <rbuis@igalia.com>
     2
     3        Handle min-width/min-height:auto for aspect-ratio
     4        https://bugs.webkit.org/show_bug.cgi?id=220582
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Implement automatic minimum size [1] handling for aspect-ratio
     9        as specified here [2].
     10
     11        [1] https://drafts.csswg.org/css-sizing-3/#automatic-minimum-size
     12        [2] https://drafts.csswg.org/css-sizing-4/#aspect-ratio-minimum
     13
     14        * rendering/RenderBox.cpp:
     15        (WebCore::RenderBox::constrainLogicalWidthInFragmentByMinMax const):
     16        (WebCore::RenderBox::constrainLogicalHeightByMinMax const):
     17        (WebCore::RenderBox::computePositionedLogicalWidthUsing const):
     18        (WebCore::RenderBox::computePositionedLogicalHeight const):
     19        (WebCore::RenderBox::computePositionedLogicalHeightUsing const):
     20
    1212021-02-11  Myles C. Maxfield  <mmaxfield@apple.com>
    222
  • trunk/Source/WebCore/rendering/RenderBox.cpp

    r272569 r272718  
    663663    if (!styleToUse.logicalMaxWidth().isUndefined())
    664664        logicalWidth = std::min(logicalWidth, computeLogicalWidthInFragmentUsing(MaxSize, styleToUse.logicalMaxWidth(), availableWidth, cb, fragment));
    665     return std::max(logicalWidth, computeLogicalWidthInFragmentUsing(MinSize, styleToUse.logicalMinWidth(), availableWidth, cb, fragment));
     665    auto minLength = styleToUse.logicalMinWidth();
     666    if (styleToUse.hasAspectRatio() && styleToUse.logicalWidth().isAuto() && minLength.isAuto() && styleToUse.overflowInlineDirection() == Overflow::Visible) {
     667        // Make sure we actually used the aspect ratio.
     668        if (shouldComputeLogicalWidthFromAspectRatio())
     669            minLength = Length(MinContent);
     670    }
     671    return std::max(logicalWidth, computeLogicalWidthInFragmentUsing(MinSize, minLength, availableWidth, cb, fragment));
    666672}
    667673
     
    673679            logicalHeight = std::min(logicalHeight, maxH.value());
    674680    }
    675     if (Optional<LayoutUnit> computedLogicalHeight = computeLogicalHeightUsing(MinSize, styleToUse.logicalMinHeight(), intrinsicContentHeight))
     681    auto logicalMinHeight = styleToUse.logicalMinHeight();
     682    if (logicalMinHeight.isAuto() && shouldComputeLogicalHeightFromAspectRatio() && intrinsicContentHeight && styleToUse.overflowBlockDirection() == Overflow::Visible)
     683        logicalMinHeight = Length(*intrinsicContentHeight, Fixed);
     684    if (Optional<LayoutUnit> computedLogicalHeight = computeLogicalHeightUsing(MinSize, logicalMinHeight, intrinsicContentHeight))
    676685        return std::max(logicalHeight, computedLogicalHeight.value());
    677686    return logicalHeight;
     
    37883797    ASSERT(widthType == MinSize || widthType == MainOrPreferredSize || !logicalWidth.isAuto());
    37893798    auto originalLogicalWidthType = logicalWidth.type();
    3790     if (widthType == MinSize && logicalWidth.isAuto())
    3791         logicalWidth = Length(0, Fixed);
    3792     else if (widthType == MainOrPreferredSize && logicalWidth.isAuto() && shouldComputeLogicalWidthFromAspectRatio())
     3799    if (widthType == MinSize && logicalWidth.isAuto()) {
     3800        if (shouldComputeLogicalWidthFromAspectRatio()) {
     3801            LayoutUnit minLogicalWidth;
     3802            LayoutUnit maxLogicalWidth;
     3803            computeIntrinsicLogicalWidths(minLogicalWidth, maxLogicalWidth);
     3804            logicalWidth = Length(minLogicalWidth, Fixed);
     3805        } else
     3806            logicalWidth = Length(0, Fixed);
     3807    } else if (widthType == MainOrPreferredSize && logicalWidth.isAuto() && shouldComputeLogicalWidthFromAspectRatio())
    37933808        logicalWidth = Length(computeLogicalWidthFromAspectRatio(), Fixed);
    37943809    else if (logicalWidth.isIntrinsic())
     
    40614076
    40624077    // Calculate constraint equation values for 'min-height' case.
    4063     if (!styleToUse.logicalMinHeight().isZero() || styleToUse.logicalMinHeight().isIntrinsic()) {
     4078    Length logicalMinHeight = styleToUse.logicalMinHeight();
     4079    if (logicalMinHeight.isAuto() || !logicalMinHeight.isZero() || logicalMinHeight.isIntrinsic()) {
    40644080        LogicalExtentComputedValues minValues;
    40654081
     
    41264142{
    41274143    ASSERT(heightType == MinSize || heightType == MainOrPreferredSize || !logicalHeightLength.isAuto());
    4128     if (heightType == MinSize && logicalHeightLength.isAuto())
    4129         logicalHeightLength = Length(0, Fixed);
     4144    if (heightType == MinSize && logicalHeightLength.isAuto()) {
     4145        if (shouldComputeLogicalHeightFromAspectRatio())
     4146            logicalHeightLength = Length(logicalHeight, Fixed);
     4147        else
     4148            logicalHeightLength = Length(0, Fixed);
     4149    }
    41304150
    41314151    // 'top' and 'bottom' cannot both be 'auto' because 'top would of been
Note: See TracChangeset for help on using the changeset viewer.