1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-28 11:55:12 +00:00

LibWeb: Apply rules for parsing a legacy color value

This commit is contained in:
Shannon Booth 2023-05-28 15:06:12 +12:00 committed by Andreas Kling
parent bc54560e59
commit 500552df54
5 changed files with 21 additions and 9 deletions

View file

@ -8,6 +8,7 @@
#include <LibWeb/CSS/StyleProperties.h>
#include <LibWeb/CSS/StyleValues/ColorStyleValue.h>
#include <LibWeb/HTML/HTMLFontElement.h>
#include <LibWeb/HTML/Parser/HTMLParser.h>
namespace Web::HTML {
@ -30,7 +31,8 @@ void HTMLFontElement::apply_presentational_hints(CSS::StyleProperties& style) co
{
for_each_attribute([&](auto& name, auto& value) {
if (name.equals_ignoring_ascii_case("color"sv)) {
auto color = Color::from_string(value);
// https://html.spec.whatwg.org/multipage/rendering.html#phrasing-content-3:rules-for-parsing-a-legacy-colour-value
auto color = parse_legacy_color_value(value);
if (color.has_value())
style.set_property(CSS::PropertyID::Color, CSS::ColorStyleValue::create(color.value()).release_value_but_fixme_should_propagate_errors());
}