⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 280889 in webkit


Ignore:
Timestamp:
Aug 11, 2021, 12:53:06 AM (5 years ago)
Author:
cathiechen
Message:

REGRESSION (r277997): Max-height not applied for image
https://bugs.webkit.org/show_bug.cgi?id=228872

Reviewed by Antti Koivisto.

Source/WebCore:

The image get stretched because constrainLogicalHeightByMinMax uses the intrinsic height for the minimum height.
According to [1], the automatic minimum size in the ratio-dependent axis of a box is its min-content size,
not the intrinsic size. To fix this, the ratio-dependent minimum height of a box should be computed from aspect-ratio
if it doesn't have any child, otherwise, then it should consider the intrinsic height.

[1] https://www.w3.org/TR/css-sizing-4/#aspect-ratio-minimum

  • rendering/RenderBox.cpp:

(WebCore::RenderBox::constrainLogicalHeightByMinMax const): The minimum height is computed from aspect-ratio if it doesn't have any child.

LayoutTests:

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r280880 r280889  
     12021-08-11  Cathie Chen  <cathiechen@igalia.com>
     2
     3        REGRESSION (r277997): Max-height not applied for image
     4        https://bugs.webkit.org/show_bug.cgi?id=228872
     5
     6        Reviewed by Antti Koivisto.
     7
     8        * TestExpectations:
     9
    1102021-08-10  Lauro Moura  <lmoura@igalia.com>
    211
  • trunk/LayoutTests/TestExpectations

    r280881 r280889  
    47034703webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/flex-aspect-ratio-025.html [ ImageOnlyFailure ]
    47044704webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/flex-aspect-ratio-026.html [ ImageOnlyFailure ]
    4705 webkit.org/b/228872 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/flex-aspect-ratio-029.html [ ImageOnlyFailure ]
    4706 webkit.org/b/228872 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/flex-aspect-ratio-030.html [ ImageOnlyFailure ]
    47074705webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/contain-intrinsic-size/contain-intrinsic-size-001.html [ ImageOnlyFailure ]
    47084706webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/contain-intrinsic-size/contain-intrinsic-size-002.html [ ImageOnlyFailure ]
  • trunk/Source/WebCore/ChangeLog

    r280887 r280889  
     12021-08-11  Cathie Chen  <cathiechen@igalia.com>
     2
     3        REGRESSION (r277997): Max-height not applied for image
     4        https://bugs.webkit.org/show_bug.cgi?id=228872
     5
     6        Reviewed by Antti Koivisto.
     7
     8        The image get stretched because constrainLogicalHeightByMinMax uses the intrinsic height for the minimum height.
     9        According to [1], the automatic minimum size in the ratio-dependent axis of a box is its min-content size,
     10        not the intrinsic size. To fix this, the ratio-dependent minimum height of a box should be computed from aspect-ratio
     11        if it doesn't have any child, otherwise, then it should consider the intrinsic height.
     12
     13        [1] https://www.w3.org/TR/css-sizing-4/#aspect-ratio-minimum
     14
     15        * rendering/RenderBox.cpp:
     16        (WebCore::RenderBox::constrainLogicalHeightByMinMax const): The minimum height is computed from aspect-ratio if it doesn't have any child.
     17
    1182021-08-11  Rob Buis  <rbuis@igalia.com>
    219
  • trunk/Source/WebCore/rendering/RenderBox.cpp

    r280631 r280889  
    678678    }
    679679    auto logicalMinHeight = styleToUse.logicalMinHeight();
    680     if (logicalMinHeight.isAuto() && shouldComputeLogicalHeightFromAspectRatio() && intrinsicContentHeight && styleToUse.overflowBlockDirection() == Overflow::Visible)
    681         logicalMinHeight = Length(*intrinsicContentHeight, LengthType::Fixed);
     680    if (logicalMinHeight.isAuto() && shouldComputeLogicalHeightFromAspectRatio() && intrinsicContentHeight && styleToUse.overflowBlockDirection() == Overflow::Visible) {
     681        auto heightFromAspectRatio = blockSizeFromAspectRatio(horizontalBorderAndPaddingExtent(), verticalBorderAndPaddingExtent(), LayoutUnit(style().logicalAspectRatio()), style().boxSizingForAspectRatio(), logicalWidth()) - borderAndPaddingLogicalHeight();
     682        if (firstChild())
     683            heightFromAspectRatio = std::max(heightFromAspectRatio, *intrinsicContentHeight);
     684        logicalMinHeight = Length(heightFromAspectRatio, LengthType::Fixed);
     685    }
    682686    if (logicalMinHeight.isMinContent() || logicalMinHeight.isMaxContent())
    683687        logicalMinHeight = Length();
Note: See TracChangeset for help on using the changeset viewer.