summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@serenityos.org>2021-09-10 20:37:09 +0100
committerAndreas Kling <kling@serenityos.org>2021-09-12 16:30:38 +0200
commit2a141600a3176b29a12bb1e18429e3f1e0d7a37c (patch)
treef38ebcee1025859f43a25b63fc847a38bd0f8004 /Userland
parentb8c4320ffa3e2080b5fdd2aaf673193536b888b0 (diff)
downloadserenity-2a141600a3176b29a12bb1e18429e3f1e0d7a37c.zip
LibWeb: Correctly parse numeric and 'auto' z-index values
As with `opacity`, this code expected a Length value, when it is specced to take a Number or `auto`. Now it's correct. :^)
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibWeb/CSS/StyleProperties.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp b/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp
index c0c5ee828a..807c624b07 100644
--- a/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp
+++ b/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp
@@ -291,10 +291,16 @@ float StyleProperties::line_height(const Layout::Node& layout_node) const
Optional<int> StyleProperties::z_index() const
{
- auto value = property(CSS::PropertyID::ZIndex);
- if (!value.has_value())
+ auto maybe_value = property(CSS::PropertyID::ZIndex);
+ if (!maybe_value.has_value())
return {};
- return static_cast<int>(value.value()->to_length().raw_value());
+ auto& value = maybe_value.value();
+
+ if (value->is_auto())
+ return 0;
+ if (value->is_numeric())
+ return static_cast<int>(static_cast<NumericStyleValue&>(*value).value());
+ return {};
}
Optional<float> StyleProperties::opacity() const