Page MenuHomePhabricator

Support "width: fit-content" in TemplateStyles/Sanitized CSS
Open, Needs TriagePublicFeature

Description

The fit-content keyword for the CSS width property is currently defined in the CSS Box Sizing Module Level 4 Editor's Draft, but it is based on the fit-content() definition from the CSS Box Sizing Module Level 3 Working Draft (both of which are standards track).

The change between them is simply from a CSS function to a keyword, but both do the same thing: they invoke the user agent's native content-width calculation. And the reason for the deferment from Level 3 to Level 4 was the overall design of "intrinsic sizing" (of which fit-content is a part) rather than significant changes to fit-content itself.

width: fit-content is well supported by all modern browsers (minus IE). Most browsers added support for this in the 2015–2017 timeframe, including Firefox, but Firefox still needs the -moz- prefix. In other words: it's still just a bit early to use in MediaWiki core or default skins, but plenty mature enough in controlled and limited use cases like TemplateStyles.

Slightly related: T216897

Event Timeline

At least add the possibility of saving the page. Currently it blocks you for even doing that (other "invalid" code passes just as well)

Not being able to save unrecognized CSS is the entire point of TemplateStyles.

Not being able to save unrecognized CSS is the entire point of TemplateStyles.

Which is why this task is asking to recognize this widely recognized CSS

Izno changed the subtype of this task from "Task" to "Feature Request".Jan 14 2023, 1:54 AM

@Ioaxxere I'm not maintainer there and my patches struggle to get merged so you can ignore my feedback but since you pinged me here I want to say for the ease of finding reviewer on the patch please add Bug: T216897 in the below of your commit message there, add a test and add appropriate links, https://gerrit.wikimedia.org/r/c/css-sanitizer/+/1070601 may help as an example. https://www.w3.org/TR/2021/WD-css-sizing-4-20210520/#sizing-values can be a better link to add to README, inline comment and the changelog and since you are adding fit-content, I think you should also add stretch and contain in addition to fit-content, at least completing one section of a specification if not all of it.

@Ioaxxere I can also take over some time later if you like to though I might have the same chance as you but I think developing the patch can be a fun by itself also.

Nux subscribed.

I'll try to work on Box sizing level 4 (replacing cssSizing3).

Change #1074721 had a related patch set uploaded (by Eccenux; author: Eccenux):

[css-sanitizer@master] Support for CSS Box Sizing Level 4

https://gerrit.wikimedia.org/r/1074721

Tests seem to be passing. Please review. I have added the parent task: T375344. The task may not be formally correct, so if anyone could clean it up, that would be great :)