Bug 234361 - [REGRESSION][[css-flexbox] child elements are shrunk to fit into container after r286206
Summary: [REGRESSION][[css-flexbox] child elements are shrunk to fit into container af...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Sergio Villar Senin
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-12-15 12:29 PST by Yury Semikhatsky
Modified: 2021-12-22 07:29 PST (History)
14 users (show)

See Also:


Attachments
example page (299 bytes, text/html)
2021-12-15 12:29 PST, Yury Semikhatsky
no flags Details
Before (5.56 KB, image/png)
2021-12-15 12:29 PST, Yury Semikhatsky
no flags Details
After (4.74 KB, image/png)
2021-12-15 12:29 PST, Yury Semikhatsky
no flags Details
Patch (4.48 KB, patch)
2021-12-20 08:40 PST, Sergio Villar Senin
no flags Details | Formatted Diff | Diff
Patch (8.67 KB, patch)
2021-12-21 02:03 PST, Sergio Villar Senin
rego: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Yury Semikhatsky 2021-12-15 12:29:13 PST
Created attachment 447272 [details]
example page

After https://github.com/WebKit/WebKit/commit/bdb68ddedc91dba21084068424ed93bf58f54f0c flex box children are shrunk to fit into the container where they previously would keep their size.


Steps to reproduce: open attached example.html in a window 500x500

Previously: both frames would have width 300px
After the change: each has width 242
Comment 1 Yury Semikhatsky 2021-12-15 12:29:41 PST
Created attachment 447273 [details]
Before
Comment 2 Yury Semikhatsky 2021-12-15 12:29:59 PST
Created attachment 447274 [details]
After
Comment 3 Sergio Villar Senin 2021-12-16 06:53:22 PST
I guess you mean r286206 then in the title...
Comment 4 Sergio Villar Senin 2021-12-16 06:57:10 PST
Does it happen if you use <div>s instead of iframes with embedded documents?
Comment 5 Sergio Villar Senin 2021-12-16 07:32:13 PST
BTW I've just tried with ToT and I cannot reproduce the issue you mention. I resize the window and both boxes end up occupying the same space...
Comment 6 Sergio Villar Senin 2021-12-16 07:36:59 PST
(In reply to Sergio Villar Senin from comment #5)
> BTW I've just tried with ToT and I cannot reproduce the issue you mention. I
> resize the window and both boxes end up occupying the same space...

Ah OK I see it now, the layout seems inconsistent, sometimes they're equally sized but then you resize and one of the becomes larger.
Comment 7 Yury Semikhatsky 2021-12-16 08:53:42 PST
(In reply to Sergio Villar Senin from comment #4)
> Does it happen if you use <div>s instead of iframes with embedded documents?

No, I can only reproduce it with iframes. Apparently there was some intrinsic min-width (don't see it in the inspector though).
Comment 8 Yury Semikhatsky 2021-12-16 09:49:15 PST
According to [1] iframe has default width=300. Before the change when two iframes having 'flex-shrink:1' were put into a flex container with width=500 they would keep width 300 (iframe's default width was treated as min-width essentially) which was consistent with Chromium behavior. After the change they are both shrunk to respect 'flex-shrink:1'. I don't know whether this new behavior is correct by the spec but it definitely breaks some web pages.


[1] https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#attr-width
Comment 9 Sergio Villar Senin 2021-12-17 02:13:00 PST
(In reply to Yury Semikhatsky from comment #8)
> According to [1] iframe has default width=300. Before the change when two
> iframes having 'flex-shrink:1' were put into a flex container with width=500
> they would keep width 300 (iframe's default width was treated as min-width
> essentially) which was consistent with Chromium behavior. After the change
> they are both shrunk to respect 'flex-shrink:1'. I don't know whether this
> new behavior is correct by the spec but it definitely breaks some web pages.

Thanks for the info. I have a patch for this issue, I'd love to hear more about those sites that are broken, just to double check that the fix works in the wild.
Comment 10 Sergio Villar Senin 2021-12-20 08:40:10 PST
Created attachment 447606 [details]
Patch
Comment 11 Sergio Villar Senin 2021-12-20 08:44:01 PST
Note that I haven't included any test because I'm importing https://github.com/web-platform-tests/wpt/pull/32141 as soon as it lands in the WPT repo (I mean as part of this patch).
Comment 12 Manuel Rego Casasnovas 2021-12-20 09:24:53 PST
(In reply to Sergio Villar Senin from comment #11)
> Note that I haven't included any test because I'm importing
> https://github.com/web-platform-tests/wpt/pull/32141 as soon as it lands in
> the WPT repo (I mean as part of this patch).

You could include the tests in this patch, and they get reviewed here, and once you get them approved here, the WPT upstream PR gets approved automatically.
Comment 13 Manuel Rego Casasnovas 2021-12-20 09:30:04 PST
Comment on attachment 447606 [details]
Patch

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

> Source/WebCore/ChangeLog:12
> +        regression.

Is there no other cases of replaced elements that need SVG images like behavior?
Comment 14 Sergio Villar Senin 2021-12-21 00:57:51 PST
(In reply to Manuel Rego Casasnovas from comment #12)
> (In reply to Sergio Villar Senin from comment #11)
> > Note that I haven't included any test because I'm importing
> > https://github.com/web-platform-tests/wpt/pull/32141 as soon as it lands in
> > the WPT repo (I mean as part of this patch).
> 
> You could include the tests in this patch, and they get reviewed here, and
> once you get them approved here, the WPT upstream PR gets approved
> automatically.

The last time I tried the exporter it failed due to naming. In webkit the reference has -expected suffix while WPT expects -ref suffix. That's why I preferred to upload it to WPT and once landed I'll include it in this patch.
Comment 15 Sergio Villar Senin 2021-12-21 01:00:50 PST
(In reply to Manuel Rego Casasnovas from comment #13)
> Comment on attachment 447606 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=447606&action=review
> 
> > Source/WebCore/ChangeLog:12
> > +        regression.
> 
> Is there no other cases of replaced elements that need SVG images like
> behavior?

No that I know of. The original patch had initially the code that I'm changing now. At the very last minute I decided to generalize it a bit thinking that replaced elements were basically just images without realizing that things like iframes were also replaced elements.

For the rest of the images (raster images) they have intrinsic dimensions (1024x768, etc...). The thing with vector graphics (like SVG) is that they're scale independent, so it does not make much sense to assign them an intrinsic size. But it does make a lot of sense to have an intrinsic ratio, so resizing the image respects the proportions.
Comment 16 Sergio Villar Senin 2021-12-21 02:03:48 PST
Created attachment 447700 [details]
Patch
Comment 17 Manuel Rego Casasnovas 2021-12-21 07:08:46 PST
Comment on attachment 447700 [details]
Patch

r=me
Comment 18 Sergio Villar Senin 2021-12-22 07:28:12 PST
Committed r287355 (245497@trunk): <https://commits.webkit.org/245497@trunk>
Comment 19 Radar WebKit Bug Importer 2021-12-22 07:29:17 PST
<rdar://problem/86810685>