diff options
Diffstat (limited to 'components/layout_2020/flow/inline.rs')
-rw-r--r-- | components/layout_2020/flow/inline.rs | 42 |
1 files changed, 34 insertions, 8 deletions
diff --git a/components/layout_2020/flow/inline.rs b/components/layout_2020/flow/inline.rs index 0cacfb794a7..c4b760275d9 100644 --- a/components/layout_2020/flow/inline.rs +++ b/components/layout_2020/flow/inline.rs @@ -465,9 +465,7 @@ fn layout_atomic<'box_tree>( let fragment = match atomic.as_replaced() { Ok(replaced) => { - // FIXME: implement https://drafts.csswg.org/css2/visudet.html#inline-replaced-width - // and https://drafts.csswg.org/css2/visudet.html#inline-replaced-height - let size = Vec2::zero(); + let size = replaced.used_size_as_if_inline_element(ifc.containing_block, &atomic.style); let fragments = replaced.make_fragments(&atomic.style, size.clone()); let content_rect = Rect { start_corner, size }; BoxFragment { @@ -482,10 +480,29 @@ fn layout_atomic<'box_tree>( }, Err(non_replaced) => { let box_size = atomic.style.box_size(); - let inline_size = box_size.inline.percentage_relative_to(cbis).auto_is(|| { - let available_size = cbis - pbm.inline_sum(); - atomic.content_sizes.shrink_to_fit(available_size) - }); + let max_box_size = atomic + .style + .max_box_size() + .percentages_relative_to(ifc.containing_block); + let min_box_size = atomic + .style + .min_box_size() + .percentages_relative_to(ifc.containing_block) + .auto_is(Length::zero); + + // https://drafts.csswg.org/css2/visudet.html#inlineblock-width + let tentative_inline_size = + box_size.inline.percentage_relative_to(cbis).auto_is(|| { + let available_size = cbis - pbm.inline_sum(); + atomic.content_sizes.shrink_to_fit(available_size) + }); + + // https://drafts.csswg.org/css2/visudet.html#min-max-widths + // In this case “applying the rules above again” with a non-auto inline-size + // always results in that size. + let inline_size = tentative_inline_size + .clamp_between_extremums(min_box_size.inline, max_box_size.inline); + let block_size = box_size .block .maybe_percentage_relative_to(ifc.containing_block.block_size.non_auto()); @@ -508,7 +525,16 @@ fn layout_atomic<'box_tree>( dummy_tree_rank, ifc.absolutely_positioned_fragments, ); - let block_size = block_size.auto_is(|| independent_layout.content_block_size); + + // https://drafts.csswg.org/css2/visudet.html#block-root-margin + let tentative_block_size = block_size.auto_is(|| independent_layout.content_block_size); + + // https://drafts.csswg.org/css2/visudet.html#min-max-heights + // In this case “applying the rules above again” with a non-auto block-size + // always results in that size. + let block_size = tentative_block_size + .clamp_between_extremums(min_box_size.block, max_box_size.block); + let content_rect = Rect { start_corner, size: Vec2 { |