diff options
author | Egor Ananyin <ananinegor@gmail.com> | 2021-07-23 13:18:09 +0300 |
---|---|---|
committer | Ali Mohammad Pur <Ali.mpfard@gmail.com> | 2021-07-24 22:02:28 +0430 |
commit | 0e6ba6e1d39e899df0beb5d3678ac9dc512d3d5c (patch) | |
tree | 1270cad3cc07a244cd143b3bf69a42aaed42049f /Userland/Libraries/LibWeb/CSS/StyleProperties.cpp | |
parent | 495f69b76ba6632f805ba2177a2c31c5422e20f1 (diff) | |
download | serenity-0e6ba6e1d39e899df0beb5d3678ac9dc512d3d5c.zip |
LibWeb: Parse and store the opacity property
Diffstat (limited to 'Userland/Libraries/LibWeb/CSS/StyleProperties.cpp')
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/StyleProperties.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp b/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp index c5a9807c49..0adb41aad6 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp @@ -229,6 +229,18 @@ Optional<int> StyleProperties::z_index() const return static_cast<int>(value.value()->to_length().raw_value()); } +Optional<float> StyleProperties::opacity() const +{ + auto value = property(CSS::PropertyID::Opacity); + if (!value.has_value()) + return {}; + + if (auto length = value.value()->to_length(); length.is_percentage()) + return clamp(static_cast<float>(length.raw_value() / 100), 0.0f, 1.0f); + else + return clamp(static_cast<float>(length.raw_value()), 0.0f, 1.0f); +} + Optional<CSS::FlexDirection> StyleProperties::flex_direction() const { auto value = property(CSS::PropertyID::FlexDirection); |