Let LengthPercentage::maybe_to_used_value() accept Option<Au> (#33450)

Bump Stylo to servo/stylo#75 and remove conversions that are no longer
necessary.

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
Oriol Brufau 2024-09-16 10:08:54 +02:00 committed by GitHub
parent 9f2306f760
commit 17f796dfc1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 26 additions and 32 deletions

28
Cargo.lock generated
View file

@ -1298,7 +1298,7 @@ dependencies = [
[[package]]
name = "derive_common"
version = "0.0.1"
source = "git+https://github.com/servo/stylo?branch=2024-09-02#89bbdff5ad80cf0a9814a7102379b5eeca89363e"
source = "git+https://github.com/servo/stylo?branch=2024-09-02#6059306e6c2cbd8c76473b545bfbfd2be4062de4"
dependencies = [
"darling",
"proc-macro2",
@ -1486,7 +1486,7 @@ dependencies = [
[[package]]
name = "dom"
version = "0.0.1"
source = "git+https://github.com/servo/stylo?branch=2024-09-02#89bbdff5ad80cf0a9814a7102379b5eeca89363e"
source = "git+https://github.com/servo/stylo?branch=2024-09-02#6059306e6c2cbd8c76473b545bfbfd2be4062de4"
dependencies = [
"bitflags 2.6.0",
]
@ -4118,7 +4118,7 @@ dependencies = [
[[package]]
name = "malloc_size_of"
version = "0.0.1"
source = "git+https://github.com/servo/stylo?branch=2024-09-02#89bbdff5ad80cf0a9814a7102379b5eeca89363e"
source = "git+https://github.com/servo/stylo?branch=2024-09-02#6059306e6c2cbd8c76473b545bfbfd2be4062de4"
dependencies = [
"accountable-refcell",
"app_units",
@ -5911,7 +5911,7 @@ dependencies = [
[[package]]
name = "selectors"
version = "0.24.0"
source = "git+https://github.com/servo/stylo?branch=2024-09-02#89bbdff5ad80cf0a9814a7102379b5eeca89363e"
source = "git+https://github.com/servo/stylo?branch=2024-09-02#6059306e6c2cbd8c76473b545bfbfd2be4062de4"
dependencies = [
"bitflags 2.6.0",
"cssparser",
@ -6199,7 +6199,7 @@ dependencies = [
[[package]]
name = "servo_arc"
version = "0.2.0"
source = "git+https://github.com/servo/stylo?branch=2024-09-02#89bbdff5ad80cf0a9814a7102379b5eeca89363e"
source = "git+https://github.com/servo/stylo?branch=2024-09-02#6059306e6c2cbd8c76473b545bfbfd2be4062de4"
dependencies = [
"serde",
"stable_deref_trait",
@ -6208,7 +6208,7 @@ dependencies = [
[[package]]
name = "servo_atoms"
version = "0.0.1"
source = "git+https://github.com/servo/stylo?branch=2024-09-02#89bbdff5ad80cf0a9814a7102379b5eeca89363e"
source = "git+https://github.com/servo/stylo?branch=2024-09-02#6059306e6c2cbd8c76473b545bfbfd2be4062de4"
dependencies = [
"string_cache",
"string_cache_codegen",
@ -6426,7 +6426,7 @@ checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d"
[[package]]
name = "size_of_test"
version = "0.0.1"
source = "git+https://github.com/servo/stylo?branch=2024-09-02#89bbdff5ad80cf0a9814a7102379b5eeca89363e"
source = "git+https://github.com/servo/stylo?branch=2024-09-02#6059306e6c2cbd8c76473b545bfbfd2be4062de4"
dependencies = [
"static_assertions",
]
@ -6567,7 +6567,7 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
[[package]]
name = "static_prefs"
version = "0.1.0"
source = "git+https://github.com/servo/stylo?branch=2024-09-02#89bbdff5ad80cf0a9814a7102379b5eeca89363e"
source = "git+https://github.com/servo/stylo?branch=2024-09-02#6059306e6c2cbd8c76473b545bfbfd2be4062de4"
[[package]]
name = "strck"
@ -6620,7 +6620,7 @@ dependencies = [
[[package]]
name = "style"
version = "0.0.1"
source = "git+https://github.com/servo/stylo?branch=2024-09-02#89bbdff5ad80cf0a9814a7102379b5eeca89363e"
source = "git+https://github.com/servo/stylo?branch=2024-09-02#6059306e6c2cbd8c76473b545bfbfd2be4062de4"
dependencies = [
"app_units",
"arrayvec",
@ -6678,7 +6678,7 @@ dependencies = [
[[package]]
name = "style_config"
version = "0.0.1"
source = "git+https://github.com/servo/stylo?branch=2024-09-02#89bbdff5ad80cf0a9814a7102379b5eeca89363e"
source = "git+https://github.com/servo/stylo?branch=2024-09-02#6059306e6c2cbd8c76473b545bfbfd2be4062de4"
dependencies = [
"lazy_static",
]
@ -6686,7 +6686,7 @@ dependencies = [
[[package]]
name = "style_derive"
version = "0.0.1"
source = "git+https://github.com/servo/stylo?branch=2024-09-02#89bbdff5ad80cf0a9814a7102379b5eeca89363e"
source = "git+https://github.com/servo/stylo?branch=2024-09-02#6059306e6c2cbd8c76473b545bfbfd2be4062de4"
dependencies = [
"darling",
"derive_common",
@ -6717,7 +6717,7 @@ dependencies = [
[[package]]
name = "style_traits"
version = "0.0.1"
source = "git+https://github.com/servo/stylo?branch=2024-09-02#89bbdff5ad80cf0a9814a7102379b5eeca89363e"
source = "git+https://github.com/servo/stylo?branch=2024-09-02#6059306e6c2cbd8c76473b545bfbfd2be4062de4"
dependencies = [
"app_units",
"bitflags 2.6.0",
@ -7084,7 +7084,7 @@ dependencies = [
[[package]]
name = "to_shmem"
version = "0.0.1"
source = "git+https://github.com/servo/stylo?branch=2024-09-02#89bbdff5ad80cf0a9814a7102379b5eeca89363e"
source = "git+https://github.com/servo/stylo?branch=2024-09-02#6059306e6c2cbd8c76473b545bfbfd2be4062de4"
dependencies = [
"cssparser",
"servo_arc",
@ -7097,7 +7097,7 @@ dependencies = [
[[package]]
name = "to_shmem_derive"
version = "0.0.1"
source = "git+https://github.com/servo/stylo?branch=2024-09-02#89bbdff5ad80cf0a9814a7102379b5eeca89363e"
source = "git+https://github.com/servo/stylo?branch=2024-09-02#6059306e6c2cbd8c76473b545bfbfd2be4062de4"
dependencies = [
"darling",
"derive_common",

View file

@ -525,7 +525,7 @@ pub fn style_length(style_length: &Size, container_size: Option<Au>) -> MaybeAut
match style_length {
Size::Auto => MaybeAuto::Auto,
Size::LengthPercentage(ref lp) => {
MaybeAuto::from_option(lp.0.maybe_to_used_value(container_size.map(|l| l.into())))
MaybeAuto::from_option(lp.0.maybe_to_used_value(container_size))
},
}
}

View file

@ -146,13 +146,12 @@ impl LogicalVec2<LengthPercentageOrAuto<'_>> {
.inline
.map(|value| value.to_used_value(containing_block.inline_size)),
block: {
let containing_block_block_size =
containing_block.block_size.non_auto().map(Into::into);
self.block
.non_auto()
.and_then(|value| value.maybe_to_used_value(containing_block_block_size))
.map(AuOrAuto::LengthPercentage)
.unwrap_or(AuOrAuto::Auto)
.and_then(|value| {
value.maybe_to_used_value(containing_block.block_size.non_auto())
})
.map_or(AuOrAuto::Auto, AuOrAuto::LengthPercentage)
},
}
}
@ -175,20 +174,17 @@ impl LogicalVec2<LengthPercentageOrAuto<'_>> {
&self,
basis: &LogicalVec2<Option<Au>>,
) -> LogicalVec2<AuOrAuto> {
let basis = basis.map(|value| value.map(Into::into));
LogicalVec2 {
inline: self
.inline
.non_auto()
.and_then(|value| value.maybe_to_used_value(basis.inline))
.map(AuOrAuto::LengthPercentage)
.unwrap_or(AuOrAuto::Auto),
.map_or(AuOrAuto::Auto, AuOrAuto::LengthPercentage),
block: self
.block
.non_auto()
.and_then(|value| value.maybe_to_used_value(basis.block))
.map(AuOrAuto::LengthPercentage)
.unwrap_or(AuOrAuto::Auto),
.map_or(AuOrAuto::Auto, AuOrAuto::LengthPercentage),
}
}
}
@ -202,9 +198,9 @@ impl LogicalVec2<Option<&'_ LengthPercentage>> {
inline: self
.inline
.map(|lp| lp.to_used_value(containing_block.inline_size)),
block: self.block.and_then(|lp| {
lp.maybe_to_used_value(containing_block.block_size.map(Into::into).non_auto())
}),
block: self
.block
.and_then(|lp| lp.maybe_to_used_value(containing_block.block_size.non_auto())),
}
}
}
@ -217,10 +213,8 @@ impl LogicalVec2<Option<&'_ LengthPercentage>> {
LogicalVec2 {
inline: self
.inline
.and_then(|v| v.maybe_to_used_value(basis.inline.map(Into::into))),
block: self
.block
.and_then(|v| v.maybe_to_used_value(basis.block.map(Into::into))),
.and_then(|v| v.maybe_to_used_value(basis.inline)),
block: self.block.and_then(|v| v.maybe_to_used_value(basis.block)),
}
}
}