mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Totally ignore abspos children for intrinsic sizing (#30010)
calculate_inline_content_size_for_block_level_boxes was relying on inline_content_sizes to get the size of each block-level box child. For absolutely positioned boxes, this was 0x0. That was no-op before #29887, but then it prevented adding the sizes of a sequence of floats. Abspos should just be ignored instead of treated as 0x0. This patch removes inline_content_sizes, moves the logic into calculate_inline_content_size_for_block_level_boxes (the only caller), and handles abspos correctly.
This commit is contained in:
parent
ae3f33b9d0
commit
9c333ab1ee
1 changed files with 26 additions and 32 deletions
|
@ -223,16 +223,30 @@ fn calculate_inline_content_size_for_block_level_boxes(
|
||||||
writing_mode: WritingMode,
|
writing_mode: WritingMode,
|
||||||
) -> ContentSizes {
|
) -> ContentSizes {
|
||||||
let get_box_info = |box_: &ArcRefCell<BlockLevelBox>| {
|
let get_box_info = |box_: &ArcRefCell<BlockLevelBox>| {
|
||||||
let size = box_
|
match &mut *box_.borrow_mut() {
|
||||||
.borrow_mut()
|
BlockLevelBox::OutOfFlowAbsolutelyPositionedBox(_) => None,
|
||||||
.inline_content_sizes(layout_context, writing_mode);
|
BlockLevelBox::OutOfFlowFloatBox(ref mut float_box) => {
|
||||||
if let BlockLevelBox::OutOfFlowFloatBox(ref float_box) = *box_.borrow_mut() {
|
let size = float_box
|
||||||
let style_box = &float_box.contents.style().get_box();
|
.contents
|
||||||
(size, style_box.float, style_box.clear)
|
.outer_inline_content_sizes(layout_context, writing_mode);
|
||||||
} else {
|
let style_box = &float_box.contents.style().get_box();
|
||||||
// The element may in fact have clearance, but the logic below ignores it,
|
Some((size, style_box.float, style_box.clear))
|
||||||
// so don't bother retrieving it from the style.
|
},
|
||||||
(size, Float::None, Clear::None)
|
BlockLevelBox::SameFormattingContextBlock {
|
||||||
|
style, contents, ..
|
||||||
|
} => {
|
||||||
|
let size = sizing::outer_inline(&style, writing_mode, || {
|
||||||
|
contents.inline_content_sizes(layout_context, style.writing_mode)
|
||||||
|
});
|
||||||
|
// The element may in fact have clearance, but the logic below ignores it,
|
||||||
|
// so don't bother retrieving it from the style.
|
||||||
|
Some((size, Float::None, Clear::None))
|
||||||
|
},
|
||||||
|
BlockLevelBox::Independent(ref mut independent) => {
|
||||||
|
let size = independent.outer_inline_content_sizes(layout_context, writing_mode);
|
||||||
|
// TODO: do the right thing instead of copying SameFormattingContextBlock.
|
||||||
|
Some((size, Float::None, Clear::None))
|
||||||
|
},
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -295,12 +309,12 @@ fn calculate_inline_content_size_for_block_level_boxes(
|
||||||
let data = if layout_context.use_rayon {
|
let data = if layout_context.use_rayon {
|
||||||
boxes
|
boxes
|
||||||
.par_iter()
|
.par_iter()
|
||||||
.map(get_box_info)
|
.filter_map(get_box_info)
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.fold(zero, accumulate)
|
.fold(zero, accumulate)
|
||||||
} else {
|
} else {
|
||||||
boxes.iter().map(get_box_info).fold(zero, accumulate)
|
boxes.iter().filter_map(get_box_info).fold(zero, accumulate)
|
||||||
};
|
};
|
||||||
data.max_size_including_uncleared_floats()
|
data.max_size_including_uncleared_floats()
|
||||||
}
|
}
|
||||||
|
@ -552,26 +566,6 @@ impl BlockLevelBox {
|
||||||
)),
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn inline_content_sizes(
|
|
||||||
&mut self,
|
|
||||||
layout_context: &LayoutContext,
|
|
||||||
containing_block_writing_mode: WritingMode,
|
|
||||||
) -> ContentSizes {
|
|
||||||
match self {
|
|
||||||
Self::SameFormattingContextBlock {
|
|
||||||
style, contents, ..
|
|
||||||
} => sizing::outer_inline(style, containing_block_writing_mode, || {
|
|
||||||
contents.inline_content_sizes(layout_context, style.writing_mode)
|
|
||||||
}),
|
|
||||||
Self::Independent(independent) => independent
|
|
||||||
.outer_inline_content_sizes(layout_context, containing_block_writing_mode),
|
|
||||||
BlockLevelBox::OutOfFlowAbsolutelyPositionedBox(_) => ContentSizes::zero(),
|
|
||||||
BlockLevelBox::OutOfFlowFloatBox(float_box) => float_box
|
|
||||||
.contents
|
|
||||||
.outer_inline_content_sizes(layout_context, containing_block_writing_mode),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Lay out a normal flow non-replaced block that does not establish a new formatting
|
/// Lay out a normal flow non-replaced block that does not establish a new formatting
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue