diff --git a/Tests/LibWeb/Layout/expected/inset-shorthand-property.txt b/Tests/LibWeb/Layout/expected/inset-shorthand-property.txt new file mode 100644 index 0000000000..5e2d9b5eef --- /dev/null +++ b/Tests/LibWeb/Layout/expected/inset-shorthand-property.txt @@ -0,0 +1,15 @@ +Viewport <#document> at (0,0) content-size 800x600 children: not-inline + BlockContainer at (0,0) content-size 800x216 [BFC] children: not-inline + BlockContainer at (8,8) content-size 784x200 children: not-inline + BlockContainer at (8,8) content-size 200x200 positioned children: inline + TextNode <#text> + BlockContainer at (38,18) content-size 150x150 positioned [BFC] children: inline + line 0 width: 26.546875, height: 17.46875, bottom: 17.46875, baseline: 13.53125 + frag 0 from TextNode start: 0, length: 3, rect: [38,18 26.546875x17.46875] + "Bad" + TextNode <#text> + TextNode <#text> + BlockContainer at (38,18) content-size 150x150 positioned [BFC] children: not-inline + TextNode <#text> + BlockContainer <(anonymous)> at (8,208) content-size 784x0 children: inline + TextNode <#text> \ No newline at end of file diff --git a/Tests/LibWeb/Layout/input/inset-shorthand-property.html b/Tests/LibWeb/Layout/input/inset-shorthand-property.html new file mode 100644 index 0000000000..079851ab0e --- /dev/null +++ b/Tests/LibWeb/Layout/input/inset-shorthand-property.html @@ -0,0 +1,25 @@ + +
+
Bad
+
+
diff --git a/Userland/Libraries/LibWeb/CSS/Properties.json b/Userland/Libraries/LibWeb/CSS/Properties.json index 202e23c3cf..effb79a88e 100644 --- a/Userland/Libraries/LibWeb/CSS/Properties.json +++ b/Userland/Libraries/LibWeb/CSS/Properties.json @@ -1151,6 +1151,24 @@ "image-rendering" ] }, + "inset": { + "inherited": false, + "initial": "auto", + "longhands": [ + "top", + "right", + "bottom", + "left" + ], + "max-values": 4, + "valid-types": [ + "length", + "percentage" + ], + "valid-identifiers": [ + "auto" + ] + }, "justify-content": { "inherited": false, "initial": "flex-start", diff --git a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp index a4ee6234d0..0de122217b 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp @@ -516,6 +516,20 @@ static void set_property_expanding_shorthands(StyleProperties& style, CSS::Prope return; } + if (property_id == CSS::PropertyID::Inset) { + if (value.is_value_list()) { + auto const& values_list = value.as_value_list(); + assign_edge_values(PropertyID::Top, PropertyID::Right, PropertyID::Bottom, PropertyID::Left, values_list.values()); + return; + } + + style.set_property(CSS::PropertyID::Top, value, declaration); + style.set_property(CSS::PropertyID::Right, value, declaration); + style.set_property(CSS::PropertyID::Bottom, value, declaration); + style.set_property(CSS::PropertyID::Left, value, declaration); + return; + } + if (property_id == CSS::PropertyID::Margin) { if (value.is_value_list()) { auto const& values_list = value.as_value_list();