Refactor positioned layout (#33922)

This unifies the size resolution into AbsoluteAxisSolver, since it needs
to know the size in order to resolve auto margins correctly anyways.
This will allow adding support for sizing keywords in a follow-up patch.

Also, this avoids doing multiple layouts due to min and max constraints,
improving performance.

Additionally, tables may end up having a custom size, different than
what we would expect by just looking at the sizing properties. This
patch ensures that we resolve margins correctly with the final size,
resulting in 2 tests now passing.

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
Oriol Brufau 2024-10-21 12:41:42 +02:00 committed by GitHub
parent fee927475b
commit 2319764a1e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 195 additions and 256 deletions

View file

@ -30,7 +30,6 @@ pub use flow::BoxTree;
pub use fragment_tree::FragmentTree;
use geom::AuOrAuto;
use style::properties::ComputedValues;
use style_ext::{Clamp, ComputedValuesExt};
use crate::geom::LogicalVec2;
@ -59,22 +58,6 @@ impl<'a> IndefiniteContainingBlock<'a> {
style,
}
}
fn new_for_intrinsic_inline_size_of_child(
&self,
style: &'a ComputedValues,
auto_minimum: &LogicalVec2<Au>,
) -> Self {
let (content_box_size, content_min_size, content_max_size, _, _) =
style.content_box_sizes_and_padding_border_margin_deprecated(self);
let block_size = content_box_size.block.map(|v| {
v.clamp_between_extremums(
content_min_size.block.auto_is(|| auto_minimum.block),
content_max_size.block,
)
});
IndefiniteContainingBlock::new_for_style_and_block_size(style, block_size)
}
}
impl<'a> From<&'_ ContainingBlock<'a>> for IndefiniteContainingBlock<'a> {