layout: Implement the fit-content() sizing function (#36056)

Spec: https://drafts.csswg.org/css-sizing-3/#funcdef-width-fit-content

It's similar to the `fit-content` keyword but, instead of clamping the
stretch size between `min-content` and `max-content`, it clamps the
provided argument.

So now that we support `fit-content`, it's quite straightforward to add.
It's just not completely clear what should happen when the argument has
a cyclic percentage, so this may need some further adjustments depending
on the outcome of https://github.com/w3c/csswg-drafts/issues/11805

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
Oriol Brufau 2025-03-23 15:26:44 +01:00 committed by GitHub
parent 3a356ffb74
commit 8c2ac88ad0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
33 changed files with 100 additions and 192 deletions

24
Cargo.lock generated
View file

@ -6513,7 +6513,7 @@ dependencies = [
[[package]]
name = "selectors"
version = "0.26.0"
source = "git+https://github.com/servo/stylo?branch=2025-03-15#4b44fbdb7f93c3f57eb99ad5f14cda5e82af4467"
source = "git+https://github.com/servo/stylo?branch=2025-03-15#bd0a7031b68ed87f9dbba0714e735fa5cf9df676"
dependencies = [
"bitflags 2.9.0",
"cssparser",
@ -6798,7 +6798,7 @@ dependencies = [
[[package]]
name = "servo_arc"
version = "0.4.0"
source = "git+https://github.com/servo/stylo?branch=2025-03-15#4b44fbdb7f93c3f57eb99ad5f14cda5e82af4467"
source = "git+https://github.com/servo/stylo?branch=2025-03-15#bd0a7031b68ed87f9dbba0714e735fa5cf9df676"
dependencies = [
"serde",
"stable_deref_trait",
@ -7248,7 +7248,7 @@ dependencies = [
[[package]]
name = "stylo"
version = "0.0.1"
source = "git+https://github.com/servo/stylo?branch=2025-03-15#4b44fbdb7f93c3f57eb99ad5f14cda5e82af4467"
source = "git+https://github.com/servo/stylo?branch=2025-03-15#bd0a7031b68ed87f9dbba0714e735fa5cf9df676"
dependencies = [
"app_units",
"arrayvec",
@ -7306,7 +7306,7 @@ dependencies = [
[[package]]
name = "stylo_atoms"
version = "0.1.0"
source = "git+https://github.com/servo/stylo?branch=2025-03-15#4b44fbdb7f93c3f57eb99ad5f14cda5e82af4467"
source = "git+https://github.com/servo/stylo?branch=2025-03-15#bd0a7031b68ed87f9dbba0714e735fa5cf9df676"
dependencies = [
"string_cache",
"string_cache_codegen",
@ -7315,12 +7315,12 @@ dependencies = [
[[package]]
name = "stylo_config"
version = "0.1.0"
source = "git+https://github.com/servo/stylo?branch=2025-03-15#4b44fbdb7f93c3f57eb99ad5f14cda5e82af4467"
source = "git+https://github.com/servo/stylo?branch=2025-03-15#bd0a7031b68ed87f9dbba0714e735fa5cf9df676"
[[package]]
name = "stylo_derive"
version = "0.0.1"
source = "git+https://github.com/servo/stylo?branch=2025-03-15#4b44fbdb7f93c3f57eb99ad5f14cda5e82af4467"
source = "git+https://github.com/servo/stylo?branch=2025-03-15#bd0a7031b68ed87f9dbba0714e735fa5cf9df676"
dependencies = [
"darling",
"proc-macro2",
@ -7332,7 +7332,7 @@ dependencies = [
[[package]]
name = "stylo_dom"
version = "0.1.0"
source = "git+https://github.com/servo/stylo?branch=2025-03-15#4b44fbdb7f93c3f57eb99ad5f14cda5e82af4467"
source = "git+https://github.com/servo/stylo?branch=2025-03-15#bd0a7031b68ed87f9dbba0714e735fa5cf9df676"
dependencies = [
"bitflags 2.9.0",
"stylo_malloc_size_of",
@ -7341,7 +7341,7 @@ dependencies = [
[[package]]
name = "stylo_malloc_size_of"
version = "0.0.1"
source = "git+https://github.com/servo/stylo?branch=2025-03-15#4b44fbdb7f93c3f57eb99ad5f14cda5e82af4467"
source = "git+https://github.com/servo/stylo?branch=2025-03-15#bd0a7031b68ed87f9dbba0714e735fa5cf9df676"
dependencies = [
"app_units",
"cssparser",
@ -7358,12 +7358,12 @@ dependencies = [
[[package]]
name = "stylo_static_prefs"
version = "0.1.0"
source = "git+https://github.com/servo/stylo?branch=2025-03-15#4b44fbdb7f93c3f57eb99ad5f14cda5e82af4467"
source = "git+https://github.com/servo/stylo?branch=2025-03-15#bd0a7031b68ed87f9dbba0714e735fa5cf9df676"
[[package]]
name = "stylo_traits"
version = "0.0.1"
source = "git+https://github.com/servo/stylo?branch=2025-03-15#4b44fbdb7f93c3f57eb99ad5f14cda5e82af4467"
source = "git+https://github.com/servo/stylo?branch=2025-03-15#bd0a7031b68ed87f9dbba0714e735fa5cf9df676"
dependencies = [
"app_units",
"bitflags 2.9.0",
@ -7746,7 +7746,7 @@ dependencies = [
[[package]]
name = "to_shmem"
version = "0.1.0"
source = "git+https://github.com/servo/stylo?branch=2025-03-15#4b44fbdb7f93c3f57eb99ad5f14cda5e82af4467"
source = "git+https://github.com/servo/stylo?branch=2025-03-15#bd0a7031b68ed87f9dbba0714e735fa5cf9df676"
dependencies = [
"cssparser",
"servo_arc",
@ -7759,7 +7759,7 @@ dependencies = [
[[package]]
name = "to_shmem_derive"
version = "0.1.0"
source = "git+https://github.com/servo/stylo?branch=2025-03-15#4b44fbdb7f93c3f57eb99ad5f14cda5e82af4467"
source = "git+https://github.com/servo/stylo?branch=2025-03-15#bd0a7031b68ed87f9dbba0714e735fa5cf9df676"
dependencies = [
"darling",
"proc-macro2",