Changeset 271293 in webkit


Ignore:
Timestamp:
Jan 8, 2021 5:29:01 AM (19 months ago)
Author:
commit-queue@webkit.org
Message:

Take aspect-ratio into account for percentage resolution
https://bugs.webkit.org/show_bug.cgi?id=220143

Patch by Rob Buis <rbuis@igalia.com> on 2021-01-08
Reviewed by Darin Adler.

Source/WebCore:

Add aspect-ratio handling to containing block available height
computations to fix percentage resolution on its children.

  • rendering/RenderBlock.cpp:

(WebCore::RenderBlock::availableLogicalHeightForPercentageComputation const):

  • rendering/RenderBox.cpp:

(WebCore::RenderBox::availableLogicalHeightUsing const):
(WebCore::blockSizeFromAspectRatio): Deleted.

  • rendering/RenderBox.h:

(WebCore::RenderBox::blockSizeFromAspectRatio):

LayoutTests:

Enable some tests that pass now.

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r271290 r271293  
     12021-01-08  Rob Buis  <rbuis@igalia.com>
     2
     3        Take aspect-ratio into account for percentage resolution
     4        https://bugs.webkit.org/show_bug.cgi?id=220143
     5
     6        Reviewed by Darin Adler.
     7
     8        Enable some tests that pass now.
     9
     10        * TestExpectations:
     11
    1122021-01-08  Philippe Normand  <pnormand@igalia.com>
    213
  • trunk/LayoutTests/TestExpectations

    r271223 r271293  
    44634463webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/intrinsic-size-008.html [ ImageOnlyFailure ]
    44644464webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/parsing/contain-intrinsic-size-invalid.html [ ImageOnlyFailure ]
    4465 webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/percentage-resolution-001.html [ ImageOnlyFailure ]
    4466 webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/percentage-resolution-002.html [ ImageOnlyFailure ]
    4467 webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/percentage-resolution-004.html [ ImageOnlyFailure ]
    44684465webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/contain-intrinsic-size/contain-intrinsic-size-001.html [ ImageOnlyFailure ]
    44694466webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/contain-intrinsic-size/contain-intrinsic-size-002.html [ ImageOnlyFailure ]
  • trunk/Source/WebCore/ChangeLog

    r271290 r271293  
     12021-01-08  Rob Buis  <rbuis@igalia.com>
     2
     3        Take aspect-ratio into account for percentage resolution
     4        https://bugs.webkit.org/show_bug.cgi?id=220143
     5
     6        Reviewed by Darin Adler.
     7
     8        Add aspect-ratio handling to containing block available height
     9        computations to fix percentage resolution on its children.
     10
     11        * rendering/RenderBlock.cpp:
     12        (WebCore::RenderBlock::availableLogicalHeightForPercentageComputation const):
     13        * rendering/RenderBox.cpp:
     14        (WebCore::RenderBox::availableLogicalHeightUsing const):
     15        (WebCore::blockSizeFromAspectRatio): Deleted.
     16        * rendering/RenderBox.h:
     17        (WebCore::RenderBox::blockSizeFromAspectRatio):
     18
    1192021-01-08  Philippe Normand  <pnormand@igalia.com>
    220
  • trunk/Source/WebCore/rendering/RenderBlock.cpp

    r271053 r271293  
    32083208        LayoutUnit contentBoxHeight = adjustContentBoxLogicalHeightForBoxSizing((LayoutUnit)styleToUse.logicalHeight().value());
    32093209        availableHeight = std::max(0_lu, constrainContentBoxLogicalHeightByMinMax(contentBoxHeight - scrollbarLogicalHeight(), WTF::nullopt));
     3210    } else if (shouldComputeLogicalHeightFromAspectRatio()) {
     3211        availableHeight = blockSizeFromAspectRatio(horizontalBorderAndPaddingExtent(), verticalBorderAndPaddingExtent(), style().logicalAspectRatio(), style().boxSizing(), logicalWidth());
    32103212    } else if (styleToUse.logicalHeight().isPercentOrCalculated() && !isOutOfFlowPositionedWithSpecifiedHeight) {
    32113213        Optional<LayoutUnit> heightWithScrollbar = computePercentageLogicalHeight(styleToUse.logicalHeight());
  • trunk/Source/WebCore/rendering/RenderBox.cpp

    r271223 r271293  
    28292829}
    28302830
    2831 static LayoutUnit blockSizeFromAspectRatio(LayoutUnit borderPaddingInlineSum, LayoutUnit borderPaddingBlockSum, double aspectRatio, BoxSizing boxSizing, LayoutUnit inlineSize)
    2832 {
    2833     if (boxSizing == BoxSizing::BorderBox)
    2834         return inlineSize / LayoutUnit(aspectRatio);
    2835 
    2836     return ((inlineSize - borderPaddingInlineSum) / LayoutUnit(aspectRatio)) + borderPaddingBlockSum;
    2837 }
    2838 
    28392831RenderBox::LogicalExtentComputedValues RenderBox::computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logicalTop) const
    28402832{
     
    33143306            return stretchedHeight.value();
    33153307    }
     3308
     3309    if (shouldComputeLogicalHeightFromAspectRatio())
     3310        return blockSizeFromAspectRatio(horizontalBorderAndPaddingExtent(), verticalBorderAndPaddingExtent(), style().logicalAspectRatio(), style().boxSizing(), logicalWidth());
    33163311
    33173312    if (h.isPercentOrCalculated() && isOutOfFlowPositioned() && !isRenderFragmentedFlow()) {
  • trunk/Source/WebCore/rendering/RenderBox.h

    r271061 r271293  
    697697    void incrementVisuallyNonEmptyPixelCountIfNeeded(const IntSize&);
    698698
     699    bool shouldComputeLogicalHeightFromAspectRatio() const;
     700    bool shouldComputeLogicalWidthFromAspectRatio() const;
     701    bool shouldComputeLogicalWidthFromAspectRatioAndInsets() const;
     702    LayoutUnit computeLogicalWidthFromAspectRatio(RenderFragmentContainer* = nullptr) const;
     703
     704    static LayoutUnit blockSizeFromAspectRatio(LayoutUnit borderPaddingInlineSum, LayoutUnit borderPaddingBlockSum, double aspectRatio, BoxSizing boxSizing, LayoutUnit inlineSize)
     705    {
     706        if (boxSizing == BoxSizing::BorderBox)
     707            return inlineSize / LayoutUnit(aspectRatio);
     708        return ((inlineSize - borderPaddingInlineSum) / LayoutUnit(aspectRatio)) + borderPaddingBlockSum;
     709    }
     710
    699711private:
    700712    bool replacedMinMaxLogicalHeightComputesAsNone(SizeType) const;
     
    744756   
    745757    void applyTopLeftLocationOffsetWithFlipping(LayoutPoint&) const;
    746 
    747     bool shouldComputeLogicalHeightFromAspectRatio() const;
    748     bool shouldComputeLogicalWidthFromAspectRatio() const;
    749     bool shouldComputeLogicalWidthFromAspectRatioAndInsets() const;
    750     LayoutUnit computeLogicalWidthFromAspectRatio(RenderFragmentContainer* = nullptr) const;
    751758
    752759private:
Note: See TracChangeset for help on using the changeset viewer.