1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-22 17:25:07 +00:00

LibHTML: Respect the CSS "color" property for text

Also remove the color values from the ComputedStyle object and get them
via StyleProperties instead.

At the moment, we only handle colors that Color::from_string() parses.
This commit is contained in:
Andreas Kling 2019-09-28 22:18:19 +02:00
parent b8cab2a934
commit 62cbaa74f3
7 changed files with 56 additions and 10 deletions

View file

@ -28,3 +28,13 @@ String StyleProperties::string_or_fallback(const StringView& property_name, cons
return fallback;
return value.value()->to_string();
}
Color StyleProperties::color_or_fallback(const StringView& property_name, Color fallback) const
{
auto value = property(property_name);
if (!value.has_value())
return fallback;
if (value.value()->type() != StyleValue::Type::Color)
return fallback;
return static_cast<ColorStyleValue&>(*value.value()).color();
}