From 3fd870a429b3dfd263aedee9b67b6f1bed5d89f3 Mon Sep 17 00:00:00 2001 From: Alan Kemp Date: Sun, 9 Jul 2023 22:49:45 +0100 Subject: [PATCH] LibWeb: Create EdgeStyleValue for BackgroundPositionXY with no offset When specifying either `background-position-x: right` or `background-position-y: bottom` without an offset value no EdgeStyleValue was created. However, the spec says the offset should be optional. Now, if you do not provide an offset, it creates the EdgeStyleValue with a default offset of 0 pixels. --- .../res/html/misc/background-position-xy.html | 2 ++ .../Text/expected/background-position-xy.txt | 2 ++ .../Text/input/background-position-xy.html | 21 +++++++++++++++++++ .../Libraries/LibWeb/CSS/Parser/Parser.cpp | 4 +++- 4 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 Tests/LibWeb/Text/expected/background-position-xy.txt create mode 100644 Tests/LibWeb/Text/input/background-position-xy.html diff --git a/Base/res/html/misc/background-position-xy.html b/Base/res/html/misc/background-position-xy.html index 7bc880e16e..a89fcca4f5 100644 --- a/Base/res/html/misc/background-position-xy.html +++ b/Base/res/html/misc/background-position-xy.html @@ -15,6 +15,7 @@
+


background-position-y
@@ -23,3 +24,4 @@
+
diff --git a/Tests/LibWeb/Text/expected/background-position-xy.txt b/Tests/LibWeb/Text/expected/background-position-xy.txt new file mode 100644 index 0000000000..65c214a249 --- /dev/null +++ b/Tests/LibWeb/Text/expected/background-position-xy.txt @@ -0,0 +1,2 @@ + right 0px +bottom 0px diff --git a/Tests/LibWeb/Text/input/background-position-xy.html b/Tests/LibWeb/Text/input/background-position-xy.html new file mode 100644 index 0000000000..14ba2b5239 --- /dev/null +++ b/Tests/LibWeb/Text/input/background-position-xy.html @@ -0,0 +1,21 @@ + + + +
diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp index 2aa09f40ef..a974ddc543 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp +++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp @@ -4783,7 +4783,9 @@ ErrorOr> Parser::parse_single_background_position_x_or_y_valu return EdgeStyleValue::create(relative_edge, *offset); } - return nullptr; + // If no offset is provided create this element but with an offset of default value of zero + transaction.commit(); + return EdgeStyleValue::create(relative_edge, Length::make_px(0)); } ErrorOr> Parser::parse_single_background_repeat_value(TokenStream& tokens)