mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 12:48:10 +00:00
LibWeb: Parse and store the opacity property
This commit is contained in:
parent
495f69b76b
commit
0e6ba6e1d3
5 changed files with 23 additions and 0 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue