layout: Unify FlexItem::new() and FlexItemBox::main_content_size_info() (#35900)

These methods were doing virtually the same thing. So this patch moves
the common logic into a new `FlexItemBox::to_flex_item()`, which is then
called by `FlexItem::new()` and `FlexItemBox::main_content_size_info()`.

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
Oriol Brufau 2025-03-14 22:37:19 +01:00 committed by GitHub
parent f93d65b496
commit 7517976722
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 188 additions and 254 deletions

View file

@ -14,15 +14,6 @@ pub(super) struct FlexRelativeVec2<T> {
pub cross: T,
}
impl<T> FlexRelativeVec2<T> {
pub fn map<U>(&self, f: impl Fn(&T) -> U) -> FlexRelativeVec2<U> {
FlexRelativeVec2 {
main: f(&self.main),
cross: f(&self.cross),
}
}
}
#[derive(Clone, Copy, Debug)]
pub(super) struct FlexRelativeSides<T> {
pub cross_start: T,