mirror of
https://github.com/servo/servo.git
synced 2025-08-02 12:10:29 +01:00
layout: Fix interaction of margin and stretch size on block-level boxes (#35904)
The CSSWG resolved that `block-size: stretch` on a block-level box stretches the margin box to fill the parent. However, if the parent doesn't have padding nor border, and doesn't establish an independent formatting context, then we assume that the margins will collapse. Therefore, we treat the margins as zero when resolving the stretch size, regardless of whether they will actually end up collapsing. https://github.com/w3c/csswg-drafts/issues/11044#issuecomment-2599101601 https://drafts.csswg.org/css-sizing-4/#stretch-fit-sizing Signed-off-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
parent
f7ddac249b
commit
9858ec81f9
14 changed files with 379 additions and 120 deletions
|
@ -30,7 +30,9 @@ use crate::cell::ArcRefCell;
|
|||
use crate::context::LayoutContext;
|
||||
use crate::dom::NodeExt;
|
||||
use crate::fragment_tree::{BaseFragmentInfo, Fragment, IFrameFragment, ImageFragment};
|
||||
use crate::geom::{LogicalVec2, PhysicalPoint, PhysicalRect, PhysicalSize, Size, Sizes};
|
||||
use crate::geom::{
|
||||
LogicalSides1D, LogicalVec2, PhysicalPoint, PhysicalRect, PhysicalSize, Size, Sizes,
|
||||
};
|
||||
use crate::layout_box_base::LayoutBoxBase;
|
||||
use crate::sizing::{ComputeInlineContentSizes, ContentSizes, InlineContentSizesResult};
|
||||
use crate::style_ext::{AspectRatio, Clamp, ComputedValuesExt, ContentBoxSizesAndPBM, LayoutStyle};
|
||||
|
@ -434,6 +436,7 @@ impl ReplacedContents {
|
|||
containing_block: &ContainingBlock,
|
||||
style: &ComputedValues,
|
||||
content_box_sizes_and_pbm: &ContentBoxSizesAndPBM,
|
||||
ignore_block_margins_for_stretch: LogicalSides1D<bool>,
|
||||
) -> LogicalVec2<Au> {
|
||||
let pbm = &content_box_sizes_and_pbm.pbm;
|
||||
self.used_size_as_if_inline_element_from_content_box_sizes(
|
||||
|
@ -442,7 +445,7 @@ impl ReplacedContents {
|
|||
self.preferred_aspect_ratio(style, &pbm.padding_border_sums),
|
||||
content_box_sizes_and_pbm.content_box_sizes.as_ref(),
|
||||
Size::FitContent.into(),
|
||||
pbm.padding_border_sums + pbm.margin.auto_is(Au::zero).sum(),
|
||||
pbm.sums_auto_is_zero(ignore_block_margins_for_stretch),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue