LibWeb: Convert opacity property from Length to Percentage

This commit is contained in:
Sam Atkins 2022-01-19 16:25:19 +00:00 committed by Andreas Kling
parent dc681913e8
commit 5e9a6302e5
Notes: sideshowbarker 2024-07-17 20:36:16 +09:00

View file

@ -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;
}