Skip to content

Truly independent web browser

LibWeb: Make anonymous block wrappers block-level

Aliaksandr Kalenik2a5b9fefb0c4
diff --git a/Libraries/LibWeb/Rust/src/css/style/layout_style.rs b/Libraries/LibWeb/Rust/src/css/style/layout_style.rs
index 4b85cf7fba6..4c153083f00 100644
--- a/Libraries/LibWeb/Rust/src/css/style/layout_style.rs
+++ b/Libraries/LibWeb/Rust/src/css/style/layout_style.rs
@@ -39,7 +39,6 @@ pub(crate) enum AnonymousStyleKind {
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub(crate) struct AnonymousStyleOverrides {
- pub inline_block_wrapper: bool,
pub overflow_x: u8,
pub overflow_y: u8,
pub columns_from_parent: bool,
@@ -401,19 +400,7 @@ impl LayoutStyle {
} else {
Self::inherited(engine, parent)
};
- let block_flow = FfiDisplay::outside_and_inside(
- if overrides.inline_block_wrapper {
- display_outside::INLINE
- } else {
- display_outside::BLOCK
- },
- if overrides.inline_block_wrapper {
- display_inside::FLOW_ROOT
- } else {
- display_inside::FLOW
- },
- false,
- );
+ let block_flow = FfiDisplay::outside_and_inside(display_outside::BLOCK, display_inside::FLOW, false);
match kind {
AnonymousStyleKind::Wrapper | AnonymousStyleKind::ButtonContentBox => style.set_display(block_flow),
AnonymousStyleKind::TableRow => style.set_display(FfiDisplay::internal(display_internal::TABLE_ROW)),
diff --git a/Libraries/LibWeb/Rust/src/layout/tree_builder.rs b/Libraries/LibWeb/Rust/src/layout/tree_builder.rs
index cbbb811ae97..3f99de2b25b 100644
--- a/Libraries/LibWeb/Rust/src/layout/tree_builder.rs
+++ b/Libraries/LibWeb/Rust/src/layout/tree_builder.rs
@@ -3836,18 +3836,11 @@ impl<'a> TreeBuilderHost<'a> {
UnplacedLayoutNode::new(slot)
}
- fn anonymous_wrapper_overrides(&self, parent: LayoutNode) -> AnonymousStyleOverrides {
- AnonymousStyleOverrides {
- inline_block_wrapper: self.display(parent).is_inline_block() && self.first_child(parent).is_invalid(),
- ..AnonymousStyleOverrides::default()
- }
- }
-
fn create_anonymous_wrapper_box(&mut self, parent: LayoutNode) -> UnplacedLayoutNode {
self.create_anonymous_box(
parent,
AnonymousStyleKind::Wrapper,
- self.anonymous_wrapper_overrides(parent),
+ AnonymousStyleOverrides::default(),
NodeKind::BlockContainer,
)
}
@@ -4808,7 +4801,7 @@ fn wrap_button_contents_if_needed(host: &mut TreeBuilderHost<'_>, layout_node: L
AnonymousStyleKind::ButtonContentBox,
AnonymousStyleOverrides {
columns_from_parent: !node_facts::has_flag(host.data(layout_node), NodeFlag::IsHtmlInputElement),
- ..host.anonymous_wrapper_overrides(layout_node)
+ ..AnonymousStyleOverrides::default()
},
NodeKind::BlockContainer,
);
@@ -4862,7 +4855,6 @@ fn wrap_fieldset_contents_if_needed(host: &mut TreeBuilderHost<'_>, layout_node:
let style = node_facts::node_style_view(host.data(layout_node)).expect("fieldset style");
let overrides = AnonymousStyleOverrides {
- inline_block_wrapper: false,
overflow_x: style.box_values().overflow_x,
overflow_y: style.box_values().overflow_y,
columns_from_parent: true,
diff --git a/Tests/LibWeb/Layout/expected/PictureInPicture/placeholder-replaces-video-without-controls.txt b/Tests/LibWeb/Layout/expected/PictureInPicture/placeholder-replaces-video-without-controls.txt
index 0c9de530be6..847f840c703 100644
--- a/Tests/LibWeb/Layout/expected/PictureInPicture/placeholder-replaces-video-without-controls.txt
+++ b/Tests/LibWeb/Layout/expected/PictureInPicture/placeholder-replaces-video-without-controls.txt
@@ -3,7 +3,7 @@ Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children
BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 483.203125 0+0+8] children: inline
frag 0 from VideoBox start: 0, length: 0, rect: [8,8 854x480] baseline: 480
VideoBox <video> at [8,8] inline-block [0+0+0 854 0+0+0] [0+0+0 480 0+0+0] children: not-inline
- BlockContainer <(anonymous)> at [8,8] inline-block [0+0+0 854 0+0+0] [0+0+0 480 0+0+0] [BFC] children: not-inline
+ BlockContainer <(anonymous)> at [8,8] [0+0+0 854 0+0+0] [0+0+0 480 0+0+0] children: not-inline
BlockContainer <div.container.video.controls-hidden.picture-in-picture> at [8,8] positioned [0+0+0 854 0+0+0] [0+0+0 480 0+0+0] [BFC] children: not-inline
Box <div.picture-in-picture-placeholder> at [8,8] flex-container(column) [0+0+0 854 0+0+0] [0+0+0 480 0+0+0] [FFC] children: not-inline
SVGSVGBox <svg.picture-in-picture-placeholder-icon> at [411,213] flex-item [0+0+0 48 0+0+0] [0+0+0 48 0+0+0] viewport-transform=[2 0 0 2 0 0] [SVG] children: not-inline
diff --git a/Tests/LibWeb/Layout/expected/PictureInPicture/placeholder-stays-after-controls-are-removed.txt b/Tests/LibWeb/Layout/expected/PictureInPicture/placeholder-stays-after-controls-are-removed.txt
index 2c965265e53..366337f49ec 100644
--- a/Tests/LibWeb/Layout/expected/PictureInPicture/placeholder-stays-after-controls-are-removed.txt
+++ b/Tests/LibWeb/Layout/expected/PictureInPicture/placeholder-stays-after-controls-are-removed.txt
@@ -3,7 +3,7 @@ Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children
BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 483.203125 0+0+8] children: inline
frag 0 from VideoBox start: 0, length: 0, rect: [8,8 854x480] baseline: 480
VideoBox <video> at [8,8] inline-block [0+0+0 854 0+0+0] [0+0+0 480 0+0+0] children: not-inline
- BlockContainer <(anonymous)> at [8,8] inline-block [0+0+0 854 0+0+0] [0+0+0 480 0+0+0] [BFC] children: not-inline
+ BlockContainer <(anonymous)> at [8,8] [0+0+0 854 0+0+0] [0+0+0 480 0+0+0] children: not-inline
BlockContainer <div.container.video.picture-in-picture.controls-hidden> at [8,8] positioned [0+0+0 854 0+0+0] [0+0+0 480 0+0+0] [BFC] children: not-inline
Box <div.picture-in-picture-placeholder> at [8,8] flex-container(column) [0+0+0 854 0+0+0] [0+0+0 480 0+0+0] [FFC] children: not-inline
SVGSVGBox <svg.picture-in-picture-placeholder-icon> at [411,213] flex-item [0+0+0 48 0+0+0] [0+0+0 48 0+0+0] viewport-transform=[2 0 0 2 0 0] [SVG] children: not-inline
diff --git a/Tests/LibWeb/Layout/expected/PictureInPicture/placeholder-stays-when-controls-are-added.txt b/Tests/LibWeb/Layout/expected/PictureInPicture/placeholder-stays-when-controls-are-added.txt
index 90478261953..17842aba66f 100644
--- a/Tests/LibWeb/Layout/expected/PictureInPicture/placeholder-stays-when-controls-are-added.txt
+++ b/Tests/LibWeb/Layout/expected/PictureInPicture/placeholder-stays-when-controls-are-added.txt
@@ -3,7 +3,7 @@ Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children
BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 483.203125 0+0+8] children: inline
frag 0 from VideoBox start: 0, length: 0, rect: [8,8 854x480] baseline: 480
VideoBox <video> at [8,8] inline-block [0+0+0 854 0+0+0] [0+0+0 480 0+0+0] children: not-inline
- BlockContainer <(anonymous)> at [8,8] inline-block [0+0+0 854 0+0+0] [0+0+0 480 0+0+0] [BFC] children: not-inline
+ BlockContainer <(anonymous)> at [8,8] [0+0+0 854 0+0+0] [0+0+0 480 0+0+0] children: not-inline
BlockContainer <div.container.video.picture-in-picture> at [8,8] positioned [0+0+0 854 0+0+0] [0+0+0 480 0+0+0] [BFC] children: not-inline
Box <div.picture-in-picture-placeholder> at [8,8] flex-container(column) [0+0+0 854 0+0+0] [0+0+0 480 0+0+0] [FFC] children: not-inline
SVGSVGBox <svg.picture-in-picture-placeholder-icon> at [411,213] flex-item [0+0+0 48 0+0+0] [0+0+0 48 0+0+0] viewport-transform=[2 0 0 2 0 0] [SVG] children: not-inline
diff --git a/Tests/LibWeb/Layout/expected/block-and-inline/button-empty.txt b/Tests/LibWeb/Layout/expected/block-and-inline/button-empty.txt
index 50d4f46b280..c9478d5cbde 100644
--- a/Tests/LibWeb/Layout/expected/block-and-inline/button-empty.txt
+++ b/Tests/LibWeb/Layout/expected/block-and-inline/button-empty.txt
@@ -4,7 +4,7 @@ Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children
frag 0 from BlockContainer start: 0, length: 0, rect: [13,20 0x0] baseline: 2
BlockContainer <button> at [13,20] inline-block [0+1+4 0 4+1+0] [0+1+1 0 1+1+0] [BFC] children: not-inline
BlockContainer <(anonymous)> at [13,20] flex-container(column) [0+0+0 0 0+0+0] [0+0+0 0 0+0+0] [FFC] children: not-inline
- BlockContainer <(anonymous)> (not painted) inline-block [BFC] children: not-inline
+ BlockContainer <(anonymous)> (not painted) [BFC] children: not-inline
SC for Viewport<#document> [0,0 800x600] (z-index: auto)
SC for BlockContainer<HTML> [0,0 800x32] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/expected/block-in-inline-in-floated-fieldset.txt b/Tests/LibWeb/Layout/expected/block-in-inline-in-floated-fieldset.txt
index 9c7d6899992..c841152a162 100644
--- a/Tests/LibWeb/Layout/expected/block-in-inline-in-floated-fieldset.txt
+++ b/Tests/LibWeb/Layout/expected/block-in-inline-in-floated-fieldset.txt
@@ -14,7 +14,7 @@ Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children
frag 0 from FieldSetBox start: 0, length: 0, rect: [730.265625,18 59.734375x20] baseline: 16.796875
TextNode <#text> (not painted)
FieldSetBox <fieldset> at [730.265625,18] inline-block [0+2+0 59.734375 0+2+0] [0+2+0 20 0+2+0] [BFC] children: not-inline
- BlockContainer <(anonymous)> at [730.265625,18] inline-block [0+0+0 59.734375 0+0+0] [0+0+0 20 0+0+0] [BFC] children: inline
+ BlockContainer <(anonymous)> at [730.265625,18] [0+0+0 59.734375 0+0+0] [0+0+0 20 0+0+0] children: inline
TextNode <#text> (not painted)
InlineNode <p> at [730.265625,20] [0+0+0 59.734375 0+0+0] [0+0+0 16 0+0+0]
InlineNode <span.actions> at [730.265625,20] [0+0+0 59.734375 0+0+0] [0+0+0 16 0+0+0]
diff --git a/Tests/LibWeb/Layout/expected/hide-audio-based-on-controls.txt b/Tests/LibWeb/Layout/expected/hide-audio-based-on-controls.txt
index 99da86c0926..181349e79d2 100644
--- a/Tests/LibWeb/Layout/expected/hide-audio-based-on-controls.txt
+++ b/Tests/LibWeb/Layout/expected/hide-audio-based-on-controls.txt
@@ -3,7 +3,7 @@ Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children
BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 46.203125 0+0+8] children: inline
frag 0 from AudioBox start: 0, length: 0, rect: [8,8 300x43] baseline: 43
AudioBox <audio> at [8,8] inline-block [0+0+0 300 0+0+0] [0+0+0 43 0+0+0] children: not-inline
- BlockContainer <(anonymous)> at [8,8] inline-block [0+0+0 300 0+0+0] [0+0+0 43 0+0+0] [BFC] children: not-inline
+ BlockContainer <(anonymous)> at [8,8] [0+0+0 300 0+0+0] [0+0+0 43 0+0+0] children: not-inline
BlockContainer <div.container.audio> at [8,8] [0+0+0 300 0+0+0] [0+0+0 43 0+0+0] [BFC] children: not-inline
Box <div.controls.visible> at [8,8] flex-container(column) [0+0+0 300 0+0+0] [0+0+0 43 0+0+0] [FFC] children: not-inline
BlockContainer <div.timeline> at [8,8] flex-item [0+0+0 300 0+0+0] [-5+0+5 5 5+0+-5] [BFC] children: not-inline
diff --git a/Tests/LibWeb/Layout/expected/popovertarget-button.txt b/Tests/LibWeb/Layout/expected/popovertarget-button.txt
index 251f7f03ad7..8fdf88894f8 100644
--- a/Tests/LibWeb/Layout/expected/popovertarget-button.txt
+++ b/Tests/LibWeb/Layout/expected/popovertarget-button.txt
@@ -4,7 +4,7 @@ Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children
frag 0 from BlockContainer start: 0, length: 0, rect: [13,20 0x0] baseline: 2
BlockContainer <button#button> at [13,20] inline-block [0+1+4 0 4+1+0] [0+1+1 0 1+1+0] [BFC] children: not-inline
BlockContainer <(anonymous)> at [13,20] flex-container(column) [0+0+0 0 0+0+0] [0+0+0 0 0+0+0] [FFC] children: not-inline
- BlockContainer <(anonymous)> (not painted) inline-block [BFC] children: not-inline
+ BlockContainer <(anonymous)> (not painted) [BFC] children: not-inline
TextNode <#text> (not painted)
TextNode <#text> (not painted)
TextNode <#text> (not painted)
diff --git a/Tests/LibWeb/Layout/expected/video-controls-default-object-size.txt b/Tests/LibWeb/Layout/expected/video-controls-default-object-size.txt
index a3e107cff25..418fd83a079 100644
--- a/Tests/LibWeb/Layout/expected/video-controls-default-object-size.txt
+++ b/Tests/LibWeb/Layout/expected/video-controls-default-object-size.txt
@@ -3,7 +3,7 @@ Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children
BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 153.203125 0+0+8] children: inline
frag 0 from VideoBox start: 0, length: 0, rect: [8,8 300x150] baseline: 150
VideoBox <video> at [8,8] inline-block [0+0+0 300 0+0+0] [0+0+0 150 0+0+0] children: not-inline
- BlockContainer <(anonymous)> at [8,8] inline-block [0+0+0 300 0+0+0] [0+0+0 150 0+0+0] [BFC] children: not-inline
+ BlockContainer <(anonymous)> at [8,8] [0+0+0 300 0+0+0] [0+0+0 150 0+0+0] children: not-inline
BlockContainer <div.container.video> at [8,8] positioned [0+0+0 300 0+0+0] [0+0+0 150 0+0+0] [BFC] children: not-inline
Box <div.video-overlay> at [8,8] positioned flex-container(row) [0+0+0 300 0+0+0] [0+0+0 150 0+0+0] [FFC] children: not-inline
Box <div.placeholder-circle> at [118,43] flex-container(row) flex-item [0+0+0 80 0+0+0] [0+0+0 80 0+0+0] [FFC] children: not-inline