Bug 238867 - Implement css property contain-intrinsic-size
Summary: Implement css property contain-intrinsic-size
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: WebKit Local Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: cathiechen
URL:
Keywords: InRadar
: 240888 (view as bug list)
Depends on:
Blocks: 236707
  Show dependency treegraph
 
Reported: 2022-04-06 07:39 PDT by cathiechen
Modified: 2022-11-01 06:42 PDT (History)
28 users (show)

See Also:


Attachments
WIP-patch (19.87 KB, patch)
2022-04-06 07:41 PDT, cathiechen
no flags Details | Formatted Diff | Diff
WIP-patch-for-ews (28.95 KB, patch)
2022-04-15 04:17 PDT, cathiechen
no flags Details | Formatted Diff | Diff
WIP-patch-for-review (28.95 KB, patch)
2022-04-15 04:17 PDT, cathiechen
no flags Details | Formatted Diff | Diff
WIP-patch-for-ews (198.47 KB, patch)
2022-04-15 05:08 PDT, cathiechen
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
WIP-patch-for-review (29.28 KB, patch)
2022-04-15 05:08 PDT, cathiechen
no flags Details | Formatted Diff | Diff
WIP-patch-for-ews (200.32 KB, patch)
2022-04-15 08:52 PDT, cathiechen
no flags Details | Formatted Diff | Diff
WIP-patch-for-review (31.13 KB, patch)
2022-04-15 08:53 PDT, cathiechen
no flags Details | Formatted Diff | Diff
WIP-patch-for-ews (200.44 KB, patch)
2022-04-15 09:06 PDT, cathiechen
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
WIP-patch-for-review (31.23 KB, patch)
2022-04-15 09:07 PDT, cathiechen
no flags Details | Formatted Diff | Diff
Patch-for-review (37.80 KB, patch)
2022-04-17 23:56 PDT, cathiechen
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
patch-for-ews-with-parsing-code (206.08 KB, patch)
2022-04-17 23:58 PDT, cathiechen
no flags Details | Formatted Diff | Diff
Patch-for-review (37.80 KB, patch)
2022-04-18 00:37 PDT, cathiechen
no flags Details | Formatted Diff | Diff
patch-for-ews-with-parsing-code (206.08 KB, patch)
2022-04-18 00:54 PDT, cathiechen
no flags Details | Formatted Diff | Diff
Patch-for-review (37.80 KB, patch)
2022-04-18 00:55 PDT, cathiechen
no flags Details | Formatted Diff | Diff
Patch (39.85 KB, patch)
2022-04-21 23:53 PDT, cathiechen
no flags Details | Formatted Diff | Diff
Patch (39.91 KB, patch)
2022-04-23 05:58 PDT, cathiechen
no flags Details | Formatted Diff | Diff
Patch (39.86 KB, patch)
2022-04-25 01:53 PDT, cathiechen
no flags Details | Formatted Diff | Diff
Patch (39.91 KB, patch)
2022-04-25 04:00 PDT, cathiechen
no flags Details | Formatted Diff | Diff
Patch (39.50 KB, patch)
2022-04-27 04:53 PDT, cathiechen
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (39.50 KB, patch)
2022-04-27 04:59 PDT, cathiechen
no flags Details | Formatted Diff | Diff
Patch (39.27 KB, patch)
2022-04-27 05:56 PDT, cathiechen
no flags Details | Formatted Diff | Diff
Patch (39.25 KB, patch)
2022-04-27 08:35 PDT, cathiechen
no flags Details | Formatted Diff | Diff
Patch (39.28 KB, patch)
2022-04-27 09:18 PDT, cathiechen
no flags Details | Formatted Diff | Diff
Patch (39.10 KB, patch)
2022-05-11 07:00 PDT, cathiechen
no flags Details | Formatted Diff | Diff
Patch (37.48 KB, patch)
2022-05-25 03:29 PDT, Rob Buis
ews-feeder: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description cathiechen 2022-04-06 07:39:05 PDT
Implement css property contain-intrinsic-size
Comment 1 cathiechen 2022-04-06 07:41:11 PDT
Created attachment 456818 [details]
WIP-patch
Comment 2 Radar WebKit Bug Importer 2022-04-13 07:40:15 PDT
<rdar://problem/91688651>
Comment 3 cathiechen 2022-04-15 04:17:05 PDT
Created attachment 457691 [details]
WIP-patch-for-ews
Comment 4 cathiechen 2022-04-15 04:17:50 PDT
Created attachment 457692 [details]
WIP-patch-for-review
Comment 5 cathiechen 2022-04-15 05:08:26 PDT
Created attachment 457693 [details]
WIP-patch-for-ews
Comment 6 cathiechen 2022-04-15 05:08:45 PDT
Created attachment 457694 [details]
WIP-patch-for-review
Comment 7 cathiechen 2022-04-15 08:52:44 PDT
Created attachment 457699 [details]
WIP-patch-for-ews
Comment 8 cathiechen 2022-04-15 08:53:21 PDT
Created attachment 457700 [details]
WIP-patch-for-review
Comment 9 cathiechen 2022-04-15 09:06:54 PDT
Created attachment 457701 [details]
WIP-patch-for-ews
Comment 10 cathiechen 2022-04-15 09:07:19 PDT
Created attachment 457702 [details]
WIP-patch-for-review
Comment 11 cathiechen 2022-04-15 10:19:22 PDT
Comment on attachment 457702 [details]
WIP-patch-for-review

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

> Source/WebCore/rendering/style/RenderStyle.cpp:783
> +    if (first.containIntrinsicWidth != second.containIntrinsicWidth

Maybe we should move this change to the parsing patch?
Comment 12 cathiechen 2022-04-17 23:56:46 PDT
Created attachment 457794 [details]
Patch-for-review
Comment 13 cathiechen 2022-04-17 23:58:15 PDT
Created attachment 457795 [details]
patch-for-ews-with-parsing-code
Comment 14 cathiechen 2022-04-18 00:04:40 PDT
Comment on attachment 457794 [details]
Patch-for-review

Hi,
I think this patch is ready for review. Thanks!
* The patch-for-review only contains the implementation part, not the parsing and runtime flags code. 
* The patch-for-ews contains the parsing and runtime flags code, see bug 238181.
Comment 15 cathiechen 2022-04-18 00:37:52 PDT
Created attachment 457797 [details]
Patch-for-review
Comment 16 cathiechen 2022-04-18 00:54:59 PDT
Created attachment 457799 [details]
patch-for-ews-with-parsing-code
Comment 17 cathiechen 2022-04-18 00:55:19 PDT
Created attachment 457800 [details]
Patch-for-review
Comment 18 Rob Buis 2022-04-20 08:28:00 PDT
Comment on attachment 457800 [details]
Patch-for-review

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

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

I think it would be nice to minimise shouldApplySizeContainment calls and also maybe turning this into ASSERT.

> Source/WebCore/rendering/RenderReplaced.cpp:526
> +    // Don't let size containment effect aspect ratio. Maybe we should split this out?

Affect.

> Source/WebCore/rendering/style/RenderStyle.cpp:779
> +    // This change should be slipt out, maybe only size containment needs relayout

Split.

> Source/WebCore/rendering/style/RenderStyle.cpp:784
> +        || first.containIntrinsicHeight != second.containIntrinsicHeight)

Can probably go on one line.
Comment 19 cathiechen 2022-04-21 23:26:10 PDT
Comment on attachment 457800 [details]
Patch-for-review

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

Hi Rob, thanks for the reivew!

>> Source/WebCore/rendering/RenderBox.cpp:5520
>> +        return false;
> 
> I think it would be nice to minimise shouldApplySizeContainment calls and also maybe turning this into ASSERT.

Hmm, there are some scenarios we need to check shouldApplySizeContainment first. How about we add an new interface sizeContainmentHasExplicitIntrinsicInnerLogicalWidth()?

>> Source/WebCore/rendering/RenderReplaced.cpp:526
>> +    // Don't let size containment effect aspect ratio. Maybe we should split this out?
> 
> Affect.

Done

>> Source/WebCore/rendering/style/RenderStyle.cpp:779
>> +    // This change should be slipt out, maybe only size containment needs relayout
> 
> Split.

Done

>> Source/WebCore/rendering/style/RenderStyle.cpp:784
>> +        || first.containIntrinsicHeight != second.containIntrinsicHeight)
> 
> Can probably go on one line.

Done
Comment 20 cathiechen 2022-04-21 23:53:52 PDT
Created attachment 458117 [details]
Patch
Comment 21 cathiechen 2022-04-23 05:58:23 PDT
Created attachment 458208 [details]
Patch
Comment 22 cathiechen 2022-04-25 01:53:32 PDT
Created attachment 458252 [details]
Patch
Comment 23 cathiechen 2022-04-25 02:00:08 PDT
Comment on attachment 458252 [details]
Patch

Hi, I think this patch is ready for review:) Please take a look, thanks!
Comment 24 Rob Buis 2022-04-25 02:11:38 PDT
Comment on attachment 458252 [details]
Patch

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

> Source/WebCore/rendering/RenderBox.cpp:3095
> +        LayoutUnit explicitIntrinsicHeight = sizeContainmentHasExplicitIntrinsicInnerLogicalHeight() ? explicitIntrinsicInnerLogicalHeight() : LayoutUnit(0);

LayoutUnit(0) -> LayoutUnit().

> Source/WebCore/rendering/RenderBox.cpp:3234
> +        estimatedHeight += explicitIntrinsicInnerLogicalHeight() + scrollbarLogicalHeight();

So is the explicit intrinsic height always excluding any scrollbar heights?

> Source/WebCore/rendering/RenderListBox.cpp:209
> +    maxLogicalWidth =  2 * optionsSpacingHorizontal;

In case sizeContainmentHasExplicitIntrinsicInnerLogicalWidth holds true, we do this statement for no good reason, since we know it will be overwritten.

> Source/WebCore/rendering/RenderListBox.cpp:214
> +                minLogicalWidth = maxLogicalWidth;

Is minLogicalWidth undefined in case style().width().isPercentOrCalculated() is true?

> Source/WebCore/rendering/RenderSlider.cpp:74
> +            minLogicalWidth = maxLogicalWidth = explicitIntrinsicInnerLogicalWidth();

I see some places min = max = .... and some max = min = ... . Better to pick one style.
Comment 25 cathiechen 2022-04-25 03:53:38 PDT
Comment on attachment 458252 [details]
Patch

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

Hi Rob, thanks for the review!

>> Source/WebCore/rendering/RenderBox.cpp:3095
>> +        LayoutUnit explicitIntrinsicHeight = sizeContainmentHasExplicitIntrinsicInnerLogicalHeight() ? explicitIntrinsicInnerLogicalHeight() : LayoutUnit(0);
> 
> LayoutUnit(0) -> LayoutUnit().

Done

>> Source/WebCore/rendering/RenderBox.cpp:3234
>> +        estimatedHeight += explicitIntrinsicInnerLogicalHeight() + scrollbarLogicalHeight();
> 
> So is the explicit intrinsic height always excluding any scrollbar heights?

Nope, scrollbar is not included in the explicit intrinsic size.

>> Source/WebCore/rendering/RenderListBox.cpp:209
>> +    maxLogicalWidth =  2 * optionsSpacingHorizontal;
> 
> In case sizeContainmentHasExplicitIntrinsicInnerLogicalWidth holds true, we do this statement for no good reason, since we know it will be overwritten.

Yes, this is outside because it can be reused by `!shouldApplySizeContainment(*this)` and `shouldApplySizeContainment(*this) && !sizeContainmentHasExplicitIntrinsicInnerLogicalWidth()`

>> Source/WebCore/rendering/RenderListBox.cpp:214
>> +                minLogicalWidth = maxLogicalWidth;
> 
> Is minLogicalWidth undefined in case style().width().isPercentOrCalculated() is true?

I guess so. This is copied from the following code, we don't want to change the behavior. Hmm, looks like we can reuse the following code, I didn't because contain-intrinsic-size-009.html fails. It looks like the failure is related to `overflow:visible` doesn't make select's scroll bar disappeared. The value of contain-intrinsic-width shouldn't include scrollbar. I'll try to explain this in TestExpectations.

>> Source/WebCore/rendering/RenderSlider.cpp:74
>> +            minLogicalWidth = maxLogicalWidth = explicitIntrinsicInnerLogicalWidth();
> 
> I see some places min = max = .... and some max = min = ... . Better to pick one style.

Done
Comment 26 cathiechen 2022-04-25 03:58:52 PDT
Comment on attachment 458252 [details]
Patch

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

>>> Source/WebCore/rendering/RenderListBox.cpp:209
>>> +    maxLogicalWidth =  2 * optionsSpacingHorizontal;
>> 
>> In case sizeContainmentHasExplicitIntrinsicInnerLogicalWidth holds true, we do this statement for no good reason, since we know it will be overwritten.
> 
> Yes, this is outside because it can be reused by `!shouldApplySizeContainment(*this)` and `shouldApplySizeContainment(*this) && !sizeContainmentHasExplicitIntrinsicInnerLogicalWidth()`

This seems hard to read, I'll rewrite it.
Comment 27 cathiechen 2022-04-25 04:00:33 PDT
Created attachment 458257 [details]
Patch
Comment 28 Rob Buis 2022-04-25 13:31:22 PDT
Comment on attachment 458257 [details]
Patch

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

> Source/WebCore/rendering/RenderBox.h:673
> +    LayoutUnit explicitIntrinsicInnerWidth() const;

This could return optional, then maybe some hasFoo methods are not needed.

> Source/WebCore/rendering/RenderListBox.cpp:213
> +            maxLogicalWidth = 2* optionsSpacingHorizontal;

2* -> 2 *
Comment 29 Darin Adler 2022-04-26 17:49:55 PDT
Comment on attachment 458257 [details]
Patch

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

> Source/WebCore/rendering/RenderReplaced.h:46
> +            LayoutSize size = LayoutSize();

The "= LayoutSize()" here doesn’t do anything and can be omitted. LayoutUnit values are initialized to 0, unlike scalars which can be left uninitialized.

> Source/WebCore/rendering/RenderVideo.cpp:117
> +        LayoutSize size = LayoutSize();

The "= LayoutSize()" here doesn’t do anything and can be omitted.
Comment 30 cathiechen 2022-04-27 03:55:23 PDT
Comment on attachment 458257 [details]
Patch

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

>> Source/WebCore/rendering/RenderBox.h:673
>> +    LayoutUnit explicitIntrinsicInnerWidth() const;
> 
> This could return optional, then maybe some hasFoo methods are not needed.

Looks like optional could make the interface much more clear. Done!

>> Source/WebCore/rendering/RenderListBox.cpp:213
>> +            maxLogicalWidth = 2* optionsSpacingHorizontal;
> 
> 2* -> 2 *

Done, thanks!

>> Source/WebCore/rendering/RenderReplaced.h:46
>> +            LayoutSize size = LayoutSize();
> 
> The "= LayoutSize()" here doesn’t do anything and can be omitted. LayoutUnit values are initialized to 0, unlike scalars which can be left uninitialized.

Done, thanks!

>> Source/WebCore/rendering/RenderVideo.cpp:117
>> +        LayoutSize size = LayoutSize();
> 
> The "= LayoutSize()" here doesn’t do anything and can be omitted.

Done, thanks!
Comment 31 cathiechen 2022-04-27 04:53:18 PDT
Created attachment 458438 [details]
Patch
Comment 32 cathiechen 2022-04-27 04:59:08 PDT
Created attachment 458439 [details]
Patch
Comment 33 cathiechen 2022-04-27 05:56:47 PDT
Created attachment 458440 [details]
Patch
Comment 34 Rob Buis 2022-04-27 06:07:13 PDT
Comment on attachment 458440 [details]
Patch

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

> Source/WebCore/ChangeLog:8
> +        This patch add support for contain-intrinsic-size value "none | <length>". The value "auto && <length>"

add -> adds.

> Source/WebCore/rendering/RenderBox.cpp:5535
> +    return std::optional<LayoutUnit>(width.value().value());

This probably does not need the explicit cast.

> Source/WebCore/rendering/RenderBox.cpp:5551
> +    return std::optional<LayoutUnit>(height.value().value());

Ditto.

> Source/WebCore/rendering/RenderGrid.cpp:544
> +        return std::optional<LayoutUnit>();

Ditto.
Comment 35 cathiechen 2022-04-27 08:23:01 PDT
Comment on attachment 458440 [details]
Patch

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

>> Source/WebCore/ChangeLog:8
>> +        This patch add support for contain-intrinsic-size value "none | <length>". The value "auto && <length>"
> 
> add -> adds.

Done

>> Source/WebCore/rendering/RenderBox.cpp:5535
>> +    return std::optional<LayoutUnit>(width.value().value());
> 
> This probably does not need the explicit cast.

Tried locally, it seems needed, for width.value().value() is a float, not LayoutUnit.

>> Source/WebCore/rendering/RenderGrid.cpp:544
>> +        return std::optional<LayoutUnit>();
> 
> Ditto.

Done.
Comment 36 cathiechen 2022-04-27 08:35:15 PDT
Created attachment 458448 [details]
Patch
Comment 37 Rob Buis 2022-04-27 09:13:31 PDT
Comment on attachment 458448 [details]
Patch

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

Patch is now good enough for me, maybe nice to use the has_value() though.

> Source/WebCore/rendering/RenderGrid.cpp:509
> +        LayoutUnit totalGuttersSize = explicitIntrinsicInnerLogicalSize(ForColumns) ? 0_lu : guttersSize(m_grid, ForColumns, 0, numTracks(ForColumns), std::nullopt);

Maybe has_value() is clearer here.

> Source/WebCore/rendering/RenderGrid.cpp:531
> +    LayoutUnit totalGuttersSize = direction == ForColumns && explicitIntrinsicInnerLogicalSize(direction) ? 0_lu : guttersSize(grid, direction, 0, numberOfTracks, std::nullopt);

Ditto.
Comment 38 cathiechen 2022-04-27 09:16:55 PDT
Comment on attachment 458448 [details]
Patch

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

>> Source/WebCore/rendering/RenderGrid.cpp:509
>> +        LayoutUnit totalGuttersSize = explicitIntrinsicInnerLogicalSize(ForColumns) ? 0_lu : guttersSize(m_grid, ForColumns, 0, numTracks(ForColumns), std::nullopt);
> 
> Maybe has_value() is clearer here.

Done, thanks:)

>> Source/WebCore/rendering/RenderGrid.cpp:531
>> +    LayoutUnit totalGuttersSize = direction == ForColumns && explicitIntrinsicInnerLogicalSize(direction) ? 0_lu : guttersSize(grid, direction, 0, numberOfTracks, std::nullopt);
> 
> Ditto.

Done
Comment 39 cathiechen 2022-04-27 09:18:26 PDT
Created attachment 458452 [details]
Patch
Comment 40 Rob Buis 2022-04-27 09:22:33 PDT
I am happy with the patch now, thanks Cathie!
Comment 41 cathiechen 2022-05-11 07:00:35 PDT
Created attachment 459164 [details]
Patch
Comment 42 cathiechen 2022-05-11 07:01:49 PDT
Rebase the code.
Comment 43 Rob Buis 2022-05-25 03:29:15 PDT
Created attachment 459749 [details]
Patch
Comment 44 Rob Buis 2022-06-08 03:34:42 PDT
Pull request: https://github.com/WebKit/WebKit/pull/1373
Comment 45 Brent Fulgham 2022-06-23 11:55:47 PDT
*** Bug 240888 has been marked as a duplicate of this bug. ***
Comment 46 cathiechen 2022-06-25 06:42:18 PDT
Rebase the code: https://github.com/WebKit/WebKit/pull/1799
Comment 47 EWS 2022-10-25 11:40:30 PDT
Committed 255971@main (7ed83ab2929f): <https://commits.webkit.org/255971@main>

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