aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOriol Brufau <obrufau@igalia.com>2023-07-19 07:38:33 +0200
committerGitHub <noreply@github.com>2023-07-19 05:38:33 +0000
commit9c333ab1eea56477a9d2647dc56f2a9aa4beec51 (patch)
tree8e138f12e38c85631ddc8f529ea09acc9bdaa895
parentae3f33b9d03393eb25503fa3b30f05957119f9a7 (diff)
downloadservo-9c333ab1eea56477a9d2647dc56f2a9aa4beec51.tar.gz
servo-9c333ab1eea56477a9d2647dc56f2a9aa4beec51.zip
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.
-rw-r--r--components/layout_2020/flow/mod.rs58
1 files changed, 26 insertions, 32 deletions
diff --git a/components/layout_2020/flow/mod.rs b/components/layout_2020/flow/mod.rs
index ca28f4318ff..da57d42334e 100644
--- a/components/layout_2020/flow/mod.rs
+++ b/components/layout_2020/flow/mod.rs
@@ -223,16 +223,30 @@ fn calculate_inline_content_size_for_block_level_boxes(
writing_mode: WritingMode,
) -> ContentSizes {
let get_box_info = |box_: &ArcRefCell<BlockLevelBox>| {
- let size = box_
- .borrow_mut()
- .inline_content_sizes(layout_context, writing_mode);
- if let BlockLevelBox::OutOfFlowFloatBox(ref float_box) = *box_.borrow_mut() {
- let style_box = &float_box.contents.style().get_box();
- (size, style_box.float, style_box.clear)
- } else {
- // The element may in fact have clearance, but the logic below ignores it,
- // so don't bother retrieving it from the style.
- (size, Float::None, Clear::None)
+ match &mut *box_.borrow_mut() {
+ BlockLevelBox::OutOfFlowAbsolutelyPositionedBox(_) => None,
+ BlockLevelBox::OutOfFlowFloatBox(ref mut float_box) => {
+ let size = float_box
+ .contents
+ .outer_inline_content_sizes(layout_context, writing_mode);
+ let style_box = &float_box.contents.style().get_box();
+ Some((size, style_box.float, style_box.clear))
+ },
+ 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 {
boxes
.par_iter()
- .map(get_box_info)
+ .filter_map(get_box_info)
.collect::<Vec<_>>()
.into_iter()
.fold(zero, accumulate)
} 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()
}
@@ -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