at (12,5658) 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,5658 9.34375x17.46875]
+ "a"
+ TextNode <#text>
+ BlockContainer
at (12,5570) 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,5570 9.46875x17.46875]
+ "b"
+ TextNode <#text>
+ BlockContainer <(anonymous)> at (10,5834) content-size 780x0 children: inline
+ TextNode <#text>
diff --git a/Tests/LibWeb/Layout/input/flex/abspos-flex-child-static-position-with-justify-content.html b/Tests/LibWeb/Layout/input/flex/abspos-flex-child-static-position-with-justify-content.html
index 7169c8f06d..d29df24aa5 100644
--- a/Tests/LibWeb/Layout/input/flex/abspos-flex-child-static-position-with-justify-content.html
+++ b/Tests/LibWeb/Layout/input/flex/abspos-flex-child-static-position-with-justify-content.html
@@ -21,6 +21,7 @@
.center { justify-content: center; }
.space-around { justify-content: space-around; }
.space-between { justify-content: space-between; }
+ .space-evenly { justify-content: space-evenly; }
.row { flex-direction: row; }
.row.reverse { flex-direction: row-reverse; }
@@ -38,6 +39,7 @@
+
@@ -45,6 +47,7 @@
+
@@ -52,6 +55,7 @@
+
@@ -59,3 +63,4 @@
+
diff --git a/Tests/LibWeb/Layout/input/flex/justify-content-1.html b/Tests/LibWeb/Layout/input/flex/justify-content-1.html
new file mode 100644
index 0000000000..1366039344
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/flex/justify-content-1.html
@@ -0,0 +1,71 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Userland/Libraries/LibWeb/CSS/Enums.json b/Userland/Libraries/LibWeb/CSS/Enums.json
index ca091a0efb..a6a3ab4a28 100644
--- a/Userland/Libraries/LibWeb/CSS/Enums.json
+++ b/Userland/Libraries/LibWeb/CSS/Enums.json
@@ -5,6 +5,7 @@
"center",
"space-between",
"space-around",
+ "space-evenly",
"stretch"
],
"align-items": [
@@ -172,7 +173,8 @@
"flex-end",
"center",
"space-between",
- "space-around"
+ "space-around",
+ "space-evenly"
],
"line-style": [
"none",
diff --git a/Userland/Libraries/LibWeb/CSS/Identifiers.json b/Userland/Libraries/LibWeb/CSS/Identifiers.json
index 6515195869..0ac0e6f519 100644
--- a/Userland/Libraries/LibWeb/CSS/Identifiers.json
+++ b/Userland/Libraries/LibWeb/CSS/Identifiers.json
@@ -272,6 +272,7 @@
"space",
"space-around",
"space-between",
+ "space-evenly",
"square",
"srgb",
"standalone",
diff --git a/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp
index 89a717b9b7..4694a5184d 100644
--- a/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp
+++ b/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp
@@ -1356,6 +1356,14 @@ void FlexFormattingContext::distribute_any_remaining_free_space()
initial_offset = space_between_items / 2.0;
}
break;
+ case CSS::JustifyContent::SpaceEvenly:
+ space_between_items = flex_line.remaining_free_space / (number_of_items + 1);
+ if (is_direction_reverse()) {
+ initial_offset = inner_main_size(flex_container()) - space_between_items;
+ } else {
+ initial_offset = space_between_items;
+ }
+ break;
}
}
@@ -1593,6 +1601,21 @@ void FlexFormattingContext::align_all_flex_lines()
start_of_current_line = gap_size / 2;
break;
}
+ case CSS::AlignContent::SpaceEvenly: {
+ auto leftover_free_space = cross_size_of_flex_container - sum_of_flex_line_cross_sizes;
+ if (leftover_free_space < 0) {
+ // If the leftover free-space is negative this value is identical to center.
+ start_of_current_line = (cross_size_of_flex_container / 2) - (sum_of_flex_line_cross_sizes / 2);
+ break;
+ }
+
+ gap_size = leftover_free_space / (m_flex_lines.size() + 1);
+
+ // The spacing between the first/last lines and the flex container edges is the size of the spacing between flex lines.
+ start_of_current_line = gap_size;
+ break;
+ }
+
case CSS::AlignContent::Stretch:
start_of_current_line = 0;
break;
@@ -2180,6 +2203,7 @@ CSSPixelPoint FlexFormattingContext::calculate_static_position(Box const& box) c
break;
case CSS::JustifyContent::Center:
case CSS::JustifyContent::SpaceAround:
+ case CSS::JustifyContent::SpaceEvenly:
pack_from_end = false;
main_offset = inner_main_size(flex_container()) / 2.0 - inner_main_size(box) / 2.0;
break;