Skip to content

Truly independent web browser

LibWeb: Keep orthogonal flow baselines with a box's other baselines

Aliaksandr Kalenike7d90fe0e343
diff --git a/Libraries/LibWeb/Rust/src/layout/flex_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/flex_formatting_context.rs
index 2a0c2752e07..cf0aef67fbb 100644
--- a/Libraries/LibWeb/Rust/src/layout/flex_formatting_context.rs
+++ b/Libraries/LibWeb/Rust/src/layout/flex_formatting_context.rs
@@ -2755,7 +2755,11 @@ impl<'pass> FlexFormattingContext<'pass> {
let used = self.item_used(index);
let collapsed = used.uses_collapsing_borders_model.get();
let margin_box_left = used.margin_left.get() + used.border_box_left(collapsed);
- return match used.orthogonal_flow_baselines().and_then(|baselines| baselines.first) {
+ return match used
+ .orthogonal_flow_baselines
+ .get()
+ .and_then(|baselines| baselines.first)
+ {
Some(baseline) => margin_box_left + baseline,
None => margin_box_left + used.content_inline_size.get() + used.border_box_right(collapsed),
};
diff --git a/Libraries/LibWeb/Rust/src/layout/formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/formatting_context.rs
index e763c15598a..c5b7fc1de4d 100644
--- a/Libraries/LibWeb/Rust/src/layout/formatting_context.rs
+++ b/Libraries/LibWeb/Rust/src/layout/formatting_context.rs
@@ -2565,11 +2565,8 @@ fn leave_own_frame(
first: along_parent_horizontal_axis(result.baselines.first),
last: along_parent_horizontal_axis(result.baselines.last),
};
- if orthogonal_flow_baselines != DerivedBaselines::default() {
- used.rare_data_mut().orthogonal_flow_baselines = Some(orthogonal_flow_baselines);
- } else if used.orthogonal_flow_baselines().is_some() {
- used.rare_data_mut().orthogonal_flow_baselines = None;
- }
+ used.orthogonal_flow_baselines
+ .set((orthogonal_flow_baselines != DerivedBaselines::default()).then_some(orthogonal_flow_baselines));
// NB: The inline size of a table wrapper in its parent's frame is the block size of its content in its own
// frame.
if result.table_wrapper_content_inline_size.is_some() {
diff --git a/Libraries/LibWeb/Rust/src/layout/grid_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/grid_formatting_context.rs
index e1dd5f6d597..6af2bf62898 100644
--- a/Libraries/LibWeb/Rust/src/layout/grid_formatting_context.rs
+++ b/Libraries/LibWeb/Rust/src/layout/grid_formatting_context.rs
@@ -4479,7 +4479,11 @@ impl<'pass> GridFormattingContext<'pass> {
let baseline = self
.sizing()
.establishes_orthogonal_flow(item.box_)
- .then(|| used.orthogonal_flow_baselines().and_then(|baselines| baselines.first))
+ .then(|| {
+ used.orthogonal_flow_baselines
+ .get()
+ .and_then(|baselines| baselines.first)
+ })
.flatten();
match baseline {
Some(baseline) => margin_box_left + baseline,
diff --git a/Libraries/LibWeb/Rust/src/layout/run_repeatability.rs b/Libraries/LibWeb/Rust/src/layout/run_repeatability.rs
index fd445073d28..cc958df92e1 100644
--- a/Libraries/LibWeb/Rust/src/layout/run_repeatability.rs
+++ b/Libraries/LibWeb/Rust/src/layout/run_repeatability.rs
@@ -308,7 +308,6 @@ fn rare_payloads_match(
math_paint_data,
used_grid_tracks,
collapsed_table_borders,
- orthogonal_flow_baselines,
} = left;
computed_svg_path.as_deref() == right.computed_svg_path.as_deref()
&& svg_text_character_cells.as_deref() == right.svg_text_character_cells.as_deref()
@@ -319,7 +318,6 @@ fn rare_payloads_match(
&& math_paint_data.as_deref() == right.math_paint_data.as_deref()
&& used_grid_tracks.as_deref() == right.used_grid_tracks.as_deref()
&& collapsed_table_borders.as_deref() == right.collapsed_table_borders.as_deref()
- && *orthogonal_flow_baselines == right.orthogonal_flow_baselines
}
fn collect_nodes_of_fragment_subtrees(links: &[fragment_tree::FragmentLink], nodes: &mut HashSet<u32>) {
diff --git a/Libraries/LibWeb/Rust/src/layout/used_values.rs b/Libraries/LibWeb/Rust/src/layout/used_values.rs
index 179e1ecab69..af2391d7086 100644
--- a/Libraries/LibWeb/Rust/src/layout/used_values.rs
+++ b/Libraries/LibWeb/Rust/src/layout/used_values.rs
@@ -246,9 +246,6 @@ pub(crate) struct UsedValuesRareData {
pub(crate) math_paint_data: Option<std::sync::Arc<math_formatting_context::MathPaintData>>,
pub(crate) used_grid_tracks: Option<std::sync::Arc<grid_formatting_context::OwnedUsedGridTracks>>,
pub(crate) collapsed_table_borders: Option<std::sync::Arc<table_formatting_context::OwnedCollapsedTableBorders>>,
- /// For a box that establishes an orthogonal flow, its baselines as distances along the horizontal axis of the frame
- /// it is laid out in, from the left edge of its content box.
- pub(crate) orthogonal_flow_baselines: Option<DerivedBaselines>,
}
impl UsedValuesRareData {
@@ -263,7 +260,6 @@ impl UsedValuesRareData {
math_paint_data,
used_grid_tracks,
collapsed_table_borders,
- orthogonal_flow_baselines,
} = self;
if computed_svg_path.is_none()
&& svg_text_character_cells.is_none()
@@ -274,7 +270,6 @@ impl UsedValuesRareData {
&& math_paint_data.is_none()
&& used_grid_tracks.is_none()
&& collapsed_table_borders.is_none()
- && orthogonal_flow_baselines.is_none()
{
return;
}
@@ -304,9 +299,6 @@ impl UsedValuesRareData {
if let Some(borders) = collapsed_table_borders {
rare.collapsed_table_borders = Some(borders);
}
- if let Some(baselines) = orthogonal_flow_baselines {
- rare.orthogonal_flow_baselines = Some(baselines);
- }
}
}
@@ -352,6 +344,9 @@ pub(crate) struct UsedValues {
pub has_last_baseline: Cell<bool>,
pub last_baseline: Cell<CssPixels>,
pub inline_alignment_baseline: Cell<Option<CssPixels>>,
+ /// For a box that establishes an orthogonal flow, its baselines as distances along the horizontal axis of the frame
+ /// it is laid out in, from the left edge of its content box.
+ pub orthogonal_flow_baselines: Cell<Option<DerivedBaselines>>,
pub(crate) line_data: RefCell<LineDataState>,
pub(crate) rare_data: LazyRefCell<UsedValuesRareData>,
@@ -390,6 +385,7 @@ impl Default for UsedValues {
has_last_baseline: Cell::new(false),
last_baseline: Cell::new(zero),
inline_alignment_baseline: Cell::new(None),
+ orthogonal_flow_baselines: Cell::new(None),
line_data: RefCell::new(LineDataState::Empty),
rare_data: LazyRefCell::new(),
anchor_resolved_values: std::cell::OnceCell::new(),
@@ -399,10 +395,6 @@ impl Default for UsedValues {
}
impl UsedValues {
- pub(crate) fn orthogonal_flow_baselines(&self) -> Option<DerivedBaselines> {
- self.rare_data.get()?.borrow().orthogonal_flow_baselines
- }
-
/// Resolves the left and right margins, borders and padding of `style`, with percentages against `basis`.
pub(crate) fn resolve_horizontal_box_model(&self, style: &StyleValues<'_>, basis: CssPixels) {
self.margin_left.set(style.margin_left().to_px(basis));
@@ -599,6 +591,7 @@ used_values_cells! {
has_last_baseline: bool,
last_baseline: CssPixels,
inline_alignment_baseline: Option<CssPixels>,
+ orthogonal_flow_baselines: Option<DerivedBaselines>,
}
}