mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Add min/max-width/height support for inline-block
(… and other non-replaced atomic inline-level boxes.)
This commit is contained in:
parent
999dd72895
commit
bf96988260
2 changed files with 35 additions and 5 deletions
|
@ -482,10 +482,29 @@ fn layout_atomic<'box_tree>(
|
||||||
},
|
},
|
||||||
Err(non_replaced) => {
|
Err(non_replaced) => {
|
||||||
let box_size = atomic.style.box_size();
|
let box_size = atomic.style.box_size();
|
||||||
let inline_size = box_size.inline.percentage_relative_to(cbis).auto_is(|| {
|
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();
|
let available_size = cbis - pbm.inline_sum();
|
||||||
atomic.content_sizes.shrink_to_fit(available_size)
|
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
|
let block_size = box_size
|
||||||
.block
|
.block
|
||||||
.maybe_percentage_relative_to(ifc.containing_block.block_size.non_auto());
|
.maybe_percentage_relative_to(ifc.containing_block.block_size.non_auto());
|
||||||
|
@ -508,7 +527,16 @@ fn layout_atomic<'box_tree>(
|
||||||
dummy_tree_rank,
|
dummy_tree_rank,
|
||||||
ifc.absolutely_positioned_fragments,
|
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 {
|
let content_rect = Rect {
|
||||||
start_corner,
|
start_corner,
|
||||||
size: Vec2 {
|
size: Vec2 {
|
||||||
|
|
|
@ -29,6 +29,8 @@ pub(crate) struct IndependentFormattingContext {
|
||||||
|
|
||||||
pub(crate) struct IndependentLayout {
|
pub(crate) struct IndependentLayout {
|
||||||
pub fragments: Vec<Fragment>,
|
pub fragments: Vec<Fragment>,
|
||||||
|
|
||||||
|
/// https://drafts.csswg.org/css2/visudet.html#root-height
|
||||||
pub content_block_size: Length,
|
pub content_block_size: Length,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue