LibWeb: Convert opacity property from Length to Percentage
This commit is contained in:
parent
dc681913e8
commit
5e9a6302e5
Notes:
sideshowbarker
2024-07-17 20:36:16 +09:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/SerenityOS/serenity/commit/5e9a6302e56 Pull-request: https://github.com/SerenityOS/serenity/pull/12007
1 changed files with 2 additions and 5 deletions
|
@ -174,11 +174,8 @@ float StyleProperties::opacity() const
|
|||
if (value->has_number())
|
||||
return clamp(value->to_number(), 0.0f, 1.0f);
|
||||
|
||||
if (value->has_length()) {
|
||||
auto length = value->to_length();
|
||||
if (length.is_percentage())
|
||||
return clamp(length.raw_value() / 100.0f, 0.0f, 1.0f);
|
||||
}
|
||||
if (value->is_percentage())
|
||||
return clamp(value->as_percentage().percentage().as_fraction(), 0.0f, 1.0f);
|
||||
|
||||
return 1.0f;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue