Bug 243321 - [css-aspect-ratio] The transferred min/max sizes should be constrained by defined sizes
Summary: [css-aspect-ratio] The transferred min/max sizes should be constrained by def...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: cathiechen
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2022-07-28 15:51 PDT by cathiechen
Modified: 2022-08-09 10:29 PDT (History)
8 users (show)

See Also:


Attachments
WIP-patch (14.73 KB, patch)
2022-07-28 15:54 PDT, cathiechen
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
WIP-patch (14.86 KB, patch)
2022-08-01 08:19 PDT, cathiechen
no flags Details | Formatted Diff | Diff
WIP-patch (13.87 KB, patch)
2022-08-01 11:00 PDT, cathiechen
no flags Details | Formatted Diff | Diff
WIP-patch (13.87 KB, patch)
2022-08-01 11:25 PDT, cathiechen
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description cathiechen 2022-07-28 15:51:32 PDT
The transferred min/max sizes should be constrained by defined sizes.
https://www.w3.org/TR/css-sizing-4/#aspect-ratio-size-transfers
Comment 1 cathiechen 2022-07-28 15:54:34 PDT
Created attachment 461283 [details]
WIP-patch

WIP Patch.
Comment 2 Rob Buis 2022-08-01 03:03:18 PDT
Comment on attachment 461283 [details]
WIP-patch

View in context: https://bugs.webkit.org/attachment.cgi?id=461283&action=review

> Source/WebCore/rendering/RenderBox.cpp:5576
> +    if (!style().hasAspectRatio())

Can this happen? Should it be an ASSERT?
Comment 3 Rob Buis 2022-08-01 03:07:57 PDT
Comment on attachment 461283 [details]
WIP-patch

View in context: https://bugs.webkit.org/attachment.cgi?id=461283&action=review

> Source/WebCore/rendering/RenderBox.cpp:5557
>  std::pair<LayoutUnit, LayoutUnit> RenderBox::computeMinMaxLogicalWidthFromAspectRatio() const

I think this can be merged with computeMinMaxLogicalHeightFromAspectRatio.

> Source/WebCore/rendering/RenderBox.cpp:5559
> +    if (!style().hasAspectRatio())

Can this happen? Should it be an ASSERT?
Comment 4 cathiechen 2022-08-01 08:14:35 PDT
Comment on attachment 461283 [details]
WIP-patch

View in context: https://bugs.webkit.org/attachment.cgi?id=461283&action=review

>> Source/WebCore/rendering/RenderBox.cpp:5559
>> +    if (!style().hasAspectRatio())
> 
> Can this happen? Should it be an ASSERT?

Done, thanks

>> Source/WebCore/rendering/RenderBox.cpp:5576
>> +    if (!style().hasAspectRatio())
> 
> Can this happen? Should it be an ASSERT?

Done
Comment 5 cathiechen 2022-08-01 08:19:02 PDT
Created attachment 461333 [details]
WIP-patch
Comment 6 cathiechen 2022-08-01 11:00:15 PDT
Created attachment 461335 [details]
WIP-patch
Comment 7 Rob Buis 2022-08-01 11:07:55 PDT
Comment on attachment 461335 [details]
WIP-patch

View in context: https://bugs.webkit.org/attachment.cgi?id=461335&action=review

> LayoutTests/TestExpectations:-4602
> -webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/block-aspect-ratio-045.html [ ImageOnlyFailure ]

Possibly it fixes select-element-001.html (on Mac).

> Source/WebCore/rendering/RenderBox.cpp:679
> +        return;

Should this be an ASSERT too?

> Source/WebCore/rendering/RenderBox.cpp:693
> +    auto shouldCheckTransferredSizes = [&](const Length& dependedLength, const Length& determinedLength) {

dependend*

> Source/WebCore/rendering/RenderBox.h:726
> +    enum class ConstrainWidthOrHeight { Width, Height };

This seems a bit superfluous. Something like ConstrainDimension { Width, Height }; ?
Comment 8 cathiechen 2022-08-01 11:19:11 PDT
Comment on attachment 461335 [details]
WIP-patch

View in context: https://bugs.webkit.org/attachment.cgi?id=461335&action=review

>> LayoutTests/TestExpectations:-4602
>> -webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/block-aspect-ratio-045.html [ ImageOnlyFailure ]
> 
> Possibly it fixes select-element-001.html (on Mac).

Yes, removed.

>> Source/WebCore/rendering/RenderBox.cpp:679
>> +        return;
> 
> Should this be an ASSERT too?

Done

>> Source/WebCore/rendering/RenderBox.cpp:693
>> +    auto shouldCheckTransferredSizes = [&](const Length& dependedLength, const Length& determinedLength) {
> 
> dependend*

Done, thanks

>> Source/WebCore/rendering/RenderBox.h:726
>> +    enum class ConstrainWidthOrHeight { Width, Height };
> 
> This seems a bit superfluous. Something like ConstrainDimension { Width, Height }; ?

Done, thanks!
Comment 9 cathiechen 2022-08-01 11:25:36 PDT
Created attachment 461336 [details]
WIP-patch
Comment 10 Rob Buis 2022-08-01 13:21:20 PDT
Comment on attachment 461335 [details]
WIP-patch

View in context: https://bugs.webkit.org/attachment.cgi?id=461335&action=review

> Source/WebCore/rendering/RenderBox.cpp:744
> +    return std::clamp(logicalWidth, computedMinWidth, computedMaxWidth);

Here we should take care to optimize the non preferred aspect ratio case, which should be the more common one.

> Source/WebCore/rendering/RenderBox.cpp:766
> +    LayoutUnit MaxH = computedLogicalMaxHeight ? computedLogicalMaxHeight.value() : LayoutUnit::max();

Variable names should not start with capitals.

> Source/WebCore/rendering/RenderBox.cpp:767
> +    LayoutUnit MinH = computedLogicalMinHeight ? computedLogicalMinHeight.value() : LayoutUnit();

Ditto.

> Source/WebCore/rendering/RenderBox.cpp:770
> +    return std::clamp(logicalHeight, MinH, MaxH);

See above.
Comment 11 cathiechen 2022-08-02 11:50:32 PDT
Pull request: https://github.com/WebKit/WebKit/pull/2952
Comment 12 Radar WebKit Bug Importer 2022-08-04 15:52:15 PDT
<rdar://problem/98152982>
Comment 13 EWS 2022-08-09 10:29:34 PDT
Committed 253262@main (94a7be7787d3): <https://commits.webkit.org/253262@main>

Reviewed commits have been landed. Closing PR #2952 and removing active labels.