Skip to content

Truly independent web browser

LibWeb: Adopt grid row measurements in grid item layout

Aliaksandr Kalenikba0e5c853531
diff --git a/Libraries/LibWeb/Rust/src/layout/fc_run_cache.rs b/Libraries/LibWeb/Rust/src/layout/fc_run_cache.rs
index ddac6744212..168429bb389 100644
--- a/Libraries/LibWeb/Rust/src/layout/fc_run_cache.rs
+++ b/Libraries/LibWeb/Rust/src/layout/fc_run_cache.rs
@@ -73,7 +73,7 @@ impl RunInputsTheStoredRunNeverObserved {
}
}
-fn root_input_cells_match_ignoring_unobserved_own_block_size(
+fn root_input_cells_match_ignoring_unobserved_own_block_size_and_block_margins(
stored: used_values::RootInputCells,
probe: used_values::RootInputCells,
own_block_size: formatting_context::OwnBlockSizeObservation,
@@ -81,12 +81,14 @@ fn root_input_cells_match_ignoring_unobserved_own_block_size(
match own_block_size {
formatting_context::OwnBlockSizeObservation::Observed => stored == probe,
formatting_context::OwnBlockSizeObservation::Unobserved => {
- let without_own_block_size = |cells| used_values::RootInputCells {
+ let without_own_block_size_and_block_margins = |cells| used_values::RootInputCells {
content_block_size: CssPixels::default(),
has_definite_block_size: false,
+ margin_top: CssPixels::default(),
+ margin_bottom: CssPixels::default(),
..cells
};
- without_own_block_size(stored) == without_own_block_size(probe)
+ without_own_block_size_and_block_margins(stored) == without_own_block_size_and_block_margins(probe)
}
}
}
@@ -138,7 +140,7 @@ impl FcRunCacheKey {
}
self.fc_type == probe.fc_type
&& self.layout_mode == probe.layout_mode
- && root_input_cells_match_ignoring_unobserved_own_block_size(
+ && root_input_cells_match_ignoring_unobserved_own_block_size_and_block_margins(
self.root_cells,
probe.root_cells,
unobserved.own_block_size,
@@ -1563,6 +1565,26 @@ mod tests {
));
}
+ #[test]
+ fn an_item_run_that_never_observed_its_own_block_size_matches_at_other_block_margins() {
+ let at_margins = |margin_top: i64, margin_bottom: i64, margin_left: i64| {
+ let mut key = item_key(40, true);
+ key.root_cells.margin_top = px(margin_top);
+ key.root_cells.margin_bottom = px(margin_bottom);
+ key.root_cells.margin_left = px(margin_left);
+ key
+ };
+ let stored = at_margins(0, 0, 0);
+ let unobserved = own_block_size(formatting_context::OwnBlockSizeObservation::Unobserved);
+ let observed = own_block_size(formatting_context::OwnBlockSizeObservation::Observed);
+ assert!(stored.matches(&at_margins(30, -10, 0), unobserved));
+ assert!(!stored.matches(&at_margins(30, -10, 0), observed));
+ assert!(
+ !stored.matches(&at_margins(0, 0, 10), unobserved),
+ "only the root's block margins are unobserved"
+ );
+ }
+
#[test]
fn stale_line_data_after_structural_inline_damage_is_taken_only_at_the_same_own_block_size() {
let mut outputs = entry(item_key(40, false), 1, None, 0).outputs;
diff --git a/Libraries/LibWeb/Rust/src/layout/flex_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/flex_formatting_context.rs
index 170422a5aab..8486f32c42e 100644
--- a/Libraries/LibWeb/Rust/src/layout/flex_formatting_context.rs
+++ b/Libraries/LibWeb/Rust/src/layout/flex_formatting_context.rs
@@ -2871,22 +2871,6 @@ impl<'pass> FlexFormattingContext<'pass> {
&& self.inline_axis_is_horizontal(self.run.box_)
}
- fn item_is_block_container_whose_committing_run_can_adopt_its_measurement(&self, index: usize) -> bool {
- let node = self.flex_items[index].box_;
- let facts = self.facts(node);
- let sizing = self.sizing();
- !facts.document_in_quirks_mode()
- && !facts.is_table_wrapper()
- && !facts.is_replaced_box()
- && !facts.has_preferred_aspect_ratio()
- && self.style(node).writing_mode() == writing_mode::HORIZONTAL_TB
- && self.inline_axis_is_horizontal(node)
- && formatting_context::formatting_context_type_created_by_box(facts)
- == Some(formatting_context::FormattingContextType::Block)
- && !sizing.own_style_depends_on_percentage_block_size(node)
- && !block_formatting_context::root_lays_out_content_against_its_own_block_size(&sizing, node)
- }
-
fn offer_item_runs_to_block_size_measurements(&mut self, measured_at: ItemBlockSizeMeasuredAt) {
if self.offers_item_runs_to_block_size_measurements() {
self.item_runs_offered_to_block_size_measurements = Some(ItemRunsOfferedToBlockSizeMeasurements {
@@ -2925,7 +2909,10 @@ impl<'pass> FlexFormattingContext<'pass> {
space_for_items: AvailableSpace,
) -> Option<formatting_context::ChildRunShape> {
let node = self.flex_items[index].box_;
- if !self.item_is_block_container_whose_committing_run_can_adopt_its_measurement(index) {
+ if !formatting_context::item_is_block_container_whose_committing_run_can_adopt_its_measurement(
+ &self.sizing(),
+ node,
+ ) {
return None;
}
let (main_size, cross_size) = if self.main_axis_is_horizontal() {
diff --git a/Libraries/LibWeb/Rust/src/layout/formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/formatting_context.rs
index 94cd7de4820..0fe0d23e060 100644
--- a/Libraries/LibWeb/Rust/src/layout/formatting_context.rs
+++ b/Libraries/LibWeb/Rust/src/layout/formatting_context.rs
@@ -2026,16 +2026,16 @@ pub(super) fn run_formatting_context(
run_repeatability::verify_repeated_run(&callbacks, box_, discarded_outputs, &outputs);
}
if cache_attempt.stores_outputs() {
- run_repeatability::verify_run_ignores_its_unobserved_own_block_size(
+ run_repeatability::verify_run_ignores_its_unobserved_own_block_size_and_block_margins(
&callbacks,
box_,
root_cells,
input,
&outputs,
- |root_cells_at_other_own_block_size, input_at_other_own_block_size| {
+ |other_root_cells, other_input| {
execute_formatting_context_run(
builds_fragments,
- root_cells_at_other_own_block_size,
+ other_root_cells,
box_,
root_containing_block,
parent_grid,
@@ -2043,7 +2043,7 @@ pub(super) fn run_formatting_context(
layout_mode,
should_collect_devtools_layout_data,
callbacks,
- input_at_other_own_block_size,
+ other_input,
parent_block,
None,
None,
@@ -2871,6 +2871,22 @@ pub(crate) trait ChildRunShapes {
) -> Option<ChildRunShape>;
}
+pub(crate) fn item_is_block_container_whose_committing_run_can_adopt_its_measurement(
+ sizing: &sizing_context::SizingContext<'_, '_>,
+ item: Node,
+) -> bool {
+ let facts = sizing.facts(item);
+ !facts.document_in_quirks_mode()
+ && !facts.is_table_wrapper()
+ && !facts.is_replaced_box()
+ && !facts.has_preferred_aspect_ratio()
+ && sizing.style(item).writing_mode() == writing_mode::HORIZONTAL_TB
+ && !sizing.establishes_orthogonal_flow(item)
+ && formatting_context_type_created_by_box(facts) == Some(FormattingContextType::Block)
+ && !sizing.own_style_depends_on_percentage_block_size(item)
+ && !block_formatting_context::root_lays_out_content_against_its_own_block_size(sizing, item)
+}
+
pub(crate) struct ChildRunPlan {
pub(crate) fc_type: FormattingContextType,
pub(crate) root_containing_block: Node,
@@ -2984,15 +3000,13 @@ pub(crate) fn lay_out_shape_for_its_result(
run_repeatability::verify_repeated_run(&callbacks, node, discarded_outputs, &outputs);
}
if cache_attempt.stores_outputs() {
- run_repeatability::verify_run_ignores_its_unobserved_own_block_size(
+ run_repeatability::verify_run_ignores_its_unobserved_own_block_size_and_block_margins(
&callbacks,
node,
root_cells,
input,
&outputs,
- |root_cells_at_other_own_block_size, input_at_other_own_block_size| {
- lay_out(root_cells_at_other_own_block_size, input_at_other_own_block_size, None)
- },
+ |other_root_cells, other_input| lay_out(other_root_cells, other_input, None),
);
}
cache_attempt.conclude(&callbacks, node, cache_key, &input, &outputs);
diff --git a/Libraries/LibWeb/Rust/src/layout/grid_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/grid_formatting_context.rs
index c966ae0c753..66e3272aff8 100644
--- a/Libraries/LibWeb/Rust/src/layout/grid_formatting_context.rs
+++ b/Libraries/LibWeb/Rust/src/layout/grid_formatting_context.rs
@@ -1107,6 +1107,44 @@ pub(crate) struct GridFormattingContext<'pass> {
columns_are_reversed: bool,
rows_are_reversed: bool,
maximum_inline_size_resolved_by_caller: Option<CssPixels>,
+ item_runs_offered_to_row_measurements: Option<RowMeasurementsAhead>,
+ next_item_lookup_start: Cell<usize>,
+}
+
+impl formatting_context::ChildRunShapes for GridFormattingContext<'_> {
+ fn child_run_shape_at(
+ &self,
+ node: Node,
+ inline_size: CssPixels,
+ constraints: ContainingBlockConstraints,
+ ) -> Option<formatting_context::ChildRunShape> {
+ let measurements_ahead = self.item_runs_offered_to_row_measurements?;
+ let item = self.items[self.index_of_item(node)?];
+ if !self.item_block_size_is_measured_ahead(item, measurements_ahead)
+ || formatting_context::formatting_context_type_created_by_box(self.facts(node))
+ != Some(formatting_context::FormattingContextType::Block)
+ || !formatting_context::item_is_block_container_whose_committing_run_can_adopt_its_measurement(
+ &self.sizing(),
+ node,
+ )
+ {
+ return None;
+ }
+ self.item_run_shape(item)
+ .filter(|shape| shape.lays_out_at(inline_size, constraints))
+ }
+}
+
+#[derive(Clone, Copy)]
+enum ItemRowArea {
+ NotYetSized,
+ SizedAt(CssPixels),
+}
+
+#[derive(Clone, Copy, PartialEq, Eq)]
+enum RowMeasurementsAhead {
+ RowTrackSizingAndItemBlockSizes,
+ ItemBlockSizesOnly,
}
#[derive(Clone, Copy)]
@@ -1223,6 +1261,8 @@ impl<'pass> GridFormattingContext<'pass> {
false,
),
maximum_inline_size_resolved_by_caller: None,
+ item_runs_offered_to_row_measurements: None,
+ next_item_lookup_start: Cell::new(0),
}
}
@@ -1244,6 +1284,7 @@ impl<'pass> GridFormattingContext<'pass> {
self.available_space = Some(available_space);
self.layout_input = Some(input);
self.maximum_inline_size_resolved_by_caller = input.sizing.maximum_inline_size_resolved_by_caller;
+ self.item_runs_offered_to_row_measurements = None;
self.column_lines.clear();
self.row_lines.clear();
self.columns.clear();
@@ -1316,8 +1357,8 @@ impl<'pass> GridFormattingContext<'pass> {
}
#[inline]
- fn sizing(&self) -> sizing_context::SizingContext<'pass, 'static> {
- sizing_context::SizingContext::new(self.run.records, self.run.callbacks)
+ fn sizing(&self) -> sizing_context::SizingContext<'pass, '_> {
+ sizing_context::SizingContext::new(self.run.records, self.run.callbacks).with_child_run_shapes(self)
}
fn parent_grid(&self) -> Option<&ParentGridData<'pass>> {
@@ -2337,6 +2378,7 @@ impl<'pass> GridFormattingContext<'pass> {
self.resolve_item_metrics(Axis::Column);
self.resolve_item_sizes(Axis::Column);
self.resolve_item_metrics(Axis::Row);
+ self.offer_runs_of_items_measured_in_their_rows(RowMeasurementsAhead::ItemBlockSizesOnly);
self.resolve_item_sizes(Axis::Row);
// NB: Sizing the columns again marks the inline sizes definite, but leaves the block sizes as they were made.
for (&item, &(_, block)) in self.items.iter().zip(&item_sizes_were_definite) {
@@ -2345,16 +2387,16 @@ impl<'pass> GridFormattingContext<'pass> {
}
fn intrinsic_contribution_constraints(&self, item: GridItem, axis: Axis) -> ContainingBlockConstraints {
- let mut constraints = self.container_constraints();
- if axis.is_column() {
- constraints = self.column_sizing_constraints(item, constraints);
+ if !axis.is_column() {
+ return self.grid_area_constraints(item);
}
+ let constraints = self.column_sizing_constraints(item, self.container_constraints());
// https://drafts.csswg.org/css-sizing-3/#cyclic-percentage-contribution
// A table's width, min-width and max-width apply to the table box inside the wrapper, so the wrapper's own
// preferred size looks auto. Those percentages still resolve against the grid area, which the column
// contribution is sizing, so they are cyclic and behave as their initial values here. This matches other
// browsers, where a width: 100% table does not grow a 1fr or auto column to the grid container's width.
- if axis.is_column() && self.facts(item.box_).is_table_wrapper() {
+ if self.facts(item.box_).is_table_wrapper() {
return ContainingBlockConstraints {
percentage_basis_inline_size: None,
..constraints
@@ -2430,7 +2472,7 @@ impl<'pass> GridFormattingContext<'pass> {
self.sizing().calculate_min_content_block_size(
item.box_,
self.item_available_space(item).inline_size.to_px_or_zero(),
- self.container_constraints(),
+ self.intrinsic_contribution_constraints(item, axis),
)
}
}
@@ -3715,8 +3757,17 @@ impl<'pass> GridFormattingContext<'pass> {
} else if preferred.is_auto() || preferred.is_fit_content() || facts.is_table_wrapper() {
// NB: A table wrapper's own size is automatic. The table box's preferred size is resolved by the table
// layout that the wrapper's content size measures.
- self.sizing()
- .calculate_fit_content_size(item.box_, axis.sizing_axis(), available, constraints)
+ let content_measurement_constraints = if axis.is_column() || facts.is_table_wrapper() {
+ constraints
+ } else {
+ self.intrinsic_contribution_constraints(item, axis)
+ };
+ self.sizing().calculate_fit_content_size(
+ item.box_,
+ axis.sizing_axis(),
+ available,
+ content_measurement_constraints,
+ )
} else {
self.sizing().calculate_inner_size_for_property(
item.box_,
@@ -4039,6 +4090,102 @@ impl<'pass> GridFormattingContext<'pass> {
(start_offset, end_offset - start_offset)
}
+ // https://drafts.csswg.org/css-grid-2/#grid-item-sizing
+ // NB: The grid area is definite, but an item that is neither stretched nor sized by its preferred
+ // block size or aspect ratio takes its block size from its content, which is indefinite for the
+ // content's percentages, as in other engines. Replaced boxes and buttons size their content
+ // against their used block size.
+ fn item_block_size_follows_from_content(&self, item: GridItem) -> bool {
+ let facts = self.facts(item.box_);
+ let preferred = self.item_preferred_size(item, Axis::Row);
+ (preferred.is_auto() || preferred.is_intrinsic_sizing_constraint())
+ && !self.item_is_stretched(item, Axis::Row)
+ && !facts.has_preferred_aspect_ratio()
+ && !facts.is_replaced_box()
+ && !facts.uses_button_layout()
+ && !(self.style(item.box_).display().is_grid_inside() && self.grid_item_is_subgridded(item, Axis::Row))
+ }
+
+ fn prepare_item_record(&self, item: GridItem, used: &UsedValues, row_area: ItemRowArea) {
+ used.has_definite_inline_size.set(true);
+ used.has_definite_block_size.set(match row_area {
+ ItemRowArea::NotYetSized => false,
+ ItemRowArea::SizedAt(_) => !self.item_block_size_follows_from_content(item),
+ });
+ }
+
+ fn item_layout_input(&self, item: GridItem, used: &UsedValues, row_area: ItemRowArea) -> LayoutInput {
+ let (available_block_size, percentage_basis_block_size) = match row_area {
+ ItemRowArea::NotYetSized => (AvailableSize::Indefinite, None),
+ ItemRowArea::SizedAt(area_block_size) => (
+ AvailableSize::definite(used.content_block_size.get()),
+ Some(area_block_size),
+ ),
+ };
+ LayoutInput {
+ available_space: AvailableSpace {
+ inline_size: AvailableSize::definite(used.content_inline_size.get()),
+ block_size: available_block_size,
+ },
+ containing_block_constraints: ContainingBlockConstraints {
+ percentage_basis_block_size,
+ ..self.grid_area_constraints(item)
+ },
+ content_box_position_in_bfc_root: None,
+ sizing: RootSizingDirectives::default(),
+ participation: ParticipationInParentFormattingContext::Item,
+ }
+ }
+
+ fn offers_item_runs_to_row_measurements(&self) -> bool {
+ let available = self.layout_input.unwrap().available_space;
+ self.run.layout_mode == LayoutMode::Normal
+ && !self.run.should_collect_devtools_layout_data
+ && !available.inline_size.is_intrinsic_sizing_constraint()
+ && !available.block_size.is_intrinsic_sizing_constraint()
+ && self.style(self.run.box_).writing_mode() == writing_mode::HORIZONTAL_TB
+ }
+
+ fn item_block_size_is_measured_ahead(&self, item: GridItem, measurements_ahead: RowMeasurementsAhead) -> bool {
+ let preferred = self.item_preferred_size(item, Axis::Row);
+ if !preferred.is_auto() && !preferred.is_intrinsic_sizing_constraint() {
+ return false;
+ }
+ !self.item_is_stretched(item, Axis::Row)
+ || (measurements_ahead == RowMeasurementsAhead::RowTrackSizingAndItemBlockSizes
+ && self.item_contributes_to_track_sizing(item, Axis::Row))
+ }
+
+ fn offer_runs_of_items_measured_in_their_rows(&mut self, measurements_ahead: RowMeasurementsAhead) {
+ if self.offers_item_runs_to_row_measurements() {
+ self.item_runs_offered_to_row_measurements = Some(measurements_ahead);
+ }
+ }
+
+ fn index_of_item(&self, node: Node) -> Option<usize> {
+ let item_count = self.items.len();
+ let start = self.next_item_lookup_start.get().min(item_count);
+ let index = (start..item_count)
+ .chain(0..start)
+ .find(|&index| self.items[index].box_ == node)?;
+ self.next_item_lookup_start.set(index + 1);
+ Some(index)
+ }
+
+ fn item_run_shape(&self, item: GridItem) -> Option<formatting_context::ChildRunShape> {
+ let record = used_values::RootInputCells::capture(self.used(item)).materialize_record();
+ self.prepare_item_record(item, &record, ItemRowArea::NotYetSized);
+ let input = self.item_layout_input(item, &record, ItemRowArea::NotYetSized);
+ let plan = formatting_context::child_run_plan(&self.run, item.box_, input, false)?;
+ Some(formatting_context::ChildRunShape {
+ node: item.box_,
+ fc_type: plan.fc_type,
+ input: plan.input,
+ root_cells: used_values::RootInputCells::capture(&record),
+ root_containing_block: plan.root_containing_block,
+ })
+ }
+
fn layout_items(&mut self, run: &FormattingContextRun<'pass>) {
let mut baseline_aligned_items = Vec::new();
for item_index in 0..self.items.len() {
@@ -4055,27 +4202,8 @@ impl<'pass> GridFormattingContext<'pass> {
used.margin_right.set(resolved.margin_end);
used.set_content_inline_size(resolved.size);
}
- {
- // https://drafts.csswg.org/css-grid-2/#grid-item-sizing
- // NB: The grid area is definite, but an item that is neither stretched nor sized by its preferred
- // block size or aspect ratio takes its block size from its content, which is indefinite for the
- // content's percentages, as in other engines. Replaced boxes and buttons size their content
- // against their used block size.
- let facts = self.facts(item.box_);
- let block_size_follows_from_content = {
- let preferred = self.item_preferred_size(item, Axis::Row);
- (preferred.is_auto() || preferred.is_intrinsic_sizing_constraint())
- && !self.item_is_stretched(item, Axis::Row)
- && !facts.has_preferred_aspect_ratio()
- && !facts.is_replaced_box()
- && !facts.uses_button_layout()
- && !(self.style(item.box_).display().is_grid_inside()
- && self.grid_item_is_subgridded(item, Axis::Row))
- };
- let used = self.used(item);
- used.has_definite_inline_size.set(true);
- used.has_definite_block_size.set(!block_size_follows_from_content);
- }
+ let row_area = ItemRowArea::SizedAt(area.size.block_size);
+ self.prepare_item_record(item, self.used(item), row_area);
let mut sizing = RootSizingDirectives::default();
if let Some(transferred) = item.block_size_transferred_through_aspect_ratio {
// NB: The content is laid out against the block size transferred through the aspect ratio, and the item
@@ -4099,25 +4227,13 @@ impl<'pass> GridFormattingContext<'pass> {
sizing.forced_min_border_box_block_size =
Some(stretched_table_box_block_size.max(sizes.table_box_border_box_block_size));
}
- let input = LayoutInput {
- available_space: AvailableSpace {
- inline_size: AvailableSize::definite(self.used(item).content_inline_size.get()),
- block_size: AvailableSize::definite(self.used(item).content_block_size.get()),
- },
- containing_block_constraints: {
- let mut constraints = self.grid_area_constraints(item);
- constraints.percentage_basis_block_size = Some(area.size.block_size);
- if let Some(inline_basis) = table_wrapper_inline_basis {
- // Table wrappers pass their constraints through to the table box, so hand them the
- // grid area in both axes for the table's percentage resolution.
- constraints.percentage_basis_inline_size = Some(inline_basis);
- }
- constraints
- },
- content_box_position_in_bfc_root: None,
- sizing,
- participation: ParticipationInParentFormattingContext::Item,
- };
+ let mut input = self.item_layout_input(item, self.used(item), row_area);
+ input.sizing = sizing;
+ if let Some(inline_basis) = table_wrapper_inline_basis {
+ // Table wrappers pass their constraints through to the table box, so hand them the
+ // grid area in both axes for the table's percentage resolution.
+ input.containing_block_constraints.percentage_basis_inline_size = Some(inline_basis);
+ }
match formatting_context::layout_inside_child(
run,
None,
@@ -4552,6 +4668,7 @@ impl<'pass> GridFormattingContext<'pass> {
// Do the first pass of resolving grid items box metrics to compute values that are independent of a track height
self.resolve_item_metrics(Axis::Row);
+ self.offer_runs_of_items_measured_in_their_rows(RowMeasurementsAhead::RowTrackSizingAndItemBlockSizes);
self.run_track_sizing(Axis::Row);
// Do the second pass of resolving box metrics to compute values that depend on a track height
self.resolve_item_metrics(Axis::Row);
diff --git a/Libraries/LibWeb/Rust/src/layout/run_repeatability.rs b/Libraries/LibWeb/Rust/src/layout/run_repeatability.rs
index 5e545025cb2..40df3ec3793 100644
--- a/Libraries/LibWeb/Rust/src/layout/run_repeatability.rs
+++ b/Libraries/LibWeb/Rust/src/layout/run_repeatability.rs
@@ -9,8 +9,9 @@
//! Both have to agree on everything the run hands its parent, which shows that a run depends on nothing but its input
//! and the state of the pass, and that what it reads from memoized layout is what it would have computed.
//!
-//! With LIBWEB_VERIFY_UNOBSERVED_BLOCK_SIZE, every run that claims it never observed its own block size is laid out
-//! again the same way, at the other definiteness of that size and with extra space, and has to agree with the run too.
+//! With LIBWEB_VERIFY_UNOBSERVED_BLOCK_SIZE, every run that claims it never observed its own block size or block
+//! margins is laid out again the same way, at the other definiteness of that size, with extra space and at other block
+//! margins, and has to agree with the run too.
use super::*;
@@ -71,15 +72,22 @@ fn unobserved_own_block_size_verification_is_enabled() -> bool {
*ENABLED.get_or_init(|| std::env::var_os("LIBWEB_VERIFY_UNOBSERVED_BLOCK_SIZE").is_some())
}
+fn run_is_verified_at_other_unobserved_root_inputs(
+ root_cells: used_values::RootInputCells,
+ input: LayoutInput,
+ result: &formatting_context::ChildLayoutResult,
+) -> bool {
+ result.own_block_size_observation == formatting_context::OwnBlockSizeObservation::Unobserved
+ && !root_cells.has_content_offset
+ && !input.available_space.block_size.is_intrinsic_sizing_constraint()
+}
+
fn root_inputs_at_other_own_block_sizes(
root_cells: used_values::RootInputCells,
input: LayoutInput,
result: &formatting_context::ChildLayoutResult,
) -> Vec<(used_values::RootInputCells, LayoutInput)> {
- if result.own_block_size_observation == formatting_context::OwnBlockSizeObservation::Observed
- || root_cells.has_content_offset
- || input.available_space.block_size.is_intrinsic_sizing_constraint()
- {
+ if !run_is_verified_at_other_unobserved_root_inputs(root_cells, input, result) {
return Vec::new();
}
let mut other_definite_own_block_sizes = Vec::new();
@@ -109,7 +117,19 @@ fn root_inputs_at_other_own_block_sizes(
.collect()
}
-pub(super) fn verify_run_ignores_its_unobserved_own_block_size(
+fn root_cells_at_other_block_margins(
+ root_cells: used_values::RootInputCells,
+ input: LayoutInput,
+ result: &formatting_context::ChildLayoutResult,
+) -> Option<used_values::RootInputCells> {
+ run_is_verified_at_other_unobserved_root_inputs(root_cells, input, result).then(|| used_values::RootInputCells {
+ margin_top: root_cells.margin_top + CssPixels::from_integer(30),
+ margin_bottom: root_cells.margin_bottom - CssPixels::from_integer(20),
+ ..root_cells
+ })
+}
+
+pub(super) fn verify_run_ignores_its_unobserved_own_block_size_and_block_margins(
callbacks: &LayoutPass<'_>,
box_: Node,
root_cells: used_values::RootInputCells,
@@ -120,28 +140,36 @@ pub(super) fn verify_run_ignores_its_unobserved_own_block_size(
if !unobserved_own_block_size_verification_is_enabled() || callbacks.scratch().reads_no_memoized_layout() {
return;
}
- let checked = format!("the run of {box_:?}, which never observed its own block size,");
- for (cells_at_other_own_block_size, input_at_other_own_block_size) in
- root_inputs_at_other_own_block_sizes(root_cells, input, &outputs.result)
- {
- let outputs_at_other_own_block_size = callbacks.arena().layout_trace.without_events(|| {
+ let checked = format!("the run of {box_:?}, which never observed its own block size or block margins,");
+ let mut reference_inputs = root_inputs_at_other_own_block_sizes(root_cells, input, &outputs.result)
+ .into_iter()
+ .map(|(cells, input)| {
+ let reference = if cells.has_definite_block_size {
+ format!("its layout at the definite block size {:?}", cells.content_block_size)
+ } else {
+ "its layout at an indefinite block size".to_owned()
+ };
+ (cells, input, reference)
+ })
+ .collect::<Vec<_>>();
+ if let Some(cells) = root_cells_at_other_block_margins(root_cells, input, &outputs.result) {
+ let reference = format!(
+ "its layout at the block margins {:?} and {:?}",
+ cells.margin_top, cells.margin_bottom
+ );
+ reference_inputs.push((cells, input, reference));
+ }
+ for (reference_cells, reference_input, reference) in reference_inputs {
+ let reference_outputs = callbacks.arena().layout_trace.without_events(|| {
callbacks
.scratch()
- .lay_out_discarded_run(|| lay_out(cells_at_other_own_block_size, input_at_other_own_block_size))
+ .lay_out_discarded_run(|| lay_out(reference_cells, reference_input))
});
- let reference = if cells_at_other_own_block_size.has_definite_block_size {
- format!(
- "its layout at the definite block size {:?}",
- cells_at_other_own_block_size.content_block_size
- )
- } else {
- "its layout at an indefinite block size".to_owned()
- };
ComparedLayouts {
checked: &checked,
reference: &reference,
}
- .verify(callbacks, box_, outputs, &outputs_at_other_own_block_size);
+ .verify(callbacks, box_, outputs, &reference_outputs);
}
}
@@ -581,4 +609,33 @@ mod tests {
[None]
);
}
+
+ #[test]
+ fn unobserved_block_margins_are_verified_at_other_block_margins_only() {
+ let (root_cells, input) = item_root_inputs(40, true);
+ assert_eq!(
+ root_cells_at_other_block_margins(
+ root_cells,
+ input,
+ &result_observing(formatting_context::OwnBlockSizeObservation::Observed, 40)
+ ),
+ None
+ );
+ let cells = root_cells_at_other_block_margins(
+ root_cells,
+ input,
+ &result_observing(formatting_context::OwnBlockSizeObservation::Unobserved, 40),
+ )
+ .expect("an unobserved own block size is verified at other block margins");
+ assert_ne!(cells.margin_top, root_cells.margin_top);
+ assert_ne!(cells.margin_bottom, root_cells.margin_bottom);
+ assert_eq!(
+ used_values::RootInputCells {
+ margin_top: root_cells.margin_top,
+ margin_bottom: root_cells.margin_bottom,
+ ..cells
+ },
+ root_cells
+ );
+ }
}
diff --git a/Tests/LibWeb/Text/expected/grid-item-measurement-quirks-mode.txt b/Tests/LibWeb/Text/expected/grid-item-measurement-quirks-mode.txt
new file mode 100644
index 00000000000..72c2585b027
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/grid-item-measurement-quirks-mode.txt
@@ -0,0 +1,5 @@
+quirks mode: true
+header, main and footer offset: 20 360 380
+stretched grid item and its min-height: 50% child: 20 20
+stretched grid item and its height: stretch child: 20 20
+start-aligned grid item and its min-height: 50% child: 20 20
diff --git a/Tests/LibWeb/Text/expected/grid-row-measurement-adoption.txt b/Tests/LibWeb/Text/expected/grid-row-measurement-adoption.txt
new file mode 100644
index 00000000000..97fa7e922c6
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/grid-row-measurement-adoption.txt
@@ -0,0 +1,9 @@
+PASS: stretched items of an auto row commit the runs their row measurements laid out (work + checks)
+PASS: a start-aligned item that sizes its row commits the run its row measurement laid out (work + checks)
+PASS: a start-aligned item shorter than its row commits the run its row measurement laid out, since its run never reads the block margins its alignment moves (work + checks)
+PASS: a center-aligned item in a fixed row commits the run its block size measurement laid out (work + checks)
+PASS: an item spanning two auto rows commits the run its row measurement laid out (work + checks)
+PASS: an item with percentage padding resolves it against its grid area and commits the run its row measurement laid out (work + checks)
+PASS: a stretched item with a percentage-height child lays it out again at its stretched size (work + checks)
+PASS: a grid laid out before its width changes (work)
+PASS: the next pass at another width reuses the item whose column did not change and adopts the one whose column did (work + checks)
diff --git a/Tests/LibWeb/Text/input/grid-item-measurement-quirks-mode.html b/Tests/LibWeb/Text/input/grid-item-measurement-quirks-mode.html
new file mode 100644
index 00000000000..362408d3d28
--- /dev/null
+++ b/Tests/LibWeb/Text/input/grid-item-measurement-quirks-mode.html
@@ -0,0 +1,22 @@
+<!DOCTYPE quirks>
+<script src="include.js"></script>
+<style>
+ body { margin: 0; font: 20px/20px SerenitySans; }
+ .grid { display: grid; width: 400px; }
+ .start { align-content: start; height: 300px; }
+ .line { height: 20px; }
+</style>
+<div class="grid" style="height: 400px; grid-template-rows: auto 1fr auto"><header id="header"><div style="min-height: 100%"><div class="line"></div></div></header><main id="main"><div class="line"></div></main><footer id="footer"><div class="line"></div></footer></div>
+<div class="grid start"><div id="stretched"><div id="stretchedChild" style="min-height: 50%"><div class="line"></div></div></div></div>
+<div class="grid start"><div id="stretchChildItem"><div id="stretchChild" style="height: stretch"><div class="line"></div></div></div></div>
+<div class="grid start"><div id="startItem" style="align-self: start"><div id="startChild" style="min-height: 50%"><div class="line"></div></div></div></div>
+<script>
+ test(() => {
+ const rect = id => document.getElementById(id).getBoundingClientRect();
+ println(`quirks mode: ${document.compatMode === "BackCompat"}`);
+ println(`header, main and footer offset: ${rect("header").height} ${rect("main").height} ${rect("footer").top - rect("header").top}`);
+ println(`stretched grid item and its min-height: 50% child: ${rect("stretched").height} ${rect("stretchedChild").height}`);
+ println(`stretched grid item and its height: stretch child: ${rect("stretchChildItem").height} ${rect("stretchChild").height}`);
+ println(`start-aligned grid item and its min-height: 50% child: ${rect("startItem").height} ${rect("startChild").height}`);
+ });
+</script>
diff --git a/Tests/LibWeb/Text/input/grid-row-measurement-adoption.html b/Tests/LibWeb/Text/input/grid-row-measurement-adoption.html
new file mode 100644
index 00000000000..920de749873
--- /dev/null
+++ b/Tests/LibWeb/Text/input/grid-row-measurement-adoption.html
@@ -0,0 +1,299 @@
+<!DOCTYPE html>
+<script src="include.js"></script>
+<script src="layout-test.js"></script>
+<style>
+ body { margin: 0; font: 20px/20px SerenitySans; }
+ #host { width: 400px; }
+ .grid { display: grid; grid-template-columns: 120px 120px; }
+ .fluid { grid-template-columns: 120px 1fr; }
+ .start { align-self: start; }
+ .center { align-self: center; }
+ .fixed { grid-template-rows: 100px; }
+ .span { grid-row: span 2; }
+ .padded { padding: 10%; }
+ .half { height: 50%; }
+</style>
+<div id="host"></div>
+<script>
+ const rect = id => document.getElementById(id).getBoundingClientRect();
+ const height = id => rect(id).height;
+ layoutTest({
+ steps: [
+ {
+ name: "stretched items of an auto row commit the runs their row measurements laid out",
+ mutate: () => {
+ host.innerHTML = `<div class="grid" id="stretched"><div id="stretchedShort">one line</div><div id="stretchedTall">some words that wrap into lines</div></div>`;
+ },
+ expect: `
+ layout FULL
+ @viewport/block RUN (cache=bypass)
+ BlockContainer<HTML>/block RUN (cache=miss)
+ Box<DIV>#stretched.grid/grid RUN (cache=miss)
+ BlockContainer<DIV>#stretchedShort/block RUN (cache=miss)
+ BlockContainer<DIV>#stretchedShort MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#stretchedShort MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#stretchedTall/block RUN (cache=miss)
+ BlockContainer<DIV>#stretchedTall MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#stretchedTall MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#stretchedShort MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#stretchedShort MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#stretchedShort MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#stretchedTall MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#stretchedTall MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#stretchedTall MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#stretchedShort/block REPLAY FRAGMENTS
+ BlockContainer<DIV>#stretchedTall/block REPLAY FRAGMENTS
+ `,
+ check: equal => {
+ equal(height("stretchedShort"), 80, "stretched short item height");
+ equal(height("stretchedTall"), 80, "stretched tall item height");
+ },
+ },
+ {
+ name: "a start-aligned item that sizes its row commits the run its row measurement laid out",
+ mutate: () => {
+ host.innerHTML = `<div class="grid" id="startSizing"><div class="start" id="startTall">some words that wrap into lines</div><div id="startSibling">one line</div></div>`;
+ },
+ expect: `
+ layout FULL
+ @viewport/block RUN (cache=bypass)
+ BlockContainer<HTML>/block RUN (cache=miss)
+ Box<DIV>#startSizing.grid/grid RUN (cache=miss)
+ BlockContainer<DIV>#startTall.start/block RUN (cache=miss)
+ BlockContainer<DIV>#startTall.start MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#startTall.start MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#startSibling/block RUN (cache=miss)
+ BlockContainer<DIV>#startSibling MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#startSibling MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#startTall.start MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#startTall.start MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#startTall.start MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#startTall.start MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#startSibling MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#startSibling MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#startSibling MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#startTall.start MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#startTall.start/block REPLAY FRAGMENTS
+ BlockContainer<DIV>#startSibling/block REPLAY FRAGMENTS
+ `,
+ check: equal => {
+ equal(height("startTall"), 80, "start-aligned item height");
+ equal(height("startSibling"), 80, "stretched sibling height");
+ },
+ },
+ {
+ name: "a start-aligned item shorter than its row commits the run its row measurement laid out, since its run never reads the block margins its alignment moves",
+ mutate: () => {
+ host.innerHTML = `<div class="grid" id="startShorter"><div class="start" id="startShort">one line</div><div id="startTaller">some words that wrap into lines</div></div>`;
+ },
+ expect: `
+ layout FULL
+ @viewport/block RUN (cache=bypass)
+ BlockContainer<HTML>/block RUN (cache=miss)
+ Box<DIV>#startShorter.grid/grid RUN (cache=miss)
+ BlockContainer<DIV>#startShort.start/block RUN (cache=miss)
+ BlockContainer<DIV>#startShort.start MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#startShort.start MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#startTaller/block RUN (cache=miss)
+ BlockContainer<DIV>#startTaller MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#startTaller MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#startShort.start MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#startShort.start MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#startShort.start MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#startShort.start MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#startTaller MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#startTaller MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#startTaller MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#startShort.start MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#startShort.start/block REPLAY FRAGMENTS
+ BlockContainer<DIV>#startTaller/block REPLAY FRAGMENTS
+ `,
+ check: equal => {
+ equal(height("startShort"), 20, "start-aligned item height");
+ equal(height("startTaller"), 80, "taller sibling height");
+ },
+ },
+ {
+ name: "a center-aligned item in a fixed row commits the run its block size measurement laid out",
+ mutate: () => {
+ host.innerHTML = `<div class="grid fixed" id="fixedRow"><div class="center" id="centered">one line</div><div id="fixedRowSibling">one line</div></div>`;
+ },
+ expect: `
+ layout FULL
+ @viewport/block RUN (cache=bypass)
+ BlockContainer<HTML>/block RUN (cache=miss)
+ Box<DIV>#fixedRow.grid.fixed/grid RUN (cache=miss)
+ BlockContainer<DIV>#centered.center/block RUN (cache=miss)
+ BlockContainer<DIV>#centered.center MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#centered.center/block REPLAY FRAGMENTS
+ BlockContainer<DIV>#fixedRowSibling/block RUN (cache=miss)
+ `,
+ check: equal => {
+ equal(height("centered"), 20, "center-aligned item height");
+ equal(rect("centered").top - rect("fixedRow").top, 40, "center-aligned item offset");
+ equal(height("fixedRowSibling"), 100, "stretched sibling height");
+ },
+ },
+ {
+ name: "an item spanning two auto rows commits the run its row measurement laid out",
+ mutate: () => {
+ host.innerHTML = `<div class="grid" id="spanning"><div class="span" id="spanner">some words that wrap into lines</div><div id="spannedFirst">one line</div><div id="spannedSecond">one line</div></div>`;
+ },
+ expect: `
+ layout FULL
+ @viewport/block RUN (cache=bypass)
+ BlockContainer<HTML>/block RUN (cache=miss)
+ Box<DIV>#spanning.grid/grid RUN (cache=miss)
+ BlockContainer<DIV>#spanner.span/block RUN (cache=miss)
+ BlockContainer<DIV>#spanner.span MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#spanner.span MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#spannedFirst/block RUN (cache=miss)
+ BlockContainer<DIV>#spannedFirst MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#spannedFirst MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#spannedSecond/block RUN (cache=miss)
+ BlockContainer<DIV>#spannedSecond MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#spannedSecond MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#spanner.span MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#spanner.span MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#spanner.span MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#spannedFirst MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#spannedFirst MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#spannedFirst MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#spannedSecond MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#spannedSecond MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#spannedSecond MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#spanner.span/block REPLAY FRAGMENTS
+ BlockContainer<DIV>#spannedFirst/block REPLAY FRAGMENTS
+ BlockContainer<DIV>#spannedSecond/block REPLAY FRAGMENTS
+ `,
+ check: equal => {
+ equal(height("spanner"), 80, "spanning item height");
+ equal(height("spannedFirst"), 40, "first spanned row height");
+ equal(height("spannedSecond"), 40, "second spanned row height");
+ },
+ },
+ {
+ name: "an item with percentage padding resolves it against its grid area and commits the run its row measurement laid out",
+ mutate: () => {
+ host.innerHTML = `<div class="grid" id="padding"><div class="padded" id="paddedItem">one line</div><div id="paddedSibling">one line</div></div>`;
+ },
+ expect: `
+ layout FULL
+ @viewport/block RUN (cache=bypass)
+ BlockContainer<HTML>/block RUN (cache=miss)
+ Box<DIV>#padding.grid/grid RUN (cache=miss)
+ BlockContainer<DIV>#paddedItem.padded/block RUN (cache=miss)
+ BlockContainer<DIV>#paddedItem.padded MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#paddedItem.padded MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#paddedSibling/block RUN (cache=miss)
+ BlockContainer<DIV>#paddedSibling MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#paddedSibling MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#paddedItem.padded MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#paddedItem.padded MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#paddedItem.padded MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#paddedSibling MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#paddedSibling MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#paddedSibling MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#paddedItem.padded/block REPLAY FRAGMENTS
+ BlockContainer<DIV>#paddedSibling/block REPLAY FRAGMENTS
+ `,
+ check: equal => {
+ equal(height("paddedItem"), 44, "padded item height");
+ equal(rect("paddedItem").width, 120, "padded item width");
+ },
+ },
+ {
+ name: "a stretched item with a percentage-height child lays it out again at its stretched size",
+ mutate: () => {
+ host.innerHTML = `<div class="grid" id="percentage"><div id="percentageItem"><div class="half" id="halfChild">one line</div></div><div id="percentageSibling">some words that wrap into lines</div></div>`;
+ },
+ expect: `
+ layout FULL
+ @viewport/block RUN (cache=bypass)
+ BlockContainer<HTML>/block RUN (cache=miss)
+ Box<DIV>#percentage.grid/grid RUN (cache=miss)
+ BlockContainer<DIV>#percentageItem/block RUN (cache=miss)
+ BlockContainer<DIV>#percentageItem MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#percentageItem MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#percentageSibling/block RUN (cache=miss)
+ BlockContainer<DIV>#percentageSibling MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#percentageSibling MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#percentageItem MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#percentageItem MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#percentageItem MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#percentageSibling MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#percentageSibling MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#percentageSibling MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#percentageItem/block RUN (cache=miss)
+ BlockContainer<DIV>#percentageSibling/block REPLAY FRAGMENTS
+ `,
+ check: equal => {
+ equal(height("percentageItem"), 80, "percentage item height");
+ equal(height("halfChild"), 40, "percentage child height");
+ },
+ },
+ {
+ name: "a grid laid out before its width changes",
+ mutate: () => {
+ host.innerHTML = `<div class="grid fluid" id="resized"><div id="resizedFixed">one line</div><div id="resizedFlexible">some words that wrap into lines</div></div>`;
+ },
+ expect: `
+ layout FULL
+ @viewport/block RUN (cache=bypass)
+ BlockContainer<HTML>/block RUN (cache=miss)
+ Box<DIV>#resized.grid.fluid/grid RUN (cache=miss)
+ BlockContainer<DIV>#resizedFlexible MEASURE min-content inline (cache=miss) FROM ITEMS
+ BlockContainer<DIV>#resizedFlexible MEASURE min-content inline (cache=hit)
+ BlockContainer<DIV>#resizedFlexible MEASURE max-content inline (cache=hit)
+ BlockContainer<DIV>#resizedFixed/block RUN (cache=miss)
+ BlockContainer<DIV>#resizedFixed MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#resizedFixed MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#resizedFlexible/block RUN (cache=miss)
+ BlockContainer<DIV>#resizedFlexible MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#resizedFlexible MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#resizedFixed MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#resizedFixed MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#resizedFixed MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#resizedFlexible MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#resizedFlexible MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#resizedFlexible MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#resizedFixed/block REPLAY FRAGMENTS
+ BlockContainer<DIV>#resizedFlexible/block REPLAY FRAGMENTS
+ `,
+ },
+ {
+ name: "the next pass at another width reuses the item whose column did not change and adopts the one whose column did",
+ mutate: () => {
+ host.style.width = "300px";
+ },
+ expect: `
+ layout FULL
+ @viewport/block RUN (cache=bypass)
+ BlockContainer<HTML>/block RUN (cache=miss)
+ Box<DIV>#resized.grid.fluid/grid RUN (cache=miss)
+ BlockContainer<DIV>#resizedFlexible MEASURE min-content inline (cache=hit)
+ BlockContainer<DIV>#resizedFlexible MEASURE min-content inline (cache=hit)
+ BlockContainer<DIV>#resizedFlexible MEASURE max-content inline (cache=hit)
+ BlockContainer<DIV>#resizedFixed MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#resizedFixed MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#resizedFixed MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#resizedFlexible/block RUN (cache=miss)
+ BlockContainer<DIV>#resizedFlexible MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#resizedFlexible MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#resizedFixed MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#resizedFixed MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#resizedFixed MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#resizedFlexible MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#resizedFlexible MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#resizedFlexible MEASURE max-content block (cache=hit)
+ BlockContainer<DIV>#resizedFixed/block REUSE SUBTREE
+ BlockContainer<DIV>#resizedFlexible/block REPLAY FRAGMENTS
+ `,
+ check: equal => {
+ equal(height("resizedFixed"), 40, "fixed column item height");
+ equal(height("resizedFlexible"), 40, "flexible column item height");
+ },
+ },
+ ],
+ });
+</script>
diff --git a/Tests/LibWeb/Text/input/svg-measurement-skips-descendants.html b/Tests/LibWeb/Text/input/svg-measurement-skips-descendants.html
index 6f0b74d4df5..c0dc4e861dc 100644
--- a/Tests/LibWeb/Text/input/svg-measurement-skips-descendants.html
+++ b/Tests/LibWeb/Text/input/svg-measurement-skips-descendants.html
@@ -45,16 +45,14 @@
@viewport/block RUN (cache=bypass)
BlockContainer<HTML>/block RUN (cache=miss)
Box<DIV>#grid/grid RUN (cache=miss)
- BlockContainer<MAIN>#article MEASURE max-content block (cache=miss)
- BlockContainer<MAIN>#article/block (intrinsic) RUN (cache=bypass)
- SVGSVGBox<svg>#svg/svg (intrinsic) READ RESULT
+ BlockContainer<MAIN>#article/block RUN (cache=miss)
+ SVGSVGBox<svg>#svg/svg REUSE SUBTREE
BlockContainer<MAIN>#article MEASURE max-content block (cache=hit)
BlockContainer<MAIN>#article MEASURE max-content block (cache=hit)
BlockContainer<MAIN>#article MEASURE max-content block (cache=hit)
BlockContainer<MAIN>#article MEASURE max-content block (cache=hit)
BlockContainer<MAIN>#article MEASURE max-content block (cache=hit)
- BlockContainer<MAIN>#article/block RUN (cache=miss)
- SVGSVGBox<svg>#svg/svg REUSE SUBTREE
+ BlockContainer<MAIN>#article/block REPLAY FRAGMENTS
`,
check: equal => {
equal(geometry(), "0,0,200,100; 20,10,50,50; 50,40,100,40; 50,40,50,20", "SVG and foreignObject geometry");
@@ -70,17 +68,15 @@
@viewport/block RUN (cache=bypass)
BlockContainer<HTML>/block RUN (cache=miss)
Box<DIV>#grid/grid RUN (cache=miss)
- BlockContainer<MAIN>#article MEASURE max-content block (cache=miss)
- BlockContainer<MAIN>#article/block (intrinsic) RUN (cache=bypass)
- SVGSVGBox<svg>#svg/svg (intrinsic) RUN (cache=miss)
+ BlockContainer<MAIN>#article/block RUN (cache=miss)
+ SVGSVGBox<svg>#svg/svg RUN (cache=miss)
+ SVGForeignObjectBox<foreignObject>#foreign/block REUSE SUBTREE
BlockContainer<MAIN>#article MEASURE max-content block (cache=hit)
BlockContainer<MAIN>#article MEASURE max-content block (cache=hit)
BlockContainer<MAIN>#article MEASURE max-content block (cache=hit)
BlockContainer<MAIN>#article MEASURE max-content block (cache=hit)
BlockContainer<MAIN>#article MEASURE max-content block (cache=hit)
- BlockContainer<MAIN>#article/block RUN (cache=miss)
- SVGSVGBox<svg>#svg/svg RUN (cache=miss)
- SVGForeignObjectBox<foreignObject>#foreign/block REUSE SUBTREE
+ BlockContainer<MAIN>#article/block REPLAY FRAGMENTS
`,
check: equal => {
equal(geometry(), "0,0,400,200; 40,20,100,100; 100,80,200,80; 100,80,100,40", "resized SVG and foreignObject geometry");