mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
layout: Require specific layout info in BoxFragment::new()
(#37917)
It was very easy to forget about using `.with_specific_layout_info()` to set the specific layout info, so it's better to make it a parameter. In fact this already happened in the past: #36993 fixed the missing specific layout info for flex items. This patch fixes it for floats and atomic inlines. It also propagates it in other cases where not doing so was not a big deal because the specific layout info was None, but that was a fragile assumption. Testing: Various WPT improvements Fixes: #37898 Signed-off-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
parent
87f2871661
commit
fe9d49fccc
16 changed files with 126 additions and 687 deletions
|
@ -299,8 +299,8 @@ impl FlexLineItem<'_> {
|
|||
.sides_to_flow_relative(item_margin)
|
||||
.to_physical(container_writing_mode),
|
||||
None, /* clearance */
|
||||
)
|
||||
.with_specific_layout_info(self.layout_result.specific_layout_info);
|
||||
self.layout_result.specific_layout_info,
|
||||
);
|
||||
|
||||
// If this flex item establishes a containing block for absolutely-positioned
|
||||
// descendants, then lay out any relevant absolutely-positioned children. This
|
||||
|
|
|
@ -460,6 +460,7 @@ impl LineItemLayout<'_, '_> {
|
|||
border.to_physical(ifc_writing_mode),
|
||||
margin.to_physical(ifc_writing_mode),
|
||||
None, /* clearance */
|
||||
None, /* specific_layout_info */
|
||||
);
|
||||
|
||||
let offset_from_parent_ifc = LogicalVec2 {
|
||||
|
|
|
@ -408,6 +408,7 @@ impl OutsideMarker {
|
|||
PhysicalSides::zero(),
|
||||
PhysicalSides::zero(),
|
||||
None,
|
||||
flow_layout.specific_layout_info,
|
||||
)))
|
||||
}
|
||||
|
||||
|
@ -1173,6 +1174,7 @@ fn layout_in_flow_non_replaced_block_level_same_formatting_context(
|
|||
pbm.border.to_physical(containing_block_writing_mode),
|
||||
margin.to_physical(containing_block_writing_mode),
|
||||
clearance,
|
||||
flow_layout.specific_layout_info,
|
||||
)
|
||||
.with_baselines(flow_layout.baselines)
|
||||
.with_block_margins_collapsed_with_children(block_margins_collapsed_with_children)
|
||||
|
@ -1285,9 +1287,9 @@ impl IndependentFormattingContext {
|
|||
pbm.border.to_physical(containing_block_writing_mode),
|
||||
margin.to_physical(containing_block_writing_mode),
|
||||
None, /* clearance */
|
||||
layout.specific_layout_info,
|
||||
)
|
||||
.with_baselines(layout.baselines)
|
||||
.with_specific_layout_info(layout.specific_layout_info)
|
||||
.with_block_margins_collapsed_with_children(block_margins_collapsed_with_children)
|
||||
}
|
||||
|
||||
|
@ -1603,9 +1605,9 @@ impl IndependentFormattingContext {
|
|||
pbm.border.to_physical(containing_block_writing_mode),
|
||||
margin.to_physical(containing_block_writing_mode),
|
||||
clearance,
|
||||
layout.specific_layout_info,
|
||||
)
|
||||
.with_baselines(layout.baselines)
|
||||
.with_specific_layout_info(layout.specific_layout_info)
|
||||
.with_block_margins_collapsed_with_children(CollapsedBlockMargins::from_margin(&margin))
|
||||
}
|
||||
}
|
||||
|
@ -2241,7 +2243,7 @@ impl IndependentFormattingContext {
|
|||
let margin = pbm.margin.auto_is(Au::zero);
|
||||
let pbm_sums = pbm.padding + pbm.border + margin;
|
||||
|
||||
let (fragments, content_rect, baselines) = match &self.contents {
|
||||
let (fragments, content_rect, baselines, specific_layout_info) = match &self.contents {
|
||||
IndependentFormattingContextContents::Replaced(replaced) => {
|
||||
// Floats and atomic inlines can't collapse margins with their parent,
|
||||
// so don't ignore block margins when resolving a stretch block size.
|
||||
|
@ -2261,7 +2263,7 @@ impl IndependentFormattingContext {
|
|||
let fragments = replaced.make_fragments(layout_context, style, content_size);
|
||||
|
||||
let content_rect = PhysicalRect::new(PhysicalPoint::zero(), content_size);
|
||||
(fragments, content_rect, None)
|
||||
(fragments, content_rect, None, None)
|
||||
},
|
||||
IndependentFormattingContextContents::NonReplaced(non_replaced) => {
|
||||
let writing_mode = self.style().writing_mode;
|
||||
|
@ -2344,6 +2346,7 @@ impl IndependentFormattingContext {
|
|||
independent_layout.fragments,
|
||||
content_rect,
|
||||
Some(independent_layout.baselines),
|
||||
independent_layout.specific_layout_info,
|
||||
)
|
||||
},
|
||||
};
|
||||
|
@ -2367,6 +2370,7 @@ impl IndependentFormattingContext {
|
|||
// so there's no need to store it explicitly in the fragment.
|
||||
// And atomic inlines don't have clearance.
|
||||
None, /* clearance */
|
||||
specific_layout_info,
|
||||
);
|
||||
|
||||
IndependentFloatOrAtomicLayoutResult {
|
||||
|
|
|
@ -116,6 +116,7 @@ impl BoxFragment {
|
|||
border: PhysicalSides<Au>,
|
||||
margin: PhysicalSides<Au>,
|
||||
clearance: Option<Au>,
|
||||
specific_layout_info: Option<SpecificLayoutInfo>,
|
||||
) -> BoxFragment {
|
||||
BoxFragment {
|
||||
base: base_fragment_info.into(),
|
||||
|
@ -132,7 +133,7 @@ impl BoxFragment {
|
|||
scrollable_overflow: None,
|
||||
resolved_sticky_insets: AtomicRefCell::default(),
|
||||
background_mode: BackgroundMode::Normal,
|
||||
specific_layout_info: None,
|
||||
specific_layout_info,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -185,11 +186,6 @@ impl BoxFragment {
|
|||
self.background_mode = BackgroundMode::None;
|
||||
}
|
||||
|
||||
pub fn with_specific_layout_info(mut self, info: Option<SpecificLayoutInfo>) -> Self {
|
||||
self.specific_layout_info = info;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_block_margins_collapsed_with_children(
|
||||
mut self,
|
||||
collapsed_margins: CollapsedBlockMargins,
|
||||
|
|
|
@ -673,8 +673,8 @@ impl HoistedAbsolutelyPositionedBox {
|
|||
pbm.border.to_physical(containing_block_writing_mode),
|
||||
margin.to_physical(containing_block_writing_mode),
|
||||
None, /* clearance */
|
||||
specific_layout_info,
|
||||
)
|
||||
.with_specific_layout_info(specific_layout_info)
|
||||
};
|
||||
|
||||
// This is an absolutely positioned element, which means it also establishes a
|
||||
|
|
|
@ -1788,8 +1788,8 @@ impl<'a> TableLayout<'a> {
|
|||
self.pbm.border.to_physical(table_writing_mode),
|
||||
PhysicalSides::zero(),
|
||||
None, /* clearance */
|
||||
)
|
||||
.with_specific_layout_info(self.specific_layout_info_for_grid());
|
||||
self.specific_layout_info_for_grid(),
|
||||
);
|
||||
}
|
||||
|
||||
let mut table_fragments = Vec::new();
|
||||
|
@ -1913,9 +1913,9 @@ impl<'a> TableLayout<'a> {
|
|||
self.pbm.border.to_physical(table_writing_mode),
|
||||
PhysicalSides::zero(),
|
||||
None, /* clearance */
|
||||
self.specific_layout_info_for_grid(),
|
||||
)
|
||||
.with_baselines(baselines)
|
||||
.with_specific_layout_info(self.specific_layout_info_for_grid())
|
||||
}
|
||||
|
||||
fn specific_layout_info_for_grid(&mut self) -> Option<SpecificLayoutInfo> {
|
||||
|
@ -2359,6 +2359,7 @@ impl<'a> RowFragmentLayout<'a> {
|
|||
PhysicalSides::zero(), /* border */
|
||||
PhysicalSides::zero(), /* margin */
|
||||
None, /* clearance */
|
||||
None, /* specific_layout_info */
|
||||
);
|
||||
row_fragment.set_does_not_paint_background();
|
||||
|
||||
|
@ -2431,6 +2432,7 @@ impl RowGroupFragmentLayout {
|
|||
PhysicalSides::zero(), /* border */
|
||||
PhysicalSides::zero(), /* margin */
|
||||
None, /* clearance */
|
||||
None, /* specific_layout_info */
|
||||
);
|
||||
row_group_fragment.set_does_not_paint_background();
|
||||
|
||||
|
@ -2910,9 +2912,9 @@ impl TableSlotCell {
|
|||
layout.border.to_physical(table_style.writing_mode),
|
||||
PhysicalSides::zero(), /* margin */
|
||||
None, /* clearance */
|
||||
specific_layout_info,
|
||||
)
|
||||
.with_baselines(layout.layout.baselines)
|
||||
.with_specific_layout_info(specific_layout_info)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -552,12 +552,12 @@ impl TaffyContainer {
|
|||
border,
|
||||
margin,
|
||||
None, /* clearance */
|
||||
child_specific_layout_info,
|
||||
)
|
||||
.with_baselines(Baselines {
|
||||
first: output.first_baselines.y.map(Au::from_f32_px),
|
||||
last: None,
|
||||
})
|
||||
.with_specific_layout_info(child_specific_layout_info);
|
||||
});
|
||||
|
||||
child.positioning_context.layout_collected_children(
|
||||
container_ctx.layout_context,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue