) [596,8 196x17]
+ TextPaintable (TextNode<#text>)
+ PaintableWithLines (BlockContainer
) [8,25 196x17]
+ TextPaintable (TextNode<#text>)
+ PaintableWithLines (BlockContainer(anonymous)) [8,42 784x0]
+ PaintableWithLines (BlockContainer(anonymous)) [8,42 784x0]
diff --git a/Tests/LibWeb/Layout/input/grid/repeat-auto-fit-fill-cannot-have-auto.html b/Tests/LibWeb/Layout/input/grid/repeat-auto-fit-fill-cannot-have-auto.html
new file mode 100644
index 0000000000..8c3026f89f
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/grid/repeat-auto-fit-fill-cannot-have-auto.html
@@ -0,0 +1,17 @@
+
+
+
diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp
index 264803ae3d..f38249cb95 100644
--- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp
+++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp
@@ -5,6 +5,7 @@
* Copyright (c) 2021, Tobias Christiansen
* Copyright (c) 2022, MacDue
* Copyright (c) 2024, Shannon Booth
+ * Copyright (c) 2024, Tommy van der Vorst
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -5469,9 +5470,18 @@ Optional Parser::parse_repeat(Vector const& com
// The repeat() notation can’t be nested.
if (track_sizing_function.value().is_repeat())
return {};
+
// Automatic repetitions (auto-fill or auto-fit) cannot be combined with intrinsic or flexible sizes.
- if (track_sizing_function.value().is_default() && track_sizing_function.value().grid_size().is_flexible_length() && (is_auto_fill || is_auto_fit))
+ // Note that 'auto' is also an intrinsic size (and thus not permitted) but we can't use
+ // track_sizing_function.is_auto(..) to check for it, as it requires AvailableSize, which is why there is
+ // a separate check for it below.
+ // https://www.w3.org/TR/css-grid-2/#repeat-syntax
+ // https://www.w3.org/TR/css-grid-2/#intrinsic-sizing-function
+ if (track_sizing_function.value().is_default()
+ && (track_sizing_function.value().grid_size().is_flexible_length() || token.is_ident("auto"sv))
+ && (is_auto_fill || is_auto_fit))
return {};
+
repeat_params.append(track_sizing_function.value());
part_two_tokens.skip_whitespace();
}