mirror of
https://github.com/servo/servo.git
synced 2025-08-13 09:25:32 +01:00
layout: Add an indefinite containing block for intrinsic sizing (#33204)
When computing the min-content or max-content size of an element we need to ignore `inline-size`, `min-inline-size` and `max-inline-size`. However, we should take the block-axis sizing properties into account. That's because the contents could have percentages depending on them, which can then affect their inline size via an aspect ratio. Therefore, this patch adds `IndefiniteContainingBlock`, which is similar to `ContainingBlock`, but it allows an indefinite inline-size. This struct is then passed arround during intrinsic sizing. More refinement will be needed in follow-up patches in order to fully address the problem. Signed-off-by: Oriol Brufau <obrufau@igalia.com> Co-authored-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
46dbe4ce32
commit
93abdf7cb5
29 changed files with 600 additions and 332 deletions
|
@ -27,7 +27,7 @@ use crate::geom::{
|
|||
PhysicalPoint, PhysicalRect, ToLogical,
|
||||
};
|
||||
use crate::style_ext::{ComputedValuesExt, DisplayInside};
|
||||
use crate::{ContainingBlock, DefiniteContainingBlock};
|
||||
use crate::{ContainingBlock, DefiniteContainingBlock, IndefiniteContainingBlock};
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
pub(crate) struct AbsolutelyPositionedBox {
|
||||
|
@ -578,8 +578,16 @@ impl HoistedAbsolutelyPositionedBox {
|
|||
let margin_sum = inline_axis.margin_start + inline_axis.margin_end;
|
||||
let available_size =
|
||||
cbis - anchor - pbm.padding_border_sums.inline - margin_sum;
|
||||
|
||||
let style = non_replaced.style.clone();
|
||||
let containing_block_for_children =
|
||||
IndefiniteContainingBlock::from(containing_block)
|
||||
.new_for_intrinsic_inline_size_of_child(
|
||||
&style,
|
||||
&LogicalVec2::zero(),
|
||||
);
|
||||
non_replaced
|
||||
.inline_content_sizes(layout_context)
|
||||
.inline_content_sizes(layout_context, &containing_block_for_children)
|
||||
.shrink_to_fit(available_size)
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue