diff options
author | Pu Xingyu <pu.stshine@gmail.com> | 2023-05-27 09:03:40 +0800 |
---|---|---|
committer | Pu Xingyu <pu.stshine@gmail.com> | 2023-05-27 09:03:40 +0800 |
commit | 1dbd74f3899ff0469472e687ecc763e116247e6e (patch) | |
tree | 6c031cdc64414bf666ecd130834d02625164e925 | |
parent | 867326c46a4af0b85be9ba6c67cb18e8832480a5 (diff) | |
download | servo-1dbd74f3899ff0469472e687ecc763e116247e6e.tar.gz servo-1dbd74f3899ff0469472e687ecc763e116247e6e.zip |
layout_2020: Add an optional box size parameter to ReplacedContent::used_size_as_if_inline_element
This allow us to specify the used size when calculating size of
replaced content.
-rw-r--r-- | components/layout_2020/flexbox/layout.rs | 1 | ||||
-rw-r--r-- | components/layout_2020/flow/inline.rs | 1 | ||||
-rw-r--r-- | components/layout_2020/flow/mod.rs | 2 | ||||
-rw-r--r-- | components/layout_2020/positioned.rs | 1 | ||||
-rw-r--r-- | components/layout_2020/replaced.rs | 3 |
5 files changed, 6 insertions, 2 deletions
diff --git a/components/layout_2020/flexbox/layout.rs b/components/layout_2020/flexbox/layout.rs index a7a2875a703..caf88955a60 100644 --- a/components/layout_2020/flexbox/layout.rs +++ b/components/layout_2020/flexbox/layout.rs @@ -1006,6 +1006,7 @@ impl<'a> FlexItem<'a> { let size = replaced.contents.used_size_as_if_inline_element( flex_context.containing_block, &replaced.style, + None, &pbm, ); let cross_size = flex_context.vec2_to_flex_relative(size.clone()).cross; diff --git a/components/layout_2020/flow/inline.rs b/components/layout_2020/flow/inline.rs index 740c34cf7c0..df96d0bbd4e 100644 --- a/components/layout_2020/flow/inline.rs +++ b/components/layout_2020/flow/inline.rs @@ -573,6 +573,7 @@ fn layout_atomic( let size = replaced.contents.used_size_as_if_inline_element( ifc.containing_block, &replaced.style, + None, &pbm, ); let fragments = replaced diff --git a/components/layout_2020/flow/mod.rs b/components/layout_2020/flow/mod.rs index 11af4147ce0..73630acf7bd 100644 --- a/components/layout_2020/flow/mod.rs +++ b/components/layout_2020/flow/mod.rs @@ -581,7 +581,7 @@ fn layout_in_flow_replaced_block_level<'a>( replaced: &ReplacedContent, ) -> BoxFragment { let pbm = style.padding_border_margin(containing_block); - let size = replaced.used_size_as_if_inline_element(containing_block, style, &pbm); + let size = replaced.used_size_as_if_inline_element(containing_block, style, None, &pbm); let (margin_inline_start, margin_inline_end) = solve_inline_margins_for_in_flow_block_level(containing_block, &pbm, size.inline); diff --git a/components/layout_2020/positioned.rs b/components/layout_2020/positioned.rs index 37f2a0fb321..727fa618292 100644 --- a/components/layout_2020/positioned.rs +++ b/components/layout_2020/positioned.rs @@ -439,6 +439,7 @@ impl HoistedAbsolutelyPositionedBox { let used_size = replaced.contents.used_size_as_if_inline_element( &containing_block.into(), &replaced.style, + None, &pbm, ); Vec2 { diff --git a/components/layout_2020/replaced.rs b/components/layout_2020/replaced.rs index 642e83f7905..af4a3c8a62b 100644 --- a/components/layout_2020/replaced.rs +++ b/components/layout_2020/replaced.rs @@ -309,13 +309,14 @@ impl ReplacedContent { &self, containing_block: &ContainingBlock, style: &ComputedValues, + box_size: Option<Vec2<LengthOrAuto>>, pbm: &PaddingBorderMargin, ) -> Vec2<Length> { let mode = style.writing_mode; let intrinsic_size = self.flow_relative_intrinsic_size(style); let intrinsic_ratio = self.inline_size_over_block_size_intrinsic_ratio(style); - let box_size = style.content_box_size(containing_block, &pbm); + let box_size = box_size.unwrap_or(style.content_box_size(containing_block, &pbm)); let max_box_size = style.content_max_box_size(containing_block, &pbm); let min_box_size = style .content_min_box_size(containing_block, &pbm) |