at (12,2726) content-size 50x50 flex-item [BFC] children: inline
+ line 0 width: 61.765625, height: 17.46875, bottom: 17.46875, baseline: 13.53125
+ frag 0 from TextNode start: 0, length: 8, rect: [12,2726 61.765625x17.46875]
+ "flex-end"
+ TextNode <#text>
+ BlockContainer
at (12,2674) content-size 50x50 flex-item [BFC] children: inline
+ line 0 width: 9.34375, height: 17.46875, bottom: 17.46875, baseline: 13.53125
+ frag 0 from TextNode start: 0, length: 1, rect: [12,2674 9.34375x17.46875]
+ "a"
+ TextNode <#text>
+ BlockContainer
at (12,2622) content-size 50x50 flex-item [BFC] children: inline
+ line 0 width: 9.46875, height: 17.46875, bottom: 17.46875, baseline: 13.53125
+ frag 0 from TextNode start: 0, length: 1, rect: [12,2622 9.46875x17.46875]
+ "b"
+ TextNode <#text>
+ BlockContainer <(anonymous)> at (10,2922) content-size 780x0 children: inline
+ TextNode <#text>
diff --git a/Tests/LibWeb/Layout/input/flex/justify-content-with-margin-auto-child.html b/Tests/LibWeb/Layout/input/flex/justify-content-with-margin-auto-child.html
new file mode 100644
index 0000000000..eb6ac4f5f5
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/flex/justify-content-with-margin-auto-child.html
@@ -0,0 +1,56 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp
index 35b9c96016..dee505204f 100644
--- a/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp
+++ b/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp
@@ -1367,26 +1367,28 @@ void FlexFormattingContext::distribute_any_remaining_free_space()
};
auto flex_region_render_cursor = FlexRegionRenderCursor::Left;
- switch (flex_container().computed_values().justify_content()) {
- case CSS::JustifyContent::FlexStart:
- case CSS::JustifyContent::Center:
- case CSS::JustifyContent::SpaceAround:
- case CSS::JustifyContent::SpaceBetween:
- case CSS::JustifyContent::SpaceEvenly:
- if (is_direction_reverse()) {
+ if (auto_margins == 0) {
+ switch (flex_container().computed_values().justify_content()) {
+ case CSS::JustifyContent::FlexStart:
+ case CSS::JustifyContent::Center:
+ case CSS::JustifyContent::SpaceAround:
+ case CSS::JustifyContent::SpaceBetween:
+ case CSS::JustifyContent::SpaceEvenly:
+ if (is_direction_reverse()) {
+ flex_region_render_cursor = FlexRegionRenderCursor::Right;
+ }
+ break;
+ case CSS::JustifyContent::End:
flex_region_render_cursor = FlexRegionRenderCursor::Right;
+ break;
+ case CSS::JustifyContent::FlexEnd:
+ if (!is_direction_reverse()) {
+ flex_region_render_cursor = FlexRegionRenderCursor::Right;
+ }
+ break;
+ default:
+ break;
}
- break;
- case CSS::JustifyContent::End:
- flex_region_render_cursor = FlexRegionRenderCursor::Right;
- break;
- case CSS::JustifyContent::FlexEnd:
- if (!is_direction_reverse()) {
- flex_region_render_cursor = FlexRegionRenderCursor::Right;
- }
- break;
- default:
- break;
}
CSSPixels cursor_offset = initial_offset;