mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 13:49:16 +00:00
LibWeb: Parse and store the opacity property
This commit is contained in:
parent
495f69b76b
commit
0e6ba6e1d3
Notes:
sideshowbarker
2024-07-18 08:23:50 +09:00
Author: https://github.com/Cleverking2003
Commit: 0e6ba6e1d3
Pull-request: https://github.com/SerenityOS/serenity/pull/8956
Reviewed-by: https://github.com/AtkinsSJ
Reviewed-by: https://github.com/alimpfard
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