Truly independent web browser
LibWeb: Lay out a grid fieldset’s legend above its grid
sideshowbarker6d6481ff715b
diff --git a/Libraries/LibWeb/Rust/src/css/computed_value_views.rs b/Libraries/LibWeb/Rust/src/css/computed_value_views.rsindex 6d3b9d4c3fe..1b2bc14fd2d 100644--- a/Libraries/LibWeb/Rust/src/css/computed_value_views.rs+++ b/Libraries/LibWeb/Rust/src/css/computed_value_views.rs@@ -969,7 +969,7 @@ impl<'a> ComputedValuesView<'a> {}#[inline]- fn alignment(self) -> &'a AlignmentValues {+ pub(crate) fn alignment(self) -> &'a AlignmentValues {self.native_group(group_index::ALIGNMENT)}diff --git a/Libraries/LibWeb/Rust/src/css/computed_values.rs b/Libraries/LibWeb/Rust/src/css/computed_values.rsindex cf01afaba0d..f022ed74f9e 100644--- a/Libraries/LibWeb/Rust/src/css/computed_values.rs+++ b/Libraries/LibWeb/Rust/src/css/computed_values.rs@@ -7182,6 +7182,26 @@ mod tests {}}+/// Copies the grid template, implicit track sizes, and fit tolerance, which the anonymous content box of a grid+/// fieldset inherits from the fieldset. The fieldset's own placement in its parent's grid stays with the fieldset.+// https://html.spec.whatwg.org/multipage/rendering.html#anonymous-fieldset-content-box+pub(crate) fn copy_fieldset_content_grid_template(source: &GridValues, target: &mut GridValues) {+ target.names = source.names.clone();+ target.name_indices = source.name_indices.clone();+ target.entries = source.entries.clone();+ target.areas = source.areas.clone();+ target.template_columns = source.template_columns;+ target.template_rows = source.template_rows;+ target.auto_columns = source.auto_columns;+ target.auto_rows = source.auto_rows;+ target.grid_template_columns_style_value = source.grid_template_columns_style_value.clone();+ target.grid_template_rows_style_value = source.grid_template_rows_style_value.clone();+ target.grid_auto_columns_style_value = source.grid_auto_columns_style_value.clone();+ target.grid_auto_rows_style_value = source.grid_auto_rows_style_value.clone();+ target.grid_template_areas_style_value = source.grid_template_areas_style_value.clone();+ target.fit_tolerance_style_value = source.fit_tolerance_style_value.clone();+}+pub(crate) fn copy_fieldset_content_alignment(source: &AlignmentValues, target: &mut AlignmentValues) {target.flex_direction = source.flex_direction;target.flex_wrap = source.flex_wrap;diff --git a/Libraries/LibWeb/Rust/src/css/style/layout_style.rs b/Libraries/LibWeb/Rust/src/css/style/layout_style.rsindex 1cb017715cc..e5b32727a64 100644--- a/Libraries/LibWeb/Rust/src/css/style/layout_style.rs+++ b/Libraries/LibWeb/Rust/src/css/style/layout_style.rs@@ -68,6 +68,23 @@ impl DerivedStyleRecord {}}+/// The inner display type of the anonymous fieldset content box of a fieldset whose display is `fieldset_display`.+// https://html.spec.whatwg.org/multipage/rendering.html#anonymous-fieldset-content-box+// If the computed value of 'display' on the fieldset element is 'grid' or 'inline-grid', then set the used value to+// 'grid'. If the computed value of 'display' on the fieldset element is 'flex' or 'inline-flex', then set the used+// value to 'flex'. Otherwise, set the used value to 'flow-root'.+pub(crate) fn fieldset_content_display_inside(fieldset_display: FfiDisplay) -> u8 {+ if fieldset_display.is_grid_lanes_inside() {+ display_inside::GRID_LANES+ } else if fieldset_display.is_grid_inside() {+ display_inside::GRID+ } else if fieldset_display.is_flex_inside() {+ display_inside::FLEX+ } else {+ display_inside::FLOW_ROOT+ }+}+trait LayoutStyleGroup: Clone + PartialEq {const INDEX: usize;}@@ -558,13 +575,10 @@ impl LayoutStyle {}AnonymousStyleKind::FieldsetContentWrapper => {let source = Self::from_record(engine, parent);+ let content_display_inside = fieldset_content_display_inside(source.group::<BoxValues>().display);style.set_display(FfiDisplay::outside_and_inside(display_outside::BLOCK,- if source.group::<BoxValues>().display.is_flex_inside() {- display_inside::FLEX- } else {- display_inside::FLOW_ROOT- },+ content_display_inside,false,));style.edit::<AlignmentValues>(|target| {@@ -573,6 +587,19 @@ impl LayoutStyle {target,);});+ if source.group::<BoxValues>().display.is_grid_inside() {+ style.edit::<GridValues>(|target| {+ crate::css::computed_values::copy_fieldset_content_grid_template(+ source.group::<GridValues>(),+ target,+ );+ });+ style.edit::<BoxValues>(|target| {+ let source = source.group::<BoxValues>();+ target.grid_auto_flow_row = source.grid_auto_flow_row;+ target.grid_auto_flow_dense = source.grid_auto_flow_dense;+ });+ }style.set_overflow(overrides.overflow_x, overrides.overflow_y);}AnonymousStyleKind::InlineStyleWrapper | AnonymousStyleKind::WritingSuggestion => style.set_display(diff --git a/Libraries/LibWeb/Rust/src/css/style/style_invalidation.rs b/Libraries/LibWeb/Rust/src/css/style/style_invalidation.rsindex eb15287e535..d1b6d84de5e 100644--- a/Libraries/LibWeb/Rust/src/css/style/style_invalidation.rs+++ b/Libraries/LibWeb/Rust/src/css/style/style_invalidation.rs@@ -1395,9 +1395,15 @@ pub(crate) fn element_record_damage_of_views(facts: ElementDamageFacts, record_mfacts.verifies_reads,);let mut damage = StyleInvalidation::unpack(packed);- // Fieldsets with a rendered legend or flex contents transfer overflow to an anonymous- // content box during tree construction. Rebuild to refresh both boxes' overrides.- if overflow_changed && facts.is_field_set {+ // Fieldsets with a rendered legend or flex or grid contents transfer overflow, and their flex or grid container+ // properties, to an anonymous content box during tree construction. Rebuild to refresh both boxes' overrides.+ let fieldset_content_box_properties_changed = facts.is_field_set+ && (overflow_changed+ || old_values.alignment() != new_values.alignment()+ || old_values.grid_values() != new_values.grid_values()+ || old_values.grid_auto_flow_row() != new_values.grid_auto_flow_row()+ || old_values.grid_auto_flow_dense() != new_values.grid_auto_flow_dense());+ if fieldset_content_box_properties_changed {damage.merge(StyleInvalidation::rebuild_layout_tree_from(REBUILD_ROOT_SELF));}// An SVG currentColor stroke stores its resolved color alongside the fact that it came fromdiff --git a/Libraries/LibWeb/Rust/src/layout/formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/formatting_context.rsindex fa4e9e74635..e55cba2973f 100644--- a/Libraries/LibWeb/Rust/src/layout/formatting_context.rs+++ b/Libraries/LibWeb/Rust/src/layout/formatting_context.rs@@ -1477,10 +1477,10 @@ pub(crate) fn formatting_context_type_created_by_node_data(});}let display = style.map(|style| style.display());- // NB: A flex fieldset lays out its legend and anonymous content box in a block formatting context.- // Flex layout applies only to the anonymous content box.+ // NB: A flex or grid fieldset lays out its legend and anonymous content box in a block formatting context.+ // Flex or grid layout applies only to the anonymous content box.if data.kind.get() == crate::layout::node_data::NodeKind::FieldSetBox- && display.is_some_and(|display| display.is_flex_inside())+ && display.is_some_and(|display| display.is_flex_inside() || display.is_grid_inside()){return Some(FormattingContextType::Block);}diff --git a/Libraries/LibWeb/Rust/src/layout/grid_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/grid_formatting_context.rsindex 180f516fe64..257f4facdc6 100644--- a/Libraries/LibWeb/Rust/src/layout/grid_formatting_context.rs+++ b/Libraries/LibWeb/Rust/src/layout/grid_formatting_context.rs@@ -1343,6 +1343,11 @@ pub(crate) struct SubgridParent<'pass> {/// (the fc-run-cache probe): a declared subgrid axis counts regardless of the/// parent-grid placement check only a run in progress can make.pub(super) fn grid_template_declares_a_subgrid_axis(pass: &LayoutPass<'_>, box_: Node) -> bool {+ // NB: A grid fieldset lays out its grid in its anonymous fieldset content box, which isn't an item of the+ // fieldset's parent grid, so neither box is a subgrid.+ if NodeFacts::new(pass, box_).is_fieldset_box() {+ return false;+ }let grid_style = pass.style_view(box_).grid_values();grid_style.template_columns.is_subgrid || grid_style.template_rows.is_subgrid}@@ -1645,11 +1650,14 @@ impl<'pass> GridFormattingContext<'pass> {/// Whether a grid container with a subgrid track list is a subgrid, rather than being forced to establish an/// independent formatting context, which makes its track list none.fn can_be_subgrid(&self, node: Node) -> bool {- !self- .run- .pass- .style_view(node)- .is_forced_to_establish_independent_formatting_context()+ // NB: A grid fieldset lays out its grid in its anonymous fieldset content box, which isn't an item of the+ // fieldset's parent grid, so neither box is a subgrid.+ !self.facts(node).is_fieldset_box()+ && !self+ .run+ .pass+ .style_view(node)+ .is_forced_to_establish_independent_formatting_context()}fn container_is_subgridded(&self, axis: Axis) -> bool {diff --git a/Libraries/LibWeb/Rust/src/layout/node_facts.rs b/Libraries/LibWeb/Rust/src/layout/node_facts.rsindex 9260d7523dd..8036f62f82c 100644--- a/Libraries/LibWeb/Rust/src/layout/node_facts.rs+++ b/Libraries/LibWeb/Rust/src/layout/node_facts.rs@@ -628,7 +628,8 @@ pub(crate) fn node_is_fieldset_content_wrapper(data: &NodeData, style: Option<Co&& data.generated_for.get() == 0&& style.is_some_and(|style| {let display = style.display();- display.is_block_outside() && (display.is_flow_root_inside() || display.is_flex_inside())+ display.is_block_outside()+ && (display.is_flow_root_inside() || display.is_flex_inside() || display.is_grid_inside())})}diff --git a/Libraries/LibWeb/Rust/src/layout/tree_plan/child_list.rs b/Libraries/LibWeb/Rust/src/layout/tree_plan/child_list.rsindex 367b4f0e2c6..516ca35654b 100644--- a/Libraries/LibWeb/Rust/src/layout/tree_plan/child_list.rs+++ b/Libraries/LibWeb/Rust/src/layout/tree_plan/child_list.rs@@ -356,7 +356,7 @@ impl PlanTree {&mut self,fieldset: NodeSlotId,legend: NodeSlotId,- is_flex: bool,+ content_display_inside: u8,) -> NodeSlotId {let first_child = self.node(fieldset).first_child();let before = if legend.is_invalid() {@@ -368,11 +368,7 @@ impl PlanTree {}self.node(legend).next_sibling()};- let wrapper = self.push_contents_wrapper(if is_flex {- crate::css::css_enums::display_inside::FLEX- } else {- crate::css::css_enums::display_inside::FLOW_ROOT- });+ let wrapper = self.push_contents_wrapper(content_display_inside);self.attach(fieldset, wrapper, before);self.derive_subtree_on_commit(wrapper);self.move_children(fieldset, wrapper, legend);diff --git a/Libraries/LibWeb/Rust/src/layout/tree_plan/planner.rs b/Libraries/LibWeb/Rust/src/layout/tree_plan/planner.rsindex fbc3ea1a3a7..f7811eed7d2 100644--- a/Libraries/LibWeb/Rust/src/layout/tree_plan/planner.rs+++ b/Libraries/LibWeb/Rust/src/layout/tree_plan/planner.rs@@ -2816,14 +2816,16 @@ impl<'a> Planner<'a> {// the content (including the '::before' and '::after' pseudo-elements) of the fieldset element except for the// rendered legend, if there is one.let legend = self.tree.rendered_legend(node);- let is_flex = self+ let content_display_inside = self.tree.style_of(node)- .is_some_and(|style| style.display().is_flex_inside());- if legend.is_invalid() && !is_flex {+ .map_or(crate::css::css_enums::display_inside::FLOW_ROOT, |style| {+ crate::css::style::layout_style::fieldset_content_display_inside(style.display())+ });+ if legend.is_invalid() && content_display_inside == crate::css::css_enums::display_inside::FLOW_ROOT {return;}- let wrapper = self.tree.wrap_fieldset_contents(node, legend, is_flex);+ let wrapper = self.tree.wrap_fieldset_contents(node, legend, content_display_inside);self.commit_one_by_one(wrapper,OneByOneRowSource::ContentsWrapper {diff --git a/Tests/LibWeb/Layout/expected/tree-builder/fieldset-display-variants.txt b/Tests/LibWeb/Layout/expected/tree-builder/fieldset-display-variants.txtindex 3d6bde055e0..4940e69c0d0 100644--- a/Tests/LibWeb/Layout/expected/tree-builder/fieldset-display-variants.txt+++ b/Tests/LibWeb/Layout/expected/tree-builder/fieldset-display-variants.txt@@ -1,6 +1,6 @@Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline- BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 436.75 0+0+0] [BFC] children: not-inline- BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 420.75 0+0+8] children: not-inline+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 434.75 0+0+0] [BFC] children: not-inline+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 418.75 0+0+8] children: not-inlineBlockContainer <(anonymous)> at [8,8] [0+0+0 784 0+0+0] [0+0+0 49.59375 0+0+0] children: inlinefrag 0 from FieldSetBox start: 0, length: 0, rect: [24,15.59375 45.296875x30] baseline: 34.59375FieldSetBox <fieldset> at [24,15.59375] inline-block [2+2+12 45.296875 12+2+2] [0+2+5.59375 30 10+2+0] [BFC] children: not-inline@@ -28,77 +28,77 @@ Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] childrenfrag 0 from TextNode start: 0, length: 1, rect: [33.34375,79.1875 9.46875x16] baseline: 13"b"TextNode <#text> (not painted)- FieldSetBox <fieldset> at [24,114.78125] [2+2+12 752 12+2+2] [0+2+5.59375 48 10+2+0] [GFC] children: not-inline- LegendBox <legend> at [26,114.78125] [0+0+2 748 2+0+0] [0+0+0 16 0+0+0] [BFC] children: inline- frag 0 from TextNode start: 0, length: 4, rect: [26,114.78125 28.8125x16] baseline: 13+ FieldSetBox <fieldset> at [24,114.78125] [2+2+12 752 12+2+2] [0+2+5.59375 46 10+2+0] [BFC] children: not-inline+ LegendBox <legend> at [26,107.1875] [0+0+2 28.8125 2+0+0] [0+0+0 16 0+0+0] [BFC] children: inline+ frag 0 from TextNode start: 0, length: 4, rect: [26,107.1875 28.8125x16] baseline: 13"grid"TextNode <#text> (not painted)- BlockContainer <(anonymous)> at [24,130.78125] [0+0+0 752 0+0+0] [0+0+0 32 0+0+0] [BFC] children: not-inline- BlockContainer <div> at [24,130.78125] [0+0+0 752 0+0+0] [0+0+0 16 0+0+0] children: inline- frag 0 from TextNode start: 0, length: 1, rect: [24,130.78125 9.34375x16] baseline: 13+ BlockContainer <(anonymous)> at [24,128.78125] [0+0+0 752 0+0+0] [0+0+0 32 0+0+0] [GFC] children: not-inline+ BlockContainer <div> at [24,128.78125] [0+0+0 752 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline+ frag 0 from TextNode start: 0, length: 1, rect: [24,128.78125 9.34375x16] baseline: 13"a"TextNode <#text> (not painted)- BlockContainer <div> at [24,146.78125] [0+0+0 752 0+0+0] [0+0+0 16 0+0+0] children: inline- frag 0 from TextNode start: 0, length: 1, rect: [24,146.78125 9.46875x16] baseline: 13+ BlockContainer <div> at [24,144.78125] [0+0+0 752 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline+ frag 0 from TextNode start: 0, length: 1, rect: [24,144.78125 9.46875x16] baseline: 13"b"TextNode <#text> (not painted)- LegendBox <legend> at [10,174.78125] [0+0+2 780 2+0+0] [0+0+0 16 0+0+0] children: inline- frag 0 from TextNode start: 0, length: 8, rect: [10,174.78125 70.25x16] baseline: 13+ LegendBox <legend> at [10,172.78125] [0+0+2 780 2+0+0] [0+0+0 16 0+0+0] children: inline+ frag 0 from TextNode start: 0, length: 8, rect: [10,172.78125 70.25x16] baseline: 13"contents"TextNode <#text> (not painted)- BlockContainer <(anonymous)> at [8,190.78125] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline- InlineNode <(anonymous)> at [24,190.78125] [2+2+12 32.140625 12+2+2] [0+2+5.59375 16 10+2+0]- frag 0 from TextNode start: 0, length: 4, rect: [24,190.78125 32.140625x16] baseline: 13+ BlockContainer <(anonymous)> at [8,188.78125] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: inline+ InlineNode <(anonymous)> at [24,188.78125] [2+2+12 32.140625 12+2+2] [0+2+5.59375 16 10+2+0]+ frag 0 from TextNode start: 0, length: 4, rect: [24,188.78125 32.140625x16] baseline: 13"text"TextNode <#text> (not painted)TextNode <#text> (not painted)- FieldSetBox <fieldset> at [24,214.375] [2+2+12 752 12+2+2] [0+2+5.59375 16 10+2+0] [BFC] children: not-inline- BlockContainer <(anonymous)> at [24,214.375] [0+0+0 752 0+0+0] [0+0+0 16 0+0+0] children: inline- frag 0 from TextNode start: 0, length: 4, rect: [24,214.375 32.140625x16] baseline: 13+ FieldSetBox <fieldset> at [24,212.375] [2+2+12 752 12+2+2] [0+2+5.59375 16 10+2+0] [BFC] children: not-inline+ BlockContainer <(anonymous)> at [24,212.375] [0+0+0 752 0+0+0] [0+0+0 16 0+0+0] children: inline+ frag 0 from TextNode start: 0, length: 4, rect: [24,212.375 32.140625x16] baseline: 13"text"TextNode <#text> (not painted)- FieldSetBox <fieldset> at [24,249.96875] [2+2+12 752 12+2+2] [0+2+5.59375 16 10+2+0] [BFC] children: not-inline- LegendBox <legend> at [26,249.96875] floating [0+0+2 108.515625 2+0+0] [0+0+0 16 0+0+0] [BFC] children: inline- frag 0 from TextNode start: 0, length: 14, rect: [26,249.96875 108.515625x16] baseline: 13+ FieldSetBox <fieldset> at [24,247.96875] [2+2+12 752 12+2+2] [0+2+5.59375 16 10+2+0] [BFC] children: not-inline+ LegendBox <legend> at [26,247.96875] floating [0+0+2 108.515625 2+0+0] [0+0+0 16 0+0+0] [BFC] children: inline+ frag 0 from TextNode start: 0, length: 14, rect: [26,247.96875 108.515625x16] baseline: 13"floated legend"TextNode <#text> (not painted)- BlockContainer <(anonymous)> at [24,249.96875] [0+0+0 752 0+0+0] [0+0+0 16 0+0+0] children: inline- frag 0 from TextNode start: 0, length: 4, rect: [136.515625,249.96875 32.140625x16] baseline: 13+ BlockContainer <(anonymous)> at [24,247.96875] [0+0+0 752 0+0+0] [0+0+0 16 0+0+0] children: inline+ frag 0 from TextNode start: 0, length: 4, rect: [136.515625,247.96875 32.140625x16] baseline: 13"text"TextNode <#text> (not painted)- FieldSetBox <fieldset> at [24,285.5625] [2+2+12 752 12+2+2] [0+2+5.59375 16 10+2+0] [BFC] children: not-inline- LegendBox <legend> at [26,285.5625] positioned [0+0+2 111.984375 2+0+0] [0+0+0 16 0+0+0] [BFC] children: inline- frag 0 from TextNode start: 0, length: 13, rect: [26,285.5625 111.984375x16] baseline: 13+ FieldSetBox <fieldset> at [24,283.5625] [2+2+12 752 12+2+2] [0+2+5.59375 16 10+2+0] [BFC] children: not-inline+ LegendBox <legend> at [26,283.5625] positioned [0+0+2 111.984375 2+0+0] [0+0+0 16 0+0+0] [BFC] children: inline+ frag 0 from TextNode start: 0, length: 13, rect: [26,283.5625 111.984375x16] baseline: 13"abspos legend"TextNode <#text> (not painted)- BlockContainer <(anonymous)> at [24,285.5625] [0+0+0 752 0+0+0] [0+0+0 16 0+0+0] children: inline- frag 0 from TextNode start: 0, length: 4, rect: [24,285.5625 32.140625x16] baseline: 13+ BlockContainer <(anonymous)> at [24,283.5625] [0+0+0 752 0+0+0] [0+0+0 16 0+0+0] children: inline+ frag 0 from TextNode start: 0, length: 4, rect: [24,283.5625 32.140625x16] baseline: 13"text"TextNode <#text> (not painted)- FieldSetBox <fieldset> at [24,321.15625] [2+2+12 752 12+2+2] [0+2+5.59375 46 10+2+0] [BFC] children: not-inline- LegendBox <legend> at [26,313.5625] [0+0+2 90.734375 2+0+0] [0+0+0 16 0+0+0] children: inline- frag 0 from TextNode start: 0, length: 12, rect: [26,313.5625 90.734375x16] baseline: 13+ FieldSetBox <fieldset> at [24,319.15625] [2+2+12 752 12+2+2] [0+2+5.59375 46 10+2+0] [BFC] children: not-inline+ LegendBox <legend> at [26,311.5625] [0+0+2 90.734375 2+0+0] [0+0+0 16 0+0+0] children: inline+ frag 0 from TextNode start: 0, length: 12, rect: [26,311.5625 90.734375x16] baseline: 13"first legend"TextNode <#text> (not painted)- BlockContainer <(anonymous)> at [24,335.15625] [0+0+0 752 0+0+0] [0+0+0 32 0+0+0] [BFC] children: not-inline- LegendBox <legend> at [26,335.15625] [0+0+2 748 2+0+0] [0+0+0 16 0+0+0] children: inline- frag 0 from TextNode start: 0, length: 13, rect: [26,335.15625 109.484375x16] baseline: 13+ BlockContainer <(anonymous)> at [24,333.15625] [0+0+0 752 0+0+0] [0+0+0 32 0+0+0] [BFC] children: not-inline+ LegendBox <legend> at [26,333.15625] [0+0+2 748 2+0+0] [0+0+0 16 0+0+0] children: inline+ frag 0 from TextNode start: 0, length: 13, rect: [26,333.15625 109.484375x16] baseline: 13"second legend"TextNode <#text> (not painted)- BlockContainer <(anonymous)> at [24,351.15625] [0+0+0 752 0+0+0] [0+0+0 16 0+0+0] children: inline- frag 0 from TextNode start: 0, length: 4, rect: [24,351.15625 32.140625x16] baseline: 13+ BlockContainer <(anonymous)> at [24,349.15625] [0+0+0 752 0+0+0] [0+0+0 16 0+0+0] children: inline+ frag 0 from TextNode start: 0, length: 4, rect: [24,349.15625 32.140625x16] baseline: 13"text"TextNode <#text> (not painted)- FieldSetBox <fieldset> at [24,386.75] [2+2+12 752 12+2+2] [0+2+5.59375 30 10+2+0] [BFC] children: not-inline- LegendBox <legend> at [26,379.15625] [0+0+2 135.03125 2+0+0] [0+0+0 16 0+0+0] children: inline- frag 0 from TextNode start: 0, length: 17, rect: [26,379.15625 135.03125x16] baseline: 13+ FieldSetBox <fieldset> at [24,384.75] [2+2+12 752 12+2+2] [0+2+5.59375 30 10+2+0] [BFC] children: not-inline+ LegendBox <legend> at [26,377.15625] [0+0+2 135.03125 2+0+0] [0+0+0 16 0+0+0] children: inline+ frag 0 from TextNode start: 0, length: 17, rect: [26,377.15625 135.03125x16] baseline: 13"legend after text"TextNode <#text> (not painted)- BlockContainer <(anonymous)> at [24,400.75] [0+0+0 752 0+0+0] [0+0+0 16 0+0+0] [BFC] children: not-inline- BlockContainer <(anonymous)> at [24,400.75] [0+0+0 752 0+0+0] [0+0+0 16 0+0+0] children: inline- frag 0 from TextNode start: 0, length: 4, rect: [24,400.75 32.140625x16] baseline: 13+ BlockContainer <(anonymous)> at [24,398.75] [0+0+0 752 0+0+0] [0+0+0 16 0+0+0] [BFC] children: not-inline+ BlockContainer <(anonymous)> at [24,398.75] [0+0+0 752 0+0+0] [0+0+0 16 0+0+0] children: inline+ frag 0 from TextNode start: 0, length: 4, rect: [24,398.75 32.140625x16] baseline: 13"text"TextNode <#text> (not painted)SC for Viewport<#document> [0,0 800x600] (z-index: auto)- SC for BlockContainer<HTML> [0,0 800x436.75] (z-index: auto)+ SC for BlockContainer<HTML> [0,0 800x434.75] (z-index: auto)diff --git a/Tests/LibWeb/TestConfig.ini b/Tests/LibWeb/TestConfig.iniindex 98ecfa5689a..37874b3d99f 100644--- a/Tests/LibWeb/TestConfig.ini+++ b/Tests/LibWeb/TestConfig.ini@@ -1373,6 +1373,8 @@ Ref/input/wpt-import/css/css-break/grid/grid-lanes/grid-lanes-container-fragmentRef/input/wpt-import/css/css-break/grid/grid-lanes/grid-lanes-container-fragmentation-005.html; Needs static-position invalidation when a relative ancestor movesRef/input/wpt-import/css/css-position/hypothetical-dynamic-change-003.html+; Need the anonymous fieldset content box of a grid fieldset to be a subgrid of the fieldset's parent grid+Ref/input/wpt-import/css/css-grid/subgrid/independent-formatting-context-fieldset.html; Need margins collapsing through empty blocks in vertical writing modesRef/input/wpt-import/css/css-writing-modes/margin-collapse-vlr-025.xhtRef/input/wpt-import/css/css-writing-modes/margin-collapse-vrl-024.xhtdiff --git a/Tests/LibWeb/Text/expected/Layout/fieldset-grid-lays-out-legend-outside-grid.txt b/Tests/LibWeb/Text/expected/Layout/fieldset-grid-lays-out-legend-outside-grid.txtnew file mode 100644index 00000000000..f496a325e27--- /dev/null+++ b/Tests/LibWeb/Text/expected/Layout/fieldset-grid-lays-out-legend-outside-grid.txt@@ -0,0 +1,13 @@+grid: 300x40; legend "Size" 42.0625x20 at 0,0; span "A" 150x20 at 0,20; span "B" 150x20 at 150,20+inline-grid: 300x40; legend "Size" 42.0625x20 at 0,0; span "A" 150x20 at 0,20; span "B" 150x20 at 150,20+gap-and-padding: 310x80; legend "Size" 42.0625x20 at 5,0; span "A" 145x20 at 5,25; span "B" 145x20 at 160,25; span "C" 145x20 at 5,55+areas: 300x40; legend "Size" 42.0625x20 at 0,0; span "A" 150x20 at 150,20; span "B" 150x20 at 0,20+auto-flow-column: 300x40; legend "Size" 42.0625x20 at 0,0; span "A" 50x20 at 0,20; span "B" 50x20 at 50,20+aligned-content: 300x100; legend "Size" 42.0625x20 at 0,0; span "A" 150x20 at 0,80; span "B" 150x20 at 150,80+floated-legend: 300x40; legend "Size" 150x20 at 0,0; span "A" 150x20 at 150,0; span "B" 150x20 at 0,20+legend-not-first: 300x40; span "A" 150x20 at 0,20; legend "Size" 42.0625x20 at 0,0; span "B" 150x20 at 150,20+no-legend: 300x20; span "A" 150x20 at 0,0; span "B" 150x20 at 150,0+grid-lanes-zero-fit-tolerance: 300x130; legend "Size" 42.0625x20 at 0,0; div "" 100x100 at 0,20; div "" 100x90 at 100,20; div "" 100x20 at 100,110+grid-lanes-normal-fit-tolerance: 300x140; legend "Size" 42.0625x20 at 0,0; div "" 100x100 at 0,20; div "" 100x90 at 100,20; div "" 100x20 at 0,120+template-changed: 300x40; legend "Size" 42.0625x20 at 0,0; span "A" 100x20 at 0,20; span "B" 200x20 at 100,20+flex-direction-changed: 300x60; legend "Size" 42.0625x20 at 0,0; span "A" 300x20 at 0,20; span "B" 300x20 at 0,40diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/rendering/non-replaced-elements/the-fieldset-and-legend-elements/fieldset-flexbox.txt b/Tests/LibWeb/Text/expected/wpt-import/html/rendering/non-replaced-elements/the-fieldset-and-legend-elements/fieldset-flexbox.txtnew file mode 100644index 00000000000..ebf518da20a--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/html/rendering/non-replaced-elements/the-fieldset-and-legend-elements/fieldset-flexbox.txt@@ -0,0 +1,8 @@+Harness status: OK++Found 3 tests++3 Pass+Pass Flex+Pass Inline flex+Pass Dynamic change of flex-direction\ No newline at end of filediff --git a/Tests/LibWeb/Text/input/Layout/fieldset-grid-lays-out-legend-outside-grid.html b/Tests/LibWeb/Text/input/Layout/fieldset-grid-lays-out-legend-outside-grid.htmlnew file mode 100644index 00000000000..d6d06f8844c--- /dev/null+++ b/Tests/LibWeb/Text/input/Layout/fieldset-grid-lays-out-legend-outside-grid.html@@ -0,0 +1,42 @@+<!DOCTYPE html>+<script src="../include.js"></script>+<style>+ body { margin: 0; font: 20px/1 serif; }+ fieldset { display: grid; grid-template-columns: 1fr 1fr; width: 300px; margin: 0 0 30px; padding: 0; border: none; }+ legend { padding: 0; }+</style>+<!-- A grid fieldset lays out its rendered legend above the grid, and its anonymous fieldset content box is the grid+ container, with the fieldset's grid template. -->+<fieldset id="grid"><legend>Size</legend><span>A</span><span>B</span></fieldset>+<fieldset id="inline-grid" style="display: inline-grid"><legend>Size</legend><span>A</span><span>B</span></fieldset>+<fieldset id="gap-and-padding" style="gap: 10px; padding: 5px"><legend>Size</legend><span>A</span><span>B</span><span>C</span></fieldset>+<fieldset id="areas" style="grid-template-areas: 'a b'"><legend>Size</legend><span style="grid-area: b">A</span><span style="grid-area: a">B</span></fieldset>+<fieldset id="auto-flow-column" style="grid-template-columns: none; grid-template-rows: 20px; grid-auto-flow: column; grid-auto-columns: 50px"><legend>Size</legend><span>A</span><span>B</span></fieldset>+<fieldset id="aligned-content" style="height: 100px; align-content: end"><legend>Size</legend><span>A</span><span>B</span></fieldset>+<fieldset id="floated-legend"><legend style="float: left">Size</legend><span>A</span><span>B</span></fieldset>+<fieldset id="legend-not-first"><span>A</span><legend>Size</legend><span>B</span></fieldset>+<fieldset id="no-legend"><span>A</span><span>B</span></fieldset>+<fieldset id="grid-lanes-zero-fit-tolerance" style="display: grid-lanes; grid-template-columns: 100px 100px; fit-tolerance: 0"><legend>Size</legend><div style="height: 100px"></div><div style="height: 90px"></div><div style="height: 20px"></div></fieldset>+<fieldset id="grid-lanes-normal-fit-tolerance" style="display: grid-lanes; grid-template-columns: 100px 100px"><legend>Size</legend><div style="height: 100px"></div><div style="height: 90px"></div><div style="height: 20px"></div></fieldset>+<fieldset id="template-changed"><legend>Size</legend><span>A</span><span>B</span></fieldset>+<fieldset id="flex-direction-changed" style="display: flex"><legend>Size</legend><span>A</span><span>B</span></fieldset>+<script>+ function run(report) {+ document.getElementById("template-changed").style.gridTemplateColumns = "1fr 2fr";+ document.getElementById("flex-direction-changed").style.flexDirection = "column";+ for (const fieldset of document.querySelectorAll("fieldset")) {+ const origin = fieldset.getBoundingClientRect();+ const children = [...fieldset.children].map(child => {+ const rect = child.getBoundingClientRect();+ return `${child.localName} "${child.textContent}" ${rect.width}x${rect.height} at ${rect.left - origin.left},${rect.top - origin.top}`;+ });+ report(`${fieldset.id}: ${origin.width}x${origin.height}; ${children.join("; ")}`);+ }+ }+</script>+<script>+ if (window.asyncTest)+ asyncTest(done => addEventListener("load", () => { run(println); done(); }));+ else+ addEventListener("load", () => { run(line => console.log(line)); window.engineCompareDone = true; });+</script>diff --git a/Tests/LibWeb/Text/input/wpt-import/html/rendering/non-replaced-elements/the-fieldset-and-legend-elements/fieldset-flexbox.html b/Tests/LibWeb/Text/input/wpt-import/html/rendering/non-replaced-elements/the-fieldset-and-legend-elements/fieldset-flexbox.htmlnew file mode 100644index 00000000000..b957f660d20--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/html/rendering/non-replaced-elements/the-fieldset-and-legend-elements/fieldset-flexbox.html@@ -0,0 +1,95 @@+<!DOCTYPE html>+<title>fieldset and CSS Flexbox</title>+<script src=../../../../resources/testharness.js></script>+<script src=../../../../resources/testharnessreport.js></script>+<style>+#test, #ref, #test-inline, #ref-inline {+ display: flex;+ justify-content: space-around;+ margin: 0;+ padding: 0;+ border: none+}+#test-inline, #ref-inline { display: inline-flex }+legend {+ float: left; /* Makes it not the "rendered legend" */+ padding: 0;+}+</style>+<fieldset id=test>+ <legend>1</legend>+ <div>2</div>+ <div>3</div>+ <div>4</div>+ <div>5</div>+ <div>6</div>+ <div>7</div>+ <div>8</div>+ <div>9</div>+</fieldset>+<hr>+<div id=ref>+ <legend>1</legend>+ <div>2</div>+ <div>3</div>+ <div>4</div>+ <div>5</div>+ <div>6</div>+ <div>7</div>+ <div>8</div>+ <div>9</div>+</div>+<hr>+<fieldset id=test-inline>+ <legend>1</legend>+ <div>2</div>+ <div>3</div>+ <div>4</div>+ <div>5</div>+ <div>6</div>+ <div>7</div>+ <div>8</div>+ <div>9</div>+</fieldset>+<div id=ref-inline>+ <div>1</div>+ <div>2</div>+ <div>3</div>+ <div>4</div>+ <div>5</div>+ <div>6</div>+ <div>7</div>+ <div>8</div>+ <div>9</div>+</div>+<script>+ test(() => {+ const testElm = document.getElementById('test');+ const refElm = document.getElementById('ref');+ assert_equals(getComputedStyle(testElm).height,+ getComputedStyle(refElm).height, 'height');+ assert_equals(testElm.querySelector('legend').offsetTop,+ testElm.querySelector('div').offsetTop, 'offsetTop')+ }, "Flex");++ test(() => {+ const testElm = document.getElementById('test-inline');+ const refElm = document.getElementById('ref-inline');+ assert_equals(getComputedStyle(testElm).height,+ getComputedStyle(refElm).height, 'height');+ assert_equals(testElm.querySelector('legend').offsetTop,+ testElm.querySelector('div').offsetTop, 'offsetTop')++ }, "Inline flex");++test(() => {+ const testElm = document.getElementById('test');+ testElm.style.flexDirection = 'row';+ const item0 = testElm.querySelectorAll('div')[0];+ const item1 = testElm.querySelectorAll('div')[1];+ assert_equals(item0.offsetTop, item1.offsetTop);++ testElm.style.flexDirection = 'column';+ assert_true(item0.offsetTop < item1.offsetTop);+}, "Dynamic change of flex-direction");+</script>