Changeset 273753 in webkit


Ignore:
Timestamp:
Mar 2, 2021 12:23:49 PM (3 years ago)
Author:
commit-queue@webkit.org
Message:

Take box-sizing into account in replaced element intrinsic sizing
https://bugs.webkit.org/show_bug.cgi?id=221671

Patch by Rob Buis <rbuis@igalia.com> 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.

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r273745 r273753  
     12021-03-02  Rob Buis  <rbuis@igalia.com>
     2
     3        Take box-sizing into account in replaced element intrinsic sizing
     4        https://bugs.webkit.org/show_bug.cgi?id=221671
     5
     6        Reviewed by Simon Fraser.
     7
     8        Enable some tests that pass now.
     9
     10        * TestExpectations:
     11
    1122021-03-02  Chris Gambrell  <cgambrell@apple.com>
    213
  • trunk/LayoutTests/TestExpectations

    r273444 r273753  
    45724572webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/intrinsic-size-014.html [ ImageOnlyFailure ]
    45734573webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/intrinsic-size-015.html [ ImageOnlyFailure ]
    4574 webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/replaced-element-031.html [ ImageOnlyFailure ]
    4575 webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/replaced-element-032.html [ ImageOnlyFailure ]
    4576 webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/replaced-element-033.html [ ImageOnlyFailure ]
    45774574webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/table-element-001.html [ ImageOnlyFailure ]
    45784575webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/contain-intrinsic-size/contain-intrinsic-size-001.html [ ImageOnlyFailure ]
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r273635 r273753  
     12021-03-02  Rob Buis  <rbuis@igalia.com>
     2
     3        Take box-sizing into account in replaced element intrinsic sizing
     4        https://bugs.webkit.org/show_bug.cgi?id=221671
     5
     6        Reviewed by Simon Fraser.
     7
     8        Sync test.
     9
     10        * web-platform-tests/css/css-sizing/aspect-ratio/replaced-element-032.html:
     11
    1122021-02-28  Antoine Quint  <graouts@webkit.org>
    213
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/replaced-element-032.html

    r271893 r273753  
    2424       (note: height here is the block size of content-box.)
    2525
    26   3rd: A green rect 20x100.
    27        border-top is 20x40 and the content box is 20x60 because we compute
     26  3rd: A green rect 10x100.
     27       border-top is 10x40 and the content box is 10x60 because we compute
    2828       the inline size by aspect-ratio which works with border-box and so the
    29        inline size is 100px / 5 = 20px.
     29       inline size is 100px / 10 = 10px.
    3030       (note: height here is the block size of border-box.)
     31
     32  4th: A green rect 10x100.
     33       border-top is 10x40 and the content box is 10x60 to add up to 10x100.
    3134-->
    3235<img src="support/1x1-green.png" style="height: 100px; aspect-ratio: auto 1/10; box-sizing: border-box;"
    3336><img src="support/1x1-green.png" style="height: 60px; aspect-ratio: 1/3; box-sizing: content-box;"
    34 ><img src="support/1x1-green.png" style="height: 100px; aspect-ratio: 1/5; box-sizing: border-box;">
     37><img src="support/1x1-green.png" style="height: 100px; aspect-ratio: 1/10; box-sizing: border-box;"
     38><img src="support/1x1-green.png" style="width: 10px; aspect-ratio: 1/6; box-sizing: content-box;">
  • trunk/Source/WebCore/ChangeLog

    r273752 r273753  
     12021-03-02  Rob Buis  <rbuis@igalia.com>
     2
     3        Take box-sizing into account in replaced element intrinsic sizing
     4        https://bugs.webkit.org/show_bug.cgi?id=221671
     5
     6        Reviewed by Simon Fraser.
     7
     8        Take box-sizing into account in replaced element intrinsic sizing when
     9        using aspect-ratio, but keep using content-box when resolving
     10        width/height when no aspect-ratio is set.
     11
     12        Tests: imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/replaced-element-031.html
     13               imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/replaced-element-032.html
     14               imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/replaced-element-033.html
     15
     16        * rendering/RenderReplaced.cpp:
     17        (WebCore::resolveWidthForRatio):
     18        (WebCore::RenderReplaced::computeReplacedLogicalWidth const):
     19        (WebCore::resolveHeightForRatio):
     20        (WebCore::RenderReplaced::computeReplacedLogicalHeight const):
     21
    1222021-03-02  Antoine Quint  <graouts@webkit.org>
    223
  • trunk/Source/WebCore/rendering/RenderBox.cpp

    r273606 r273753  
    24902490{
    24912491    if (boxSizing == BoxSizing::BorderBox)
    2492         return blockSize * LayoutUnit(aspectRatio);
    2493 
    2494     return ((blockSize - borderPaddingBlockSum) * LayoutUnit(aspectRatio)) + borderPaddingInlineSum;
     2492        return blockSize * aspectRatio;
     2493
     2494    return ((blockSize - borderPaddingBlockSum) * aspectRatio) + borderPaddingInlineSum;
    24952495}
    24962496
  • trunk/Source/WebCore/rendering/RenderReplaced.cpp

    r272711 r273753  
    533533}
    534534
     535static inline LayoutUnit resolveWidthForRatio(LayoutUnit borderAndPaddingLogicalHeight, LayoutUnit borderAndPaddingLogicalWidth, LayoutUnit logicalHeight, double aspectRatio, BoxSizing boxSizing)
     536{
     537    if (boxSizing == BoxSizing::BorderBox)
     538        return LayoutUnit(round((logicalHeight + borderAndPaddingLogicalHeight) * aspectRatio)) - borderAndPaddingLogicalWidth;
     539    return LayoutUnit(round(logicalHeight * aspectRatio));
     540}
     541
    535542LayoutUnit RenderReplaced::computeReplacedLogicalWidth(ShouldComputePreferred shouldComputePreferred) const
    536543{
     
    568575                LayoutUnit estimatedUsedWidth = hasIntrinsicWidth ? LayoutUnit(constrainedSize.width()) : computeConstrainedLogicalWidth(shouldComputePreferred);
    569576                LayoutUnit logicalHeight = computeReplacedLogicalHeight(Optional<LayoutUnit>(estimatedUsedWidth));
    570                 return computeReplacedLogicalWidthRespectingMinMaxWidth(roundToInt(round(logicalHeight * intrinsicRatio)), shouldComputePreferred);
     577                BoxSizing boxSizing = BoxSizing::ContentBox;
     578                if (style().hasAspectRatio())
     579                    boxSizing = style().boxSizingForAspectRatio();
     580                return computeReplacedLogicalWidthRespectingMinMaxWidth(resolveWidthForRatio(borderAndPaddingLogicalHeight(), borderAndPaddingLogicalWidth(), logicalHeight, intrinsicRatio, boxSizing), shouldComputePreferred);
    571581            }
    572582
     
    597607}
    598608
     609static inline LayoutUnit resolveHeightForRatio(LayoutUnit borderAndPaddingLogicalWidth, LayoutUnit borderAndPaddingLogicalHeight, LayoutUnit logicalWidth, double aspectRatio, BoxSizing boxSizing)
     610{
     611    if (boxSizing == BoxSizing::BorderBox)
     612        return LayoutUnit(round((logicalWidth + borderAndPaddingLogicalWidth) / aspectRatio)) - borderAndPaddingLogicalHeight;
     613    return LayoutUnit(round(logicalWidth / aspectRatio));
     614}
     615
    599616LayoutUnit RenderReplaced::computeReplacedLogicalHeight(Optional<LayoutUnit> estimatedUsedWidth) const
    600617{
     
    626643    if (intrinsicRatio) {
    627644        LayoutUnit usedWidth = estimatedUsedWidth ? estimatedUsedWidth.value() : availableLogicalWidth();
    628         return computeReplacedLogicalHeightRespectingMinMaxHeight(roundToInt(round(usedWidth / intrinsicRatio)));
     645        BoxSizing boxSizing = BoxSizing::ContentBox;
     646        if (style().hasAspectRatio())
     647            boxSizing = style().boxSizingForAspectRatio();
     648        return computeReplacedLogicalHeightRespectingMinMaxHeight(resolveHeightForRatio(borderAndPaddingLogicalWidth(), borderAndPaddingLogicalHeight(), usedWidth, intrinsicRatio, boxSizing));
    629649    }
    630650
Note: See TracChangeset for help on using the changeset viewer.