WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
231952
[css-flexbox] Add support for replaced elements with intrinsic ratio and no intrinsic size
https://bugs.webkit.org/show_bug.cgi?id=231952
Summary
[css-flexbox] Add support for replaced elements with intrinsic ratio and no i...
Sergio Villar Senin
Reported
2021-10-19 07:24:47 PDT
[css-flexbox] Add support for replaced elements with intrinsic ratio and no intrinsic size
Attachments
Patch
(7.49 KB, patch)
2021-10-19 07:32 PDT
,
Sergio Villar Senin
no flags
Details
Formatted Diff
Diff
Patch
(7.74 KB, patch)
2021-10-19 08:24 PDT
,
Sergio Villar Senin
no flags
Details
Formatted Diff
Diff
Patch
(8.23 KB, patch)
2021-10-27 11:20 PDT
,
Sergio Villar Senin
rego
: review+
Details
Formatted Diff
Diff
Show Obsolete
(2)
View All
Add attachment
proposed patch, testcase, etc.
Sergio Villar Senin
Comment 1
2021-10-19 07:32:28 PDT
Created
attachment 441722
[details]
Patch
Rob Buis
Comment 2
2021-10-19 07:57:49 PDT
Comment on
attachment 441722
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=441722&action=review
> Source/WebCore/rendering/RenderFlexibleBox.cpp:621 > +static bool isRenderReplacedWithIntrinsicAspectRatio(const RenderBox& child)
I think it is worth trying to make this a method on RenderReplaced instead of static, so we do not need to make computeIntrinsicRatioInformation public on RenderReplaced.h.
> Source/WebCore/rendering/RenderFlexibleBox.cpp:625 > + // It's common for some replaced elements, such SVGs, to have intrinsic aspect ratios but no intrinsic sizes.
"such as SVGs"
Sergio Villar Senin
Comment 3
2021-10-19 08:24:36 PDT
Created
attachment 441729
[details]
Patch
Sergio Villar Senin
Comment 4
2021-10-19 08:25:59 PDT
Comment on
attachment 441722
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=441722&action=review
>> Source/WebCore/rendering/RenderFlexibleBox.cpp:621 >> +static bool isRenderReplacedWithIntrinsicAspectRatio(const RenderBox& child) > > I think it is worth trying to make this a method on RenderReplaced instead of static, so we do not need to make computeIntrinsicRatioInformation public on RenderReplaced.h.
Good suggestion. I filed wkb.ug/231955 to tackle this.
>> Source/WebCore/rendering/RenderFlexibleBox.cpp:625 >> + // It's common for some replaced elements, such SVGs, to have intrinsic aspect ratios but no intrinsic sizes. > > "such as SVGs"
OK
Radar WebKit Bug Importer
Comment 5
2021-10-26 07:25:28 PDT
<
rdar://problem/84662305
>
Sergio Villar Senin
Comment 6
2021-10-27 11:20:56 PDT
Created
attachment 442613
[details]
Patch
Manuel Rego Casasnovas
Comment 7
2021-11-25 03:45:03 PST
Comment on
attachment 442613
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=442613&action=review
> Source/WebCore/rendering/RenderFlexibleBox.cpp:898 > + ratio = downcast<RenderReplaced>(child).computeIntrinsicAspectRatio();
One question, is this always using the intrinsic aspect ratio for replaced elements? Even if you set your own value (e.g. "aspect-ratio: 1;")?
Javier Fernandez
Comment 8
2021-11-25 06:03:28 PST
Comment on
attachment 442613
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=442613&action=review
> Source/WebCore/rendering/RenderFlexibleBox.cpp:904 > + ASSERT(childIntrinsicSize.height());
Is this ASSERT correct ? How we can guarantee that the child's intrinsic size isn't 0 ? For instance, for replaced elements, if shouldApplySizeContainment() is true we would return LayoutSize()
Sergio Villar Senin
Comment 9
2021-11-25 09:52:06 PST
Comment on
attachment 442613
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=442613&action=review
Thanks for taking a look!
>> Source/WebCore/rendering/RenderFlexibleBox.cpp:898 >> + ratio = downcast<RenderReplaced>(child).computeIntrinsicAspectRatio(); > > One question, is this always using the intrinsic aspect ratio for replaced elements? Even if you set your own value (e.g. "aspect-ratio: 1;")?
It considers all the situations. This method just calls RenderReplaced::computeAspectRatioInformationForRenderBox() which already takes care of many different situations, like having/not having intrinsic sizes, using aspect-ratio etc...
>> Source/WebCore/rendering/RenderFlexibleBox.cpp:904 >> + ASSERT(childIntrinsicSize.height()); > > Is this ASSERT correct ? How we can guarantee that the child's intrinsic size isn't 0 ? > For instance, for replaced elements, if shouldApplySizeContainment() is true we would return LayoutSize()
Well that ASSERT was there before this patch so I am not adding anything. Anyway as you ask, it's true that it's far from obvious. This is the rationale, this method computeMainSizeFromAspectRatioUsing() is only called whenever childHasComputableAspectRatio() is true. That method is implemented as follows. return child.intrinsicSize().height() || child.style().hasAspectRatio() So we either have a positive intrinsic height (in which case the ASSERT is true) or hasAspectRatio() is true. If you check hasAspectRatio() implementation it's almost equal to the condition in the if branch, something like this: return child.style().aspectRatioType() == AspectRatioType::Ratio || (child.style().aspectRatioType() == AspectRatioType::AutoAndRatio; So we have two possibilities for hasAspectRatio() == true: a) child.style().aspectRatioType() == AspectRatioType::Ratio. If that's the case then the code should have taken the if branch not the else b) child.style().aspectRatioType() == AspectRatioType::AutoAndRatio. If that condition is true the only possibility to end up in the else branch is that the intrinsic size is not empty, because otherwise we should have taken the if branch as well. Summing up, if we take the else branch we know that child.intrinsicSize().height() is true in childHasComputableAspectRatio() or that we are in the above case b) in which case we know that the height is also valid.
Manuel Rego Casasnovas
Comment 10
2021-11-25 12:38:41 PST
Comment on
attachment 442613
[details]
Patch Ok, thanks for the clarifications. r=me
Sergio Villar Senin
Comment 11
2021-11-29 02:01:03 PST
Committed
r286206
(
244588@main
): <
https://commits.webkit.org/244588@main
>
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug