1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 11:48:10 +00:00

LibWeb: Fix CSS opacity parsing

The StyleProperties code for opacity existed before NumericStyleValue
was a thing, and was affected by over-enthusiastic unitless-length
parsing, so it assumed everything was a length. Now it matches the
Color4 spec instead, accepting either a number, or a percentage.

We also get to remove the hack! :^)
This commit is contained in:
Sam Atkins 2021-09-10 20:23:57 +01:00 committed by Andreas Kling
parent 8dc4f3763d
commit b8c4320ffa
2 changed files with 14 additions and 12 deletions

View file

@ -2888,12 +2888,6 @@ RefPtr<StyleValue> Parser::parse_css_value(ParsingContext const& context, Proper
}
}
// FIXME: This is a hack for the `opacity` property which should really take an <alpha-value>
if (property_id == PropertyID::Opacity && component_value.is(Token::Type::Number)) {
String string = component_value.token().number_string_value();
return LengthStyleValue::create(Length::make_px(strtof(string.characters(), nullptr)));
}
if (auto builtin = parse_builtin_value(context, component_value))
return builtin;